Example #1
0
 private void btnDangNhap_Click(object sender, EventArgs e)
 {
     if (txtTaiKhoan.Text.Length == 0)
     {
         lbThongBao.Text    = "Vui lòng nhập tài khoản!";
         lbThongBao.Visible = true;
     }
     else if (txtTaiKhoan.Text.Length > 20)
     {
         lbThongBao.Text    = "Tài khoản gồm 20 kí tự trở xuống!";
         lbThongBao.Visible = true;
     }
     else if (txtMatKhau.Text.Length == 0)
     {
         lbThongBao.Text    = "Vui lòng nhập mật khẩu!";
         lbThongBao.Visible = true;
     }
     else if (txtMatKhau.Text.Length > 20)
     {
         lbThongBao.Text    = "Mật khẩu gồm 20 kí tự trở xuống!";
         lbThongBao.Visible = true;
     }
     else
     {
         DTO_DangNhap dn = new DTO_DangNhap(txtTaiKhoan.Text, txtMatKhau.Text);
         if (busDN.checkDangNhap(dn) == true)
         {
             LuuThongTin.taikhoan = txtTaiKhoan.Text;
             MessageBox.Show("Đăng nhập thành công!", "Thống Báo");
             txtTaiKhoan.Text = "";
             txtMatKhau.Text  = "";
             frmGiaoDienChinh frm = new frmGiaoDienChinh();
             frm.FormClosed += new FormClosedEventHandler(frm_FormClosed);
             frm.Show();
             this.Hide();
             lbThongBao.Visible = false;
         }
         else
         {
             lbThongBao.Text    = "Sai tên tài khoản hoặc mặt khẩu!";
             lbThongBao.Visible = true;
         }
     }
 }
 private void btnDangNhap_Click(object sender, EventArgs e)
 {
     if (txtTaiKhoan.Text.Length == 0)
     {
         lbThongBao.Text    = "Vui lòng nhập tài khoản!";
         lbThongBao.Visible = true;
     }
     else if (txtTaiKhoan.Text.Length > 20)
     {
         lbThongBao.Text    = "Tài khoản gồm 20 kí tự trở xuống!";
         lbThongBao.Visible = true;
     }
     else if (txtMatKhau.Text.Length == 0)
     {
         lbThongBao.Text    = "Vui lòng nhập mật khẩu!";
         lbThongBao.Visible = true;
     }
     else if (txtMatKhau.Text.Length > 20)
     {
         lbThongBao.Text    = "Mật khẩu gồm 20 kí tự trở xuống!";
         lbThongBao.Visible = true;
     }
     else
     {
         DTO_DangNhap dn = new DTO_DangNhap(txtTaiKhoan.Text, txtMatKhau.Text);
         if (busDN.checkDangNhap(dn) == true)
         {
             MessageBox.Show("Đăng nhập thành công!", "Thống Báo");
             frmGiaoDienChinh f = new frmGiaoDienChinh();
             f.ShowDialog();
             lbThongBao.Visible = false;
         }
         else
         {
             lbThongBao.Text    = "Sai tên tài khoản hoặc mặt khẩu!";
             lbThongBao.Visible = true;
         }
     }
 }