12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace Дол_Восток
- {
- public partial class addZakPredstavitel : Form
- {
- SqlCommand query = null;
- public addZakPredstavitel()
- {
- InitializeComponent();
- }
- private void tb_add_Click(object sender, EventArgs e)
- {
- try
- {
- DateTime date1 = DateTime.Parse(dtp_dateBirthZP.Text);
- query = new SqlCommand($"insert into passport (kem_vudan, date_vudach, seria, nomer) values (@kem_vudan, @date_vudach, @seria, @nomer)", db_helper.sqlConnection);
- query.Parameters.AddWithValue("kem_vudan", tb_kemVudanZP.Text);
- query.Parameters.AddWithValue("date_vudach", $"{date1.Day}.{date1.Month}.{date1.Year}");
- query.Parameters.AddWithValue("seria", mtb_seriaZP.Text);
- query.Parameters.AddWithValue("nomer", mtb_nomerZP.Text);
- query.ExecuteNonQuery();
- query = new SqlCommand($"select kod_passport from passport where kem_vudan like '{tb_kemVudanZP.Text}' and date_vudach like '{date1.Day}.{date1.Month}.{date1.Year}' and seria like '{mtb_seriaZP.Text}' and nomer like '{mtb_nomerZP.Text}'", db_helper.sqlConnection);
- string kodPassport = query.ExecuteScalar().ToString();
- date1 = DateTime.Parse(dtp_dateBirthZP.Text);
- query = new SqlCommand($"insert into zakon_predstavitel (surname, [name], patronymic, date_birth, adress, kod_passport, inn, snils, telephone, work_place) values (@surname, @name, @patronymic, @date_birth, @adress, @kod_passport, @inn, @snils, @telephone, @work_place)", db_helper.sqlConnection);
- query.Parameters.AddWithValue("surname", tb_surnameZP.Text);
- query.Parameters.AddWithValue("name", tb_nameZP.Text);
- query.Parameters.AddWithValue("patronymic", tb_patronymicZP.Text);
- query.Parameters.AddWithValue("date_birth", $"{date1.Day}.{date1.Month}.{date1.Year}");
- query.Parameters.AddWithValue("adress", tb_adressZP.Text);
- query.Parameters.AddWithValue("kod_passport", kodPassport);
- query.Parameters.AddWithValue("inn", mtb_innZP.Text);
- query.Parameters.AddWithValue("snils", mtb_snilsZP.Text);
- query.Parameters.AddWithValue("telephone", mtb_telephoneZP.Text);
- query.Parameters.AddWithValue("work_place", tb_workPlaceZP.Text);
- if (query.ExecuteNonQuery().ToString().Equals("1"))
- {
- MessageBox.Show("Добавление данных прошло успешно!", "Уведомление", MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.Close();
- }
- }
- catch
- {
- MessageBox.Show("Произошла непредвиденная ошибка!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- private void addZakPredstavitel_Load(object sender, EventArgs e)
- {
- }
- }
- }
|