public NewRepair(Repair repair) { InitializeComponent(); this.Title = "Repair"; //Get repair information string repairDescription = repair.getRepairDescription(); string vin = repair.getVIN(); List <RepairLineItem> lineItems = repair.GetLineItems(); //Get customer information Customer customer = _customerManager.getCustomerByID(repair.getCustomerID()); string firstName = customer.getFirstName(); string lastName = customer.getLastName(); string address = customer.getAddress(); string email = customer.getEmailAddress(); string phoneNumber = customer.getPhoneNumber(); //Set everything to disabled btnAddLineItem.Visibility = Visibility.Hidden; btnRemoveLineItem.Visibility = Visibility.Hidden; txtVIN.IsEnabled = false; cboCustomers.IsEnabled = false; chkNewCustomer.IsEnabled = false; txtFirstName.IsEnabled = false; txtLastName.IsEnabled = false; txtAddress.IsEnabled = false; txtEmailAddress.IsEnabled = false; txtPhoneNumber.IsEnabled = false; txtDescription.IsEnabled = false; btnSaveRepair.Visibility = Visibility.Hidden; //Set the text of everything txtVIN.Text = repair.getVIN(); txtDescription.Text = repair.getRepairDescription(); txtFirstName.Text = customer.getFirstName(); txtLastName.Text = customer.getLastName(); txtAddress.Text = customer.getAddress(); txtEmailAddress.Text = customer.getEmailAddress(); txtPhoneNumber.Text = customer.getPhoneNumber(); //Set the combo box item cboCustomers.Items.Clear(); cboCustomers.Items.Add(customer.getName()); cboCustomers.SelectedIndex = 0; //Add items to the datagrid _lineItems = repair.GetLineItems(); dgLineItemList.ItemsSource = _lineItems; //dgLineItemList.Columns.RemoveAt(0); //dgLineItemList.Columns.RemoveAt(1); }
public bool addNewRepair(Repair repair) { int result = 0; int employeeID = repair.getEmployeeID(); string repairDescription = repair.getRepairDescription(); int customerID = repair.getCustomerID(); string vin = repair.getVIN(); DateTime date = repair.getDate(); List <RepairLineItem> lineItems = repair.GetLineItems(); int billingLineItemID = repair.getbillingLineItemID(); Decimal amount = repair.getAmount(); try { result = accessor.addNewRepair(repairDescription, employeeID, vin, customerID, date, billingLineItemID, amount); foreach (RepairLineItem lineItem in lineItems) { string partType = lineItem.getPartType(); Decimal amount2 = lineItem.getAmount(); string serialNumber = lineItem.getSerialNumber(); accessor.addNewRepairLineItem(result, amount, partType, serialNumber); } } catch (Exception ex) { throw ex; } return(result == 1); }