1 |
// ResultDialog.cpp : implementation file |
/* |
2 |
// |
* Developed by Torben H. Nielsen |
3 |
|
*/ |
4 |
|
|
5 |
#include "stdafx.h" |
#include "stdafx.h" |
6 |
#include "h6-udlånssystem.h" |
#include "h6-udlånssystem.h" |
33 |
BEGIN_MESSAGE_MAP(ResultDialog, CDialog) |
BEGIN_MESSAGE_MAP(ResultDialog, CDialog) |
34 |
ON_WM_SETFOCUS() |
ON_WM_SETFOCUS() |
35 |
ON_BN_CLICKED(IDC_DETAILS, OnBnClickedDetails) |
ON_BN_CLICKED(IDC_DETAILS, OnBnClickedDetails) |
36 |
|
ON_NOTIFY(NM_DBLCLK, IDC_LIST, OnNMDblclkList) |
37 |
END_MESSAGE_MAP() |
END_MESSAGE_MAP() |
38 |
|
|
39 |
|
|
63 |
void ResultDialog::LoadResults(void) |
void ResultDialog::LoadResults(void) |
64 |
{ |
{ |
65 |
CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST); |
CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST); |
66 |
EquipmentVector result = CommonStorage::Instance()->getSearchResult(); |
vector<Equipment> result = CommonStorage::Instance()->getSearchResult(); |
67 |
|
|
68 |
CString count; |
CString count; |
69 |
count.Format("Found %d items", result.size()); |
count.Format("Found %d items", result.size()); |
78 |
|
|
79 |
if (result.size() >0) { |
if (result.size() >0) { |
80 |
list->SetColumnWidth(0,LVSCW_AUTOSIZE); |
list->SetColumnWidth(0,LVSCW_AUTOSIZE); |
81 |
list->SetColumnWidth(1,80); |
list->SetColumnWidth(1,100); |
82 |
list->SetColumnWidth(2,80); |
list->SetColumnWidth(2,100); |
83 |
} |
} |
84 |
|
|
85 |
} |
} |
104 |
void ResultDialog::OnBnClickedDetails() |
void ResultDialog::OnBnClickedDetails() |
105 |
{ |
{ |
106 |
CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST); |
CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST); |
107 |
int sel = list->GetSelectionMark(); |
if (list->GetItemCount() > 0) { |
108 |
if (sel == -1) { |
|
109 |
MessageBox("You must select an item"); |
int sel = list->GetSelectionMark(); |
110 |
return; |
CString barcode = list->GetItemText(sel,0); |
111 |
|
|
112 |
|
if (sel == -1) { |
113 |
|
MessageBox("You must select an item"); |
114 |
|
} else { |
115 |
|
ResultDetailsDialog resdialog; |
116 |
|
resdialog.m_barcode = barcode; |
117 |
|
|
118 |
|
resdialog.DoModal(); |
119 |
|
} |
120 |
} |
} |
121 |
|
} |
122 |
|
|
123 |
ResultDetailsDialog resdialog; |
void ResultDialog::OnNMDblclkList(NMHDR *pNMHDR, LRESULT *pResult) |
124 |
resdialog.m_resultIndex = sel; |
{ |
125 |
|
CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST); |
126 |
|
if (list->GetItemCount() > 0) { |
127 |
|
int sel = list->GetSelectionMark(); |
128 |
|
CString barcode = list->GetItemText(sel,0); |
129 |
|
|
130 |
|
ResultDetailsDialog resdialog; |
131 |
|
resdialog.m_barcode = barcode; |
132 |
|
|
133 |
|
resdialog.DoModal(); |
134 |
|
} |
135 |
|
|
136 |
resdialog.DoModal(); |
*pResult = 0; |
137 |
} |
} |