/// <summary> /// This will delete an existing Invoice /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDeleteInvoice_Click(object sender, RoutedEventArgs e) { try { clsInvoice invoice = (clsInvoice)dgInvoices.SelectedItem; string invoiceNum = invoice.InvoiceNum.ToString(); ml.DeleteLineItems(invoiceNum); ml.DeleteInvoice(invoiceNum); dgInvoices.ClearValue(ItemsControl.ItemsSourceProperty); //Populate DataGrid with Invoices List <clsInvoice> refresh = ml.GetAllInvoices(); dgInvoices.ItemsSource = refresh; //disable Delete and Edit Buttons btnDeleteInvoice.IsEnabled = false; btnEditInvoice.IsEnabled = false; } catch (Exception ex) { HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex.Message); } }