Пример #1
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if (ValidateChildren(ValidationConstraints.Enabled))
     {
         if (Login_BLL.Instance.CheckNguoiDung(txtUser.Text, txtPassword.Text) == true)
         {
             if (Login_BLL.Instance.GetNguoiDungByUserAndPW(txtUser.Text, txtPassword.Text).ID_QuyenHan == 1)
             {
                 FormQuanLy f = new FormQuanLy(txtUser.Text);
                 this.Visible = false;
                 f.ShowDialog();
                 this.Visible     = true;
                 txtUser.Text     = "";
                 txtPassword.Text = "";
             }
             else if (Login_BLL.Instance.GetNguoiDungByUserAndPW(txtUser.Text, txtPassword.Text).ID_QuyenHan == 2)
             {
                 FormNhanVien f = new FormNhanVien(txtUser.Text);
                 this.Visible = false;
                 f.ShowDialog();
                 this.Visible     = true;
                 txtUser.Text     = "";
                 txtPassword.Text = "";
             }
         }
         else
         {
             MessageBox.Show("Sai thong tin");
         }
     }
 }
Пример #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (Login_BLL.Instance.CheckNguoiDung(txtUser.Text, txtPassword.Text) == true)
            {
                if (Login_BLL.Instance.GetNguoiDungByUserAndPW(txtUser.Text, txtPassword.Text).ID_QuyenHan == 1)
                {
                    FormQuanLy f = new FormQuanLy();
                    f.ShowDialog();
                }
                else if (Login_BLL.Instance.GetNguoiDungByUserAndPW(txtUser.Text, txtPassword.Text).ID_QuyenHan == 2)
                {
                    FormNhanVien f = new FormNhanVien();
                    f.ShowDialog();
                }
            }
            else
            {
                MessageBox.Show("Sai thong tin");
            }
            //int checkql = 0;
            //int checknv = 0;
            //DHP_07Entities db = new DHP_07Entities();
            //var l1 = db.NguoiDungs.Select(p => p).ToList();
            //foreach (NguoiDung i in l1)
            //{
            //    if(txtUser.Text == i.Username.ToString() && txtPassword.Text == i.Password && i.ID_QuyenHan == 1)
            //    {
            //        checkql++;
            //        break;
            //    }
            //    else if(txtUser.Text == i.Username.ToString() && txtPassword.Text == i.Password && i.ID_QuyenHan == 2)
            //    {
            //        checknv++;
            //        break;
            //    }

            //}
            //if (checkql != 0)
            //{
            //    FormQuanLy f = new FormQuanLy();
            //    f.ShowDialog();
            //}
            //else if (checknv !=0)
            //{
            //    FormNhanVien f = new FormNhanVien();
            //    f.ShowDialog();
            //}
            //else
            //{
            //    MessageBox.Show("Sai thong tin");
            //}
        }