/// <summary> /// Called on a click of the Delete button. Deletes the existing Invoice in the DB. /// </summary> /// <param name="sender">The Delete button.</param> /// <param name="e">The RoutedEventArgs.</param> private void btn_delete_invoice_click(object sender, RoutedEventArgs e) { try { if (CurrentInvoice.ID == null) { return; } BusCtrl.deleteInvoice(CurrentInvoice.ID); lblStatus.Content = "Invoice " + CurrentInvoice.ID + " Deleted"; txtInvoiceID.Text = ""; DatePickerDate.SelectedDate = null; txtTotalCost.Text = ""; stackPanelInvoiceProducts.Children.Clear(); CurrentInvoice = new Invoice(); } catch (Exception ex) { SearchWindow.HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex.Message); } //delete the current invoice. this will probalby be done in some object manager class that you pass the id }
/// <summary> /// Opens the Invoice Search window. /// </summary> /// <param name="sender">The Search button.</param> /// <param name="e">The RoutedEventArgs.</param> private void btn_search_click(object sender, RoutedEventArgs e) { //this will open the search window. Will need a constructor on the search window that accepts //an out variable to be set to the id to populate in the main window try { //CurrentInvoice = BusCtrl.getInvoiceByID(5000); //showInvoiceInfo(); //return; int lookUpId = new SearchWindow().ShowDialog(); if (lookUpId == -1) { return; } CurrentInvoice = BusCtrl.getInvoiceByID(lookUpId); showInvoiceInfo(); } catch (Exception ex) { //handle error } }