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

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

  ViewVC Help
Powered by ViewVC 1.1.20