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