예제 #1
0
 /// <summary>
 /// Handle the delete invoice button being clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnDeleteInvoice_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (!sqlProvider.DeleteInvoiceLineItems(invoice))
         {
             MessageBox.Show("Failed to remove line items from the database.");
             return;
         }
         if (!sqlProvider.DeleteInvoice(invoice))
         {
             MessageBox.Show("Failed to remove the invoice from the database. Line items removed successfully");
             return;
         }
         isNewInvoice               = false;
         lblInvoiceNum.Content      = "Invoice";
         dgInvoiceItems.ItemsSource = null;
         dgInvoiceItems.Items.Refresh();
         invoice = null;
         btnEditInvoice.IsEnabled   = false;
         btnDeleteInvoice.IsEnabled = false;
         dpInvoiceDate.SelectedDate = null;
         lblTotalCost.Content       = "";
         btnEditInvoice.IsEnabled   = false;
         btnDeleteInvoice.IsEnabled = false;
         UpdateIsEnabledField(false);
         MessageBox.Show("Invoice deleted successfully.");
     }
     catch (Exception ex)
     {
         //This is the top level method so we want to handle the exception
         HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                     MethodInfo.GetCurrentMethod().Name, ex.Message);
     }
 }