} // end of previous method - dataGridViewFleet_SelectionChanged() // ------------------------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonModifyFleetSubmit_Click(object sender, EventArgs e) { // Removes Current Instance of Vehicle. fleet.RemoveVehicle(selectedVehicle); string rego = textBoxModifyRego.Text; string make = textBoxModifyMake.Text; string model = textBoxModifyModel.Text; Vehicle.VehicleClassEnum vehicleClass = (Vehicle.VehicleClassEnum)comboBoxModifyVehicleClass.SelectedValue; int year = int.Parse(textBoxModifyYear.Text); Vehicle.TransmissionTypeEnum transmissionType = (Vehicle.TransmissionTypeEnum)comboBoxModiyTransmission.SelectedValue; int engineSize = int.Parse(numericUpDownAddVehicleEngineSize.Value.ToString()); bool turbo = checkBoxModifyTurbo.Checked; Vehicle.FuelTypeEnum fuelType = (Vehicle.FuelTypeEnum)comboBoxModifyFuelType.SelectedValue; int numSeats = int.Parse(numericUpDownModifyNumSeats.Value.ToString()); bool GPS = checkBoxModifyGPS.Checked; bool Sunroof = checkBoxModifySunroof.Checked; string colour = textBoxModifyColour.Text; double dailyRate = double.Parse(numericUpDownModifyDailyRate.Value.ToString()); Vehicle newVehicle = new Vehicle(rego, make, model, year, vehicleClass, numSeats, transmissionType, engineSize, turbo, fuelType, GPS, Sunroof, colour, dailyRate); fleet.AddVehicle(newVehicle); PopulateDataGridViewFleet(); groupBoxModifyFleet.Visible = false; groupBoxModifyFleetOptions.Enabled = true; } // end of previous method - dataGridViewFleet_SelectionChanged()
} // end of previous method - dataGridViewFleet_SelectionChanged() // ------------------------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonAddVehicleSubmit_Click(object sender, EventArgs e) { // Validate Required Inputs // Validate Rego if (string.IsNullOrWhiteSpace(textBoxAddVehicleRego.Text)) { MessageBox.Show("Error! - The Vehicle Rego is required!"); return; } // Validate Make if (string.IsNullOrWhiteSpace(textBoxAddVehicleMake.Text)) { MessageBox.Show("Error! - The Vehicle Make is required!"); return; } // Validate Model if (string.IsNullOrWhiteSpace(textBoxAddVehicleModel.Text)) { MessageBox.Show("Error! - The Vehicle Model is required!"); return; } // Validate Class if (string.IsNullOrWhiteSpace(comboBoxAddVehicleClass.SelectedValue.ToString())) { MessageBox.Show("Error! - The Vehicle Class is required!"); return; } // Validate Year if (string.IsNullOrWhiteSpace(textBoxAddVehicleYear.Text)) { MessageBox.Show("Error! - The Vehicle Year is required!"); return; } string rego = textBoxAddVehicleRego.Text; string make = textBoxAddVehicleMake.Text; string model = textBoxAddVehicleModel.Text; Vehicle.VehicleClassEnum vehicleClass = (Vehicle.VehicleClassEnum)comboBoxAddVehicleClass.SelectedValue; int year = int.Parse(textBoxAddVehicleYear.Text); Vehicle.TransmissionTypeEnum transmissionType = (Vehicle.TransmissionTypeEnum)comboBoxAddVehicleTransmission.SelectedValue; int engineSize = int.Parse(numericUpDownAddVehicleEngineSize.Value.ToString()); bool turbo = checkBoxAddVehicleTurbo.Checked; Vehicle.FuelTypeEnum fuelType = (Vehicle.FuelTypeEnum)comboBoxAddVehicleFuelType.SelectedValue; int numSeats = int.Parse(numericUpDownAddVehicleNumSeats.Value.ToString()); bool GPS = checkBoxAddVehicleGPS.Checked; bool Sunroof = checkBoxAddVehicleSunRoof.Checked; string colour; if (textBoxAddVehicleColour.Text == "") { colour = "Black"; } else { colour = textBoxAddVehicleColour.Text; } double dailyRate = double.Parse(numericUpDownAddVehicleDailyRate.Value.ToString()); Vehicle newVehicle = new Vehicle(rego, make, model, year, vehicleClass, numSeats, transmissionType, engineSize, turbo, fuelType, GPS, Sunroof, colour, dailyRate); fleet.AddVehicle(newVehicle); PopulateDataGridViewFleet(); // Resets the Inputs to empty/ Defualts textBoxAddVehicleRego.Text = ""; textBoxAddVehicleMake.Text = ""; textBoxAddVehicleModel.Text = ""; textBoxAddVehicleYear.Text = ""; numericUpDownAddVehicleNumSeats.Value = 2; numericUpDownAddVehicleEngineSize.Value = 4; checkBoxAddVehicleTurbo.Checked = false; checkBoxAddVehicleGPS.Checked = false; checkBoxAddVehicleSunRoof.Checked = false; textBoxAddVehicleColour.Text = ""; numericUpDownAddVehicleDailyRate.Value = 50; groupBoxAddVehicle.Enabled = false; groupBoxAddVehicle.Visible = false; groupBoxModifyFleetOptions.Enabled = true; } // end of previous method - dataGridViewFleet_SelectionChanged()