/[H6]/ResultDetailsDialog.cpp
ViewVC logotype

Annotation of /ResultDetailsDialog.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 21 - (hide annotations) (download)
Fri Sep 1 02:24:38 2006 UTC (17 years ago) by torben
File size: 4585 byte(s)
Added ResultDetailsDialog.[cpp|h] - still not complete
1 torben 21 // ResultDetailsDialog.cpp : implementation file
2     //
3    
4     #include "stdafx.h"
5     #include "h6-udlånssystem.h"
6     #include "ResultDetailsDialog.h"
7     #include ".\resultdetailsdialog.h"
8     #include "CommonStorage.h"
9    
10     // ResultDetailsDialog dialog
11    
12     IMPLEMENT_DYNAMIC(ResultDetailsDialog, CDialog)
13     ResultDetailsDialog::ResultDetailsDialog(CWnd* pParent /*=NULL*/)
14     : CDialog(ResultDetailsDialog::IDD, pParent)
15     {
16     m_loadingData = false;
17     }
18    
19     ResultDetailsDialog::~ResultDetailsDialog()
20     {
21     }
22    
23     void ResultDetailsDialog::DoDataExchange(CDataExchange* pDX)
24     {
25     CDialog::DoDataExchange(pDX);
26     }
27    
28    
29     BEGIN_MESSAGE_MAP(ResultDetailsDialog, CDialog)
30     ON_EN_CHANGE(IDC_BARCODE, OnEnChangeBarcode)
31     ON_EN_CHANGE(IDC_NAME, OnEnChangeName)
32     ON_EN_CHANGE(IDC_DESCRIPTION, OnEnChangeDescription)
33     ON_EN_CHANGE(IDC_PLACEMENT, OnEnChangePlacement)
34     ON_EN_CHANGE(IDC_STATUS, OnEnChangeStatus)
35     ON_BN_CLICKED(IDC_CLOSE, OnBnClickedClose)
36     END_MESSAGE_MAP()
37    
38    
39     // ResultDetailsDialog message handlers
40    
41     void ResultDetailsDialog::LoadData(void)
42     {
43     if (m_loadingData == true)
44     return;
45     m_loadingData = true;
46     Equipment currentdata = CommonStorage::Instance()->getSearchResult()[m_resultIndex];
47    
48     GetDlgItem(IDC_BARCODE)->SetWindowText(currentdata.barcode);
49     GetDlgItem(IDC_NAME)->SetWindowText(currentdata.name);
50     GetDlgItem(IDC_DESCRIPTION)->SetWindowText(currentdata.description);
51     GetDlgItem(IDC_PLACEMENT)->SetWindowText(currentdata.placement);
52     GetDlgItem(IDC_STATUS)->SetWindowText(currentdata.status);
53    
54     m_loadingData = false;
55     }
56    
57     void ResultDetailsDialog::LoadListControls(void)
58     {
59     if (CommonStorage::Instance()->getAdmin() ) {
60     Equipment currentdata = CommonStorage::Instance()->getSearchResult()[m_resultIndex];
61    
62     //load Equipment::checkouts
63     CListCtrl *checkouts = (CListCtrl*) GetDlgItem(IDC_CHECKOUTS);
64     checkouts->InsertColumn(0,"Inits");
65     checkouts->InsertColumn(1,"Start date");
66     checkouts->InsertColumn(2,"Return date");
67     checkouts->InsertColumn(3,"Number of days");
68    
69     for (int i=0; i<currentdata.checkouts.size(); i++) {
70     int nItem = checkouts->InsertItem(i,currentdata.checkouts[i].inits);
71     checkouts->SetItemText(nItem,1,currentdata.checkouts[i].startdate);
72     checkouts->SetItemText(nItem,2,currentdata.checkouts[i].enddate);
73     checkouts->SetItemText(nItem,3,currentdata.checkouts[i].numdays);
74     }
75     checkouts->SetColumnWidth(0,LVSCW_AUTOSIZE_USEHEADER);
76     checkouts->SetColumnWidth(1,LVSCW_AUTOSIZE_USEHEADER);
77     checkouts->SetColumnWidth(2,LVSCW_AUTOSIZE_USEHEADER);
78     checkouts->SetColumnWidth(3,LVSCW_AUTOSIZE_USEHEADER);
79    
80     // load Equipment::reservations
81     CListCtrl *reservations = (CListCtrl*) GetDlgItem(IDC_RESERVATIONS);
82     reservations->InsertColumn(0,"Inits");
83     reservations->InsertColumn(1,"Start date");
84     reservations->InsertColumn(2,"Number of days");
85    
86     for (int i=0; i<currentdata.reservations.size(); i++) {
87     int nItem = reservations->InsertItem(i, currentdata.reservations[i].inits);
88     reservations->SetItemText(nItem,1, currentdata.reservations[i].startdate);
89     reservations->SetItemText(nItem,2, currentdata.reservations[i].numdays);
90     }
91    
92     reservations->SetColumnWidth(0,LVSCW_AUTOSIZE_USEHEADER);
93     reservations->SetColumnWidth(1,LVSCW_AUTOSIZE_USEHEADER);
94     reservations->SetColumnWidth(2,LVSCW_AUTOSIZE_USEHEADER);
95    
96    
97     } else { // not administrator
98     GetDlgItem(IDC_CHECKOUTS)->EnableWindow(false);
99     GetDlgItem(IDC_RESERVATIONS)->EnableWindow(false);
100     }
101     }
102    
103    
104     BOOL ResultDetailsDialog::OnInitDialog()
105     {
106     CDialog::OnInitDialog();
107    
108    
109     GetDlgItem(IDC_RESERVE)->EnableWindow(CommonStorage::Instance()->getAdmin());
110     GetDlgItem(IDC_CHECKOUT)->EnableWindow(CommonStorage::Instance()->getAdmin());
111     GetDlgItem(IDC_RETURN)->EnableWindow(CommonStorage::Instance()->getAdmin());
112    
113     CString status = CommonStorage::Instance()->getSearchResult()[m_resultIndex].status;
114    
115     if (status == "Ledig")
116     GetDlgItem(IDC_RETURN)->EnableWindow(false);
117     if (status == "Udlånt")
118     GetDlgItem(IDC_CHECKOUT)->EnableWindow(false);
119     if (status == "Reserveret")
120     GetDlgItem(IDC_RETURN)->EnableWindow(false);
121    
122     LoadData();
123     LoadListControls();
124    
125     return TRUE;
126     }
127    
128     void ResultDetailsDialog::OnEnChangeBarcode()
129     {
130     LoadData();
131     }
132    
133     void ResultDetailsDialog::OnEnChangeName()
134     {
135     LoadData();
136     }
137    
138     void ResultDetailsDialog::OnEnChangeDescription()
139     {
140     LoadData();
141     }
142    
143     void ResultDetailsDialog::OnEnChangePlacement()
144     {
145     LoadData();
146     }
147    
148    
149    
150     void ResultDetailsDialog::OnEnChangeStatus()
151     {
152     LoadData();
153     }
154    
155    
156     void ResultDetailsDialog::OnBnClickedClose()
157     {
158     OnOK();
159     }

  ViewVC Help
Powered by ViewVC 1.1.20