/[H6]/SearchDialog.cpp
ViewVC logotype

Contents of /SearchDialog.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 28 - (show annotations) (download)
Sun Sep 3 09:15:24 2006 UTC (17 years, 7 months ago) by torben
File size: 2578 byte(s)
Max 13 characters in searchdialog: barcode field
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 ((CEdit*)GetDlgItem(IDC_BARCODE))->SetLimitText(13); //max 13 chars in barcode field
67
68 return TRUE;
69 }
70
71 void SearchDialog::OnBnClickedClear()
72 {
73 ((CButton*)GetDlgItem(IDC_AVAILABLE))->SetCheck(true);
74 ((CButton*)GetDlgItem(IDC_RESERVED))->SetCheck(false);
75 ((CButton*)GetDlgItem(IDC_DEPOSITED))->SetCheck(false);
76 GetDlgItem(IDC_NAME)->SetWindowText("");
77 GetDlgItem(IDC_BARCODE)->SetWindowText("");
78 GetDlgItem(IDC_INITS)->SetWindowText("");
79 }
80
81
82 void SearchDialog::OnBnClickedSearch()
83 {
84 CString inits,barcode,name;
85 bool available, reserved,deposited;
86
87 available = ( ((CButton*)GetDlgItem(IDC_AVAILABLE))->GetCheck() == 1);
88 reserved = ( ((CButton*)GetDlgItem(IDC_RESERVED))->GetCheck() == 1);
89 deposited = ( ((CButton*)GetDlgItem(IDC_DEPOSITED))->GetCheck() == 1);
90
91 GetDlgItem(IDC_INITS)->GetWindowText(inits);
92 GetDlgItem(IDC_BARCODE)->GetWindowText(barcode);
93 GetDlgItem(IDC_NAME)->GetWindowText(name);
94
95 DatabaseLayer *dblayer = CommonStorage::Instance()->getDBLayer();
96
97
98 vector<Equipment> buffer = dblayer->Search(barcode, name, inits, available, reserved, deposited);
99 CommonStorage::Instance()->setSearchResult(buffer);
100 CommonStorage::Instance()->getTabCtrl()->SetCurSel(1);
101 CommonStorage::Instance()->getTabCtrl()->ChangeFocus();;
102
103 }
104
105

  ViewVC Help
Powered by ViewVC 1.1.20