private void EditDataViewVehicle_Load(object sender, EventArgs e) { //Checks wether the current user isn't logged in. if (FormController.CurrentCustomer == null) { Feedback.ErrorCustomerIsntLoggedIn(); ParentForm.Close(); return; } //Checks wether the current user is admin. if (!FormController.CurrentCustomer.IsAdmin) { Feedback.ErrorCustomerIsntAdmin(); ParentForm.Close(); return; } //Get a list with all brands and add them to the brand-combobox. if (DBController.TryGetVehicleBrands(out List <string> brands)) { comboBrand.Items.AddRange(brands.ToArray()); } else { Feedback.ErrorDatabaseLoadBrands(); ParentForm.Close(); return; } //Get a list with all gears and add them to the gear-combobox. if (DBController.TryGetVehicleGears(out List <string> gears)) { comboGear.Items.AddRange(gears.ToArray()); } else { Feedback.ErrorDatabaseLoadGears(); ParentForm.Close(); return; } //Get a list with all fuel types and add them to the fuel-combobox. if (DBController.TryGetFuelTypes(out List <string> fuel)) { comboFuel.Items.AddRange(fuel.ToArray()); } else { Feedback.ErrorDatabaseLoadFuels(); ParentForm.Close(); return; } if (vehicleOld != null) { comboBrand.SelectedItem = vehicleOld.Brand; comboFuel.SelectedItem = vehicleOld.FuelType; comboGear.SelectedItem = vehicleOld.Gear; } }