Example #1
0
 private void PW_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 (PW_text.Text == "")      //ถ้า PW_text ว่าง จะมีข้อความให้พิมพ์ password
         {
             MessageBox.Show("กรุณาพิมพ์ Password", "แจ้งเตือน");
             PW_text.Focus();//โฟกัสที่  PW_text
         }
         else if (ID_text.Text != "123321")
         {
             MessageBox.Show("Password ของคุณผิด", "แจ้งเตือนครั้งที่" + i);
             PW_text.Focus();     //โฟกัสที่  PW_text
             PW_text.SelectAll(); //ครอบtext ใน PW_text (เพื่อง่ายต่อการแก้ไข)
             i++;                 //เพิ่มค่า i
             if (i > 3)           //ถ้าค่าiเกิน สาม
             {
                 //ถ้ารหัสไม่ถูก 3 ครั้ง จะออกจากระบบอัตโนมัติ
                 MessageBox.Show("คุณพิมพ์ Passwrod ครบ 3 ครั้งแล้ว....ทำการปิดโปรแกรม", "แจ้งเตือน");
                 Application.Exit();
             }
         }
         else
         {
             Login_bt_Click(sender, e);//กดLogin อัตโนมัติ
         }
     }
 }
Example #2
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
         }
     }
 }
Example #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();
            }
        }
Example #4
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();
         }
     }
 }