Exemplo n.º 1
0
        private void DeleteUserPremission(int userId)
        {
            LoginDataLimit ldlModel = new LoginDataLimit();

            ldlModel.DataIds = "";
            ldlModel.LoginId = userId;
            //删除用户数据权限
            LoginDataLimitManager.Setlimit(ldlModel);
            //删除用户角色权限
            LoginUserLimitManager.DeleteLoginLimitByUser(userId);
        }
Exemplo n.º 2
0
        protected void BtnSave_Click(object sender, ImageClickEventArgs e)
        {
            List <MyTreeNode> dataList   = HidData.Value == string.Empty ? null : ReadNode(HidData.Value);
            List <MyTreeNode> menuList   = HidMenu.Value == string.Empty ? null : ReadNode(HidMenu.Value);
            List <MyTreeNode> noMenuList = HidNoMenu.Value == string.Empty ? null : ReadNode(HidNoMenu.Value);

            object loginId = Request.QueryString["id"];
            int    id      = 0;

            if (loginId == null || !int.TryParse(loginId.ToString(), out id) || Convert.ToInt32(loginId) <= 0)
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('参数错误')</script>");
                return;
            }
            LoginDataLimit ldl = new LoginDataLimit();

            if (dataList == null)
            {
                ldl.DataIds = string.Empty;
            }
            else
            {
                StringBuilder dataIds = new StringBuilder();
                foreach (MyTreeNode node in dataList)
                {
                    if (!node.IsParent)
                    {
                        dataIds.Append(node.Id);
                        dataIds.Append(",");
                    }
                }

                ldl.DataIds = dataIds.ToString().TrimEnd(',');
            }
            ldl.LoginId = Convert.ToInt32(loginId);
            ldl.RoleId  = int.Parse(DdlRoleList.SelectedValue);

            if (LoginDataLimitManager.Setlimit(ldl))
            {
                InitDataTree(Convert.ToInt32(loginId));
            }

            IList <LoginUserLimit> lulList = LoginUserLimitManager.getAllNodeById(Convert.ToInt32(loginId));

            ArrayList arrNodes = new ArrayList();

            foreach (LoginUserLimit userLimit in lulList)
            {
                arrNodes.Add(userLimit.Nodeid.Nodeid.ToString());
            }

            foreach (MyTreeNode mtn in menuList)
            {
                if (!arrNodes.Contains(mtn.Id.ToString()))
                {
                    LoginUserLimitManager.InsertUserLimt(loginId.ToString(), mtn.Id.ToString());
                }
            }

            foreach (MyTreeNode mtn in noMenuList)
            {
                if (arrNodes.Contains(mtn.Id.ToString()))
                {
                    LoginUserLimitManager.DeleteUserLimit(loginId.ToString(), mtn.Id.ToString());
                }
            }

            InitMenuTree(Convert.ToInt32(loginId));


            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('保存成功');self.location.href='../SysSet/LoginSet.aspx'</script>");
        }