private void button1_Click(object sender, EventArgs e) { using (var connection = new SqlConnection(ConnectToSql.ConnectionString)) { connection.Open(); using (var command = new SqlCommand("InsertDolzh", connection)) { try { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@Номер", int.Parse(nDolzh.Text))); command.Parameters.Add(new SqlParameter("@Должность", Dolzh.Text)); command.ExecuteNonQuery(); this.Hide(); } catch (Exception) { MessageBox.Show("Введите корректные данные"); } Option main = this.Owner as Option; if (main != null) { main.Obnov(); } } } }
private void button1_Click(object sender, EventArgs e) { using (var connection = new SqlConnection(ConnectToSql.ConnectionString)) { connection.Open(); using (var command = new SqlCommand("InsertPodp", connection)) { try { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@Код", int.Parse(Kod.Text))); command.Parameters.Add(new SqlParameter("@ФИО", FIO.Text)); command.Parameters.Add(new SqlParameter("@Основание", Osnov.Text)); command.ExecuteNonQuery(); } catch (Exception) { MessageBox.Show("Введите корректные данные"); } Option main = this.Owner as Option; if (main != null) { main.Obnov(); } } } }
private void button2_Click(object sender, EventArgs e) { using (var connection = new SqlConnection(ConnectToSql.ConnectionString)) { connection.Open(); using (var command = new SqlCommand("upUser", connection)) { try { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@Код", int.Parse(Kod.Text))); command.Parameters.Add(new SqlParameter("@Логин", login.Text)); command.Parameters.Add(new SqlParameter("@Пароль", password.Text)); command.ExecuteNonQuery(); this.Hide(); } catch (Exception) { MessageBox.Show("Введите корректные данные"); } Option main = this.Owner as Option; if (main != null) { main.Obnov(); } } } }