public void AddNewRentalSubMenu(bool clear = true) { if (clear) { Console.Clear(); } Console.WriteLine("### Rent Vehicle Submenu ###\n\n"); CustomerIDValidInput(); RegistrationValidInput(); RentalTimeValidationInput(); double dailyRate = Fleet.GetVehicle(RegistrationRent).dailyRate; if (Fleet.RentVehicle(RegistrationRent, CustomerIDRent, dailyRate)) { string days = RentalTime.ToString() == "1" ? "day" : "days"; double TotalCost = dailyRate * RentalTime; Console.WriteLine($"\nSuccessfully added customer '{CustomerIDRent}' renting '{RegistrationRent}'" + $" for '{RentalTime}' {days} with a total cost of {TotalCost.ToString("C")}"); Fleet.SaveRentalsToFile(); } else { Console.WriteLine($"\nCannot add customer '{CustomerIDRent}' with '{RegistrationRent}' to the rental list.\n"); } LastMRRCscreen(() => SubMenu("Rentals"), () => AddNewRentalSubMenu()); }
// Main method interface to do modify operations on vehicle public void ModifyVehicleSubmenu(bool clear = true) { if (clear) { Console.Clear(); } Console.WriteLine("### Modify Vehicle Submenu ###\n"); // Require the operator to enter the vehicle registration to be modified ModifyRegoValidInput(); // Save the changed ID to -1 in case customer decideds to retain the same ID in the modification menu. Crm.SaveToFile(); string subMenu = "a) Modify Default Vehicle Fields" + "\nb) Modify All Vehicle Fields"; Console.WriteLine("\nPlease enter a character from the options below:\n"); Console.WriteLine(subMenu); // Return the vehicle which matches the provided registration to modify and assign to vehicle object Vehicle vehicle = Fleet.GetVehicle(regoToModify); // Wait for user to input the next key inputkey = Console.ReadKey(); switch (inputkey.Key) { case A_Pressed: ModifyVehicle(vehicle); break; case B_Pressed: ModifyVehicle(vehicle, true); break; case H_Pressed: MRRCInterface(); break; case Backspace_Pressed: ModifyVehicleSubmenu(); break; case Escape_Pressed: QuitMessage(); break; case Q_Pressed: SubMenu("Fleet"); break; default: // if any key other than above listed is pressed, do: Console.Clear(); Console.WriteLine("You Pressed '{0}', Please enter a valid option\n", inputkey.Key.ToString()); ModifyVehicleSubmenu(false); break; } }
private void dgvFleet_SelectionChanged(object sender, EventArgs e) { //Author: Jericho Duggan int rowsCount = dgvFleet.SelectedRows.Count; if (rowsCount == 0 || rowsCount > 1) { selectedVehicle = null; } else { string selectedRego = (dgvFleet.SelectedRows[0].Cells[V_REG].Value.ToString()); selectedVehicle = fleet.GetVehicle(selectedRego); } }