Beispiel #1
0
 private void DeletePhoneButton_Click(object sender, EventArgs e)
 {
     if (PhoneList.SelectedRows.Count != 0)
     {
         if (PhoneList.SelectedRows != null && PhoneList.SelectedRows[0] != null &&
             PhoneList.SelectedRows[0].Cells[1].Value != null && PhoneList.SelectedRows[0].Cells[2].Value != null &&
             PhoneList.SelectedRows[0].Cells[0].Value != null)
         {
             int phone_number;
             if (Int32.TryParse(PhoneList.SelectedRows[0].Cells[2].Value.ToString(), out phone_number))
             {
                 AsmxService.DelPhone(new Phone
                 {
                     Id           = int.Parse(PhoneList.SelectedRows[0].Cells[0].Value.ToString()),
                     Last_name    = PhoneList.SelectedRows[0].Cells[1].Value.ToString(),
                     Phone_number = Int32.Parse(PhoneList.SelectedRows[0].Cells[2].Value.ToString())
                 });
                 LoadPhoneList();
             }
             else
             {
                 MessageBox.Show("В номере телефона доступны только цифры");
             }
         }
     }
     if (CatList.SelectedRows.Count != 0)
     {
         if (CatList.SelectedRows != null && CatList.SelectedRows[0] != null &&
             CatList.SelectedRows[0].Cells[1].Value != null && CatList.SelectedRows[0].Cells[2].Value != null &&
             CatList.SelectedRows[0].Cells[0].Value != null)
         {
             int ifInt;
             if (!Int32.TryParse(CatList.SelectedRows[0].Cells[2].Value.ToString(), out ifInt))
             {
                 WCFService.DelCat(new ClassLibrary.Cat
                 {
                     Id    = int.Parse(CatList.SelectedRows[0].Cells[0].Value.ToString()),
                     Name  = CatList.SelectedRows[0].Cells[1].Value.ToString(),
                     Breed = CatList.SelectedRows[0].Cells[2].Value.ToString()
                 });
                 LoadCatList();
             }
             else
             {
                 MessageBox.Show("Порода кота не может содержать цифры");
             }
         }
     }
 }