private void CheckUser(object sender, EventArgs e) { Messages msg = new Messages(); if (TextIIN.Text == "") { msg.DataError("Введите ИИН!"); TextIIN.Focus(); } conn.Open(); switch (sw) { case 0: sql = "SELECT COUNT(*) FROM PERSON WHERE PERSON_IIN = '" + TextIIN.Text + "'"; MySqlCommand checkp = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(checkp.ExecuteScalar()); break; case 1: sql = "SELECT COUNT(*) FROM DOCTOR WHERE DOC_IIN = '" + TextIIN.Text + "'"; MySqlCommand checkd = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(checkd.ExecuteScalar()); break; } if (COUNT == 1) { PanelClinic.Visible = true; } else { msg.DataError("Пользователя нет в базе!"); } conn.Close(); }
private void DeleteGroup(object sender, EventArgs e) { Messages msg = new Messages(); conn.Open(); iin = TextIIN.Text; if (TextIIN.Text == "") { msg.DataError("Заполните ИИН!"); } else { sql = "UPDATE PERSON SET SOCIAL_GROUP_ID_SOCIAL_GROUP = NULL WHERE PERSON_IIN = '" + iin + "'"; MySqlCommand upd2 = new MySqlCommand(sql, conn); if (upd2.ExecuteNonQuery() == 1) { msg.DropSuccess(); this.Close(); DoctorMode doctorMode = new DoctorMode(did); doctorMode.Show(); conn.Close(); } else { msg.DropSuccess(); conn.Close(); } } }
private void CheckIIN(object sender, EventArgs e) { Messages msg = new Messages(); iin = TextIIN.Text; conn.Open(); sql = "SELECT COUNT(*) " + "FROM PERSON_HAS_DOCTOR " + "WHERE PERSON_HAS_DOCTOR.PERSON_PERSON_IIN = '" + iin + "' " + "AND PERSON_HAS_DOCTOR.DOCTOR_ID_DOCTOR = " + did + ""; MySqlCommand checkperson = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(checkperson.ExecuteScalar()); if (COUNT == 0) { msg.DataError("Пациент не найден!"); conn.Close(); } else { CreateButton.Visible = true; ChooseButton.Visible = true; ChangeButton.Visible = true; ViewButton.Visible = true; conn.Close(); } }
private void AddGroupToPerson(object sender, EventArgs e) { Messages msg = new Messages(); iin = TextIIN.Text; if (TextIIN.Text == "" | CBSetGroup.Text == "") { msg.DataError("Заполните данные!"); } else { conn.Open(); sql = "SELECT ID_SOCIAL_GROUP FROM SOCIAL_GROUP WHERE SOCIAL_GROUP = '" + CBSetGroup.Text + "'"; MySqlCommand sgid = new MySqlCommand(sql, conn); sg = Convert.ToInt32(sgid.ExecuteScalar()); sql = "UPDATE EMEDICINE.PERSON SET SOCIAL_GROUP_ID_SOCIAL_GROUP = " + sg + " WHERE PERSON_IIN = '" + iin + "'"; MySqlCommand upd1 = new MySqlCommand(sql, conn); if (upd1.ExecuteNonQuery() == 1) { msg.WriteSuccess(); this.Close(); DoctorMode doctorMode = new DoctorMode(did); doctorMode.Show(); conn.Close(); } else { msg.WriteError(); conn.Close(); } } }
private void SelectCity(object sender, EventArgs e) { Messages msg = new Messages(); CBSetClinic.Text = ""; CBSetClinic.Items.Clear(); conn.Open(); sql = "SELECT COUNT(*) FROM CLINIC WHERE CITY_ID_CITY = (" + "SELECT ID_CITY FROM CITY WHERE CITY = '" + CBCity.Text + "')"; MySqlCommand check = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(check.ExecuteScalar()); if (COUNT == 0) { msg.DataError("В данном городе нет зарегистрированных аптек!"); conn.Close(); } else { sql = "SELECT * FROM CLINIC WHERE CITY_ID_CITY = (" + "SELECT ID_CITY FROM CITY WHERE CITY = '" + CBCity.Text + "') " + "ORDER BY 2 ASC"; MySqlCommand setSpec = new MySqlCommand(sql, conn); MySqlDataReader reader = setSpec.ExecuteReader(); while (reader.Read()) { CBSetClinic.Items.Add(reader.GetString("CLINIC_NAME")); } conn.Close(); } }
public PersonMode(string login) { conn.Close(); Messages msg = new Messages(); iin = login; InitializeComponent(); DataTable dt = new DataTable(); conn.Open(); sql = "SELECT COUNT(*) " + "FROM PRESCRIPTION " + "WHERE PERSON_PERSON_IIN = '" + iin + "'"; MySqlCommand check = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(check.ExecuteScalar()); if (COUNT == 0) { msg.DataError("Активных рецептов нет!"); } conn.Close(); conn.Open(); sql = "SELECT SOCIAL_GROUP_ID_SOCIAL_GROUP " + "FROM PERSON " + "WHERE PERSON.PERSON_IIN = '" + iin + "'"; MySqlCommand ch = new MySqlCommand(sql, conn); MySqlDataReader mdr_info = ch.ExecuteReader(); mdr_info.Read(); if (mdr_info.IsDBNull(0)) { button1.Visible = false; conn.Close(); } else { button1.Visible = true; conn.Close(); } this.BackColor = Color.White; comboBox1.DropDownStyle = ComboBoxStyle.DropDownList; ExitButton.BackColor = Color.White; ExitButton.ForeColor = Color.FromArgb(10, 131, 35); button1.BackColor = Color.White; button1.ForeColor = Color.FromArgb(10, 131, 35); }
public DoctorJournal(int id) { Messages msg = new Messages(); did = id; InitializeComponent(); conn.Open(); sql = "SELECT COUNT(*) " + "FROM PRESCRIPTION " + "WHERE DOCTOR_ID_DOCTOR = " + did + ""; MySqlCommand check = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(check.ExecuteScalar()); if (COUNT == 0) { msg.DataError("Журналов нет!"); CBJType.Enabled = false; } CBJType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.BackColor = Color.White; ExitButton.BackColor = Color.White; ExitButton.ForeColor = Color.FromArgb(10, 131, 35); }
private void CreateNewPerson(object sender, EventArgs e) { Messages msg = new Messages(); if (TextLastName.Text == "") { msg.DataError("Введите фамилию!"); TextLastName.Focus(); } else if (TextFirstName.Text == "") { msg.DataError("Введите имя!"); TextFirstName.Focus(); } else if (SexSet.Text == "") { msg.DataError("Выберите пол!"); SexSet.Focus(); } else if (TextIIN.Text.Length != 12) { msg.DataError("Введите корректный ИИН!"); TextIIN.Focus(); } else if (TextEmail.Text == "") { msg.DataError("Введите адрес электронной почты!"); TextEmail.Focus(); } else if (TextPhone.Text == "") { msg.DataError("Введите номер телефона!"); TextPhone.Focus(); } else if (TextPassword.Text == "") { msg.DataError("Введите пароль!"); TextPassword.Focus(); } else if (TextPassword.Text != TextRepPassword.Text) { msg.DataError("Пароли не совпадают!"); TextPassword.Focus(); } else { conn.Open(); sqlins = "INSERT INTO PERSON (PERSON_LASTNAME, " + "PERSON_FIRSTNAME, " + "PERSON_PATRONYMIC, " + "PERSON_BIRTHDAY, " + "PERSON_IIN, " + "PERSON_PASSWORD, " + "PERSON_EMAIL, " + "PERSON_SEX, " + "PERSON_PHONE) " + "VALUES ('" + TextLastName.Text + "', " + "'" + TextFirstName.Text + "', " + "'" + TextPatronymic.Text + "', " + "'" + this.BirthdaySet.Text + "', " + "'" + TextIIN.Text + "', " + "'" + TextPassword.Text + "', " + "'" + TextEmail.Text + "', " + "'" + SexSet.Text + "'," + "'" + TextPhone.Text + "')"; sql = "SELECT COUNT(*) FROM PERSON WHERE PERSON_EMAIL = '" + TextEmail.Text + "'"; MySqlCommand checkEmail = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(checkEmail.ExecuteScalar()); if (COUNT == 0) { sql = "SELECT COUNT(*) FROM PERSON WHERE PERSON_IIN = '" + TextIIN.Text + "'"; MySqlCommand checkIIN = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(checkIIN.ExecuteScalar()); if (COUNT == 0) { MySqlCommand cmd = new MySqlCommand(sqlins, conn); if (cmd.ExecuteNonQuery() == 1) { msg.WriteSuccess(); this.Close(); AdminMainForm amf = new AdminMainForm(); amf.Show(); conn.Close(); } else { msg.WriteError(); conn.Close(); } } else { msg.DataError("Номер документа уже существует в системе!"); conn.Close(); COUNT = 0; } } } }
private void CreateNewAssignment(object sender, EventArgs e) { conn.Close(); Messages msg = new Messages(); iin = TextIIN.Text; if (TextAssign.Text == "") { msg.DataError("Введите назначение!"); TextAssign.Focus(); } else { conn.Open(); sql = "SELECT COUNT(*) FROM ASSIGNMENT WHERE ASSIGNMENT_NAME LIKE '%" + TextAssign.Text + "'"; MySqlCommand check = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(check.ExecuteScalar()); if (COUNT == 0) { sql = "INSERT INTO ASSIGNMENT(ASSIGNMENT_NAME) VALUES ('" + TextAssign.Text + "')"; MySqlCommand insassign = new MySqlCommand(sql, conn); if (insassign.ExecuteNonQuery() == 1) { sql = "INSERT INTO PERSON_HAS_ASSIGNMENT (PERSON_PERSON_IIN, ASSIGNMENT_ID_ASSIGNMENT) " + "VALUES('" + iin + "', (SELECT ID_ASSIGNMENT FROM ASSIGNMENT " + "WHERE ASSIGNMENT_NAME = '" + TextAssign.Text + "'))"; MySqlCommand inspa = new MySqlCommand(sql, conn); if (inspa.ExecuteNonQuery() == 1) { msg.WriteSuccess(); conn.Close(); CreatePanel.Visible = false; } else { msg.WriteError(); conn.Close(); } } else { msg.WriteError(); conn.Close(); } } else { conn.Close(); CreatePanel.Visible = false; ChoosePanel.Visible = true; sw = 0; conn.Open(); ChoosePanel.Visible = true; sql = "SELECT * FROM ASSIGNMENT ORDER BY 2 ASC"; MySqlCommand assign = new MySqlCommand(sql, conn); MySqlDataReader reader = assign.ExecuteReader(); while (reader.Read()) { CBSetAssign.Items.Add(reader.GetString("ASSIGNMENT_NAME")); } conn.Close(); } } }
private void CreateNewDrug(object sender, EventArgs e) { Messages msg = new Messages(); if (TextNameMedicine.Text == "") { msg.DataError("Введите название!"); TextNameMedicine.Focus(); } else if (CBSetCategory.Text == "") { msg.DataError("Выберите категорию!"); CBSetCategory.Focus(); } else if (CBSetGroup.Text == "") { msg.DataError("Выберите группу!"); CBSetGroup.Focus(); } else if (CBSetType.Text == "") { msg.DataError("Выберите тип!"); CBSetType.Focus(); } else { conn.Open(); sql = "SELECT COUNT(*) FROM DRUG WHERE DRUG_NAME = '" + TextNameMedicine.Text + "'"; MySqlCommand check = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(check.ExecuteScalar()); if (COUNT == 0) { sql = "SELECT ID_GROUP FROM DRUG_GROUP WHERE GROUP_NAME = '" + CBSetGroup.Text + "'"; MySqlCommand grid = new MySqlCommand(sql, conn); groupid = Convert.ToInt32(grid.ExecuteScalar()); sql = "SELECT ID_TYPE FROM DRUG_TYPE WHERE TYPE_NAME = '" + CBSetType.Text + "'"; MySqlCommand tyid = new MySqlCommand(sql, conn); typeid = Convert.ToInt32(tyid.ExecuteScalar()); sql = "INSERT INTO DRUG (DRUG_NAME, " + "DRUG_TYPE_ID_TYPE, " + "DRUG_GROUP_ID_GROUP) " + "VALUES ('" + TextNameMedicine.Text + "'," + "" + typeid + ", " + "" + groupid + ")"; MySqlCommand medins = new MySqlCommand(sql, conn); if (medins.ExecuteNonQuery() == 1) { msg.WriteSuccess(); this.Close(); AdminMainForm amf = new AdminMainForm(); amf.Show(); conn.Close(); } else { msg.WriteError(); conn.Close(); } } else { msg.DataError("Препарат уже существует в базе!"); conn.Close(); } } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { Messages msg = new Messages(); switch (comboBox1.SelectedIndex) { case 0: DataTable dt1 = new DataTable(); conn.Open(); sql = "SELECT COUNT(*) " + "FROM PRESCRIPTION " + "WHERE PERSON_PERSON_IIN = '" + iin + "'"; MySqlCommand check1 = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(check1.ExecuteScalar()); if (COUNT == 0) { msg.DataError("Активных рецептов нет!"); } else { sql = "SELECT SPECIALISATION.SPECIALISATION 'Врач'," + "DRUG.DRUG_NAME 'Препарат', " + "PRESCRIPTION.PRESCRIPTION_DATE_START 'Дата начала' " + "FROM SPECIALISATION INNER JOIN DOCTOR " + "ON ID_SPEC = SPECIALISATION_ID_SPEC " + "INNER JOIN PRESCRIPTION " + "ON ID_DOCTOR = DOCTOR_ID_DOCTOR " + "INNER JOIN DRUG " + "ON DRUG.ID_MEDICINE = PRESCRIPTION.MEDICINE_ID_MEDICINE " + "WHERE PRESCRIPTION.PERSON_PERSON_IIN = '" + iin + "' " + "AND PRESCRIPTION.PRESCRIPTION_DATE_FINISH IS NULL"; MySqlCommand prescriptionlist = new MySqlCommand(sql, conn); MySqlDataReader reader = prescriptionlist.ExecuteReader(); dt1.Load(reader); PrescriptionList.DataSource = dt1; conn.Close(); } break; case 1: DataTable dt2 = new DataTable(); conn.Open(); sql = "SELECT COUNT(*) " + "FROM PERSON_has_ASSIGNMENT " + "WHERE PERSON_has_ASSIGNMENT.PERSON_PERSON_IIN = '" + iin + "'"; MySqlCommand check2 = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(check2.ExecuteScalar()); if (COUNT == 0) { msg.DataError("Назначений нет!"); conn.Close(); } else { sql = "SELECT ASSIGNMENT.ASSIGNMENT_NAME 'Назначение' " + "FROM ASSIGNMENT INNER JOIN PERSON_has_ASSIGNMENT " + "ON ASSIGNMENT.ID_ASSIGNMENT = PERSON_has_ASSIGNMENT.ASSIGNMENT_ID_ASSIGNMENT " + "WHERE PERSON_has_ASSIGNMENT.PERSON_PERSON_IIN = '" + iin + "' "; MySqlCommand reclist = new MySqlCommand(sql, conn); MySqlDataReader reader = reclist.ExecuteReader(); dt2.Load(reader); PrescriptionList.DataSource = dt2; conn.Close(); } break; case 2: DataTable dt3 = new DataTable(); conn.Open(); sql = "SELECT COUNT(*) " + "FROM FORBIDDEN_DRUG " + "WHERE FORBIDDEN_DRUG.PERSON_PERSON_IIN = '" + iin + "'"; MySqlCommand check3 = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(check3.ExecuteScalar()); if (COUNT == 0) { msg.DataError("Ограничений нет!"); conn.Close(); } else { sql = "SELECT DRUG_NAME 'Препарат' " + "FROM DRUG " + "INNER JOIN FORBIDDEN_DRUG ON " + "DRUG.ID_MEDICINE = FORBIDDEN_DRUG.MEDICINE_ID_MEDICINE " + "WHERE FORBIDDEN_DRUG.PERSON_PERSON_IIN = '" + iin + "' "; MySqlCommand reclist = new MySqlCommand(sql, conn); MySqlDataReader reader = reclist.ExecuteReader(); dt3.Load(reader); PrescriptionList.DataSource = dt3; conn.Close(); } break; } }
private void CreateNewRecord(object sender, EventArgs e) { Messages msg = new Messages(); AdminMainForm amf = new AdminMainForm(); if (CBCity.Text == "") { msg.DataError("Выберите город!"); CBCity.Focus(); } else if (CBCountry.Text == "") { msg.DataError("Выберите страну!"); CBCountry.Focus(); } else if (CBRegion.Text == "") { msg.DataError("Выберите регион!"); CBRegion.Focus(); } else if (CBSetClinic.Text == "") { msg.DataError("Выберите поликлинику!"); CBSetClinic.Focus(); } else { conn.Open(); sql = "SELECT ID_CLINIC FROM CLINIC WHERE CLINIC_NAME = '" + CBSetClinic.Text + "'"; MySqlCommand clinicid = new MySqlCommand(sql, conn); cid = Convert.ToInt32(clinicid.ExecuteScalar()); switch (sw) { case 0: sql = "SELECT COUNT(*) " + "FROM CLINIC_HAS_PERSON " + "WHERE PERSON_PERSON_IIN = '" + TextIIN.Text + "' AND " + "CLINIC_ID_CLINIC = " + cid + ""; MySqlCommand pcheck = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(pcheck.ExecuteScalar()); if (COUNT == 0) { sql = "INSERT INTO CLINIC_HAS_PERSON " + "(PERSON_PERSON_IIN, CLINIC_ID_CLINIC) " + "VALUES ('" + TextIIN.Text + "'," + cid + ")"; MySqlCommand pins = new MySqlCommand(sql, conn); if (pins.ExecuteNonQuery() == 1) { msg.WriteSuccess(); this.Close(); amf.Show(); conn.Close(); } else { msg.WriteError(); conn.Close(); } } else { msg.DataError("Запись уже существует в базе данных!"); conn.Close(); } break; case 1: sql = "SELECT ID_DOCTOR FROM DOCTOR WHERE DOC_IIN = '" + TextIIN.Text + "'"; MySqlCommand dociin = new MySqlCommand(sql, conn); did = Convert.ToInt32(dociin.ExecuteScalar()); sql = "SELECT COUNT(*) " + "FROM CLINIC_HAS_DOCTOR " + "WHERE DOCTOR_ID_DOCTOR = " + did + " AND " + "CLINIC_ID_CLINIC = " + cid + ""; MySqlCommand dcheck = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(dcheck.ExecuteScalar()); if (COUNT == 0) { sql = "INSERT INTO CLINIC_HAS_DOCTOR " + "(DOCTOR_ID_DOCTOR, CLINIC_ID_CLINIC) " + "VALUES (" + did + " ," + cid + ")"; MySqlCommand dins = new MySqlCommand(sql, conn); if (dins.ExecuteNonQuery() == 1) { msg.WriteSuccess(); this.Close(); amf.Show(); conn.Close(); } else { msg.WriteError(); conn.Close(); } } else { msg.DataError("Запись уже существует в базе данных!"); conn.Close(); } break; } } }
private void SetMedicineToPerson(object sender, EventArgs e) { iin = TextIIN.Text; Messages msg = new Messages(); if (CBSetType.Text == "") { msg.DataError("Выберите тип препарата!"); CBSetType.Focus(); } else if (TextIIN.Text.Length != 12) { msg.DataError("Введите корректный ИИН!"); TextIIN.Focus(); } else if (CBSetCategory.Text == "") { msg.DataError("Выберите категорию препарата!"); CBSetCategory.Focus(); } else if (CBSetGroup.Text == "") { msg.DataError("Выберите группу препарата!"); CBSetGroup.Focus(); } else if (CBSetName.Text == "") { msg.DataError("Выберите название препарата!"); CBSetName.Focus(); } else { conn.Open(); sql = "SELECT COUNT(*) " + "FROM PERSON_HAS_DOCTOR " + "WHERE PERSON_HAS_DOCTOR.PERSON_PERSON_IIN = '" + iin + "' " + "AND PERSON_HAS_DOCTOR.DOCTOR_ID_DOCTOR = " + did + ""; MySqlCommand checkperson = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(checkperson.ExecuteScalar()); if (COUNT == 0) { msg.DataError("Невозможно назначить препарат!"); conn.Close(); } else { sql = "SELECT ID_MEDICINE FROM DRUG WHERE DRUG_NAME = '" + CBSetName.Text + "' "; MySqlCommand medicineid = new MySqlCommand(sql, conn); mid = Convert.ToInt32(medicineid.ExecuteScalar()); switch (CBSetType.SelectedIndex) { case 0: sql = "SELECT COUNT(*) FROM FORBIDDEN_DRUG WHERE MEDICINE_ID_MEDICINE = " + mid + ""; MySqlCommand recmed = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(recmed.ExecuteScalar()); if (COUNT == 0) { sql = "SELECT COUNT(*) FROM RECOMMENDED_DRUG " + "WHERE MEDICINE_ID_MEDICINE = " + mid + " AND PERSON_PERSON_IIN = " + iin + ""; MySqlCommand checkmed = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(checkmed.ExecuteScalar()); if (COUNT == 0) { sql = "INSERT INTO RECOMMENDED_DRUG ( PERSON_PERSON_IIN, MEDICINE_ID_MEDICINE) " + "VALUES ('" + iin + "', " + mid + ")"; MySqlCommand insrecmed = new MySqlCommand(sql, conn); if (insrecmed.ExecuteNonQuery() == 1) { msg.WriteSuccess(); this.Close(); DoctorMode doctorMode = new DoctorMode(did); doctorMode.Show(); conn.Close(); } else { msg.WriteError(); conn.Close(); } } else { msg.DataError("Запись уже существует!"); conn.Close(); } } else { msg.DataError("Ошибка совместимости!"); conn.Close(); } break; case 1: sql = "SELECT COUNT(*) FROM RECOMMENDED_DRUG WHERE MEDICINE_ID_MEDICINE = " + mid + ""; MySqlCommand formed = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(formed.ExecuteScalar()); if (COUNT == 0) { sql = "SELECT COUNT(*) FROM FORBIDDEN_DRUG " + "WHERE MEDICINE_ID_MEDICINE = " + mid + " AND PERSON_PERSON_IIN = " + iin + ""; MySqlCommand checkmed = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(checkmed.ExecuteScalar()); if (COUNT == 0) { sql = "INSERT INTO FORBIDDEN_DRUG (MEDICINE_ID_MEDICINE, PERSON_PERSON_IIN) " + "VALUES (" + mid + ",'" + iin + "')"; MySqlCommand insrformed = new MySqlCommand(sql, conn); if (insrformed.ExecuteNonQuery() == 1) { msg.WriteSuccess(); this.Close(); DoctorMode doctorMode = new DoctorMode(did); doctorMode.Show(); } else { msg.WriteError(); conn.Close(); } } else { msg.DataError("Запись уже существует!"); conn.Close(); } } else { msg.DataError("Ошибка совместимости!"); conn.Close(); } break; } } } }
private void AddNewRecord(object sender, EventArgs e) { Messages msg = new Messages(); if (CBSetClinic.Text == "") { msg.DataError("Выберите поликлинику!"); CBSetClinic.Focus(); } else if (TextIIN.Text == "") { msg.DataError("Введите ИИН!"); TextIIN.Focus(); } else { conn.Open(); sql = "SELECT COUNT(*) " + "FROM PERSON WHERE PERSON_IIN = '" + TextIIN.Text + "' "; MySqlCommand check = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(check.ExecuteScalar()); if (COUNT == 0) { msg.DataError("Пациент не найден в базе данных!"); conn.Close(); } else { sql = "SELECT COUNT(*) " + "FROM PERSON_HAS_DOCTOR " + "WHERE PERSON_PERSON_IIN = '" + TextIIN.Text + "' " + "AND CLINIC_ID_CLINIC = " + cid + " " + "AND DOCTOR_ID_DOCTOR = " + did + ""; MySqlCommand checkpc = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(checkpc.ExecuteScalar()); if (COUNT == 0) { sql = "INSERT INTO PERSON_HAS_DOCTOR (PERSON_PERSON_IIN, CLINIC_ID_CLINIC, DOCTOR_ID_DOCTOR) " + "VALUES ('" + TextIIN.Text + "'," + cid + ", " + did + ")"; MySqlCommand ins = new MySqlCommand(sql, conn); if (ins.ExecuteNonQuery() == 1) { msg.WriteSuccess(); this.Close(); conn.Close(); DoctorMode doctorMode = new DoctorMode(did); doctorMode.Show(); } else { msg.WriteError(); conn.Close(); } } else { msg.DataError("Запись уже существует в базе данных!"); conn.Close(); } } } }
private void CreateNewDoctor(object sender, EventArgs e) { Messages msg = new Messages(); if (TextLastName.Text == "") { msg.DataError("Введите фамилию!"); TextLastName.Focus(); } else if (TextFirstName.Text == "") { msg.DataError("Введите имя!"); TextFirstName.Focus(); } else if (TextIIN.Text.Length != 12) { msg.DataError("Введите корректный ИИН!"); TextIIN.Focus(); } else if (TextEmail.Text == "") { msg.DataError("Введите адрес электронной почты!"); TextEmail.Focus(); } else if (TextPhone.Text == "") { msg.DataError("Введите номер телефона!"); TextPhone.Focus(); } else if (TextPassword.Text == "") { msg.DataError("Введите пароль!"); TextPassword.Focus(); } else if (TextPassword.Text != TextRepPassword.Text) { msg.DataError("Пароли не совпадают!"); TextPassword.Focus(); } else if (CBSetSpec.Text == "") { msg.DataError("Выберите специализацию!"); CBSetSpec.Focus(); } else { conn.Open(); sql = "SELECT COUNT(*) FROM DOCTOR WHERE DOC_EMAIL = '" + TextEmail.Text + "'"; MySqlCommand checkEmail = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(checkEmail.ExecuteScalar()); if (COUNT == 0) { sql = "SELECT COUNT(*) FROM DOCTOR WHERE DOC_IIN = '" + TextIIN.Text + "'"; MySqlCommand checkIIN = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(checkIIN.ExecuteScalar()); if (COUNT == 0) { sql = "INSERT INTO DOCTOR (DOC_LASTNAME, " + "DOC_FIRSTNAME, " + "DOC_PATRONYMIC, " + "DOC_IIN, " + "DOC_EMAIL, " + "DOC_PHONE, " + "DOC_PASSWORD, " + "SPECIALISATION_ID_SPEC) " + "VALUES ('" + TextLastName.Text + "', " + "'" + TextFirstName.Text + "', " + "'" + TextPatronymic.Text + "', " + "'" + TextIIN.Text + "', " + "'" + TextEmail.Text + "', " + "'" + TextPhone.Text + "', " + "'" + TextPassword.Text + "', " + "" + idspec + ")"; MySqlCommand insdoc = new MySqlCommand(sql, conn); if (insdoc.ExecuteNonQuery() == 1) { msg.WriteSuccess(); this.Close(); AdminMainForm amf = new AdminMainForm(); amf.Show(); conn.Close(); } else { msg.WriteError(); conn.Close(); } } else { msg.DataError("ИИН уже существует в системе!"); conn.Close(); } } else { msg.DataError("Электронный адрес уже существует в системе!"); conn.Close(); } } }
private void SetPrescription(object sender, EventArgs e) { Messages msg = new Messages(); iin = TextIIN.Text; conn.Open(); switch (sw) { case 1: if (CBSetName1.Text == "") { msg.DataError("Заполните данные!"); } else { sql = "SELECT ID_MEDICINE FROM DRUG WHERE DRUG_NAME = '" + CBSetName1.Text + "'"; MySqlCommand med1 = new MySqlCommand(sql, conn); m1 = Convert.ToInt32(med1.ExecuteScalar()); sql = "SELECT COUNT(*) FROM FORBIDDEN_DRUG " + "WHERE PERSON_PERSON_IIN = '" + iin + "' " + "AND MEDICINE_ID_MEDICINE = " + m1 + ""; MySqlCommand c1 = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(c1.ExecuteScalar()); if (COUNT == 0) { sql = "INSERT INTO PRESCRIPTION (MEDICINE_ID_MEDICINE, PRESCRIPTION_DATE_START, PERSON_PERSON_IIN, DOCTOR_ID_DOCTOR) " + "VALUES (" + m1 + ",'" + date + "', '" + iin + "', " + did + ")"; MySqlCommand inspr1 = new MySqlCommand(sql, conn); if (inspr1.ExecuteNonQuery() == 1) { msg.WriteSuccess(); this.Close(); DoctorMode doctorMode = new DoctorMode(did); doctorMode.Show(); conn.Close(); } else { msg.DataError("Создание рецепта не удалось!"); conn.Close(); } } else { msg.DataError("Ошибка совместимости!"); conn.Close(); } } break; case 2: if (CBSetName1.Text == CBSetName2.Text) { msg.DataError("Данные совпадают!"); } else if (CBSetName1.Text == "" | CBSetName2.Text == "") { msg.DataError("Заполните данные!"); } else { sql = "SELECT ID_MEDICINE FROM DRUG WHERE DRUG_NAME = '" + CBSetName1.Text + "'"; MySqlCommand med1 = new MySqlCommand(sql, conn); m1 = Convert.ToInt32(med1.ExecuteScalar()); sql = "SELECT COUNT(*) FROM FORBIDDEN_DRUG " + "WHERE PERSON_PERSON_IIN = '" + iin + "' " + "AND MEDICINE_ID_MEDICINE = " + m1 + ""; MySqlCommand c1 = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(c1.ExecuteScalar()); if (COUNT == 0) { sql = "SELECT ID_MEDICINE FROM DRUG WHERE DRUG_NAME = '" + CBSetName2.Text + "'"; MySqlCommand med2 = new MySqlCommand(sql, conn); m2 = Convert.ToInt32(med2.ExecuteScalar()); sql = "SELECT COUNT(*) FROM FORBIDDEN_DRUG " + "WHERE PERSON_PERSON_IIN = '" + iin + "' " + "AND MEDICINE_ID_MEDICINE = " + m2 + ""; MySqlCommand c2 = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(c2.ExecuteScalar()); if (COUNT == 0) { sqlins1 = "INSERT INTO PRESCRIPTION (MEDICINE_ID_MEDICINE, PRESCRIPTION_DATE_START, PERSON_PERSON_IIN, DOCTOR_ID_DOCTOR) " + "VALUES (" + m1 + ",'" + date + "', '" + iin + "', " + did + ")"; MySqlCommand inspr1 = new MySqlCommand(sqlins1, conn); sqlins2 = "INSERT INTO PRESCRIPTION (MEDICINE_ID_MEDICINE, PRESCRIPTION_DATE_START, PERSON_PERSON_IIN, DOCTOR_ID_DOCTOR) " + "VALUES (" + m2 + ",'" + date + "', '" + iin + "', " + did + ")"; MySqlCommand inspr2 = new MySqlCommand(sqlins2, conn); if (inspr1.ExecuteNonQuery() == 1) { if (inspr2.ExecuteNonQuery() == 1) { msg.WriteSuccess(); this.Close(); DoctorMode doctorMode = new DoctorMode(did); doctorMode.Show(); conn.Close(); } else { msg.DataError("Создание рецепта не удалось!"); conn.Close(); } } else { msg.DataError("Создание рецепта не удалось!"); conn.Close(); } } else { msg.DataError("Ошибка совместимости!"); conn.Close(); } } else { msg.DataError("Ошибка совместимости!"); conn.Close(); } } break; case 3: if (CBSetName1.Text == CBSetName2.Text | CBSetName1.Text == CBSetName3.Text | CBSetName3.Text == CBSetName2.Text) { msg.DataError("Данные совпадают!"); } else if (CBSetName1.Text == "" | CBSetName2.Text == "" | CBSetName3.Text == "") { msg.DataError("Заполните данные!"); } else { sql = "SELECT ID_MEDICINE FROM DRUG WHERE DRUG_NAME = '" + CBSetName1.Text + "'"; MySqlCommand med1 = new MySqlCommand(sql, conn); m1 = Convert.ToInt32(med1.ExecuteScalar()); sql = "SELECT COUNT(*) FROM FORBIDDEN_DRUG " + "WHERE PERSON_PERSON_IIN = '" + iin + "' " + "AND MEDICINE_ID_MEDICINE = " + m1 + ""; MySqlCommand c1 = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(c1.ExecuteScalar()); if (COUNT == 0) { sql = "SELECT ID_MEDICINE FROM DRUG WHERE DRUG_NAME = '" + CBSetName2.Text + "'"; MySqlCommand med2 = new MySqlCommand(sql, conn); m2 = Convert.ToInt32(med2.ExecuteScalar()); sql = "SELECT COUNT(*) FROM FORBIDDEN_DRUG " + "WHERE PERSON_PERSON_IIN = '" + iin + "' " + "AND MEDICINE_ID_MEDICINE = " + m2 + ""; MySqlCommand c2 = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(c2.ExecuteScalar()); if (COUNT == 0) { sql = "SELECT ID_MEDICINE FROM DRUG WHERE DRUG_NAME = '" + CBSetName3.Text + "'"; MySqlCommand med3 = new MySqlCommand(sql, conn); m3 = Convert.ToInt32(med2.ExecuteScalar()); sql = "SELECT COUNT(*) FROM FORBIDDEN_DRUG " + "WHERE PERSON_PERSON_IIN = '" + iin + "' " + "AND MEDICINE_ID_MEDICINE = " + m3 + ""; MySqlCommand c3 = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(c3.ExecuteScalar()); if (COUNT == 0) { sqlins1 = "INSERT INTO PRESCRIPTION (MEDICINE_ID_MEDICINE, PRESCRIPTION_DATE_START, PERSON_PERSON_IIN, DOCTOR_ID_DOCTOR) " + "VALUES (" + m1 + ",'" + date + "', '" + iin + "', " + did + ")"; MySqlCommand inspr1 = new MySqlCommand(sqlins1, conn); sqlins2 = "INSERT INTO PRESCRIPTION (MEDICINE_ID_MEDICINE, PRESCRIPTION_DATE_START, PERSON_PERSON_IIN, DOCTOR_ID_DOCTOR) " + "VALUES (" + m2 + ",'" + date + "', '" + iin + "', " + did + ")"; MySqlCommand inspr2 = new MySqlCommand(sqlins2, conn); sqlins3 = "INSERT INTO PRESCRIPTION (MEDICINE_ID_MEDICINE, PRESCRIPTION_DATE_START, PERSON_PERSON_IIN, DOCTOR_ID_DOCTOR) " + "VALUES (" + m3 + ",'" + date + "', '" + iin + "', " + did + ")"; MySqlCommand inspr3 = new MySqlCommand(sqlins3, conn); if (inspr1.ExecuteNonQuery() == 1) { if (inspr2.ExecuteNonQuery() == 1) { if (inspr3.ExecuteNonQuery() == 1) { msg.WriteSuccess(); this.Close(); DoctorMode doctorMode = new DoctorMode(did); doctorMode.Show(); conn.Close(); } else { msg.DataError("Создание рецепта не удалось!"); conn.Close(); } } else { msg.DataError("Создание рецепта не удалось!"); conn.Close(); } } else { msg.DataError("Создание рецепта не удалось!"); conn.Close(); } } else { msg.DataError("Ошибка совместимости!"); conn.Close(); } } else { msg.DataError("Ошибка совместимости!"); conn.Close(); } } else { msg.DataError("Ошибка совместимости!"); conn.Close(); } } break; case 4: if (CBSetName1.Text == CBSetName2.Text | CBSetName1.Text == CBSetName3.Text | CBSetName1.Text == CBSetName4.Text | CBSetName2.Text == CBSetName3.Text | CBSetName2.Text == CBSetName4.Text | CBSetName3.Text == CBSetName4.Text) { msg.DataError("Данные совпадают!"); } else if (CBSetName1.Text == "" | CBSetName2.Text == "" | CBSetName3.Text == "" | CBSetName4.Text == "") { msg.DataError("Заполните данные!"); } else { sql = "SELECT ID_MEDICINE FROM DRUG WHERE DRUG_NAME = '" + CBSetName1.Text + "'"; MySqlCommand med1 = new MySqlCommand(sql, conn); m1 = Convert.ToInt32(med1.ExecuteScalar()); sql = "SELECT COUNT(*) FROM FORBIDDEN_DRUG " + "WHERE PERSON_PERSON_IIN = '" + iin + "' " + "AND MEDICINE_ID_MEDICINE = " + m1 + ""; MySqlCommand c1 = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(c1.ExecuteScalar()); if (COUNT == 0) { sql = "SELECT ID_MEDICINE FROM DRUG WHERE DRUG_NAME = '" + CBSetName2.Text + "'"; MySqlCommand med2 = new MySqlCommand(sql, conn); m2 = Convert.ToInt32(med2.ExecuteScalar()); sql = "SELECT COUNT(*) FROM FORBIDDEN_DRUG " + "WHERE PERSON_PERSON_IIN = '" + iin + "' " + "AND MEDICINE_ID_MEDICINE = " + m2 + ""; MySqlCommand c2 = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(c2.ExecuteScalar()); if (COUNT == 0) { sql = "SELECT ID_MEDICINE FROM DRUG WHERE DRUG_NAME = '" + CBSetName3.Text + "'"; MySqlCommand med3 = new MySqlCommand(sql, conn); m3 = Convert.ToInt32(med2.ExecuteScalar()); sql = "SELECT COUNT(*) FROM FORBIDDEN_DRUG " + "WHERE PERSON_PERSON_IIN = '" + iin + "' " + "AND MEDICINE_ID_MEDICINE = " + m3 + ""; MySqlCommand c3 = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(c3.ExecuteScalar()); if (COUNT == 0) { sql = "SELECT ID_MEDICINE FROM DRUG WHERE DRUG_NAME = '" + CBSetName4.Text + "'"; MySqlCommand med4 = new MySqlCommand(sql, conn); m4 = Convert.ToInt32(med2.ExecuteScalar()); sql = "SELECT COUNT(*) FROM FORBIDDEN_DRUG " + "WHERE PERSON_PERSON_IIN = '" + iin + "' " + "AND MEDICINE_ID_MEDICINE = " + m4 + ""; MySqlCommand c4 = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(c4.ExecuteScalar()); if (COUNT == 0) { sqlins1 = "INSERT INTO PRESCRIPTION (MEDICINE_ID_MEDICINE, PRESCRIPTION_DATE_START, PERSON_PERSON_IIN, DOCTOR_ID_DOCTOR) " + "VALUES (" + m1 + ",'" + date + "', '" + iin + "', " + did + ")"; MySqlCommand inspr1 = new MySqlCommand(sqlins1, conn); sqlins2 = "INSERT INTO PRESCRIPTION (MEDICINE_ID_MEDICINE, PRESCRIPTION_DATE_START, PERSON_PERSON_IIN, DOCTOR_ID_DOCTOR) " + "VALUES (" + m2 + ",'" + date + "', '" + iin + "', " + did + ")"; MySqlCommand inspr2 = new MySqlCommand(sqlins2, conn); sqlins3 = "INSERT INTO PRESCRIPTION (MEDICINE_ID_MEDICINE, PRESCRIPTION_DATE_START, PERSON_PERSON_IIN, DOCTOR_ID_DOCTOR) " + "VALUES (" + m3 + ",'" + date + "', '" + iin + "', " + did + ")"; MySqlCommand inspr3 = new MySqlCommand(sqlins3, conn); sqlins4 = "INSERT INTO PRESCRIPTION (MEDICINE_ID_MEDICINE, PRESCRIPTION_DATE_START, PERSON_PERSON_IIN, DOCTOR_ID_DOCTOR) " + "VALUES (" + m4 + ",'" + date + "', '" + iin + "', " + did + ")"; MySqlCommand inspr4 = new MySqlCommand(sqlins4, conn); if (inspr1.ExecuteNonQuery() == 1) { if (inspr2.ExecuteNonQuery() == 1) { if (inspr3.ExecuteNonQuery() == 1) { if (inspr4.ExecuteNonQuery() == 1) { msg.WriteSuccess(); this.Close(); DoctorMode doctorMode = new DoctorMode(did); doctorMode.Show(); conn.Close(); } else { msg.DataError("Создание рецепта не удалось!"); conn.Close(); } } else { msg.DataError("Создание рецепта не удалось!"); conn.Close(); } } else { msg.DataError("Создание рецепта не удалось!"); conn.Close(); } } else { msg.DataError("Создание рецепта не удалось!"); conn.Close(); } } else { msg.DataError("Ошибка совместимости!"); conn.Close(); } } else { msg.DataError("Ошибка совместимости!"); conn.Close(); } } else { msg.DataError("Ошибка совместимости!"); conn.Close(); } } else { msg.DataError("Ошибка совместимости!"); conn.Close(); } } break; } }
private void Login(object sender, EventArgs e) { Messages msg = new Messages(); AdminMainForm amf; amf = new AdminMainForm(); MainForm mainForm = new MainForm(); switch (sw) { case 0: sql = "SELECT COUNT(*) FROM INFO WHERE INFO_LOGIN = '******'"; MySqlCommand querycheckadm = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(querycheckadm.ExecuteScalar()); if (COUNT == 0) { msg.DataError("Логин и/или пароль неверный"); } else { sql = "SELECT ID_INFO FROM INFO WHERE INFO_LOGIN = '******'"; MySqlCommand queryidadm = new MySqlCommand(sql, conn); id = (int)queryidadm.ExecuteScalar(); sql = "SELECT INFO_PASSWORD FROM INFO WHERE ID_INFO = '" + id + "'"; MySqlCommand querypasswordadm = new MySqlCommand(sql, conn); password = querypasswordadm.ExecuteScalar().ToString(); if (TextPassword.Text == password) { this.Close(); amf.Show(); TextLogin.Text = ""; TextPassword.Text = ""; conn.Close(); } else { msg.DataError("Логин и/или пароль неверный"); } } break; case 1: sql = "SELECT COUNT(*) FROM PERSON WHERE PERSON_IIN = '" + TextLogin.Text + "'"; MySqlCommand querycheckperson = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(querycheckperson.ExecuteScalar()); if (COUNT == 0) { MessageBox.Show("Логин и/или пароль неверный", "Ошибка входа", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { sql = "SELECT PERSON_PASSWORD FROM PERSON WHERE PERSON_IIN = '" + TextLogin.Text + "'"; MySqlCommand querypasswordperson = new MySqlCommand(sql, conn); password = querypasswordperson.ExecuteScalar().ToString(); if (TextPassword.Text == password) { login = TextLogin.Text; PersonMode person = new PersonMode(login); person.Show(); this.Close(); conn.Close(); } else { msg.DataError("Логин и/или пароль неверный"); } } break; case 2: sql = "SELECT COUNT(*) FROM DOCTOR WHERE DOC_IIN = '" + TextLogin.Text + "'"; MySqlCommand querycheckdoc = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(querycheckdoc.ExecuteScalar()); if (COUNT == 0) { msg.DataError("Логин и/или пароль неверный"); } else { sql = "SELECT ID_DOCTOR FROM DOCTOR WHERE DOC_IIN = '" + TextLogin.Text + "'"; MySqlCommand queryiddoc = new MySqlCommand(sql, conn); id = (int)queryiddoc.ExecuteScalar(); sql = "SELECT DOC_PASSWORD FROM DOCTOR WHERE ID_DOCTOR = '" + id + "'"; MySqlCommand querypassworddoc = new MySqlCommand(sql, conn); password = querypassworddoc.ExecuteScalar().ToString(); if (TextPassword.Text == password) { DoctorMode doctor = new DoctorMode(id); doctor.Show(); this.Close(); conn.Close(); } else { msg.DataError("Логин и/или пароль неверный"); } } break; } }
private void CreateNewClinic(object sender, EventArgs e) { Messages msg = new Messages(); if (TextNameClPh.Text == "") { msg.DataError("Введите название!"); TextNameClPh.Focus(); } else if (TextZipClPh.Text == "") { msg.DataError("Введите почтовый индекс!"); TextZipClPh.Focus(); } else if (CBCity.Text == "") { msg.DataError("Выберите город!"); CBCity.Focus(); } else if (CBCountry.Text == "") { msg.DataError("Выберите страну!"); CBCountry.Focus(); } else if (CBRegion.Text == "") { msg.DataError("Выберите регион!"); CBRegion.Focus(); } else if (TextStreetClPh.Text == "") { msg.DataError("Введите улицу!"); TextStreetClPh.Focus(); } else if (TextBuildingClPh.Text == "") { msg.DataError("Введите номер строения!"); TextBuildingClPh.Focus(); } else if (TextPhoneClPh.Text == "") { msg.DataError("Введите номер телефона!"); TextPhoneClPh.Focus(); } else { conn.Open(); sql = "SELECT ID_CITY FROM CITY WHERE CITY ='" + CBCity.Text + "'"; MySqlCommand cid = new MySqlCommand(sql, conn); cityid = Convert.ToInt32(cid.ExecuteScalar()); } sql = "SELECT COUNT(*) FROM CLINIC WHERE CLINIC_NAME = '" + TextNameClPh.Text + "'"; MySqlCommand querycheckcl = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(querycheckcl.ExecuteScalar()); if (COUNT == 0) { sql = "INSERT INTO CLINIC (CLINIC_NAME, " + "CITY_ID_CITY, " + "CLINIC_ZIP_CODE, " + "CLINIC_STREET, " + "CLINIC_BUILDING) " + "VALUES ('" + TextNameClPh.Text + "', " + "" + cityid + "," + " '" + TextZipClPh.Text + "'," + " '" + TextStreetClPh.Text + "'," + " '" + TextBuildingClPh.Text + "')"; MySqlCommand cmdcl = new MySqlCommand(sql, conn); if (cmdcl.ExecuteNonQuery() == 1) { sql = "SELECT ID_CLINIC FROM CLINIC WHERE CLINIC_NAME = '" + TextNameClPh.Text + "'"; MySqlCommand clquery = new MySqlCommand(sql, conn); id = (int)clquery.ExecuteScalar(); sql = "INSERT INTO CLINIC_PHONE (CLINIC_PHONE, CLINIC_ID_CLINIC) VALUES ('" + TextPhoneClPh.Text + "', " + id + ")"; MySqlCommand clphone = new MySqlCommand(sql, conn); if (clphone.ExecuteNonQuery() == 1) { msg.WriteSuccess(); this.Close(); AdminMainForm amf = new AdminMainForm(); amf.Show(); conn.Close(); } else { msg.WriteError(); conn.Close(); } } else { msg.WriteError(); conn.Close(); } } else { msg.DataError("Такое медицинское учреждение уже существует!"); conn.Close(); } }