Example #1
0
        private void LvwTradeIns_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            //Make a list and add trade-ins to it
            List <Car> usedCars = new List <Car>();

            foreach (Car car in cars)
            {
                if (car.isUsed() && (car.getTradeInID() != 0))
                {
                    usedCars.Add(car);
                }
            }

            //Get the selected car object
            Car car2;

            if (lvwTradeIns.SelectedIndex != -1)
            {
                car2 = usedCars[lvwTradeIns.SelectedIndex];
            }
            else
            {
                car2 = usedCars[0];
            }

            //Pass the car to a new form
            Car    updatedCar;
            NewCar carForm = new NewCar(car2);

            carForm.ShowDialog();
            updatedCar = carForm.currentCar;
        }
Example #2
0
        private void BtnTradeIn_Click(object sender, RoutedEventArgs e)
        {
            //Make a new car form
            NewCar carForm = new NewCar(true);

            carForm.isTradeIn(true);
            carForm.ShowDialog();

            //Get the trade in destination
            string destination = carForm.shipmentAmountOrTradeInDestination;

            //Try to add to the database
            if (carForm.saved)
            {
                Car car = carForm.currentCar;
                try
                {
                    _carManager.addTradeIn(car, destination, _employee.getEmployeeID(), DateTime.Now);
                }
                catch (Exception ex)
                {
                    lblStatusMessage.Content = ex.Message;
                }
            }
        }
Example #3
0
        private void LvwNewCars_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            //Make a list of new cars and add new cars to it
            List <Car> newCars = new List <Car>();

            foreach (Car car in cars)
            {
                if (!car.isUsed())
                {
                    newCars.Add(car);
                }
            }

            //Get the selected car object
            Car car2;

            if (lvwNewCars.SelectedIndex != -1)
            {
                car2 = newCars[lvwNewCars.SelectedIndex];
            }
            else
            {
                car2 = newCars[0];
            }

            //Send the car to a new form
            Car    updatedCar;
            NewCar carForm = new NewCar(car2);

            carForm.ShowDialog();
            updatedCar = carForm.currentCar;
        }
Example #4
0
        private void BtnUsedCar_Click(object sender, RoutedEventArgs e)
        {
            //Make a new form
            NewCar carForm = new NewCar(true);

            carForm.isTradeIn(false);
            carForm.ShowDialog();

            //Get the shipment amount
            Decimal shipmentAmount = Convert.ToDecimal(
                carForm.shipmentAmountOrTradeInDestination);

            //Try to add to the database
            if (carForm.saved)
            {
                Car car = carForm.currentCar;
                try
                {
                    _carManager.addCar(car, shipmentAmount, _employee.getEmployeeID(), DateTime.Now);
                }
                catch (Exception ex)
                {
                    lblStatusMessage.Content = ex.Message;
                }
            }
        }