Exemplo n.º 1
0
        private List <SOSOshop.Model.Roles_Permissions> GetNewList(int RoleID)
        {
            List <SOSOshop.Model.Roles_Permissions> list = new List <SOSOshop.Model.Roles_Permissions>();

            SOSOshop.Model.Roles_Permissions rModel = null; int OperateCode; List <int> OperateCodes = new List <int>();
            foreach (TreeNode tNode in TreeView1.CheckedNodes)
            {
                rModel    = new SOSOshop.Model.Roles_Permissions();
                rModel.ID = RoleID;
                if (ChangeHope.Common.ValidateHelper.IsNumber(tNode.Value))
                {
                    OperateCode = int.Parse(tNode.Value);
                    if (OperateCodes.Contains(OperateCode))
                    {
                        continue;
                    }
                    else
                    {
                        OperateCodes.Add(OperateCode);
                    }
                    rModel.OperateCode = OperateCode;
                }
                else
                {
                    continue;
                }
                list.Add(rModel);
                rModel = null;
            }
            return(list);
        }
Exemplo n.º 2
0
        private void UpdatePowers(List <SOSOshop.Model.Roles_Permissions> newList, List <SOSOshop.Model.Roles_Permissions> oldList)
        {
            //分析要删除的权限信息,分析要增加的信息:数据库已有信息和当前得到的信息的比较
            List <SOSOshop.Model.Roles_Permissions> AddList = new List <SOSOshop.Model.Roles_Permissions>();
            bool      bl = true;
            ArrayList al = new ArrayList();

            foreach (SOSOshop.Model.Roles_Permissions nrModel in newList)
            {
                bl = true;

                foreach (SOSOshop.Model.Roles_Permissions orModel in oldList)
                {
                    if (orModel.OperateCode == nrModel.OperateCode)
                    {
                        bl = false;
                        //  oldList.Remove(orModel);
                        al.Add(orModel);
                        // break;
                    }
                    else
                    {
                    }
                }
                if (bl)
                {
                    AddList.Add(nrModel);
                }
                foreach (object o in al)
                {
                    SOSOshop.Model.Roles_Permissions rp = (SOSOshop.Model.Roles_Permissions)o;
                    if (null != oldList.Find(x => x.ID == rp.ID && x.OperateCode == rp.OperateCode))
                    {
                        oldList.Remove(rp);
                    }
                }
                al = new ArrayList();
            }
            try
            {
                if (oldList.Count > 0)
                {
                    bll.Del(oldList);
                }
                bll.Add(AddList);
                #region 后台用户操作日志记录
                SOSOshop.Model.AdminInfo adminInfo = SOSOshop.BLL.AdministrorManager.Get();
                SOSOshop.BLL.Logs.Log.LogAdminAdd("管理角色【" + RoleName.Text + "】的权限", (adminInfo == null ? 0 : adminInfo.AdminId), (adminInfo == null ? "" : adminInfo.AdminName), 1);
                #endregion
            }
            catch
            { }
        }
Exemplo n.º 3
0
        private void AddPowers(int RoleID)
        {
            TreeNode tn = new TreeNode();

            List <SOSOshop.Model.Roles_Permissions> list = new List <SOSOshop.Model.Roles_Permissions>();

            SOSOshop.Model.Roles_Permissions rModel = null;
            foreach (TreeNode tNode in TreeView1.CheckedNodes)
            {
                rModel    = new SOSOshop.Model.Roles_Permissions();
                rModel.ID = RoleID;
                if (ChangeHope.Common.ValidateHelper.IsNumber(tNode.Value))
                {
                    rModel.OperateCode = int.Parse(tNode.Value);
                }
                else
                {
                    continue;
                }
                list.Add(rModel);
                rModel = null;
            }
            bll.Add(list);
        }
Exemplo n.º 4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            List <SOSOshop.Model.Roles_Permissions> oldList = bll.GetListByColumn("id", RoleID);
            List <SOSOshop.Model.Roles_Permissions> newList = GetNewList(RoleID);

            //try
            //{
            if (statebl)//特殊权限关闭
            {
                if (oldList.Count > 0)
                {
                    //if (!SOSOshop.BLL.PowerPass.isPass("007003004", YXShop.Common.PowerEnum.PowerType.update))
                    //{
                    //    //bp = new BasePage();
                    //    //bp.PageError("对不起,你没有修改角色权限的权限!", "../index.aspx");
                    //}
                    UpdatePowers(newList, oldList);
                }
                else
                {
                    //if (!SOSOshop.BLL.PowerPass.isPass("007003002", YXShop.Common.PowerEnum.PowerType.add))
                    //{
                    //    //bp = new BasePage();
                    //    //bp.PageError("对不起,你没有添加角色权限的权限!", "../index.aspx");
                    //}
                    bll.Add(newList);
                }
            }
            else
            {
                int    counter  = 0;
                string powerStr = "";
                foreach (ListItem lItem in CheckBoxList1.Items)
                {
                    if (lItem.Selected)
                    {
                        powerStr += lItem.Value + ",";
                    }
                }
                powerStr = powerStr.TrimEnd(',');
                string[] powerArr = powerStr.Split(',');
                counter = powerArr.Length;
                int roleValue = 0;
                if (counter == 1) //look
                {
                    roleValue = SOSOshop.BLL.PowerEnum.PowerType.look.GetHashCode();
                }
                else if (counter == 2) //add,del,update
                {
                    switch (powerArr[1])
                    {
                    case "add":
                        roleValue = SOSOshop.BLL.PowerEnum.PowerType.add.GetHashCode();
                        break;

                    case "del":
                        roleValue = SOSOshop.BLL.PowerEnum.PowerType.del.GetHashCode();
                        break;

                    case "update":
                        roleValue = SOSOshop.BLL.PowerEnum.PowerType.update.GetHashCode();
                        break;
                    }
                }
                else if (counter == 3) //deladd, delupdate, updateadd
                {
                    switch (powerArr[1])
                    {
                    case "add":
                        switch (powerArr[2])
                        {
                        case "del":
                            roleValue = SOSOshop.BLL.PowerEnum.PowerType.deladd.GetHashCode();
                            break;

                        case "update":
                            roleValue = SOSOshop.BLL.PowerEnum.PowerType.updateadd.GetHashCode();
                            break;
                        }
                        break;

                    case "del":
                        switch (powerArr[2])
                        {
                        case "add":
                            roleValue = SOSOshop.BLL.PowerEnum.PowerType.deladd.GetHashCode();
                            break;

                        case "update":
                            roleValue = SOSOshop.BLL.PowerEnum.PowerType.delupdate.GetHashCode();
                            break;
                        }
                        break;

                    case "update":
                        switch (powerArr[2])
                        {
                        case "add":
                            roleValue = SOSOshop.BLL.PowerEnum.PowerType.updateadd.GetHashCode();
                            break;

                        case "del":
                            roleValue = SOSOshop.BLL.PowerEnum.PowerType.delupdate.GetHashCode();
                            break;
                        }
                        break;
                    }
                }
                else //all,other
                {
                    roleValue = SOSOshop.BLL.PowerEnum.PowerType.all.GetHashCode();
                }
                //try//权限设置
                //{
                if (ispower)
                {
                    //if (! SOSOshop.BLL.PowerPass.isPass("007003004", YXShop.Common.PowerEnum.PowerType.update))
                    //{
                    //    //bp = new BasePage();
                    //    //bp.PageError("对不起,你没有修改角色权限的权限!", "../index.aspx");
                    //}
                }
                else
                {
                    //if (!SOSOshop.BLL.PowerPass.isPass("007003002", YXShop.Common.PowerEnum.PowerType.add))
                    //{
                    //    //bp = new BasePage();
                    //    //bp.PageError("对不起,你没有添加角色权限的权限!", "../index.aspx");
                    //}
                }
                SOSOshop.Model.Roles_Permissions rpModel = new SOSOshop.Model.Roles_Permissions();
                rpModel.ID          = RoleID;
                rpModel.OperateCode = roleValue;
                bll.Delete(RoleID);

                List <SOSOshop.Model.Roles_Permissions> rpList = new List <SOSOshop.Model.Roles_Permissions>();
                rpList.Add(rpModel);
                bll.Add(rpList);
                //}
                //catch { }
            }
            ChangeHope.WebPage.BasePage.PageRight("设置成功。", "popedom_manage.aspx?id=" + Request["id"]);
            //Response.Redirect("popedom_manage.aspx", true);
            //}
            //catch { }
        }