private void button1_Click(object sender, EventArgs e) { using (var connection = new SqlConnection(ConnectToSql.ConnectionString)) { connection.Open(); using (var command = new SqlCommand("InsertSot", connection)) { try { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@Табельныйномер", int.Parse(textBox1.Text))); command.Parameters.Add(new SqlParameter("@ФИО", textBox2.Text)); command.Parameters.Add(new SqlParameter("@ФИО_ип", textBox3.Text)); command.Parameters.Add(new SqlParameter("@ФИО_Рп", textBox4.Text)); command.Parameters.Add(new SqlParameter("@ФИО_дп", textBox5.Text)); command.Parameters.Add(new SqlParameter("@Должность", (int)dol.SelectedValue)); command.Parameters.Add(new SqlParameter("@ДатаРождения", dateB.Value)); command.Parameters.Add(new SqlParameter("@ИНН", textBox6.Text)); command.Parameters.Add(new SqlParameter("@Контакты", textBox7.Text)); command.Parameters.Add(new SqlParameter("@АдресПрописки", textBox8.Text)); command.Parameters.Add(new SqlParameter("@ПаспортСерия", int.Parse(textBox9.Text))); command.Parameters.Add(new SqlParameter("@ПаспортНомер", int.Parse(textBox10.Text))); command.Parameters.Add(new SqlParameter("@ПаспортКемВыдан", textBox11.Text)); command.Parameters.Add(new SqlParameter("@ПаспортДатаВыдачи", dateOut.Value)); command.Parameters.Add(new SqlParameter("@ПаспортКодПодразделения", textBox12.Text)); command.ExecuteNonQuery(); this.Hide(); } catch (Exception) { MessageBox.Show("Введите корректные данные"); } Sprav main = this.Owner as Sprav; if (main != null) { main.Obnov(); } } } }
private void insertKont_Click(object sender, EventArgs e) { using (var connection = new SqlConnection(ConnectToSql.ConnectionString)) { connection.Open(); using (var command = new SqlCommand("insKontr", connection)) { try { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@Договор", int.Parse(Dogovor.Text))); command.Parameters.Add(new SqlParameter("@ВидКонтрагента", (int)VidK.SelectedValue)); command.Parameters.Add(new SqlParameter("@Наименование", nKont.Text)); command.Parameters.Add(new SqlParameter("@ПолноеНаименование", fnKont.Text)); command.Parameters.Add(new SqlParameter("@ИНН", INN.Text)); command.Parameters.Add(new SqlParameter("@КПП", KPP.Text)); command.Parameters.Add(new SqlParameter("@ФИОруководителя", FIO.Text)); command.Parameters.Add(new SqlParameter("@ФИО_РодПадеж", FIOrp.Text)); command.Parameters.Add(new SqlParameter("@Должность_РодПадеж", Dolrp.Text)); command.Parameters.Add(new SqlParameter("@Основание_РодПадеж", Ocnrp.Text)); command.Parameters.Add(new SqlParameter("@Мастер", (int)mast.SelectedValue)); command.Parameters.Add(new SqlParameter("@ПочтовыйАдрес", pAdr.Text)); command.Parameters.Add(new SqlParameter("@ЮридическийАдрес", uAdr.Text)); command.Parameters.Add(new SqlParameter("@Контакты", kont.Text)); command.ExecuteNonQuery(); this.Hide(); } catch (Exception) { MessageBox.Show("Введите корректные данные"); } Sprav main = this.Owner as Sprav; if (main != null) { main.Obnov(); } } } }