123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- 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 changeZakPredstavitel : Form
- {
- SqlCommand query = null;
- public changeZakPredstavitel()
- {
- InitializeComponent();
- }
- private void changeZakPredstavitel_Load(object sender, EventArgs e)
- {
- try
- {
- query = new SqlCommand($"select surname from zakon_predstavitel where kod_zakon_predstavitel like '{changeChild.row}'", db_helper.sqlConnection);
- tb_surnameZP.Text = query.ExecuteScalar().ToString();
- query = new SqlCommand($"select [name] from zakon_predstavitel where kod_zakon_predstavitel like '{changeChild.row}'", db_helper.sqlConnection);
- tb_nameZP.Text = query.ExecuteScalar().ToString();
- query = new SqlCommand($"select patronymic from zakon_predstavitel where kod_zakon_predstavitel like '{changeChild.row}'", db_helper.sqlConnection);
- tb_patronymicZP.Text = query.ExecuteScalar().ToString();
- query = new SqlCommand($"select date_birth from zakon_predstavitel where kod_zakon_predstavitel like '{changeChild.row}'", db_helper.sqlConnection);
- dtp_dateBirthZP.Text = query.ExecuteScalar().ToString();
- query = new SqlCommand($"select adress from zakon_predstavitel where kod_zakon_predstavitel like '{changeChild.row}'", db_helper.sqlConnection);
- tb_adressZP.Text = query.ExecuteScalar().ToString();
- query = new SqlCommand($"select kem_vudan from zakon_predstavitel z join passport p on p.kod_passport = z.kod_passport where kod_zakon_predstavitel like '{changeChild.row}'", db_helper.sqlConnection);
- tb_kemVudanZP.Text = query.ExecuteScalar().ToString();
- query = new SqlCommand($"select date_vudach from zakon_predstavitel z join passport p on p.kod_passport = z.kod_passport where kod_zakon_predstavitel like '{changeChild.row}'", db_helper.sqlConnection);
- dtp_dateVudachZP.Text = query.ExecuteScalar().ToString();
- query = new SqlCommand($"select seria from zakon_predstavitel z join passport p on p.kod_passport = z.kod_passport where kod_zakon_predstavitel like '{changeChild.row}'", db_helper.sqlConnection);
- mtb_seriaZP.Text = query.ExecuteScalar().ToString();
- query = new SqlCommand($"select nomer from zakon_predstavitel z join passport p on p.kod_passport = z.kod_passport where kod_zakon_predstavitel like '{changeChild.row}'", db_helper.sqlConnection);
- mtb_nomerZP.Text = query.ExecuteScalar().ToString();
- query = new SqlCommand($"select inn from zakon_predstavitel where kod_zakon_predstavitel like '{changeChild.row}'", db_helper.sqlConnection);
- mtb_innZP.Text = query.ExecuteScalar().ToString();
- query = new SqlCommand($"select snils from zakon_predstavitel where kod_zakon_predstavitel like '{changeChild.row}'", db_helper.sqlConnection);
- mtb_snilsZP.Text = query.ExecuteScalar().ToString();
- query = new SqlCommand($"select telephone from zakon_predstavitel where kod_zakon_predstavitel like '{changeChild.row}'", db_helper.sqlConnection);
- mtb_telephoneZP.Text = query.ExecuteScalar().ToString();
- query = new SqlCommand($"select work_place from zakon_predstavitel where kod_zakon_predstavitel like '{changeChild.row}'", db_helper.sqlConnection);
- tb_workPlaceZP.Text = query.ExecuteScalar().ToString();
- }
- catch
- {
- MessageBox.Show("Произошла непредвиденная ошибка!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- private void bt_change_Click(object sender, EventArgs e)
- {
- try
- {
- query = new SqlCommand($"select kod_passport from zakon_predstavitel where kod_zakon_predstavitel like '{changeChild.row}'", db_helper.sqlConnection);
- string kodPassport = query.ExecuteScalar().ToString();
- DateTime date1 = DateTime.Parse(dtp_dateVudachZP.Text);
- query = new SqlCommand($"update passport set kem_vudan = @kem_vudan, date_vudach = @date_vudach, seria = @seria, nomer = @nomer where kod_passport like (select kod_passport from zakon_predstavitel where kod_zakon_predstavitel like '{changeChild.row}')", 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();
- date1 = DateTime.Parse(dtp_dateBirthZP.Text);
- query = new SqlCommand($"update zakon_predstavitel set surname = @surname, [name] = @name, patronymic = @patronymic, date_birth = @date_birth, adress = @adress, inn = @inn, snils = @snils, telephone = @telephone, work_place = @work_place where kod_zakon_predstavitel like '{changeChild.row}'", 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("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 label3_Click(object sender, EventArgs e)
- {
- }
- }
- }
|