Ejemplo n.º 1
0
        private void DangNhap()
        {
            if (txtAccount.Text.Trim().Equals("") == true)
            {
                MessageBox.Show("Tài khoản không được để trắng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtAccount.Focus();
                return;
            }
            if (txtPass.Text.Trim().Equals("") == true)
            {
                MessageBox.Show("Mật khẩu không được để trắng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtPass.Focus();
                return;
            }
            string shashPass = "";

            shashPass = _validation.EncryptPassword(txtAccount.Text.Trim(), txtPass.Text.Trim());
            nhanvienBL ctr = new nhanvienBL();

            if (ctr.DangNhap(txtAccount.Text.Trim(), shashPass) == true)
            {
                Data.use = txtAccount.Text.Trim();
                success  = true;
            }
            else
            {
                MessageBox.Show("Đăng nhập không thành công.\nVui lòng kiểm tra lại tài khoản và mật khẩu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtAccount.Focus();
                return;
            }
        }
Ejemplo n.º 2
0
        private void DangNhap()
        {
            if (txtAccount.Text.Trim().Equals("") == true)
            {
                MessageBox.Show("Tài khoản không được để trắng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtAccount.Focus();
                return;
            }
            if (txtPass.Text.Trim().Equals("") == true)
            {
                MessageBox.Show("Mật khẩu không được để trắng.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtPass.Focus();
                return;
            }
            string shashPass = "";

            shashPass = _validation.EncryptPassword(txtAccount.Text.Trim(), txtPass.Text.Trim());
            nhanvienBL ctr = new nhanvienBL();

            if (ctr.DangNhap(txtAccount.Text.Trim(), shashPass) == true)
            {
                try
                {
                    Data.iduse = ctr.GetIDNhanVienByAccount(txtAccount.Text.Trim());
                    Data.use   = txtAccount.Text.Trim();
                    this.Hide();
                    _ctrlog.Append(Data.use, "Đăng nhập hệ thống.");
                    frmMain frm = new frmMain();
                    frm.ShowDialog();
                    if (frm.isActiveclose == false)
                    {
                        this.Show();
                    }
                    else
                    {
                        this.Dispose();
                    }
                }
                catch (Exception e) { this.Dispose(); }
            }
            else
            {
                MessageBox.Show("Đăng nhập không thành công.\nVui lòng kiểm tra lại tài khoản và mật khẩu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtAccount.Focus();
                return;
            }
        }