Пример #1
0
        // 确定按钮
        private void Ok_Click(object sender, EventArgs e)
        {
            string username  = TextAccount.Text.Trim();
            string password  = TextPasswd.Text.Trim();
            string sex       = TextSex.Text.Trim();
            string birthday  = TextBirthday.Text.Trim();
            string telephone = TextPhone.Text.Trim();
            string email     = TextEmail.Text.Trim();

            String2NULL(ref username);
            String2NULL(ref password);
            String2NULL(ref sex);
            String2NULL(ref birthday);
            String2NULL(ref telephone);
            String2NULL(ref email);

            #region 查询数据库当前账号是否被注册过
            sqlCon.Open();

            string         sql_cmd = String.Format("select * from [user] where username={0}", username);
            SqlDataAdapter sda     = new SqlDataAdapter(sql_cmd, sqlCon);
            DataSet        ds      = new DataSet();
            sda.Fill(ds);

            if (ds.Tables[0].Rows.Count > 0)
            {
                MessageBox.Show("当前账户名已被使用,请重新输入!");
            }
            else
            {
                sql_cmd = String.Format("insert into [user] values({0},{1},{2},{3},{4},{5},0,0,NULL,NULL)",
                                        username, password, sex, birthday, telephone, email);
                SqlCommand SqlCmd = new SqlCommand(sql_cmd, sqlCon);
                SqlCmd.ExecuteNonQuery();
                MessageBox.Show("账号创建成功!");
            }
            TextAccount.Clear();
            TextPasswd.Clear();
            TextSex.Clear();
            TextBirthday.Clear();
            TextPhone.Clear();
            TextEmail.Clear();
            TextAccount.Focus();

            sqlCon.Close();
            #endregion
        }
Пример #2
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();
                }
            }
        }
Пример #3
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;
                    }
                }
            }
        }