Ejemplo n.º 1
0
        /// <summary>
        /// If a new invoice is created the user may enter data pertaining to that invoice.
        /// An auto-generated number from the database will be given to the invoice as the invoice number.
        /// An invoice date will also be assigned by the user.  Next different items will be entered by the user.
        /// The items will be selected from a drop down box and the cost for that item will be put into a read only textbox.
        /// This will be the default cost of an item. Once the item is selected, the user can add the item.  As many items as needed should be able to be added.
        /// All items entered should be displayed for viewing in a list (something like a DataGrid).  Items may be deleted from the list.
        /// A running total of the cost should be displayed as items are entered or deleted.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CreateSaveInvoiceButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (InvoiceDatePicker.SelectedDate == null)
                {
                    MessageBox.Show(this, "Please select a date.", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                    InvoiceDatePicker.Focus();
                }
                else
                {
                    var invoice = App.InvoiceService.CurrentInvoice;
                    if (invoice == null)
                    {
                        invoice = new Invoice
                        {
                            InvoiceDate = (DateTime)InvoiceDatePicker.SelectedDate
                        };

                        App.InvoiceService.CurrentInvoice = invoice;
                        MessageBox.Show(this, "Invoice Created", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        MessageBox.Show(this, "Invoice Saved", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                    }

                    ViewModel.RefreshInvoice();
                }
            }
            catch (Exception ex)
            {
                Error.HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex);
            }
        }
 private void ClearInvoiceFields()
 {
     InvoiceNumberValue.Text = "";
     InvoiceAmountValue.Text = "";
     InvoiceDatePicker.ResetText();
     InvoiceStatusValue.SelectedIndex = -1;
     CreateInvoiceBtn.Text            = "Create Invoice";
 }