Exemple #1
0
        public void TestDangNhap_Rong()
        {
            LoginBus lgBUS = new LoginBus();
            string   user  = "";
            string   pass  = "";
            bool     b     = true;
            Account  acc   = new Account(user, pass);
            LoginBus DN    = new LoginBus();

            b = lgBUS.loginbus(acc);
            Assert.AreEqual(false, b);
        }
Exemple #2
0
        public void TestDangNhap_Thieu_Pass()
        {
            LoginBus lgBUS = new LoginBus();
            string   user  = "******";
            string   pass  = "";
            bool     b     = true;
            Account  acc   = new Account(user, pass);
            LoginBus DN    = new LoginBus();

            b = lgBUS.loginbus(acc);
            Assert.AreNotEqual(true, b);
        }
        private void btn_signin_Click_1(object sender, EventArgs e)
        {
            string name = txt_username.Text, pass = txt_password.Text;

            if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(pass))
            {
                MessageBox.Show("ban phai nhap day du thong tin ", "chua nhap thong tin", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                sqlcnn.Open();
                string     select = "SELECT Loai FROM NguoiDung WHERE TaiKhoan = '" + txt_username.Text + "'";
                SqlCommand cmd    = new SqlCommand(select, sqlcnn);
                QLKhoHang.intLoai = cmd.ExecuteScalar().ToString();
                sqlcnn.Close();
                QLKhoHang.strUser = txt_username.Text;
                //if (txtUseName.Text == "admin" && txtPassWord.Text == "123")\
                //if (name == "admin" && pass == "123")
                bool b = false;
                try
                {
                    Account acc = new Account(name, pass);
                    b = lgBUS.loginbus(acc);
                    //label2.DataBindings.Add()
                }
                catch (SqlException ex)
                {
                    MessageBox.Show("may ngu qua \n" + ex.Message);
                }
                if (b)                                    //
                {
                    this.DialogResult = DialogResult.Yes; // dong lenh nay dung de gan gia tri ok vo form 2
                    this.Close();
                    // neu nhap dung mat khau thi form 2 se co gia tri dialog la ok, form 1 se xet gia tri
                    // neu bang ok thi tat form 2, mo form 1 , va enable cac gia tri ca form 1
                }
                else
                {
                    DialogResult result = MessageBox.Show("ban nhap sai tai khoan hoac mat khau !", "wrong", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                    if (result == DialogResult.Cancel)
                    {
                        Application.Exit();
                    }
                }
            }
        }