private void btnThayDoiMatKhau_Click(object sender, EventArgs e)
 {
     if (txtMatKhauMoi1.Text != "" && txtMatKhauMoi2.Text != "" && txtMatKhau.Text != "")
     {
         if (CheckPassWord() == true)
         {
             BLL.DangNhapBLL changePassword = new BLL.DangNhapBLL();
             if (changePassword.UpdateAccountUserNameAndPassWord(txtTenTaiKhoan.Text, txtMatKhauMoi1.Text) == true)
             {
                 MessageBox.Show("Thay đỗi mật khẩu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 txtMatKhauMoi1.Text = "";
                 txtMatKhau.Text     = "";
                 txtMatKhauMoi2.Text = "";
                 txtMatKhau.Focus();
             }
             else
             {
                 MessageBox.Show("Có lỗi trong quá trình thực hiện !!! ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         else
         {
             MessageBox.Show("Mật khẩu bạn nhập vào không đúng !!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Vui lòng nhập đầy đủ thông tin !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 private void btnCapNhatTK_Click(object sender, EventArgs e)
 {
     txtUsernameTK.Text = cbbTenNhanVienTK.SelectedValue.ToString();
     DTO.DangNhapDTO dangNhap = null;
     if (cbbQuyenHanTK.Text == "Admin")
     {
         dangNhap = new DTO.DangNhapDTO(txtUsernameTK.Text, txtPasswordTK.Text, true);
     }
     else if (cbbQuyenHanTK.Text == "User")
     {
         dangNhap = new DTO.DangNhapDTO(txtUsernameTK.Text, txtPasswordTK.Text, false);
     }
     if (txtPasswordTK.Text != "" && cbbQuyenHanTK.Text != "")
     {
         BLL.DangNhapBLL taiKhoan = new BLL.DangNhapBLL();
         if (taiKhoan.Update(dangNhap) == true)
         {
             MessageBox.Show("Cập nhật Tài khoản thành công");
             LoadTK();
             LamMoiTaiKhoan();
         }
         else
         {
             MessageBox.Show("Lỗi xảy ra trong quá trình thực hiện");
         }
     }
 }
 private void btnThemTK_Click(object sender, EventArgs e)
 {
     txtUsernameTK.Text = cbbTenNhanVienTK.SelectedValue.ToString();
     if (txtPasswordTK.Text != "" && cbbQuyenHanTK.Text != "")
     {
         BLL.DangNhapBLL taiKhoan = new BLL.DangNhapBLL();
         if (cbbQuyenHanTK.Text == "Admin")
         {
             if (taiKhoan.Insert(txtUsernameTK.Text, txtPasswordTK.Text, true) == true)
             {
                 MessageBox.Show("Thêm Tài khoản thành công");
                 LoadTK();
                 LamMoiTaiKhoan();
             }
             else
             {
                 MessageBox.Show("Lỗi xảy ra trong quá trình thực hiện");
             }
         }
         else if (cbbQuyenHanTK.Text == "User")
         {
             if (taiKhoan.Insert(txtUsernameTK.Text, txtPasswordTK.Text, false) == true)
             {
                 MessageBox.Show("Thêm Tài khoản thành công");
                 LoadTK();
                 LamMoiTaiKhoan();
             }
             else
             {
                 MessageBox.Show("Lỗi xảy ra trong quá trình thực hiện");
             }
         }
     }
 }
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            string userName = txtUserName.Text;
            string passWord = txtPassWord.Text;

            if (Login(userName, passWord))
            {
                BLL.DangNhapBLL acc     = new BLL.DangNhapBLL();
                DTO.DangNhapDTO account = acc.GetAccountByUserName(userName);
                frmManager      f       = new frmManager(account);
                this.Hide();
                f.ShowDialog();
                txtPassWord.Text = "";
                txtPassWord.Focus();
                this.Show();
            }
            else
            {
                if (txtPassWord.Text.Length == 0 || txtUserName.Text.Length == 0)
                {
                    MessageBox.Show("Bạn Chưa Nhập Tài Khoản Hoặc Mật Khẩu !!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtPassWord.Text = "";
                    txtUserName.Text = "";
                    txtUserName.Focus();
                }
                else
                {
                    MessageBox.Show("Bạn Đã Nhập Sai Tài Khoản Hoặc Mật Khẩu !!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtPassWord.Text = "";
                    txtPassWord.Focus();
                }
            }
        }
 private void btnXoaTK_Click(object sender, EventArgs e)
 {
     txtUsernameTK.Text = cbbTenNhanVienTK.SelectedValue.ToString();
     if (txtUsernameTK.Text != "")
     {
         BLL.DangNhapBLL taiKhoan = new BLL.DangNhapBLL();
         if (taiKhoan.Delete(txtUsernameTK.Text) == true)
         {
             MessageBox.Show("Xóa tài khoản thành công");
             LoadTK();
         }
         else
         {
             MessageBox.Show("Lỗi xảy ra trong quá trình thực hiện");
         }
     }
 }
 private bool CheckPassWord()
 {
     BLL.DangNhapBLL dangNhap = new BLL.DangNhapBLL();
     return(dangNhap.Login(txtTenTaiKhoan.Text, txtMatKhau.Text));
 }
 private void LoadTK()
 {
     BLL.DangNhapBLL taiKhoan = new BLL.DangNhapBLL();
     dgvTK.DataSource = taiKhoan.Load();
 }
 private bool Login(string userName, string passWord)
 {
     BLL.DangNhapBLL checkLogin = new BLL.DangNhapBLL();
     return(checkLogin.Login(userName, passWord));
 }