예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            ObjDangnhap.TaiKhoan = txtTaiKhoan.Text;
            ObjDangnhap.MatKhau  = txtMatKhau.Text;

            if (txtTaiKhoan.Text == "" || txtMatKhau.Text == "")
            {
                MessageBox.Show("Không được bỏ trống các trường!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (txtTaiKhoan.Text == "")
                {
                    txtTaiKhoan.Focus();
                }
                else
                {
                    txtMatKhau.Focus();
                }
            }
            else
            {
                if (DangNhap_BUS.Kiemtrataikhoan_bool(ObjDangnhap) == true)
                {
                    txtTaiKhoan.Text = "";
                    txtMatKhau.Text  = "";

                    taiKhoan = ObjDangnhap.TaiKhoan;
                    matKhau  = ObjDangnhap.MatKhau;
                    maQuyen  = DangNhap_BUS.Maquyen_string(ObjDangnhap);

                    MessageBox.Show("Đăng nhập thành công!", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    Run_MAIN(int.Parse(maQuyen));

                    this.Close();
                }
                else
                {
                    MessageBox.Show("Tài khoản hoặc mật khẩu không đúng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtTaiKhoan.Text = "";
                    txtMatKhau.Text  = "";
                    txtTaiKhoan.Focus();
                }
            }
        }
예제 #2
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            ObjDangnhap.TaiKhoan = txtTaiKhoan.Text;
            ObjDangnhap.MatKhau  = txtMatKhau.Text;

            if (txtTaiKhoan.Text == "" || txtMatKhau.Text == "")
            {
                MessageBox.Show("Không được bỏ trống các trường!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (txtTaiKhoan.Text == "")
                {
                    txtTaiKhoan.Focus();
                }
                else
                {
                    txtMatKhau.Focus();
                }
            }
            else
            {
                if (DangNhap_BUS.KiemTraTaiKhoan(ObjDangnhap) == true)
                {
                    txtTaiKhoan.Text = "";
                    txtMatKhau.Text  = "";

                    taiKhoan = ObjDangnhap.TaiKhoan;
                    matKhau  = ObjDangnhap.MatKhau;
                    maQuyen  = DangNhap_BUS.MaQuyen(ObjDangnhap); // Lấy mã quyền của người dùng

                    MessageBox.Show("Đăng nhập thành công!", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    Run_MAIN(int.Parse(maQuyen)); // chạy hàm hiển thị tương ứng với mã quyền đó
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Tài khoản hoặc mật khẩu không đúng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtTaiKhoan.Text = "";
                    txtMatKhau.Text  = "";
                    txtTaiKhoan.Focus();
                }
            }
        }