123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- 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 hospital
- {
- public partial class updateMedCard : Form
- {
- SqlConnection sqlConnection = null;
- SqlDataReader reader = null;
- SqlCommand a = null;
- public updateMedCard()
- {
- InitializeComponent();
- }
- private void updateMedCard_Load(object sender, EventArgs e)
- {
- try
- {
- FormCreating.openConnection(ref sqlConnection);
- disabilityCB.Items.Add("Да");
- disabilityCB.Items.Add("Нет");
- a = new SqlCommand("select name_blood from blood_type", sqlConnection);
- reader = a.ExecuteReader();
- while (reader.Read())
- {
- bloodCB.Items.Add(reader.GetString(0));
- }
- reader.Close();
- a = new SqlCommand($"select name_factor from rh_factor", sqlConnection);
- reader = a.ExecuteReader();
- while (reader.Read())
- {
- rhFactorCB.Items.Add(reader.GetString(0));
- }
- reader.Close();
- a = new SqlCommand($"select surname_patient from medical_cards where id_card like {mainMenu.index}", sqlConnection);
- surnameTB.Text = a.ExecuteScalar().ToString();
- a = new SqlCommand($"select name_patient from medical_cards where id_card like {mainMenu.index}", sqlConnection);
- nameTB.Text = a.ExecuteScalar().ToString();
- a = new SqlCommand($"select midname_patient from medical_cards where id_card like {mainMenu.index}", sqlConnection);
- midnameTB.Text = a.ExecuteScalar().ToString();
- a = new SqlCommand($"select date_birthday_patient from medical_cards where id_card like {mainMenu.index}", sqlConnection);
- birthDateDTP.Text = a.ExecuteScalar().ToString();
- a = new SqlCommand($"select telephone_patient from medical_cards where id_card like {mainMenu.index}", sqlConnection);
- telephoneMTB.Text = a.ExecuteScalar().ToString();
- a = new SqlCommand($"select iian_patient from medical_cards where id_card like {mainMenu.index}", sqlConnection);
- iianMTB.Text = a.ExecuteScalar().ToString();
- a = new SqlCommand($"select Passport_Number_Patient from medical_cards where id_card like {mainMenu.index}", sqlConnection);
- passportNumberMTB.Text = a.ExecuteScalar().ToString();
- a = new SqlCommand($"select Passport_Date_Patient from medical_cards where id_card like {mainMenu.index}", sqlConnection);
- passportDateDTP.Text = a.ExecuteScalar().ToString();
- a = new SqlCommand($"select Passport_Place_Patient from medical_cards where id_card like {mainMenu.index}", sqlConnection);
- passpordPlaceTB.Text = a.ExecuteScalar().ToString();
- a = new SqlCommand($"select Passport_Code_Patient from medical_cards where id_card like {mainMenu.index}", sqlConnection);
- passportCodeMTB.Text = a.ExecuteScalar().ToString();
- a = new SqlCommand($"select Number_Policy_Patient from medical_cards where id_card like {mainMenu.index}", sqlConnection);
- policyNumberMTB.Text = a.ExecuteScalar().ToString();
- a = new SqlCommand($"select Disability_Patient from medical_cards where id_card like {mainMenu.index}", sqlConnection);
- disabilityCB.SelectedItem = a.ExecuteScalar().ToString();
- if (disabilityCB.SelectedItem.Equals("Нет"))
- {
- descriptionDisabilityRTB.Visible = false;
- }
- else
- {
- descriptionDisabilityRTB.Visible = true;
- }
- a = new SqlCommand($"select Description_Disability from medical_cards where id_card like {mainMenu.index}", sqlConnection);
- descriptionDisabilityRTB.Text = a.ExecuteScalar().ToString();
- a = new SqlCommand($"select name_blood from medical_cards join blood_type on medical_cards.id_blood = blood_type.id_blood where id_card like {mainMenu.index}", sqlConnection);
- bloodCB.SelectedItem = a.ExecuteScalar().ToString();
- a = new SqlCommand($"select name_factor from medical_cards join rh_factor on rh_factor.id_factor = medical_cards.id_factor where id_card like {mainMenu.index}", sqlConnection);
- rhFactorCB.SelectedItem = a.ExecuteScalar().ToString();
- a = new SqlCommand($"select WorkStudy_Place from medical_cards where id_card like {mainMenu.index}", sqlConnection);
- workStudyPlaceRTB.Text = a.ExecuteScalar().ToString();
- }
- catch
- {
- MessageBox.Show("Произошла непредвиденная ошибка", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- debugAndTrace.writeInFile("ERROR");
- }
- }
- private void update_Click(object sender, EventArgs e)
- {
- try
- {
- var res = MessageBox.Show("Уверены, что хотите изменить данные?", "Предупреждение", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (res == DialogResult.Yes)
- {
- DateTime date1 = DateTime.Parse(birthDateDTP.Text);
- DateTime date2 = DateTime.Parse(passportDateDTP.Text);
- SqlCommand bloodIndex = new SqlCommand($"select id_blood from blood_type where name_blood like N'{bloodCB.SelectedItem}'", sqlConnection);
- SqlCommand factorIndex = new SqlCommand($"select id_factor from rh_factor where name_factor like N'{rhFactorCB.SelectedItem}'", sqlConnection);
- a = new SqlCommand($"update medical_cards set Surname_Patient = @Surname_Patient, Name_Patient = @Name_Patient, Midname_Patient = @Midname_Patient, Date_Birthday_Patient = @Date_Birthday_Patient, Telephone_Patient = @Telephone_Patient, IIAN_Patient = @IIAN_Patient, Passport_Number_Patient = @Passport_Number_Patient, Passport_Date_Patient = @Passport_Date_Patient, Passport_Place_Patient = @Passport_Place_Patient, Passport_Code_Patient = @Passport_Code_Patient, Number_Policy_Patient = @Number_Policy_Patient, Disability_Patient = @Disability_Patient, Description_Disability = @Description_Disability, ID_Blood = @ID_Blood, ID_Factor = @ID_Factor, WorkStudy_Place = @WorkStudy_Place where id_card like {mainMenu.index}", sqlConnection);
- a.Parameters.AddWithValue("Surname_Patient", surnameTB.Text);
- a.Parameters.AddWithValue("Name_Patient", nameTB.Text);
- a.Parameters.AddWithValue("Midname_Patient", midnameTB.Text);
- a.Parameters.AddWithValue("Date_Birthday_Patient", $"{date1.Day}/{date1.Month}/{date1.Year}");
- a.Parameters.AddWithValue("Telephone_Patient", telephoneMTB.Text);
- a.Parameters.AddWithValue("IIAN_Patient", iianMTB.Text);
- a.Parameters.AddWithValue("Passport_Number_Patient", passportNumberMTB.Text);
- a.Parameters.AddWithValue("Passport_Date_Patient", $"{date2.Day}/{date2.Month}/{date2.Year}");
- a.Parameters.AddWithValue("Passport_Place_Patient", passpordPlaceTB.Text);
- a.Parameters.AddWithValue("Passport_Code_Patient", passportCodeMTB.Text);
- a.Parameters.AddWithValue("Number_Policy_Patient", policyNumberMTB.Text);
- a.Parameters.AddWithValue("Disability_Patient", disabilityCB.SelectedItem);
- a.Parameters.AddWithValue("Description_Disability", descriptionDisabilityRTB.Text);
- a.Parameters.AddWithValue("ID_Blood", bloodIndex.ExecuteScalar().ToString());
- a.Parameters.AddWithValue("ID_Factor", factorIndex.ExecuteScalar().ToString());
- a.Parameters.AddWithValue("WorkStudy_Place", workStudyPlaceRTB.Text);
- a.ExecuteNonQuery();
- Array.Resize(ref auth.data, 16);
- auth.data[0] = $"Фамилия: {surnameTB.Text}";
- auth.data[1] = $"Имя: {nameTB.Text}";
- auth.data[2] = $"Отчество: {midnameTB.Text}";
- auth.data[3] = $"Дата рождения: {date1.Day}/{date1.Month}/{date1.Year}";
- auth.data[4] = $"Телефон: {telephoneMTB.Text}";
- auth.data[5] = $"СНИЛС: {iianMTB.Text}";
- auth.data[6] = $"Серия и номер паспорта: {passportNumberMTB.Text}";
- auth.data[7] = $"Дата выдачи паспорта: {date2.Day}/{date2.Month}/{date2.Year}";
- auth.data[8] = $"Кем выдан: {passpordPlaceTB.Text}";
- auth.data[9] = $"Код подразделения: {passportCodeMTB.Text}";
- auth.data[10] = $"Номер страхового полиса: {policyNumberMTB.Text}";
- auth.data[11] = $"Инвалидность: {disabilityCB.SelectedIndex}";
- auth.data[12] = $"Описание инвалидности(если есть): {descriptionDisabilityRTB.Text}";
- auth.data[13] = $"Группа крови: {bloodCB.SelectedItem}";
- auth.data[14] = $"Резус фактор: {rhFactorCB.SelectedItem}";
- auth.data[15] = $"Описание трудовой деятельности: {workStudyPlaceRTB.Text}";
- debugAndTrace.writeInFile($"Изменение медицинской карты {mainMenu.index}", auth.data);
- if (a.ExecuteNonQuery() == 1)
- {
- MessageBox.Show("Изменение данных произошло успешно", "Уведомление", MessageBoxButtons.OK, MessageBoxIcon.Information);
- debugAndTrace.writeInFile($"Изменение медицинской карты {mainMenu.index}", auth.data);
- debugAndTrace.writeInFile("Переход на главную форму");
- this.Close();
- }
- else
- {
- MessageBox.Show("Произошла ошибка", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- debugAndTrace.writeInFile("Ошибка добавления данных", auth.data);
- }
- }
- else
- {
- MessageBox.Show("Действие отменено", "Уведомление", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- catch
- {
- MessageBox.Show("Произошла непредвиденная ошибка", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- debugAndTrace.writeInFile("ERROR");
- }
- }
- private void disabilityCB_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (disabilityCB.SelectedItem.Equals("Нет"))
- {
- descriptionDisabilityRTB.Visible = false;
- }
- else
- {
- descriptionDisabilityRTB.Visible = true;
- }
- }
- private void backBTN_Click(object sender, EventArgs e)
- {
- try
- {
- var res = MessageBox.Show("Уверены, что хотите отменить изменение медицинской карты?", "Предупреждение", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (res == DialogResult.Yes)
- {
- debugAndTrace.writeInFile("Отмена изменения медицинской карты");
- this.Close();
- }
- else
- {
- MessageBox.Show("Действие отменено", "Уведомление", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- catch
- {
- MessageBox.Show("Произошла непредвиденная ошибка", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- debugAndTrace.writeInFile("ERROR");
- }
- }
- }
- }
|