Example #1
0
        private void addCar_btn_Click(object sender, EventArgs e)
        {
            var addEditVehicle = new AddEditVehicle(this);

            addEditVehicle.MdiParent = this.MdiParent;
            addEditVehicle.Show();
        }
Example #2
0
        private void btnAddNewCar_Click(object sender, EventArgs e)
        {
            AddEditVehicle form = new AddEditVehicle(this);

            form.MdiParent = this.MdiParent;
            form.Show();
        }
Example #3
0
        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();
        }
Example #4
0
 private void btn_AddCar_Click(object sender, EventArgs e)
 {
     if (!Utils.FormIsOpen("AddEditVehicle"))
     {
         AddEditVehicle addEditVehicle = new AddEditVehicle(this);
         addEditVehicle.MdiParent = this.MdiParent;
         addEditVehicle.Show();
     }
 }
Example #5
0
        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}");
     }
 }
Example #7
0
 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");
     }
 }