示例#1
0
        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();
                }
            }
        }
示例#2
0
        private void ModifyAssignmen(object sender, EventArgs e)
        {
            conn.Close();
            Messages msg = new Messages();

            conn.Open();
            iin = TextIIN.Text;
            switch (sw)
            {
            case 0:
                sql = "SELECT COUNT(*) " +
                      "FROM PERSON_HAS_ASSIGNMENT INNER JOIN ASSIGNMENT " +
                      "ON PERSON_HAS_ASSIGNMENT.ASSIGNMENT_ID_ASSIGNMENT = ASSIGNMENT.ID_ASSIGNMENT " +
                      "WHERE ASSIGNMENT.ASSIGNMENT_NAME = '" + CBSetAssign.Text + "'" +
                      "AND PERSON_HAS_ASSIGNMENT.PERSON_PERSON_IIN = '" + iin + "'";
                MySqlCommand check = new MySqlCommand(sql, conn);
                COUNT = Convert.ToInt32(check.ExecuteScalar());
                if (COUNT == 0)
                {
                    sql = "INSERT INTO PERSON_HAS_ASSIGNMENT (PERSON_PERSON_IIN, ASSIGNMENT_ID_ASSIGNMENT) " +
                          "VALUES('" + iin + "', (SELECT ID_ASSIGNMENT FROM ASSIGNMENT " +
                          "WHERE ASSIGNMENT_NAME = '" + CBSetAssign.Text + "'))";
                    MySqlCommand insert = new MySqlCommand(sql, conn);
                    if (insert.ExecuteNonQuery() == 1)
                    {
                        msg.WriteSuccess();
                        conn.Close();
                        ChoosePanel.Visible = false;
                        CBSetAssign.Items.Clear();
                    }
                    else
                    {
                        msg.WriteError();
                        conn.Close();
                    }
                }
                else
                {
                    msg.WriteError();
                    conn.Close();
                }
                break;

            case 1:
                sql = "DELETE FROM PERSON_HAS_ASSIGNMENT " +
                      "WHERE ASSIGNMENT_ID_ASSIGNMENT = (SELECT ID_ASSIGNMENT FROM ASSIGNMENT " +
                      "WHERE ASSIGNMENT_NAME = '" + CBSetAssign.Text + "') " +
                      "AND PERSON_PERSON_IIN = '" + iin + "'";
                MySqlCommand del = new MySqlCommand(sql, conn);
                if (del.ExecuteNonQuery() == 1)
                {
                    msg.DropSuccess();
                    conn.Close();
                    ChoosePanel.Visible = false;
                    CBSetAssign.Items.Clear();
                }
                else
                {
                    msg.DropError();
                    conn.Close();
                }
                break;
            }
        }
示例#3
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();
                }
            }
        }
示例#4
0
        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();
                }
            }
        }
示例#5
0
        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;
                }
            }
        }
示例#6
0
        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;
                    }
                }
            }
        }
示例#7
0
        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();
                    }
                }
            }
        }
示例#8
0
        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();
                }
            }
        }
示例#9
0
        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;
            }
        }
示例#10
0
        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();
            }
        }
示例#11
0
        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;
                    }
                }
            }
        }