コード例 #1
0
 /// <summary>
 /// Called on a click of the Edit button. Edits the existing Invoice in the DB.
 /// </summary>
 /// <param name="sender">The Edit button.</param>
 /// <param name="e">The RoutedEventArgs.</param>
 private void btn_edit_invoice_click(object sender, RoutedEventArgs e)
 {
     try
     {
         BusCtrl.updateInvoice(CurrentInvoice, CurrentInvoice.products);
         lblStatus.Content = "Updated Invoice " + CurrentInvoice.ID;
     }
     catch (Exception ex)
     {
         SearchWindow.HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                                  MethodInfo.GetCurrentMethod().Name, ex.Message);
     }
     //update current invoice in db. This will proably be done by passing the relavant info into a manager class
 }
コード例 #2
0
 /// <summary>
 /// Opens the Product window.
 /// </summary>
 /// <param name="sender">The Product button.</param>
 /// <param name="e">The RoutedEventArgs.</param>
 private void btn_product_click(object sender, RoutedEventArgs e)
 {
     try
     {
         new ProductWindow().ShowDialog();
         populateProductDropdown();
     }catch (Exception ex)
     {
         SearchWindow.HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                                  MethodInfo.GetCurrentMethod().Name, ex.Message);
     }
     //no data will need to be passed between these two objects, but both should have access to the static manger
     //class that will hold the datastructures with the invoice and product data as well as
     //comunicate with the db class
 }
コード例 #3
0
 /// <summary>
 /// add selected product to new product list and refresh UI
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnAddProduct_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (comboProductSelect.SelectedItem is Product)
         {
             CurrentInvoice.products.Add((comboProductSelect.SelectedItem as Product).Clone() as Product);
             showInvoiceInfo();
         }
     }
     catch (Exception ex)
     {
         SearchWindow.HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                                  MethodInfo.GetCurrentMethod().Name, ex.Message);
     }
 }
コード例 #4
0
 /// <summary>
 /// Clear the screen of invoice related data
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnClear_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         txtInvoiceID.Text           = "";
         DatePickerDate.SelectedDate = null;
         stackPanelInvoiceProducts.Children.Clear();
         comboProductSelect.SelectedIndex = -1;
         txtTotalCost.Text = "";
         CurrentInvoice    = new Invoice();
     }
     catch (Exception ex)
     {
         SearchWindow.HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                                  MethodInfo.GetCurrentMethod().Name, ex.Message);
     }
 }
コード例 #5
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);
     }
 }
コード例 #6
0
 /// <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
 }