Exemplo n.º 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            NhanvienController nvController = new NhanvienController();

            if (!Regex.IsMatch(txtUsername.Text, "^([a-zA-Z]{1}[\\w|\\.|\\|_|\\-]{4,18}\\w{1})$"))
            {
                MessageBox.Show("Tên tài khoản:\n + Bắt đầu bằng 1 chữ cái \n + Chỉ chứa chữ cái, số hoặc các dấu ._- \n + Kết thúc bằng một chữ cái hoặc số \n + Phân biệt hoa thường", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            ;
            tblNhanVien nhanvien = nvController.LayThongTin(txtUsername.Text, txtPassword.Text);

            if (nhanvien.sMaNV != null && nhanvien.sMaNV.Length > 0)
            {
                MessageBox.Show("Xin chào " + nhanvien.sHoTenNV + "!", "Đăng nhập thành công!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TrangChu formTrangChu = new TrangChu(this, txtUsername.Text);
                txtPassword.Text = "";
                txtUsername.Text = "";
                this.Hide();
                formTrangChu.Show();
            }
            else
            {
                MessageBox.Show("Không tìm thấy thông tin đăng nhập!", "Đăng nhập không thành công!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Text = "";
                txtUsername.Text = "";
            }
        }
Exemplo n.º 2
0
        private void btnXacNhan_Click(object sender, EventArgs e)
        {
            tblNhanVien nhanvien = nvController.LayThongTin(username, txtMKCu.Text);

            if (nhanvien.sMaNV != null && nhanvien.sMaNV.Length > 0)
            {
                string mkMoi   = txtMKMoi.Text;
                string nhapLai = txtNhapLai.Text;
                if (mkMoi.Equals(nhapLai))
                {
                    nvController.doiMatKhau(username, mkMoi);
                    MessageBox.Show("Đổi mật khẩu cho tài khoản " + username + " thành công!", "Đổi mật khẩu thành công!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Mật khẩu nhập lại không chính xác", "Đổi mật khẩu không thành công!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Mật khẩu cũ không chính xác", "Đổi mật khẩu không thành công!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }