/[H6]/ResultDialog.cpp
ViewVC logotype

Annotation of /ResultDialog.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 30 - (hide annotations) (download)
Sun Sep 3 09:19:06 2006 UTC (17 years, 10 months ago) by torben
File size: 2537 byte(s)
Finished the checkout (and reservation) dialog
1 torben 5 // ResultDialog.cpp : implementation file
2     //
3    
4     #include "stdafx.h"
5     #include "h6-udlånssystem.h"
6     #include "ResultDialog.h"
7     #include ".\resultdialog.h"
8    
9 torben 14 #include "CommonStorage.h"
10     #include "Containers.h"
11     #include "ResultDetailsDialog.h"
12 torben 5
13 torben 14
14 torben 5 // ResultDialog dialog
15    
16     IMPLEMENT_DYNAMIC(ResultDialog, CDialog)
17     ResultDialog::ResultDialog(CWnd* pParent /*=NULL*/)
18     : CDialog(ResultDialog::IDD, pParent)
19     {
20     }
21    
22     ResultDialog::~ResultDialog()
23     {
24     }
25    
26     void ResultDialog::DoDataExchange(CDataExchange* pDX)
27     {
28     CDialog::DoDataExchange(pDX);
29     }
30    
31    
32     BEGIN_MESSAGE_MAP(ResultDialog, CDialog)
33 torben 14 ON_WM_SETFOCUS()
34     ON_BN_CLICKED(IDC_DETAILS, OnBnClickedDetails)
35 torben 5 END_MESSAGE_MAP()
36    
37    
38     // ResultDialog message handlers
39    
40     void ResultDialog::OnOK()
41     {
42     // TODO: Add your specialized code here and/or call the base class
43    
44     //CDialog::OnOK();
45     }
46    
47     void ResultDialog::OnCancel()
48     {
49     // TODO: Add your specialized code here and/or call the base class
50    
51     //CDialog::OnCancel();
52     }
53 torben 14
54     void ResultDialog::OnSetFocus(CWnd* pOldWnd)
55     {
56     CDialog::OnSetFocus(pOldWnd);
57     LoadResults();
58    
59     }
60    
61     void ResultDialog::LoadResults(void)
62     {
63     CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
64     EquipmentVector result = CommonStorage::Instance()->getSearchResult();
65    
66     CString count;
67     count.Format("Found %d items", result.size());
68     GetDlgItem(IDC_COUNTER)->SetWindowText(count);
69     list->DeleteAllItems();
70    
71     for (int i=0; i<result.size(); i++) {
72     int nItem = list->InsertItem(i, result[i].barcode);
73     list->SetItemText(nItem,1,result[i].name);
74     list->SetItemText(nItem,2,result[i].status);
75     }
76    
77     if (result.size() >0) {
78     list->SetColumnWidth(0,LVSCW_AUTOSIZE);
79 torben 20 list->SetColumnWidth(1,100);
80     list->SetColumnWidth(2,100);
81 torben 14 }
82    
83     }
84    
85     BOOL ResultDialog::OnInitDialog()
86     {
87     CDialog::OnInitDialog();
88    
89     CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
90     list->SetExtendedStyle( LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT );
91     list->InsertColumn(0,"Barcode");
92     list->InsertColumn(1,"Equipment");
93     list->InsertColumn(2,"Status");
94    
95     list->SetColumnWidth(0,LVSCW_AUTOSIZE_USEHEADER);
96     list->SetColumnWidth(1,LVSCW_AUTOSIZE_USEHEADER);
97     list->SetColumnWidth(2,LVSCW_AUTOSIZE_USEHEADER);
98    
99     return TRUE;
100     }
101    
102     void ResultDialog::OnBnClickedDetails()
103     {
104     CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
105     int sel = list->GetSelectionMark();
106 torben 30
107 torben 14 if (sel == -1) {
108     MessageBox("You must select an item");
109 torben 30 } else {
110     ResultDetailsDialog resdialog;
111     resdialog.m_resultIndex = sel;
112    
113     resdialog.DoModal();
114 torben 14 }
115     }

  ViewVC Help
Powered by ViewVC 1.1.20