1 |
// EquipmentEditDialog.cpp : implementation file
|
2 |
//
|
3 |
|
4 |
#include "stdafx.h"
|
5 |
#include "h6-udlånssystem.h"
|
6 |
#include "EquipmentEditDialog.h"
|
7 |
#include ".\equipmenteditdialog.h"
|
8 |
|
9 |
|
10 |
// EquipmentEditDialog dialog
|
11 |
|
12 |
IMPLEMENT_DYNAMIC(EquipmentEditDialog, CDialog)
|
13 |
EquipmentEditDialog::EquipmentEditDialog(CWnd* pParent /*=NULL*/)
|
14 |
: CDialog(EquipmentEditDialog::IDD, pParent)
|
15 |
{
|
16 |
}
|
17 |
|
18 |
EquipmentEditDialog::~EquipmentEditDialog()
|
19 |
{
|
20 |
}
|
21 |
|
22 |
void EquipmentEditDialog::DoDataExchange(CDataExchange* pDX)
|
23 |
{
|
24 |
CDialog::DoDataExchange(pDX);
|
25 |
}
|
26 |
|
27 |
|
28 |
BEGIN_MESSAGE_MAP(EquipmentEditDialog, CDialog)
|
29 |
ON_BN_CLICKED(IDOK, OnBnClickedOk)
|
30 |
END_MESSAGE_MAP()
|
31 |
|
32 |
|
33 |
// EquipmentEditDialog message handlers
|
34 |
|
35 |
void EquipmentEditDialog::OnBnClickedOk()
|
36 |
{
|
37 |
CString barcode,name,placement,description;
|
38 |
|
39 |
GetDlgItem(IDC_BARCODE)->GetWindowText(barcode);
|
40 |
GetDlgItem(IDC_NAME)->GetWindowText(name);
|
41 |
GetDlgItem(IDC_PLACEMENT)->GetWindowText(placement);
|
42 |
GetDlgItem(IDC_DESCRIPTION)->GetWindowText(description);
|
43 |
|
44 |
//If the barcode is EAN-13 maybe we should check for a valid barcode??
|
45 |
if (barcode.GetLength() != 13) {
|
46 |
MessageBox("Barcode must be 13 characters long");
|
47 |
return;
|
48 |
}
|
49 |
|
50 |
if (name == "") {
|
51 |
MessageBox("You must enter a name");
|
52 |
return;
|
53 |
}
|
54 |
|
55 |
if (placement == "") {
|
56 |
MessageBox("You must enter a placement");
|
57 |
return;
|
58 |
}
|
59 |
|
60 |
m_currentEquipment.barcode = barcode;
|
61 |
m_currentEquipment.description = description;
|
62 |
m_currentEquipment.name = name;
|
63 |
m_currentEquipment.placement = placement;
|
64 |
// TODO: Add your control notification handler code here
|
65 |
OnOK();
|
66 |
}
|
67 |
|
68 |
BOOL EquipmentEditDialog::OnInitDialog()
|
69 |
{
|
70 |
CDialog::OnInitDialog();
|
71 |
|
72 |
((CEdit*)GetDlgItem(IDC_BARCODE))->SetLimitText(13);
|
73 |
((CEdit*)GetDlgItem(IDC_NAME))->SetLimitText(20);
|
74 |
((CEdit*)GetDlgItem(IDC_DESCRIPTION))->SetLimitText(200);
|
75 |
((CEdit*)GetDlgItem(IDC_PLACEMENT))->SetLimitText(20);
|
76 |
|
77 |
if (m_currentEquipment.barcode != "") {
|
78 |
GetDlgItem(IDC_BARCODE)->SetWindowText(m_currentEquipment.barcode);
|
79 |
GetDlgItem(IDC_NAME)->SetWindowText(m_currentEquipment.name);
|
80 |
GetDlgItem(IDC_DESCRIPTION)->SetWindowText(m_currentEquipment.description);
|
81 |
GetDlgItem(IDC_PLACEMENT)->SetWindowText(m_currentEquipment.placement);
|
82 |
((CEdit*)GetDlgItem(IDC_BARCODE))->SetReadOnly(true);
|
83 |
}
|
84 |
|
85 |
return TRUE; // return TRUE unless you set the focus to a control
|
86 |
}
|