6 |
#include "SearchDialog.h" |
#include "SearchDialog.h" |
7 |
#include ".\searchdialog.h" |
#include ".\searchdialog.h" |
8 |
|
|
9 |
|
#include "CommonStorage.h" |
10 |
|
#include "DatabaseLayer.h" |
11 |
|
|
12 |
|
#include "MyTabCtrl.h" |
13 |
|
|
14 |
// SearchDialog dialog |
// SearchDialog dialog |
15 |
|
|
30 |
|
|
31 |
|
|
32 |
BEGIN_MESSAGE_MAP(SearchDialog, CDialog) |
BEGIN_MESSAGE_MAP(SearchDialog, CDialog) |
33 |
|
ON_WM_SETFOCUS() |
34 |
|
ON_BN_CLICKED(IDC_CLEAR, OnBnClickedClear) |
35 |
|
ON_BN_CLICKED(IDC_SEARCH, OnBnClickedSearch) |
36 |
END_MESSAGE_MAP() |
END_MESSAGE_MAP() |
37 |
|
|
38 |
|
|
40 |
|
|
41 |
void SearchDialog::OnOK() |
void SearchDialog::OnOK() |
42 |
{ |
{ |
|
// TODO: Add your specialized code here and/or call the base class |
|
|
|
|
43 |
//CDialog::OnOK(); |
//CDialog::OnOK(); |
44 |
} |
} |
45 |
|
|
46 |
void SearchDialog::OnCancel() |
void SearchDialog::OnCancel() |
47 |
{ |
{ |
|
// TODO: Add your specialized code here and/or call the base class |
|
|
|
|
48 |
//CDialog::OnCancel(); |
//CDialog::OnCancel(); |
49 |
} |
} |
50 |
|
|
51 |
|
void SearchDialog::OnSetFocus(CWnd* pOldWnd) |
52 |
|
{ |
53 |
|
GetDlgItem(IDC_INITS)->EnableWindow( CommonStorage::Instance()->getAdmin() ); |
54 |
|
|
55 |
|
if (! CommonStorage::Instance()->getAdmin() ) { |
56 |
|
GetDlgItem(IDC_INITS)->SetWindowText(""); |
57 |
|
} |
58 |
|
} |
59 |
|
|
60 |
|
BOOL SearchDialog::OnInitDialog() |
61 |
|
{ |
62 |
|
CDialog::OnInitDialog(); |
63 |
|
|
64 |
|
GetDlgItem(IDC_INITS)->EnableWindow(false); |
65 |
|
((CButton*)GetDlgItem(IDC_AVAILABLE))->SetCheck(true); |
66 |
|
|
67 |
|
return TRUE; |
68 |
|
} |
69 |
|
|
70 |
|
void SearchDialog::OnBnClickedClear() |
71 |
|
{ |
72 |
|
((CButton*)GetDlgItem(IDC_AVAILABLE))->SetCheck(true); |
73 |
|
((CButton*)GetDlgItem(IDC_RESERVED))->SetCheck(false); |
74 |
|
((CButton*)GetDlgItem(IDC_DEPOSITED))->SetCheck(false); |
75 |
|
GetDlgItem(IDC_NAME)->SetWindowText(""); |
76 |
|
GetDlgItem(IDC_BARCODE)->SetWindowText(""); |
77 |
|
GetDlgItem(IDC_INITS)->SetWindowText(""); |
78 |
|
} |
79 |
|
|
80 |
|
|
81 |
|
void SearchDialog::OnBnClickedSearch() |
82 |
|
{ |
83 |
|
CString inits,barcode,name; |
84 |
|
bool available, reserved,deposited; |
85 |
|
|
86 |
|
available = ( ((CButton*)GetDlgItem(IDC_AVAILABLE))->GetCheck() == 1); |
87 |
|
reserved = ( ((CButton*)GetDlgItem(IDC_RESERVED))->GetCheck() == 1); |
88 |
|
deposited = ( ((CButton*)GetDlgItem(IDC_DEPOSITED))->GetCheck() == 1); |
89 |
|
|
90 |
|
GetDlgItem(IDC_INITS)->GetWindowText(inits); |
91 |
|
GetDlgItem(IDC_BARCODE)->GetWindowText(barcode); |
92 |
|
GetDlgItem(IDC_NAME)->GetWindowText(name); |
93 |
|
|
94 |
|
DatabaseLayer *dblayer = CommonStorage::Instance()->getDBLayer(); |
95 |
|
|
96 |
|
|
97 |
|
vector<Equipment> buffer = dblayer->Search(barcode, name, inits, available, reserved, deposited); |
98 |
|
CommonStorage::Instance()->setSearchResult(buffer); |
99 |
|
CommonStorage::Instance()->getTabCtrl()->SetCurSel(1); |
100 |
|
CommonStorage::Instance()->getTabCtrl()->ChangeFocus();; |
101 |
|
|
102 |
|
} |
103 |
|
|
104 |
|
|