--- AdminDialog.cpp 2006/08/30 21:57:57 9 +++ AdminDialog.cpp 2006/08/31 07:09:37 10 @@ -118,13 +118,11 @@ void AdminDialog::OnBnClickedRdusers() { - GetDlgItem(IDC_DELETE)->EnableWindow(true); LoadUsers(); } void AdminDialog::OnBnClickedRdequipment() { - GetDlgItem(IDC_DELETE)->EnableWindow(false); LoadEquipment(); } @@ -238,19 +236,27 @@ int sel = list->GetSelectionMark(); if (sel == -1) { - MessageBox("You must select an user to delete"); + MessageBox("You must select an user/equipment to delete"); return; } - CString inits = list->GetItemText(sel,0); - CString name = list->GetItemText(sel,1); + DatabaseLayer *dblayer = CommonStorage::Instance()->getDBLayer(); + CString id = list->GetItemText(sel,0); + CString name = list->GetItemText(sel,1); CString question; - question.Format("Are you sure you want to delete %s : %s ?", inits,name); - if (MessageBox(question, "Delete",MB_YESNO) == IDYES) { - Person p = CommonStorage::Instance()->getDBLayer()->GetPerson(inits); - CommonStorage::Instance()->getDBLayer()->DeletePerson(p); - LoadUsers(); - } + question.Format("Are you sure you want to delete %s : %s ?", id,name); + if ( ((CButton*)GetDlgItem(IDC_RDUSERS))->GetCheck() ) { + if (MessageBox(question, "Delete user",MB_YESNO) == IDYES) { + Person p = CommonStorage::Instance()->getDBLayer()->GetPerson(id); + CommonStorage::Instance()->getDBLayer()->DeletePerson(p); + LoadUsers(); + } + } else { + if (MessageBox(question,"Delete equipment", MB_YESNO) == IDYES) { + dblayer->DeleteEquipment(id); + LoadEquipment(); + } + } }