private void BtnNewSale_Click(object sender, RoutedEventArgs e) { NewSale saleForm = new NewSale(); saleForm.ShowDialog(); if (saleForm.saved) { string firstName; string lastName; try { //Add a customer if ((bool)saleForm.chkExisting.IsChecked) { _customerManager.addNewCustomer(saleForm.cust); } //New Bill List <BillingLineItem> lineItems = new List <BillingLineItem>(); firstName = saleForm.cust.getFirstName(); lastName = saleForm.cust.getLastName(); int c = _customerManager.getCustomerIDByCustomerName(firstName, lastName); //New billing line item lineItems.Add(new BillingLineItem(0, saleForm.sale.getSaleAmount())); _billingManager.newBill(new Bill(0, c, saleForm.sale.getSaleAmount(), 0, DateTime.Now, DateTime.Now.AddDays(30), lineItems)); //New sale firstName = saleForm.cust.getFirstName(); lastName = saleForm.cust.getLastName(); string vin = saleForm.availableCars[saleForm.cboCar.SelectedIndex].getVIN(); saleForm.sale.addEmployee(_employee.getEmployeeID()); saleForm.sale.setBillingLineItemID(_billingManager.getLastestBillingLineItem()); saleForm.sale.setCustomerID(_customerManager.getCustomerIDByCustomerName(firstName, lastName)); _saleManager.addNewSale(saleForm.sale, vin); lblStatusMessage.Content = "Update success"; } catch (Exception ex) { lblStatusMessage.Content = ex.Message; } } }
private void LvwSalesLog_MouseDoubleClick(object sender, MouseButtonEventArgs e) { //Get a list of sales List <Sale> sales = _saleManager.returnAllSales(); Sale sale; //Get the selected item if (lvwSalesLog.SelectedIndex != -1) { sale = sales[lvwSalesLog.SelectedIndex]; } else { sale = sales[0]; } //Pass the sale to a new form NewSale saleForm = new NewSale(sale); saleForm.ShowDialog(); }