Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SystemUsersBO aSystemUsersBO = new SystemUsersBO();
            PermitsBO aPermitsBO = new PermitsBO();

            if (IsPostBack == true)
            {
                string Pass = Library.StringUtility.md5(Page.Request.Form["txtPassword"].ToString());
                string User = Page.Request.Form["txtUsername"].ToString();
                bool disable = false;
                SystemUsers aSystemUsers = aSystemUsersBO.Sel_ByUsername_ByPassword(User, Pass,disable);

                if (aSystemUsers != null)
                {
                    Session["LoginAccount"] = aSystemUsers;
                    List<vw_PermitsViewAll> ListPermitViewAll = aPermitsBO.GetAllInfoLogin_ByUsername(aSystemUsers.Username);
                    Session["LoginPermitViewAll"] = ListPermitViewAll;

                    Response.Redirect("Main.aspx");
                }
                else
                {

                    Response.Redirect("Default.aspx");
                }

            }
        }
Exemplo n.º 2
0
        private static bool Login(string UserName, string Password)
        {
            try
            {
                SystemUsersBO aSystemUsersBO = new SystemUsersBO();

                SystemUsers aSystemUsers = aSystemUsersBO.CheckAccount(UserName, Password);

                if (aSystemUsers != null)
                {
                    if (aSystemUsers.Disable == true)
                    {
                        throw new Exception("Bạn đang bị tạm khóa toàn hệ thống với lý do:[Chưa rõ]");
                    }
                    else
                    {

                        PermitsBO aPermitsBO = new PermitsBO();
                        CORE.CURRENTUSER.ListPermitViewAll = aPermitsBO.GetAllInfoLogin_ByUsername(aSystemUsers.Username)
                            .Where(p => p.Permits_SystemUsers_Disable == false)
                            .Where(p => p.Permits_Disable == false)
                            .Where(p => p.PermitDetails_Disable == false)
                            .Where(p => p.Permits_SystemKey == CORE.SYSTEM.SystemKey).ToList();

                        if (CORE.CURRENTUSER.ListPermitViewAll.Count == 0)
                        {
                            throw new Exception("Bạn không đủ quyền vào phần mềm này");
                        }
                        else
                        {
                            CORE.CURRENTUSER.SystemUser = aSystemUsers;
                            return true;
                        }

                    }

                }
                else
                {
                    throw new Exception("Sai username hoặc password");
                }
            }
            catch (Exception eee)
            {
                throw eee;
            }
        }