private void changeButton_Click(object sender, EventArgs e) { AddSickForm form = new AddSickForm(); form.SetTextBoxes(Convert.ToString(dataGridView1.CurrentRow.Cells[1].Value), Convert.ToString(dataGridView1.CurrentRow.Cells[2].Value), Convert.ToString(dataGridView1.CurrentRow.Cells[3].Value), Convert.ToString(dataGridView1.CurrentRow.Cells[4].Value), Convert.ToString(dataGridView1.CurrentRow.Cells[5].Value), Convert.ToString(dataGridView1.CurrentRow.Cells[6].Value)); form.ShowDialog(); string surname = form.GetSurname(); string name = form.GetName(); string patr = form.GetPatr(); string num = form.GetNumber(); string seria = form.GetSeria(); string path = form.GetPath(); dataGridView1.CurrentRow.Cells[1].Value = surname; dataGridView1.CurrentRow.Cells[2].Value = name; dataGridView1.CurrentRow.Cells[3].Value = patr; dataGridView1.CurrentRow.Cells[4].Value = num; dataGridView1.CurrentRow.Cells[5].Value = seria; dataGridView1.CurrentRow.Cells[6].Value = path; BindingSource bs = new BindingSource(ds, "Больные"); dataGridView1.DataSource = bs; UpdateGrid(); }
private void button1_Click(object sender, EventArgs e) { AddSickForm form = new AddSickForm(); form.ShowDialog(); string surname = form.GetSurname(); string name = form.GetName(); string patr = form.GetPatr(); string num = form.GetNumber(); string seria = form.GetSeria(); string path = form.GetPath(); LoadGrid(); if (surname != "" && name != "" && patr != "" && num != "" && seria != "") { try { oleDbConnection1.Open(); oleDbDataAdapter1.InsertCommand.CommandText = "INSERT INTO [Больные] (Фамилия, Имя, Отчество, [Номер паспорта], [Серия паспорта], фото) VALUES ('" + surname + "', '" + name + "', '" + patr + "', '" + num + "', '" + seria + "', '" + path + "')"; oleDbDataAdapter1.InsertCommand.ExecuteNonQuery(); } catch (Exception) { }; } oleDbConnection1.Close(); UpdateGrid(); }