コード例 #1
0
 /// <summary>
 /// Called on a click of the Add button. Inserts a new Invoice into the DB.
 /// </summary>
 /// <param name="sender">The Add button.</param>
 /// <param name="e">The RoutedEventArgs.</param>
 private void btn_add_invoice_click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (DatePickerDate.SelectedDate == null || CurrentInvoice.products.Count == 0)
         {
             lblStatus.Content = "Cannot add an empty invoice";
             return;
         }
         int newId = BusCtrl.addInvoice(DatePickerDate.SelectedDate.Value, CurrentInvoice.products);
         //insert new invoiced data into the db. this will probably be done through a manager class to avoid work on the ui
         lblStatus.Content = "Invoice #" + newId + " added";
         CurrentInvoice    = BusCtrl.getInvoiceByID(newId);
         showInvoiceInfo();
     }
     catch (Exception ex)
     {
         SearchWindow.HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                                  MethodInfo.GetCurrentMethod().Name, ex.Message);
     }
 }
コード例 #2
0
        /// <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
            }
        }