示例#1
0
 public void BtnDelete_Click(object sender, RoutedEventArgs e)
 {
     if (delete())
     {
         try
         {
             var boxResult = MessageBox.Show("Are you sure you want to Delete this Pet Type?", "Delete Pet Type", MessageBoxButton.YesNo);
             if (boxResult == MessageBoxResult.Yes)
             {
                 var result = _petTypeManager.DeletePetType(cboPetType.SelectedItem.ToString());
                 if (result == true)
                 {
                     this.DialogResult = true;
                     MessageBox.Show("Pet Type Deleted.");
                     Close();
                 }
                 else
                 {
                     MessageBox.Show("Pet Type could not be deleted");
                     this.DialogResult = false;
                 }
             }
         }
         //catch (SqlException ex)
         //{
         //    MessageBox.Show(ex.Message + Environment.NewLine + "Pet Type could not be Deleted.");
         //}
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Deleting Pet Type Failed.");
         }
     }
 }