Beispiel #1
0
        private void btnSettNameCar_Click(object sender, EventArgs e)
        {
            try
            {
                if (dtgModelCars.SelectedRows[0].Index >= 0)
                {
                    int i_row = dtgModelCars.SelectedRows[0].Index;
                    MarkaAutoSettings.TextBtn     = "Изменить";
                    MarkaAutoSettings.NameCar     = dtgModelCars.Rows[i_row].Cells[1].Value.ToString();
                    MarkaAutoSettings.ID          = Convert.ToInt32(dtgModelCars.Rows[i_row].Cells[0].Value);
                    MarkaAutoSettings.logo        = picBox.Image;
                    MarkaAutoSettings.namePicture = dtgModelCars.Rows[i_row].Cells[2].FormattedValue.ToString().Trim();
                    SettingsMarka setmarka = new SettingsMarka();

                    setmarka.ShowDialog();
                    if (MarkaAutoSettings.is_click)
                    {
                        RefreshDataGrid();
                        for (int i = 0; i < dtgModelCars.RowCount; i++)
                        {
                            if (Convert.ToInt32(dtgModelCars.Rows[i].Cells[0].Value) == MarkaAutoSettings.ID)
                            {
                                dtgModelCars.Rows[i].Cells[1].Selected = true;
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Неправильное расположение файла!", " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        private void btnAddNameCar_Click(object sender, EventArgs e)
        {
            MarkaAutoSettings.TextBtn = "Добавить";
            SettingsMarka setmarka = new SettingsMarka();

            setmarka.ShowDialog();

            string newName = "";

            if (MarkaAutoSettings.is_click)
            {
                RefreshDataGrid();
                newName = MarkaAutoSettings.NameCar;
                for (int i = 0; i < dtgModelCars.RowCount; i++)
                {
                    if (dtgModelCars.Rows[i].Cells[1].Value.ToString().Trim() == newName)
                    {
                        dtgModelCars.Rows[i].Cells[1].Selected = true;
                        break;
                    }
                }
                MarkaAutoSettings.namePicture = "";
            }
        }