private void addCar_btn_Click(object sender, EventArgs e) { var addEditVehicle = new AddEditVehicle(this); addEditVehicle.MdiParent = this.MdiParent; addEditVehicle.Show(); }
private void btnAddNewCar_Click(object sender, EventArgs e) { AddEditVehicle form = new AddEditVehicle(this); form.MdiParent = this.MdiParent; form.Show(); }
private void btnEditCar_Click(object sender, EventArgs e) { var id = (int)dgvVehicleList.SelectedRows[0].Cells["id"].Value; var car = _db.TypesOfCars.FirstOrDefault(q => q.Id == id); var form = new AddEditVehicle(car, this); form.MdiParent = this.MdiParent; form.Show(); }
private void btn_AddCar_Click(object sender, EventArgs e) { if (!Utils.FormIsOpen("AddEditVehicle")) { AddEditVehicle addEditVehicle = new AddEditVehicle(this); addEditVehicle.MdiParent = this.MdiParent; addEditVehicle.Show(); } }
private void editCar_btn_Click(object sender, EventArgs e) { try { //Obtain id for row to be edited //Cast to integer var Id = (int)vehicleList_gv.SelectedRows[0].Cells["id"].Value; //Query database for records var car = carRentalEntities.TypeOfCars.FirstOrDefault(q => q.id == Id); //Launch window to edit data retrieved var addEditVehicle = new AddEditVehicle(car, this); addEditVehicle.MdiParent = this.MdiParent; addEditVehicle.Show(); } catch (Exception ex) { MessageBox.Show($"Error: {ex.Message}"); } }
private void btnEditCar_Click(object sender, EventArgs e) { try { //get ID of selected Row var id = (int)dgvVehicleList.SelectedRows[0].Cells["Id"].Value; //query database for record var car = db.TypesOfCars.FirstOrDefault(q => q.Id == id); //launch AddEditVehicle window with data if (!Utils.FormIsOpen("AddEditVehicle")) { var addEditVehicle = new AddEditVehicle(car, this); addEditVehicle.MdiParent = this.MdiParent; addEditVehicle.Show(); } } catch (Exception ex) { MessageBox.Show($"Error: {ex.Message}"); } }
private void btn_EditCar_Click(object sender, EventArgs e) { try { if (!Utils.FormIsOpen("AddEditVehicle")) { // get id //We expect Int here (data type from database column). otherwise use var./ need casting int id = (int)dGV_VehicleList.SelectedRows[0].Cells["Id"].Value; //query var car = _db.TypesOfCars.FirstOrDefault(q => q.Id == id); // launch addeditvehicle window with data AddEditVehicle addEditVehicle = new AddEditVehicle(car, this); addEditVehicle.MdiParent = this.MdiParent; addEditVehicle.Show(); } } catch (Exception) { MessageBox.Show("You Have to select a whole row in order to edit", "Error"); } }