Ejemplo n.º 1
0
        private void LvwRepairLog_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            //Get the selected item
            Repair repair;

            if (lvwRepairLog.SelectedIndex != -1)
            {
                repair = repairs[lvwRepairLog.SelectedIndex];
            }
            else
            {
                repair = repairs[0];
            }

            //Pass the repair to a new form
            NewRepair repairWindow = new NewRepair(repair);

            repairWindow.ShowDialog();
        }
Ejemplo n.º 2
0
        private void BtnNewRepair_Click(object sender, RoutedEventArgs e)
        {
            //Create a new form
            NewRepair repairForm = new NewRepair();

            repairForm.ShowDialog();

            try
            {
                //New customer
                if (repairForm.chkNewCustomer.IsChecked == true)
                {
                    _customerManager.addNewCustomer(repairForm.customer);
                }

                //New Bill
                string firstName = repairForm.customer.getFirstName();
                string lastName  = repairForm.customer.getLastName();
                int    c         = _customerManager.getCustomerIDByCustomerName(firstName, lastName);

                //New line item
                List <BillingLineItem> lineItems = new List <BillingLineItem>();
                lineItems.Add(new BillingLineItem(0, repairForm.repair.getAmount()));
                _billingManager.newBill(new Bill(0, c,
                                                 repairForm.repair.getAmount(), 0, DateTime.Now, DateTime.Now.AddDays(30), lineItems));

                //Add repair
                repairForm.repair.setEmployeeID(_employee.getEmployeeID());
                repairForm.repair.setCustomerID(_customerManager.getCustomerIDByCustomerName(
                                                    repairForm.customer.getFirstName(), repairForm.customer.getLastName()));
                repairForm.repair.setBillingLineItemID(_billingManager.getLastestBillingLineItem());
                _repairManager.addNewRepair(repairForm.repair);
            }
            catch (Exception ex)
            {
                //throw ex;
                lblStatusMessage.Content = ex.Message;
            }
        }