/// <summary> /// Method subscribe to event handler which re-populate list view items /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnUpdateInvoiceSent(object sender, InvoiceEventInfo e) { Invoice updateInvoice = e.UpdateInvoice; addInvoiceToLibrary.ChangeElementAtPosition(updateInvoice, lstInvoices.SelectedIndex); UpdateListViewInvoices(); }
/// <summary> /// Publisher event handler method to invoice updated variables /// </summary> /// <param name="e"></param> public void OnUpdateInvoice(InvoiceEventInfo e) { if (UpdateInvoice != null) { UpdateInvoice(this, e); // call event handler } }
/// <summary> /// Method to calculate discount and new total invoice price /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDiscount_Click(object sender, RoutedEventArgs e) { if (ValidateInput()) { documentInvoice.Discount = Convert.ToDecimal(txtDiscount.Text); lblTotal.Content = documentInvoice.TotalInvoice().ToString("F"); UpdateGUI(); InvoiceEventInfo updateTotal = new InvoiceEventInfo(documentInvoice); OnUpdateInvoice(updateTotal); } }
/// <summary> /// Method to handle changes by the user in the Due date data timepicker /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void daPDueDate_SelectedDateChanged(object sender, SelectionChangedEventArgs e) { bool proceed = documentInvoice.ValidateDueDate(daPDueDate.SelectedDate.Value); if (proceed) { documentInvoice.DueDate = daPDueDate.SelectedDate.Value; InvoiceEventInfo updateTotal = new InvoiceEventInfo(documentInvoice); OnUpdateInvoice(updateTotal); daPDueDate.BorderBrush = Brushes.White; lblErrorDueDate.Content = string.Empty; } else { lblErrorDueDate.Foreground = Brushes.Red; lblErrorDueDate.Content = "Error! Due Date < Created Date"; daPDueDate.BorderBrush = Brushes.Red; } }