Exemplo n.º 1
0
        private void BtnDangNhap_Click(object sender, EventArgs e)
        {
            //check if ten dang nhap or mat khau is null
            if (string.IsNullOrEmpty(tbTenTaiKhoan.Text))
            {
                MessageBox.Show("Tên đăng nhập không để trống");
                return;
            }

            if (string.IsNullOrEmpty(tbMatKhau.Text))
            {
                MessageBox.Show("Mật khẩu không để trống");
                return;
            }

            string tenTk, matKhau;

            tenTk   = tbTenTaiKhoan.Text;
            matKhau = tbMatKhau.Text;

            //check if account exist
            if (!taiKhoanBUS.ExistInDatabase(tenTk))
            {
                MessageBox.Show("Tài khoản này không tồn tại");
                return;
            }

            //check if password correct
            if (!taiKhoanBUS.LogIn(tenTk, matKhau))
            {
                MessageBox.Show("Mật khẩu cho tài khoản này không đúng \nXin hãy nhập lại");
                return;
            }

            MessageBox.Show("Đăng nhập thành công");
            TaiKhoan.TaiKhoanHienTai = taiKhoanBUS.Read(tenTk);
            OpenFormMain();
        }