/[H6]/SearchDialog.cpp
ViewVC logotype

Contents of /SearchDialog.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 14 - (show annotations) (download)
Thu Aug 31 15:58:20 2006 UTC (17 years, 8 months ago) by torben
File size: 2491 byte(s)
Implemented search and result dialogs
1 // SearchDialog.cpp : implementation file
2 //
3
4 #include "stdafx.h"
5 #include "h6-udlånssystem.h"
6 #include "SearchDialog.h"
7 #include ".\searchdialog.h"
8
9 #include "CommonStorage.h"
10 #include "DatabaseLayer.h"
11
12 #include "MyTabCtrl.h"
13
14 // SearchDialog dialog
15
16 IMPLEMENT_DYNAMIC(SearchDialog, CDialog)
17 SearchDialog::SearchDialog(CWnd* pParent /*=NULL*/)
18 : CDialog(SearchDialog::IDD, pParent)
19 {
20 }
21
22 SearchDialog::~SearchDialog()
23 {
24 }
25
26 void SearchDialog::DoDataExchange(CDataExchange* pDX)
27 {
28 CDialog::DoDataExchange(pDX);
29 }
30
31
32 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()
37
38
39 // SearchDialog message handlers
40
41 void SearchDialog::OnOK()
42 {
43 //CDialog::OnOK();
44 }
45
46 void SearchDialog::OnCancel()
47 {
48 //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

  ViewVC Help
Powered by ViewVC 1.1.20