private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { switch (e.ColumnIndex) { case 1: // name break; case 2: // description break; case 3: // price bool flag = decimal.TryParse((string)dataGridView1[e.ColumnIndex, e.RowIndex].Value, out var newPrice); if (!flag) { MessageBox.Show("Цена должна быть числом"); dataGridView1[e.ColumnIndex, e.RowIndex].Value = DBController.GetPropertyValue((int)dataGridView1[0, e.RowIndex].Value, columnNames[e.ColumnIndex]); return; } ; break; case 4: // quantity if (!CheckIntInput((string)dataGridView1[e.ColumnIndex, e.RowIndex].Value, "Количество")) { dataGridView1[e.ColumnIndex, e.RowIndex].Value = DBController.GetPropertyValue((int)dataGridView1[0, e.RowIndex].Value, columnNames[e.ColumnIndex]); return; } break; case 5: // author DBController.ChangeGameAuthor((int)dataGridView1[0, e.RowIndex].Value, (string)dataGridView1[e.ColumnIndex, e.RowIndex].Value); DisplayGamesInfo(); return; case 6: // min duration if (!CheckIntInput((string)dataGridView1[e.ColumnIndex, e.RowIndex].Value, "Длительность")) { dataGridView1[e.ColumnIndex, e.RowIndex].Value = DBController.GetPropertyValue((int)dataGridView1[0, e.RowIndex].Value, columnNames[e.ColumnIndex]); return; } break; case 7: // max duration if (!CheckIntInput((string)dataGridView1[e.ColumnIndex, e.RowIndex].Value, "Длительность")) { dataGridView1[e.ColumnIndex, e.RowIndex].Value = DBController.GetPropertyValue((int)dataGridView1[0, e.RowIndex].Value, columnNames[e.ColumnIndex]); return; } break; case 8: // genre string genreDescription = ""; var addGenreDescriptionForm = new AddingDescriptionForm(FormTypes.genre); addGenreDescriptionForm.Description = DBController.GetGenreDescription((int)dataGridView1[0, e.RowIndex].Value); if (addGenreDescriptionForm.ShowDialog() != DialogResult.OK) { dataGridView1[e.ColumnIndex, e.RowIndex].Value = DBController.GetPropertyValue((int)dataGridView1[0, e.RowIndex].Value, columnNames[e.ColumnIndex]); return; } genreDescription = addGenreDescriptionForm.Description; DBController.ChangeGameGenre((int)dataGridView1[0, e.RowIndex].Value, (string)dataGridView1[e.ColumnIndex, e.RowIndex].Value, genreDescription); break; case 9: // min players if (!CheckIntInput((string)dataGridView1[e.ColumnIndex, e.RowIndex].Value, "Количество игроков")) { dataGridView1[e.ColumnIndex, e.RowIndex].Value = DBController.GetPropertyValue((int)dataGridView1[0, e.RowIndex].Value, columnNames[e.ColumnIndex]); return; } break; case 10: // max players if (!CheckIntInput((string)dataGridView1[e.ColumnIndex, e.RowIndex].Value, "Количество игроков")) { dataGridView1[e.ColumnIndex, e.RowIndex].Value = DBController.GetPropertyValue((int)dataGridView1[0, e.RowIndex].Value, columnNames[e.ColumnIndex]); return; } break; case 11: // type string typeDescription = ""; var addTypeDescriptionForm = new AddingDescriptionForm(FormTypes.type); addTypeDescriptionForm.Description = DBController.GetTypeDescription((int)dataGridView1[0, e.RowIndex].Value); if (addTypeDescriptionForm.ShowDialog() != DialogResult.OK) { dataGridView1[e.ColumnIndex, e.RowIndex].Value = DBController.GetPropertyValue((int)dataGridView1[0, e.RowIndex].Value, columnNames[e.ColumnIndex]); return; } typeDescription = addTypeDescriptionForm.Description; DBController.ChangeGameType((int)dataGridView1[0, e.RowIndex].Value, (string)dataGridView1[e.ColumnIndex, e.RowIndex].Value, typeDescription); break; } var result = DBController.ChangeGameProperty( (int)dataGridView1[0, e.RowIndex].Value, columnNames[e.ColumnIndex], (string)dataGridView1[e.ColumnIndex, e.RowIndex].Value); if (!result) { MessageBox.Show("Данное название уже есть в базе. Попробуйте другое"); dataGridView1[e.ColumnIndex, e.RowIndex].Value = DBController.GetPropertyValue((int)dataGridView1[0, e.RowIndex].Value, columnNames[e.ColumnIndex]); } DisplayGamesInfo(); }