private void button2_Click(object sender, EventArgs e) { if ((checkBox1.Checked) || (checkBox2.Checked) || (checkBox3.Checked) || (checkBox4.Checked) || (checkBox5.Checked)) { Form31 f = new Form31(); this.Hide(); f.ShowDialog(); Close(); } else { MessageBox.Show("Надо ответить на вопрос", "Заголовок", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void button4_Click(object sender, EventArgs e) { int index, n; string SqlText = "UPDATE [Personal] SET "; string Personal_ID, Surname, Posada_ID, NomerTelefony, KilkistPolotiv, Vik; // перевірка, чи є взагалі записи в таблиці Source n = dataGridView1.Rows.Count; if (n == 1) { return; } Form31 f = new Form31(); // заповнити форму даними перед відкриттям index = dataGridView1.CurrentRow.Index; Personal_ID = dataGridView1[0, index].Value.ToString(); Surname = dataGridView1[0, index].Value.ToString(); Posada_ID = dataGridView1[1, index].Value.ToString(); NomerTelefony = dataGridView1[2, index].Value.ToString(); KilkistPolotiv = dataGridView1[2, index].Value.ToString(); Vik = dataGridView1[2, index].Value.ToString(); f.textBox1.Text = Surname; f.textBox2.Text = Posada_ID; f.textBox3.Text = NomerTelefony; f.textBox4.Text = KilkistPolotiv; f.textBox5.Text = Vik; if (f.ShowDialog() == DialogResult.OK) { Surname = f.textBox1.Text; Posada_ID = f.textBox2.Text; NomerTelefony = f.textBox3.Text; KilkistPolotiv = f.textBox4.Text; Vik = f.textBox5.Text; SqlText += "Surname = \'" + Surname + "\', Posada_ID = '" + Posada_ID + "\', NomerTelefony = '" + NomerTelefony + "\', KilkistPolotiv = '" + KilkistPolotiv + "\', Vik = '" + Vik + ""; SqlText += "WHERE [Personal].Personal_ID = " + Personal_ID; MyExecuteNonQuery(SqlText); Personal(); } }