コード例 #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         string user = textBox1.Text;
         string pass = textBox2.Text;
         if (user.Equals(""))
         {
             MessageBox.Show("Bạn Chưa Nhập Tên Đăng Nhập", "Đăng Nhập", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.textBox1.Clear();
             this.textBox1.Focus();
         }
         else if (pass.Equals(""))
         {
             MessageBox.Show("Bạn Chưa Nhập Mật Khẩu", "Đăng Nhập", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.textBox2.Clear();
             this.textBox2.Focus();
         }
         else
         {
             string txt = getMD5(textBox2.Text);
             String sv  = "select count(*) from tkad where tk = N'" + textBox1.Text + "' and mk=N'" + txt + "'";
             String sv1 = "select * from tkad where tk = N'" + textBox1.Text + "' ";
             int    i   = KetNoiCSDL.count(sv);
             if (sai > 0)
             {
                 if (i != 0)
                 {
                     DataTable tb     = KetNoiCSDL.laybang(sv1);
                     String    ten    = tb.Rows[0][0].ToString();
                     String    status = tb.Rows[0][2].ToString();
                     if (status.Equals("Admin"))
                     {
                         this.Close();
                         MessageBox.Show("Bạn Đã Đăng Nhập Vào Tài Khoản Admin!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         main Main_chinh = new main(1, ten);
                         Main_chinh.Show();
                     }
                     else if (status.Equals("User"))
                     {
                         this.Close();
                         MessageBox.Show("Bạn Đã Đăng Nhập Vào Tài Khoản User!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         main Main_chinh = new main(0, ten);
                         Main_chinh.Show();
                     }
                     else if (status.Equals("Giáo viên"))
                     {
                         this.Close();
                         MessageBox.Show("Bạn Đã Đăng Nhập Vào Tài Khoản Giáo viên!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         main Main_chinh = new main(3, ten);
                         Main_chinh.Show();
                     }
                     else
                     {
                         this.Close();
                         MessageBox.Show("Bạn Đã Đăng Nhập Vào Tài Khoản Trưởng khoa!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         main Main_chinh = new main(2, ten);
                         Main_chinh.Show();
                     }
                 }
                 else
                 {
                     sai = sai - 1;
                     MessageBox.Show("Username Hoặc Password Sai! Bạn Còn " + sai + " Lần Đăng Nhập!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     this.textBox1.Clear();
                     this.textBox2.Clear();
                     this.textBox1.Focus();
                 }
             }
             else
             {
                 MessageBox.Show("Đã Hết Lượt Truy Cập, Mời Bạn Đăng Nhập Lại!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.Close();
                 Form1 f = new Form1();
                 f.Show();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Đã Có Lỗi Xảy Ra. Vui Lòng Kiểm Tra Lại!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #2
0
ファイル: dangnhap.cs プロジェクト: ncthanh239/DMN
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         string user = textBox1.Text;
         string pass = textBox2.Text;
         if (user.Equals(""))
         {
             MessageBox.Show("Bạn Chưa Nhập Tên Đăng Nhập", "Đăng Nhập", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.textBox1.Clear();
             this.textBox1.Focus();
         }
         else if (pass.Equals(""))
         {
             MessageBox.Show("Bạn Chưa Nhập Mật Khẩu", "Đăng Nhập", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.textBox2.Clear();
             this.textBox2.Focus();
         }
         else
         {
             String sv = "select count(*) from tkuser where tk = N'" + textBox1.Text + "' and mk=N'" + textBox2.Text + "'";
             int    i  = KetNoiCSDL.count(sv);
             String ad = "select count(*) from tkad where tk = N'" + textBox1.Text + "' and mk=N'" + textBox2.Text + "'";
             int    i1 = KetNoiCSDL.count(ad);
             String gv = "select count(*) from tkgv where tk = N'" + textBox1.Text + "' and mk=N'" + textBox2.Text + "'";
             int    i2 = KetNoiCSDL.count(gv);
             String tk = "select count(*) from tktk where tk = N'" + textBox1.Text + "' and mk=N'" + textBox2.Text + "'";
             int    i3 = KetNoiCSDL.count(tk);
             if (sai > 0)
             {
                 if (i != 0)
                 {
                     this.Close();
                     MessageBox.Show("Bạn Đã Đăng Nhập Vào Tài Khoản User!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     main Main_chinh = new main(0);
                     Main_chinh.Show();
                 }
                 else if (i1 != 0)
                 {
                     this.Close();
                     MessageBox.Show("Bạn Đã Đăng Nhập Vào Tài Khoản Admin!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     main Main_chinh = new main(1);
                     Main_chinh.Show();
                 }
                 else if (i2 != 0)
                 {
                     this.Close();
                     MessageBox.Show("Bạn Đã Đăng Nhập Vào Tài Khoản Giáo Viên!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     main Main_chinh = new main(2);
                     Main_chinh.Show();
                 }
                 else if (i3 != 0)
                 {
                     this.Close();
                     MessageBox.Show("Bạn Đã Đăng Nhập Vào Tài Khoản Trưởng Khoa!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     main Main_chinh = new main(3);
                     Main_chinh.Show();
                 }
                 else
                 {
                     sai = sai - 1;
                     MessageBox.Show("Username Hoặc Password Sai! Bạn Còn " + sai + " Lần Đăng Nhập!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     this.textBox1.Clear();
                     this.textBox2.Clear();
                     this.textBox1.Focus();
                 }
             }
             else
             {
                 MessageBox.Show("Đã Hết Lượt Truy Cập, Mời Bạn Đăng Nhập Lại!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.Close();
                 Form1 f = new Form1();
                 f.Show();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Đã Có Lỗi Xảy Ra. Vui Lòng Kiểm Tra Lại!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }