private void button1_Click(object sender, EventArgs e) { if (dataGridView3.RowCount == 0) { return; } int row = dataGridView3.CurrentRow.Index; int id = Convert.ToInt32(dataGridView3[0, row].Value); CulturalСreative culturalСreative = new CulturalСreative(new double[] { 2, 3, 4, 5, 6 }, new double[] { 2, 3, 4, 5, 6 }, new double[] { 8 }); culturalСreative.SetInObjectFromDataBase(id); culturalСreative.SetInWord(); }
private void finish_Click(object sender, EventArgs e) { #region Проверка на заполненность if (!Data.IsFilled(fields)) { MessageBox.Show("Заполните пустые поля!", "Внимание"); return; } #endregion #region Запись в объекты culturalCreative.levels = culturalCreative.SetFromTables(culturalCreative.levels, tables); culturalCreative.performances = culturalCreative.SetFromTables(culturalCreative.performances, tablesA); culturalCreative.participations = culturalCreative.SetFromTables(culturalCreative.participations, tablesB); #endregion OleDbCommand command = new OleDbCommand("INSERT INTO Culture (Уровень1,Уровень2,Уровень3,Уровень4,Уровень5,УровеньА1, УровеньА2, УровеньА3, УровеньА4, УровеньА5,УровеньВ1,Результат)" + "VALUES(@Уровень1,@Уровень2,@Уровень3,@Уровень4,@Уровень5,@УровеньА1, @УровеньА2, @УровеньА3, @УровеньА4, @УровеньА5,@УровеньВ1,@Результат)", Data.OleDbConnection); command.Parameters.AddWithValue("Уровень1", culturalCreative.levels[0].SetEventsInDataBase()); command.Parameters.AddWithValue("Уровень2", culturalCreative.levels[1].SetEventsInDataBase()); command.Parameters.AddWithValue("Уровень3", culturalCreative.levels[2].SetEventsInDataBase()); command.Parameters.AddWithValue("Уровень4", culturalCreative.levels[3].SetEventsInDataBase()); command.Parameters.AddWithValue("Уровень5", culturalCreative.levels[4].SetEventsInDataBase()); command.Parameters.AddWithValue("УровеньА1", culturalCreative.performances[0].SetEventsInDataBase()); command.Parameters.AddWithValue("УровеньА2", culturalCreative.performances[1].SetEventsInDataBase()); command.Parameters.AddWithValue("УровеньА3", culturalCreative.performances[2].SetEventsInDataBase()); command.Parameters.AddWithValue("УровеньА4", culturalCreative.performances[3].SetEventsInDataBase()); command.Parameters.AddWithValue("УровеньА5", culturalCreative.performances[4].SetEventsInDataBase()); command.Parameters.AddWithValue("УровеньВ1", culturalCreative.participations[0].SetEventsInDataBase()); command.Parameters.AddWithValue("Результат", culturalCreative.result.ToString()); command.ExecuteNonQuery(); int id = 0; command = new OleDbCommand("SELECT @@IDENTITY AS id", Data.OleDbConnection); OleDbDataReader sqlReaderA = null; sqlReaderA = command.ExecuteReader(); while (sqlReaderA.Read()) { id = Convert.ToInt32(sqlReaderA["id"]); } if (sqlReaderA != null) { sqlReaderA.Close(); } culturalCreative.human.SetInDataBase(id); culturalCreative.SetInWord(); if (!Data.panel.Controls.Contains(Tables.Instance)) //если нет в массиве то добавляем { Data.panel.Controls.Add(Tables.Instance); Tables.Instance.Dock = DockStyle.Fill; Tables.Instance.BringToFront(); } else { Tables.Instance.BringToFront(); } }