Ejemplo n.º 1
0
 private void ID_text_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape)
     {
         BottonExit_Click(sender, e); //ถ้ากดปุ่ม "escape" ตอนอยู่ที่ textbox ของ username จะกดปุ่ม exit โดยอัตโนมัติ
     }
     if (e.KeyCode == Keys.Enter)     //ถ้ากด enter
     {
         if (ID_text.Text == "")      //ถ้า ID_text ว่าง จะมีข้อความให้พิมพ์ username
         {
             MessageBox.Show("กรุณาพิมพ์ username", "แจ้งเตือน");
             ID_text.Focus();//โฟกัสที่ ID_text
         }
         else if (ID_text.Text != "admin")
         {
             MessageBox.Show("username ของคุณผิด", "แจ้งเตือน");
             ID_text.Focus();     //โฟกัสที่ ID_text
             ID_text.SelectAll(); //ครอบtext ในID_text (เพื่อง่ายต่อการแก้ไข)
         }
         else
         {
             PW_text.Focus(); //โฟกัสที่PW_text
         }
     }
 }
Ejemplo n.º 2
0
 private void ADD_NEW_Click(object sender, EventArgs e)
 {
     ID_text.Clear();
     name_text.Clear();
     statue_text.Clear();
     AmountOfMedicine_txt.Clear();
     phoneNumber_text.Clear();
 }
Ejemplo n.º 3
0
        private void SingUp_Btn_Click(object sender, EventArgs e)
        {
            if (CheckID_Btn.Enabled)
            {
                MessageBox.Show("아이디 확인을 해주세요.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ID_text.Focus();
                return;
            }


            if (PW_text.Text.Length < 8)
            {
                MessageBox.Show("비밀번호는 8자 이상 입력하셔야합니다.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                PW_text.Focus();
                return;
            }

            if (Email_text.Text.Length == 0 || Email_Combo.SelectedItem.ToString().Length == 0)
            {
                MessageBox.Show("이메일을 입력하세요.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Email_text.Focus();
                return;
            }


            Http http = new Http("SignUp.php");

            http.PostParam.Append("ID=" + ID_text.Text);
            http.PostParam.Append("&PW=" + PW_text.Text);
            http.PostParam.Append("&Email=" + Email_text.Text + "@" + Email_Combo.SelectedItem.ToString());
            http.Data = UTF8Encoding.UTF8.GetBytes(http.PostParam.ToString());

            string result = http.Client_To_Server();

            if (result.Equals("-1"))//회원 가입 실패
            {
                MessageBox.Show("회원 가입도중 오류가 났습니다 잠시 후 다시 실행해주세요.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (result.Equals("1"))//회원 가입 성공
            {
                F_Account          = new Account(Home_Panel, ID_text.Text);
                F_Account.TopLevel = false;
                F_Account.Dock     = System.Windows.Forms.DockStyle.Fill;
                Home_Panel.Controls.Add(F_Account);
                F_Account.Show();
                Close();
            }
        }
Ejemplo n.º 4
0
        private void ID_text_Leave(object sender, EventArgs e)
        {
            Regex   regex   = new Regex(@"[a-zA-Z0-9]");
            Boolean ismatch = regex.IsMatch(ID_text.Text);

            if (ID_text.Text.Length == 0)
            {
                MessageBox.Show("아이디를 입력해주세요.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ID_text.Focus();
            }

            if (!ismatch)
            {
                MessageBox.Show("아이디는 영문자,숫자만 가능합니다.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ID_text.Text = "";
                ID_text.Focus();
            }
        }
Ejemplo n.º 5
0
 int i = 1; //กำหนดตัวแปร
 private void Login_bt_Click(object sender, EventArgs e)
 {
     if ((ID_text.Text == "admin") && (PW_text.Text == "123321"))//ถ้า username="******" และ password="******"
     {
         //เข้าสู่ระบบ
         Main f2 = new Main();
         f2.Show();
         this.Hide();
     }
     else if (ID_text.Text == "")//ถ้าไม่มีการพิมพ์ username จะมีข้อความเตือนโชว์ขึ้น
     {
         //ข้อความเตือนให้ใส่ username
         MessageBox.Show("กรุณาพิมพ์ username", "แจ้งเตือน");
         ID_text.Focus();
     }
     else if (PW_text.Text == "")
     {
         //ข้อความเตือนให้ใส่ Password
         MessageBox.Show("กรุณาพิมพ์ Password", "แจ้งเตือน");
         PW_text.Focus();
     }
     else if (ID_text.Text != "admin")
     {
         //ข้อความเตือนว่า username ผิด
         MessageBox.Show("username ของคุณผิด", "แจ้งเตือน");
         ID_text.Focus();     //โฟกัสที่ username
         ID_text.SelectAll(); //เลือกข้อความใน textboxทั้งหมด (เพื่อให้ง่ายต่อการลบ)
     }
     else if (PW_text.Text != "123321")
     {
         MessageBox.Show("Password ของคุณผิด", "แจ้งเตือนครั้งที่" + i);
         PW_text.Focus();     //โฟกัสที่ Password
         PW_text.SelectAll(); //เลือกข้อความใน textboxทั้งหมด (เพื่อให้ง่ายต่อการลบ)
         i++;                 // บวก i หนึ่งครั้ง
         if (i > 3)           //ถ้า i มากกว่าสาม
         {
             //จะมีข้อความเตือนว่า เข้าระบบครบที่กำหนด แล้วจะออกจากโปรแกรม
             MessageBox.Show("คุณพิมพ์ Passwrod ครบ 3 ครั้งแล้ว....ทำการปิดโปรแกรม", "แจ้งเตือน");
             Application.Exit();
         }
     }
 }
Ejemplo n.º 6
0
        private void ADD_Click(object sender, EventArgs e)
        {
            try
            {
                con.Open();

                OleDbCommand command = new OleDbCommand();
                command.Connection = con;

                if (name_text.Text != "" && statue_text.Text != "" && phoneNumber_text.Text != "")
                {
                    if (phoneNumber_text.TextLength == 11)
                    {
                        string s = "insert into Doctor (doctor_ID,name,statue,phone,amount_of_medicine)" +
                                   "values('" + ID_text.Text + "','" + name_text.Text + "','" + statue_text.Text + "','" + phoneNumber_text.Text + "','" + AmountOfMedicine_txt.Text + "')";
                        command.CommandText = s;
                        command.ExecuteNonQuery();
                        MessageBox.Show("ADD is done! ");
                        ID_text.Clear();
                        name_text.Clear();
                        statue_text.Clear();
                        AmountOfMedicine_txt.Clear();
                        phoneNumber_text.Clear();
                    }
                    else
                    {
                        MessageBox.Show("phone number is not correct, mobile phone number should be 11 number! ");
                    }
                }
                else
                {
                    MessageBox.Show(" data not complete, please complete it ");
                }



                comboBox1.Items.Clear();

                con.Close();

                try
                {
                    con.Open();

                    command.Connection = con;
                    string query = "select * from Doctor";

                    command.CommandText = query;
                    OleDbDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        comboBox1.Items.Add(reader["name"].ToString());
                    }

                    con.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error Happen! ");
                }
                finally
                {
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(" patient number already exist! ");
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
        }