private void InsertAdmin_Click(object sender, EventArgs e) { string cmd_text; EditionInsertion editionInsertion = new EditionInsertion(); //EditionInsertion editionInsertion = new EditionInsertion(); if (editionInsertion.ShowDialog() == DialogResult.OK) { cmd_text = "INSERT INTO Admins (Логин, Пароль, Фамилия, Имя, Отчество, [Номер телефона], Гостиница) VALUES (" + "'" + editionInsertion.textBox1.Text + "' , '" + editionInsertion.textBox2.Text + "' , '" + editionInsertion.textBox3.Text + "' , '" + editionInsertion.textBox4.Text + "', '" + editionInsertion.textBox5.Text + "', '" + editionInsertion.textBox6.Text + "', '" + editionInsertion.textBox7.Text + "')"; // создать соединение с базой данных OleDbConnection sql_conn = new OleDbConnection(ConnectionString); sql_conn.Open(); // открыть соединение // создать команду на языке OleDbCommand sql_comm = new OleDbCommand(cmd_text, sql_conn); sql_comm.ExecuteNonQuery(); // выполнить команду на языке SQL sql_conn.Close(); // закрыть соединение ShowAdmins(); editionInsertion.Close(); //this.adminListTableAdapter.Fill(this.dataBaseDataSet.AdminList); } }
private void Edit_Click(object sender, EventArgs e) { string cmd_text; EditionInsertion editionInsertion = new EditionInsertion(); int index; string CurrentAdmin; index = dataGridView2.CurrentRow.Index; CurrentAdmin = Convert.ToString(dataGridView2[0, index].Value); editionInsertion.textBox1.Text = CurrentAdmin; editionInsertion.textBox2.Text = Convert.ToString(dataGridView2[1, index].Value); editionInsertion.textBox3.Text = Convert.ToString(dataGridView2[2, index].Value); editionInsertion.textBox4.Text = Convert.ToString(dataGridView2[3, index].Value); editionInsertion.textBox5.Text = Convert.ToString(dataGridView2[4, index].Value); editionInsertion.textBox6.Text = Convert.ToString(dataGridView2[5, index].Value); editionInsertion.textBox7.Text = Convert.ToString(dataGridView2[6, index].Value); if (editionInsertion.ShowDialog() == DialogResult.OK) { cmd_text = "UPDATE [AdminList] SET [Логин] = '" + editionInsertion.textBox1.Text + "', " + "[Пароль] = '" + editionInsertion.textBox2.Text + "', " + "[Фамилия] = '" + editionInsertion.textBox3.Text + "', " + "[Имя] = '" + editionInsertion.textBox4.Text + "', " + "[Отчество] = '" + editionInsertion.textBox5.Text + "', " + "[Номер телефона] = '" + editionInsertion.textBox6.Text + "', " + "[Гостиница] = '" + editionInsertion.textBox7.Text + "' " + "WHERE [Логин] = '" + CurrentAdmin + "'"; OleDbConnection sql_conn = new OleDbConnection(ConnectionString); sql_conn.ResetState(); // создать команду на языке SQL OleDbCommand sql_comm = new OleDbCommand(cmd_text, sql_conn); sql_conn.Open(); sql_comm.ExecuteNonQuery(); sql_conn.Close(); this.adminListTableAdapter.Fill(this.dataBaseDataSet.AdminList); } }
private void RegAdmin_Click(object sender, EventArgs e) { EditionInsertion editionInsertion = new EditionInsertion(); int index = dataGridView2.CurrentRow.Index; string Id = dataGridView2[0, index].Value.ToString(); editionInsertion.textBox1.Text = Convert.ToString(dataGridView2[0, index].Value); editionInsertion.textBox2.Text = Convert.ToString(dataGridView2[1, index].Value); editionInsertion.textBox3.Text = Convert.ToString(dataGridView2[2, index].Value); editionInsertion.textBox4.Text = dataGridView2[3, index].Value.ToString(); editionInsertion.textBox5.Text = dataGridView2[4, index].Value.ToString(); editionInsertion.textBox6.Text = dataGridView2[5, index].Value.ToString(); editionInsertion.textBox7.Text = dataGridView2[6, index].Value.ToString(); if (editionInsertion.ShowDialog() == DialogResult.OK) { string Up_to_Date = "UPDATE Admins SET " + "Логин='" + editionInsertion.textBox1.Text + "'," + "Пароль='" + editionInsertion.textBox2.Text + "'," + "Фамилия='" + editionInsertion.textBox3.Text + "'," + "[Имя]='" + editionInsertion.textBox4.Text + "'," + "Отчество='" + editionInsertion.textBox5.Text + "'," + "[Номер телефона]='" + editionInsertion.textBox6.Text + "'," + "Гостиница='" + editionInsertion.textBox7.Text + "'" + " Where Логин='" + Id + "'"; OleDbConnection sql_conn = new OleDbConnection(ConnectionString); OleDbCommand sql_comm = new OleDbCommand(Up_to_Date, sql_conn); sql_conn.Open(); sql_comm.ExecuteNonQuery(); sql_conn.Close(); ShowAdmins(); editionInsertion.Close(); } }
public OpenClose(EditionInsertion editionInsertion) { new EditionInsertion(); }