/[H6]/ResultDialog.cpp
ViewVC logotype

Contents of /ResultDialog.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 54 - (show annotations) (download)
Tue Sep 12 09:09:30 2006 UTC (17 years, 7 months ago) by torben
File size: 2958 byte(s)
In the Search() function in the databaselayers we shouldn't waste time and space on finding
the previous checkouts and the current reservations - this should be done in getEquipment().

ResultDialog and ResultDetailsDialog now communicates throuh a CString barcode, insted of an index into the search result.

On an administrative action the ResultDetailsDialog now refreshes the data instead of closing the dialog.
1 /*
2 * Developed by Torben H. Nielsen
3 */
4
5 #include "stdafx.h"
6 #include "h6-udlånssystem.h"
7 #include "ResultDialog.h"
8 #include ".\resultdialog.h"
9
10 #include "CommonStorage.h"
11 #include "Containers.h"
12 #include "ResultDetailsDialog.h"
13
14
15 // ResultDialog dialog
16
17 IMPLEMENT_DYNAMIC(ResultDialog, CDialog)
18 ResultDialog::ResultDialog(CWnd* pParent /*=NULL*/)
19 : CDialog(ResultDialog::IDD, pParent)
20 {
21 }
22
23 ResultDialog::~ResultDialog()
24 {
25 }
26
27 void ResultDialog::DoDataExchange(CDataExchange* pDX)
28 {
29 CDialog::DoDataExchange(pDX);
30 }
31
32
33 BEGIN_MESSAGE_MAP(ResultDialog, CDialog)
34 ON_WM_SETFOCUS()
35 ON_BN_CLICKED(IDC_DETAILS, OnBnClickedDetails)
36 ON_NOTIFY(NM_DBLCLK, IDC_LIST, OnNMDblclkList)
37 END_MESSAGE_MAP()
38
39
40 // ResultDialog message handlers
41
42 void ResultDialog::OnOK()
43 {
44 // TODO: Add your specialized code here and/or call the base class
45
46 //CDialog::OnOK();
47 }
48
49 void ResultDialog::OnCancel()
50 {
51 // TODO: Add your specialized code here and/or call the base class
52
53 //CDialog::OnCancel();
54 }
55
56 void ResultDialog::OnSetFocus(CWnd* pOldWnd)
57 {
58 CDialog::OnSetFocus(pOldWnd);
59 LoadResults();
60
61 }
62
63 void ResultDialog::LoadResults(void)
64 {
65 CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
66 vector<Equipment> result = CommonStorage::Instance()->getSearchResult();
67
68 CString count;
69 count.Format("Found %d items", result.size());
70 GetDlgItem(IDC_COUNTER)->SetWindowText(count);
71 list->DeleteAllItems();
72
73 for (int i=0; i<result.size(); i++) {
74 int nItem = list->InsertItem(i, result[i].barcode);
75 list->SetItemText(nItem,1,result[i].name);
76 list->SetItemText(nItem,2,result[i].status);
77 }
78
79 if (result.size() >0) {
80 list->SetColumnWidth(0,LVSCW_AUTOSIZE);
81 list->SetColumnWidth(1,100);
82 list->SetColumnWidth(2,100);
83 }
84
85 }
86
87 BOOL ResultDialog::OnInitDialog()
88 {
89 CDialog::OnInitDialog();
90
91 CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
92 list->SetExtendedStyle( LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT );
93 list->InsertColumn(0,"Barcode");
94 list->InsertColumn(1,"Equipment");
95 list->InsertColumn(2,"Status");
96
97 list->SetColumnWidth(0,LVSCW_AUTOSIZE_USEHEADER);
98 list->SetColumnWidth(1,LVSCW_AUTOSIZE_USEHEADER);
99 list->SetColumnWidth(2,LVSCW_AUTOSIZE_USEHEADER);
100
101 return TRUE;
102 }
103
104 void ResultDialog::OnBnClickedDetails()
105 {
106 CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
107 int sel = list->GetSelectionMark();
108 CString barcode = list->GetItemText(sel,0);
109
110 if (sel == -1) {
111 MessageBox("You must select an item");
112 } else {
113 ResultDetailsDialog resdialog;
114 resdialog.m_barcode = barcode;
115
116 resdialog.DoModal();
117 }
118 }
119
120 void ResultDialog::OnNMDblclkList(NMHDR *pNMHDR, LRESULT *pResult)
121 {
122 CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
123 int sel = list->GetSelectionMark();
124 CString barcode = list->GetItemText(sel,0);
125
126 ResultDetailsDialog resdialog;
127 resdialog.m_barcode = barcode;
128
129 resdialog.DoModal();
130
131 *pResult = 0;
132 }

  ViewVC Help
Powered by ViewVC 1.1.20