Example #1
0
        private void buttonUpdateCar_Click(object sender, EventArgs e)
        {
            if (!Utils.FormIsOpen("AddEditCar") && dataGridViewManageCars.SelectedRows.Count > 0)
            {
                // get the values of the selected row for pre-populating edit form
                DataGridViewRow selectedRow = dataGridViewManageCars.SelectedRows[0];

                int    carID        = (int)selectedRow.Cells["ID"].Value;
                string make         = selectedRow.Cells["Make"].Value.ToString();
                string model        = selectedRow.Cells["Model"].Value.ToString();
                string year         = selectedRow.Cells["Year"].Value.ToString();
                string vin          = selectedRow.Cells["VIN"].Value.ToString();
                string licensePlate = selectedRow.Cells["LicensePlate"].Value.ToString();

                var manageCarVM = new ManageCarViewModel
                {
                    ID           = carID,
                    Make         = make,
                    Model        = model,
                    Year         = year,
                    VIN          = vin,
                    LicensePlate = licensePlate,
                };

                AddEditCar addEditCarForm = new AddEditCar(isEdit: true, manageCarVM: manageCarVM, manageCarsForm: this);
                addEditCarForm.MdiParent = this.MdiParent;
                addEditCarForm.Show();
            }
            else
            {
                MessageBox.Show("Info: An instance of the Add/Edit Car Window is open.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #2
0
 private void buttonAddCar_Click(object sender, EventArgs e)
 {
     if (!Utils.FormIsOpen("AddEditCar"))
     {
         AddEditCar addEditCarForm = new AddEditCar(isEdit: false, manageCarsForm: this);
         addEditCarForm.MdiParent = this.MdiParent;
         addEditCarForm.Show();
     }
     else
     {
         MessageBox.Show("Info: An instance of the Add/Edit Car Window is open.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }