示例#1
0
        private void Cancel(object sender, EventArgs e)
        {
            this.Close();
            AdminMainForm amf = new AdminMainForm();

            amf.Show();
            conn.Close();
        }
示例#2
0
 private void CreateNewAdministrator(object sender, EventArgs e)
 {
     if (TextLogin.Text == "")
     {
         MessageBox.Show("Введите логин!");
         TextLogin.Focus();
     }
     else if (TextPassword.Text == "")
     {
         MessageBox.Show("Введите пароль!");
         TextPassword.Focus();
     }
     else
     {
         conn.Open();
         sql = "SELECT COUNT(*) FROM INFO WHERE INFO_LOGIN = '******'";
         MySqlCommand querycheckadm = new MySqlCommand(sql, conn);
         COUNT = Convert.ToInt32(querycheckadm.ExecuteScalar());
         if (COUNT == 0)
         {
             sql = "INSERT INTO INFO (INFO_LOGIN, INFO_PASSWORD) VALUES ('" + TextLogin.Text + "','" + TextPassword.Text + "')";
             MySqlCommand cmd = new MySqlCommand(sql, conn);
             if (cmd.ExecuteNonQuery() == 1)
             {
                 MessageBox.Show("Пользователь успешно создан!");
                 this.Close();
                 AdminMainForm amf = new AdminMainForm();
                 amf.Show();
                 conn.Close();
             }
             else
             {
                 MessageBox.Show("Запись не удалась");
                 conn.Close();
             }
         }
         else
         {
             MessageBox.Show("Такой пользователь уже существует!");
             conn.Close();
         }
     }
 }
示例#3
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();
                }
            }
        }
示例#4
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;
                }
            }
        }
示例#5
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();
                }
            }
        }
示例#6
0
        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;
            }
        }
示例#7
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();
            }
        }
示例#8
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;
                    }
                }
            }
        }