1 |
// AdminDialog.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" |
119 |
|
|
120 |
void AdminDialog::OnBnClickedRdusers() |
void AdminDialog::OnBnClickedRdusers() |
121 |
{ |
{ |
|
GetDlgItem(IDC_DELETE)->EnableWindow(true); |
|
122 |
LoadUsers(); |
LoadUsers(); |
123 |
} |
} |
124 |
|
|
125 |
void AdminDialog::OnBnClickedRdequipment() |
void AdminDialog::OnBnClickedRdequipment() |
126 |
{ |
{ |
|
GetDlgItem(IDC_DELETE)->EnableWindow(false); |
|
127 |
LoadEquipment(); |
LoadEquipment(); |
128 |
} |
} |
129 |
|
|
237 |
int sel = list->GetSelectionMark(); |
int sel = list->GetSelectionMark(); |
238 |
|
|
239 |
if (sel == -1) { |
if (sel == -1) { |
240 |
MessageBox("You must select an user to delete"); |
MessageBox("You must select an user/equipment to delete"); |
241 |
return; |
return; |
242 |
} |
} |
243 |
|
|
244 |
CString inits = list->GetItemText(sel,0); |
DatabaseLayer *dblayer = CommonStorage::Instance()->getDBLayer(); |
|
CString name = list->GetItemText(sel,1); |
|
245 |
|
|
246 |
|
CString id = list->GetItemText(sel,0); |
247 |
|
CString name = list->GetItemText(sel,1); |
248 |
CString question; |
CString question; |
249 |
question.Format("Are you sure you want to delete %s : %s ?", inits,name); |
question.Format("Are you sure you want to delete %s : %s ?", id,name); |
|
if (MessageBox(question, "Delete",MB_YESNO) == IDYES) { |
|
|
Person p = CommonStorage::Instance()->getDBLayer()->GetPerson(inits); |
|
|
CommonStorage::Instance()->getDBLayer()->DeletePerson(p); |
|
|
LoadUsers(); |
|
|
} |
|
250 |
|
|
251 |
|
if ( ((CButton*)GetDlgItem(IDC_RDUSERS))->GetCheck() ) { |
252 |
|
if (MessageBox(question, "Delete user",MB_YESNO) == IDYES) { |
253 |
|
Person p = CommonStorage::Instance()->getDBLayer()->GetPerson(id); |
254 |
|
CommonStorage::Instance()->getDBLayer()->DeletePerson(p); |
255 |
|
LoadUsers(); |
256 |
|
} |
257 |
|
} else { |
258 |
|
if (MessageBox(question,"Delete equipment", MB_YESNO) == IDYES) { |
259 |
|
Equipment e; |
260 |
|
e.barcode = id; |
261 |
|
dblayer->DeleteEquipment(e); |
262 |
|
LoadEquipment(); |
263 |
|
} |
264 |
|
} |
265 |
} |
} |