/[H6]/SearchDialog.cpp
ViewVC logotype

Diff of /SearchDialog.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5 by torben, Wed Aug 30 08:19:13 2006 UTC revision 28 by torben, Sun Sep 3 09:15:24 2006 UTC
# Line 6  Line 6 
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    
# Line 26  void SearchDialog::DoDataExchange(CDataE Line 30  void SearchDialog::DoDataExchange(CDataE
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    
# Line 33  END_MESSAGE_MAP() Line 40  END_MESSAGE_MAP()
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            ((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    

Legend:
Removed from v.5  
changed lines
  Added in v.28

  ViewVC Help
Powered by ViewVC 1.1.20