123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- 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 addSotrudnic : Form
- {
- SqlCommand query = null;
- public addSotrudnic()
- {
- InitializeComponent();
- }
- private void addSotrudnic_Load(object sender, EventArgs e)
- {
- try
- {
- query = new SqlCommand($"select dolgnost from dolgnost", db_helper.sqlConnection);
- SqlDataReader reader = query.ExecuteReader();
- while (reader.Read())
- {
- cb_dolgnost.Items.Add(reader.GetString(0));
- }
- reader.Close();
- }
- catch
- {
- MessageBox.Show("Произошла непредвиденная ошибка!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- private void bt_add_Click(object sender, EventArgs e)
- {
- try
- {
- query = new SqlCommand($"insert into experience (kol_vo_smen, num_sertificat, work_place, student_otryad, status_otryad) values (@kol_vo_smen, @num_sertificat, @work_place, @student_otryad, @status_otryad)", db_helper.sqlConnection);
- query.Parameters.AddWithValue($"kol_vo_smen", nud_kolSmen.Value);
- query.Parameters.AddWithValue($"num_sertificat", mtb_numSertificat.Text);
- query.Parameters.AddWithValue($"work_place", tb_workPlace.Text);
- query.Parameters.AddWithValue($"student_otryad", tb_studentOtryad.Text);
- query.Parameters.AddWithValue($"status_otryad", tb_statusOtryad.Text);
- query.ExecuteNonQuery();
- DateTime date1 = DateTime.Parse(dtp_dateVudach.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_kemVudan.Text);
- query.Parameters.AddWithValue($"date_vudach", $"{date1.Day}.{date1.Month}.{date1.Year}");
- query.Parameters.AddWithValue($"seria", mtb_seria.Text);
- query.Parameters.AddWithValue($"nomer", mtb_nomer.Text);
- query.ExecuteNonQuery();
- query = new SqlCommand($"select kod_passport from passport where kem_vudan like '{tb_kemVudan.Text}' and date_vudach like '{date1.Day}.{date1.Month}.{date1.Year}' and seria like '{mtb_seria.Text}' and nomer like '{mtb_nomer.Text}'", db_helper.sqlConnection);
- string kodPassport = query.ExecuteScalar().ToString();
- query = new SqlCommand($"select kod_experince from experience where kol_vo_smen like '{nud_kolSmen.Value}' and num_sertificat like '{mtb_numSertificat.Text}' and work_place like '{tb_workPlace.Text}' and student_otryad like '{tb_studentOtryad.Text}' and status_otryad like '{tb_statusOtryad.Text}'", db_helper.sqlConnection);
- string kodExp = query.ExecuteScalar().ToString();
- query = new SqlCommand($"select kod_dolgnost from dolgnost where dolgnost like '{cb_dolgnost.SelectedItem}'", db_helper.sqlConnection);
- string kodDolgnost = query.ExecuteScalar().ToString();
- date1 = DateTime.Parse(dtp_dateBirth.Text);
- query = new SqlCommand($"insert into sotrudnic (surname, [name], patronymic, telephone, date_birth, adress, family_status, obrazovanie, kod_passport, inn, snils, num_med_book, kod_dolgnost, salary, kod_experience) values (@surname, @name, @patronymic, @telephone, @date_birth, @adress, @family_status, @obrazovanie, @kod_passport, @inn, @snils, @num_med_book, @kod_dolgnost, @salary, @kod_experience)", db_helper.sqlConnection);
- query.Parameters.AddWithValue($"surname", tb_surname.Text);
- query.Parameters.AddWithValue($"name", tb_name.Text);
- query.Parameters.AddWithValue($"patronymic", tb_patronymic.Text);
- query.Parameters.AddWithValue($"telephone", mtb_telephone.Text);
- query.Parameters.AddWithValue($"date_birth", $"{date1.Day}.{date1.Month}.{date1.Year}");
- query.Parameters.AddWithValue($"adress", tb_adress.Text);
- query.Parameters.AddWithValue($"family_status", cb_familyStatus.SelectedItem);
- query.Parameters.AddWithValue($"obrazovanie", cb_obrazovanie.SelectedItem);
- query.Parameters.AddWithValue($"kod_passport", kodPassport);
- query.Parameters.AddWithValue($"inn", mtb_INN.Text);
- query.Parameters.AddWithValue($"snils", mtb_snils.Text);
- query.Parameters.AddWithValue($"num_med_book", nud_numMedBook.Value);
- query.Parameters.AddWithValue($"kod_dolgnost", kodDolgnost);
- query.Parameters.AddWithValue($"salary", nud_salary.Value);
- query.Parameters.AddWithValue($"kod_experience", kodExp);
- if (query.ExecuteNonQuery().ToString().Equals("1"))
- {
- MessageBox.Show("Данные успешно добавлены!", "Уведомление", MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.Close();
- }
- }
- catch
- {
- MessageBox.Show("Произошла непредвиденная ошибка!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
- }
|