/[H6]/CheckoutDialog.cpp
ViewVC logotype

Annotation of /CheckoutDialog.cpp

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20