Beispiel #1
0
        private void submitButton_Click(object sender, System.EventArgs e)
        {
            Distance distance = new Distance();

            distance.miles = DistanceNumericUpDown.Value;
            lorryServicesObj.CalculateFuel(lorryToCalculate, distance);
            (Owner as LorryFormView).FillLorryList();
            Close();
        }
        public void Select(Lorry selectedLorry)
        {
            bool exit = false;

            while (!exit)
            {
                Console.WriteLine("\nSelected Lorry:");
                PrintInfo(selectedLorry, false);
                Console.WriteLine("Choose an option:");
                Console.WriteLine("\t1. Edit");
                Console.WriteLine("\t2. Delete");
                Console.WriteLine("\t3. Calculate fuel");
                Console.WriteLine("\t4. Refuel");
                Console.WriteLine("\t5. Passengers");
                Console.WriteLine("\t6. Back");

                switch (Console.ReadKey(true).KeyChar)
                {
                case '1':
                    LorryEditConsoleView lorryEditConsoleView = new LorryEditConsoleView(selectedLorry);
                    selectedLorry = lorryServicesObj.Update(lorryEditConsoleView.Load());
                    break;

                case '2':
                    Console.Write("Type vehicle name to confirm:");
                    if (Console.ReadLine() == selectedLorry.vehicleName)
                    {
                        lorryServicesObj.Delete(selectedLorry);
                        exit = true;
                    }
                    else
                    {
                        Console.WriteLine("Cancelled");
                    }
                    break;

                case '3':
                    Console.Write("Enter distance in miles: ");
                    Distance distance = new Distance();
                    distance.miles = Convert.ToDecimal(Console.ReadLine());
                    selectedLorry  = lorryServicesObj.CalculateFuel(selectedLorry, distance);
                    break;

                case '4':
                    selectedLorry = lorryServicesObj.Refuel(selectedLorry);
                    break;

                case '5':
                    LorryPassengerConsoleView lorryPassengers = new LorryPassengerConsoleView(selectedLorry);
                    lorryPassengers.Load();
                    break;

                case '6':
                    exit = true;
                    break;

                default:
                    Console.WriteLine("Invalid input");
                    break;
                }
            }
        }