/[H6]/AdminDialog.cpp
ViewVC logotype

Diff of /AdminDialog.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 9 by torben, Wed Aug 30 21:57:57 2006 UTC revision 10 by torben, Thu Aug 31 07:09:37 2006 UTC
# Line 118  BOOL AdminDialog::OnInitDialog() Line 118  BOOL AdminDialog::OnInitDialog()
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    
# Line 238  void AdminDialog::OnBnClickedDelete() Line 236  void AdminDialog::OnBnClickedDelete()
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                            dblayer->DeleteEquipment(id);
259                            LoadEquipment();
260                    }
261            }
262  }  }

Legend:
Removed from v.9  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.20