1 |
// ResultDetailsDialog.cpp : implementation file |
/* |
2 |
// |
* Developed by Torben H. Nielsen |
3 |
|
*/ |
4 |
|
|
5 |
|
|
6 |
#include "stdafx.h" |
#include "stdafx.h" |
7 |
#include "h6-udlånssystem.h" |
#include "h6-udlånssystem.h" |
10 |
#include "CommonStorage.h" |
#include "CommonStorage.h" |
11 |
#include "DatabaseLayer.h" |
#include "DatabaseLayer.h" |
12 |
#include "CheckoutDialog.h" |
#include "CheckoutDialog.h" |
13 |
|
#include "SearchDialog.h" |
14 |
|
#include "ResultDialog.h" |
15 |
|
#include "MyTabCtrl.h" |
16 |
|
|
17 |
// ResultDetailsDialog dialog |
// ResultDetailsDialog dialog |
18 |
|
|
72 |
|
|
73 |
//load Equipment::checkouts |
//load Equipment::checkouts |
74 |
CListCtrl *checkouts = (CListCtrl*) GetDlgItem(IDC_CHECKOUTS); |
CListCtrl *checkouts = (CListCtrl*) GetDlgItem(IDC_CHECKOUTS); |
75 |
checkouts->SetExtendedStyle( LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT ); |
checkouts->DeleteAllItems(); |
|
checkouts->InsertColumn(0,"Inits"); |
|
|
checkouts->InsertColumn(1,"Start date"); |
|
|
checkouts->InsertColumn(2,"Return date"); |
|
|
checkouts->InsertColumn(3,"Number of days"); |
|
76 |
|
|
77 |
for (int i=0; i<currentdata.checkouts.size(); i++) { |
for (int i=0; i<currentdata.checkouts.size(); i++) { |
78 |
int nItem = checkouts->InsertItem(i,currentdata.checkouts[i].inits); |
int nItem = checkouts->InsertItem(i,currentdata.checkouts[i].inits); |
87 |
|
|
88 |
// load Equipment::reservations |
// load Equipment::reservations |
89 |
CListCtrl *reservations = (CListCtrl*) GetDlgItem(IDC_RESERVATIONS); |
CListCtrl *reservations = (CListCtrl*) GetDlgItem(IDC_RESERVATIONS); |
90 |
reservations->SetExtendedStyle( LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT ); |
reservations->DeleteAllItems(); |
|
reservations->InsertColumn(0,"#"); |
|
|
reservations->InsertColumn(1,"Inits"); |
|
|
reservations->InsertColumn(2,"Reservation date"); |
|
91 |
|
|
92 |
|
|
93 |
for (int i=0; i<currentdata.reservations.size(); i++) { |
for (int i=0; i<currentdata.reservations.size(); i++) { |
119 |
{ |
{ |
120 |
CDialog::OnInitDialog(); |
CDialog::OnInitDialog(); |
121 |
|
|
122 |
|
CListCtrl *checkouts = (CListCtrl*) GetDlgItem(IDC_CHECKOUTS); |
123 |
|
checkouts->SetExtendedStyle( LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT ); |
124 |
|
checkouts->InsertColumn(0,"Inits"); |
125 |
|
checkouts->InsertColumn(1,"Start date"); |
126 |
|
checkouts->InsertColumn(2,"Return date"); |
127 |
|
checkouts->InsertColumn(3,"Number of days"); |
128 |
|
checkouts->SetColumnWidth(0,LVSCW_AUTOSIZE_USEHEADER); |
129 |
|
checkouts->SetColumnWidth(1,LVSCW_AUTOSIZE_USEHEADER); |
130 |
|
checkouts->SetColumnWidth(2,LVSCW_AUTOSIZE_USEHEADER); |
131 |
|
checkouts->SetColumnWidth(3,LVSCW_AUTOSIZE_USEHEADER); |
132 |
|
|
133 |
|
CListCtrl *reservations = (CListCtrl*) GetDlgItem(IDC_RESERVATIONS); |
134 |
|
reservations->SetExtendedStyle( LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT ); |
135 |
|
reservations->InsertColumn(0,"#"); |
136 |
|
reservations->InsertColumn(1,"Inits"); |
137 |
|
reservations->InsertColumn(2,"Reservation date"); |
138 |
|
reservations->SetColumnWidth(0,LVSCW_AUTOSIZE_USEHEADER); |
139 |
|
reservations->SetColumnWidth(1,LVSCW_AUTOSIZE_USEHEADER); |
140 |
|
reservations->SetColumnWidth(2,LVSCW_AUTOSIZE_USEHEADER); |
141 |
|
|
142 |
|
|
143 |
|
|
144 |
GetDlgItem(IDC_RESERVE)->EnableWindow(CommonStorage::Instance()->getAdmin()); |
GetDlgItem(IDC_RESERVE)->EnableWindow(CommonStorage::Instance()->getAdmin()); |
145 |
GetDlgItem(IDC_CHECKOUT)->EnableWindow(CommonStorage::Instance()->getAdmin()); |
GetDlgItem(IDC_CHECKOUT)->EnableWindow(CommonStorage::Instance()->getAdmin()); |
146 |
GetDlgItem(IDC_RETURN)->EnableWindow(CommonStorage::Instance()->getAdmin()); |
GetDlgItem(IDC_RETURN)->EnableWindow(CommonStorage::Instance()->getAdmin()); |
204 |
CString barcode = CommonStorage::Instance()->getSearchResult()[m_resultIndex].barcode; |
CString barcode = CommonStorage::Instance()->getSearchResult()[m_resultIndex].barcode; |
205 |
|
|
206 |
CommonStorage::Instance()->getDBLayer()->ReturnEquipment(barcode); |
CommonStorage::Instance()->getDBLayer()->ReturnEquipment(barcode); |
207 |
MessageBox("The Item is returned, but the changes won't show until the next query"); |
((SearchDialog*)CommonStorage::Instance()->getTabCtrl()->m_tabs[0])->OnBnClickedSearch(); |
208 |
|
((ResultDialog*)CommonStorage::Instance()->getTabCtrl()->m_tabs[1])->LoadResults(); |
209 |
OnOK(); |
OnOK(); |
210 |
} |
} |
211 |
|
|
236 |
if (status == "Reserveret") { //if the equipment was reserved, we must delete the reservation |
if (status == "Reserveret") { //if the equipment was reserved, we must delete the reservation |
237 |
dblayer->DeleteReservation(eq.barcode, topReservation.reservationID); |
dblayer->DeleteReservation(eq.barcode, topReservation.reservationID); |
238 |
} |
} |
239 |
|
((SearchDialog*)CommonStorage::Instance()->getTabCtrl()->m_tabs[0])->OnBnClickedSearch(); |
240 |
|
((ResultDialog*)CommonStorage::Instance()->getTabCtrl()->m_tabs[1])->LoadResults(); |
241 |
OnOK(); |
OnOK(); |
242 |
} |
} |
243 |
} |
} |
253 |
CString barcode; |
CString barcode; |
254 |
GetDlgItem(IDC_BARCODE)->GetWindowText(barcode); |
GetDlgItem(IDC_BARCODE)->GetWindowText(barcode); |
255 |
dblayer->EquipmentReservation(barcode,p); |
dblayer->EquipmentReservation(barcode,p); |
256 |
OnOK(); |
|
257 |
|
((SearchDialog*)CommonStorage::Instance()->getTabCtrl()->m_tabs[0])->OnBnClickedSearch(); |
258 |
|
((ResultDialog*)CommonStorage::Instance()->getTabCtrl()->m_tabs[1])->LoadResults(); |
259 |
|
LoadListControls(); |
260 |
|
|
261 |
} |
} |
262 |
} |
} |
263 |
|
|
268 |
CString reservationID = CommonStorage::Instance()->getSearchResult()[m_resultIndex].reservations[sel].reservationID; |
CString reservationID = CommonStorage::Instance()->getSearchResult()[m_resultIndex].reservations[sel].reservationID; |
269 |
CString barcode = CommonStorage::Instance()->getSearchResult()[m_resultIndex].barcode; |
CString barcode = CommonStorage::Instance()->getSearchResult()[m_resultIndex].barcode; |
270 |
CommonStorage::Instance()->getDBLayer()->DeleteReservation(barcode, reservationID); |
CommonStorage::Instance()->getDBLayer()->DeleteReservation(barcode, reservationID); |
271 |
MessageBox("Reservation deleted, but won't show until next search"); |
((SearchDialog*)CommonStorage::Instance()->getTabCtrl()->m_tabs[0])->OnBnClickedSearch(); |
272 |
|
((ResultDialog*)CommonStorage::Instance()->getTabCtrl()->m_tabs[1])->LoadResults(); |
273 |
|
LoadListControls(); |
274 |
} else { |
} else { |
275 |
MessageBox("No reservation is selected"); |
MessageBox("No reservation is selected"); |
276 |
} |
} |