private void LoadInvoice(int invoiceID) { try { invoice = sqlProvider.GetInvoice(invoiceID.ToString()); if (invoice == null) { throw new Exception("Failed to retrieve the invoice from the database"); } lineItems = sqlProvider.GetInvoiceLineItems(invoiceID.ToString()); if (lineItems == null) { throw new Exception("Failed to retrieve line items from the database"); } DateTime invoiceDate; if (DateTime.TryParse(invoice.sInvoiceDate, out invoiceDate)) { dpInvoiceDate.SelectedDate = invoiceDate; } else { MessageBox.Show("Failed to load invoice date."); } int totalCost; if (int.TryParse(invoice.sTotalCost, out totalCost)) { lblTotalCost.Content = $"{totalCost:C}"; } else { MessageBox.Show("Failed to load the invoice total cost"); } dgInvoiceItems.ItemsSource = lineItems; btnEditInvoice.IsEnabled = true; btnDeleteInvoice.IsEnabled = true; lblInvoiceNum.Content = $"Invoice #{invoiceID}"; } 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); } }