/[H6]/CheckoutDialog.cpp
ViewVC logotype

Contents of /CheckoutDialog.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 30 - (show annotations) (download)
Sun Sep 3 09:19:06 2006 UTC (17 years, 7 months ago) by torben
File size: 2854 byte(s)
Finished the checkout (and reservation) dialog
1 // CheckoutDialog.cpp : implementation file
2 //
3
4 #include "stdafx.h"
5 #include "h6-udlånssystem.h"
6 #include "CheckoutDialog.h"
7 #include ".\checkoutdialog.h"
8
9 #include "CommonStorage.h"
10 #include "DatabaseLayer.h"
11 #include "Containers.h"
12
13
14
15 // CheckoutDialog dialog
16
17 IMPLEMENT_DYNAMIC(CheckoutDialog, CDialog)
18 CheckoutDialog::CheckoutDialog(CWnd* pParent /*=NULL*/)
19 : CDialog(CheckoutDialog::IDD, pParent)
20 {
21 }
22
23 CheckoutDialog::~CheckoutDialog()
24 {
25 }
26
27 void CheckoutDialog::DoDataExchange(CDataExchange* pDX)
28 {
29 CDialog::DoDataExchange(pDX);
30 }
31
32
33 BEGIN_MESSAGE_MAP(CheckoutDialog, CDialog)
34 ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST, OnLvnItemchangedList)
35 ON_BN_CLICKED(IDOK, OnBnClickedOk)
36 END_MESSAGE_MAP()
37
38
39 // CheckoutDialog message handlers
40
41 BOOL CheckoutDialog::OnInitDialog()
42 {
43 CDialog::OnInitDialog();
44
45 if (m_checkoutMode == true) {
46 this->SetWindowText("Checkout");
47 GetDlgItem(IDC_NUMDAYS)->SetWindowText("30");
48
49 if (m_reservedTo != "") {
50 GetDlgItem(IDC_INITS)->SetWindowText(m_reservedTo);
51 GetDlgItem(IDC_INITS)->EnableWindow(false);
52 GetDlgItem(IDC_LIST)->EnableWindow(false);
53 }
54
55 } else {//reservation
56 this->SetWindowText("Reservation");
57 GetDlgItem(IDC_NUMDAYS)->EnableWindow(false);
58 }
59
60 CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
61 list->SetExtendedStyle( LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT );
62 list->InsertColumn(0,"Inits");
63 list->InsertColumn(1,"Name");
64
65 m_persons = CommonStorage::Instance()->getDBLayer()->GetPersonAll();
66
67 for (int i=0; i<m_persons.size(); i++) {
68 int nItem = list->InsertItem(i, m_persons[i].inits);
69 list->SetItemText(nItem, 1, m_persons[i].name);
70 }
71 list->SetColumnWidth(0,50);
72 list->SetColumnWidth(1, LVSCW_AUTOSIZE);
73
74 ((CEdit*)GetDlgItem(IDC_INITS))->SetLimitText(4);
75
76 return TRUE;
77 }
78
79 void CheckoutDialog::OnLvnItemchangedList(NMHDR *pNMHDR, LRESULT *pResult)
80 {
81 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
82
83 CListCtrl* list = (CListCtrl*) GetDlgItem(IDC_LIST);
84 int selected = list->GetSelectionMark();
85 CString inits = list->GetItemText(selected,0);
86
87 GetDlgItem(IDC_INITS)->SetWindowText(inits);
88
89 *pResult = 0;
90 }
91
92 void CheckoutDialog::OnBnClickedOk()
93 {
94 GetDlgItem(IDC_INITS)->GetWindowText(m_inits);
95 GetDlgItem(IDC_NUMDAYS)->GetWindowText(m_numdays);
96 bool foundInits = false;
97
98 if (m_inits == "") {
99 MessageBox("You must fill out the initials field");
100 return;
101 }
102
103 if (m_checkoutMode == true && m_numdays == "") {
104 MessageBox("You must enter number of days");
105 return;
106 }
107
108 for (int i=0; i<m_persons.size(); i++) {
109 if (m_persons[i].inits.MakeLower() == m_inits.MakeLower()) {
110 foundInits = true;
111 break;
112 }
113 }
114
115 if (foundInits == false) {
116 MessageBox("You must enter a valid set of initials");
117 return;
118 }
119
120 OnOK();
121 }

  ViewVC Help
Powered by ViewVC 1.1.20