Example #1
0
 public void btn_DangNhap_Click(object sender, EventArgs e)
 {
     try
     {
         if (txt_EmailDangNhap.Text == "" || txt_MatKhauDangNhap.Text == "")
         {
             MessageBox.Show("Email đăng nhập và Password không được để trống!");
             return;
         }
         if (!KiemTraEmail(txt_EmailDangNhap.Text))
         {
             MessageBox.Show("Email không đúng định dạng!");
             return;
         }
         if (txt_MatKhauDangNhap.Text.Length < 6)
         {
             MessageBox.Show("Mật khẩu phải dài hơn hoặc bằng 6 kỹ tự!");
             return;
         }
         DTO_NHANVIEN nv = new DTO_NHANVIEN();
         nv.Email   = txt_EmailDangNhap.Text.ToLower();
         nv.matKhau = txt_MatKhauDangNhap.Text.ToLower();
         if (BUS_NHANVIEN.DangNhap(nv))
         {
             string mail = nv.Email;
             cache.mail = mail;                 // truyền mail đăng nhập cho Home
             DataTable dt = BUS_NHANVIEN.LayVaiTroNV(nv.Email);
             vaitro = dt.Rows[0][0].ToString(); // lấy vai trò nhân viên
             MessageBox.Show("Login Successfully");
             cache.session = 1;                 // đăng nhập thành công
             if (cbx_ghiNhoDangNhap.Checked)
             {
                 Properties.Settings.Default.user = txt_EmailDangNhap.Text;
                 Properties.Settings.Default.pass = txt_MatKhauDangNhap.Text;
                 Properties.Settings.Default.Save();
             }
             else
             {
                 Properties.Settings.Default.user      = "";
                 Properties.Settings.Default.pass      = "";
                 Properties.Settings.Default.isChecked = false;
                 Properties.Settings.Default.Save();
             }
             this.Close();
         }
         else
         {
             MessageBox.Show("Login Fail, Email or PassWord Wrong!");
             txt_EmailDangNhap.Text   = null;
             txt_MatKhauDangNhap.Text = null;
             txt_EmailDangNhap.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #2
0
        public void TestDangNhap004()
        {
            DTO_NHANVIEN nv = new DTO_NHANVIEN();

            nv.Email   = "*****@*****.**";
            nv.matKhau = "123456";
            bool result = BUS_NHANVIEN.DangNhap(nv);

            Assert.IsTrue(result);
        }
Example #3
0
        public void TestDangNhap003()
        {
            DTO_NHANVIEN nv = new DTO_NHANVIEN();

            nv.Email   = "*****@*****.**";
            nv.matKhau = "654321";
            bool result = BUS_NHANVIEN.DangNhap(nv);

            Assert.IsFalse(result);
        }
Example #4
0
        public void TestDangNhap001()
        {
            DTO_NHANVIEN nv = new DTO_NHANVIEN();

            nv.Email   = " ";
            nv.matKhau = "123456";
            bool result = BUS_NHANVIEN.DangNhap(nv);

            Assert.IsFalse(result);
        }