Ejemplo n.º 1
0
        public string DeleteRole(HttpContext context)
        {
            string status = "{\"status\":-1}";
            int    roleID = 0;

            if (int.TryParse(context.Request.Form["pid"], out roleID) && roleID > 0)
            {
                BCtrl_SysRole bllRole = new BCtrl_SysRole();

                if (bllRole.IsCanDelRole(roleID))
                {
                    if (bllRole.Delete(roleID))
                    {
                        ClearCacheOrSession.ClearRoleCacheByCRUD();
                        status = "{\"status\":1}";
                    }
                    else
                    {
                        status = "{\"status\":0}";
                    }
                }
                else
                {
                    status = "{\"status\":2}";
                }
            }

            return(status);
        }
Ejemplo n.º 2
0
        public string SaveRoleFunRel(HttpContext context)
        {
            string status = "{\"status\":0;}";

            int    roleID      = 0;
            string roleName    = context.Request.Form["rname"];
            string functionsid = context.Request.Form["functionsid"];

            if (!int.TryParse(context.Request.Form["pid"], out roleID) || string.IsNullOrEmpty(functionsid) || string.IsNullOrEmpty(roleName))
            {
                status = "{\"status\":-1}";  //传递参数不完整
            }
            else
            {
                BCtrl_SysRole bllRole = new BCtrl_SysRole();
                List <SysRoleFunctionRelEntity> roleFunlist = new List <SysRoleFunctionRelEntity>();
                SysRoleEntity roleEntity = null;

                String[] funid = functionsid.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (String var in funid)
                {
                    SysRoleFunctionRelEntity fe = new SysRoleFunctionRelEntity();
                    fe.RFRel_FunctionID = Convert.ToInt32(var);
                    fe.RFRel_RoleID     = roleID;
                    roleFunlist.Add(fe);
                }

                if (roleID > 0)
                {
                    //修改
                    roleEntity           = bllRole.QueryEntity(roleID);
                    roleEntity.Role_Name = roleName;

                    if (roleEntity != null)
                    {
                        if (bllRole.Update(roleEntity, roleFunlist))
                        {
                            status = "{\"status\":1}";
                        }
                    }
                }
                else
                {
                    //添加
                    roleEntity            = new SysRoleEntity();
                    roleEntity.Role_Name  = roleName;
                    roleEntity.CreateTime = DateTime.Now;

                    if (bllRole.Insert(roleEntity, roleFunlist))
                    {
                        status = "{\"status\":1}";
                    }
                }
            }

            return(status);
        }
Ejemplo n.º 3
0
        private DataTable GetQueryData(bool isDownload)
        {
            BCtrl_SysRole bll      = new BCtrl_SysRole();
            int           totalcnt = 0;

            SysRoleSearchEntity entity = new SysRoleSearchEntity();

            entity.Role_Name       = _strRolename;
            entity.PageSize        = base.PageSize;
            entity.PageIndex       = base.PageIndex;
            entity.UseDBPagination = !isDownload;

            DataTable table = bll.QueryRoleTableByPage(entity, out totalcnt);

            base.TotalRecords = totalcnt;

            return(table);
        }
Ejemplo n.º 4
0
        public string IsUseableRoleName(HttpContext context)
        {
            int    roleID   = 0;
            string roleName = context.Request.Form["rname"];

            if (!string.IsNullOrEmpty(roleName) && int.TryParse(context.Request.Form["pid"], out roleID))
            {
                BCtrl_SysRole bllRole   = new BCtrl_SysRole();
                bool          isUseable = bllRole.IsUseableRoleName(roleID, roleName);

                if (isUseable)
                {
                    return("true");
                }
                else
                {
                    return("false");
                }
            }
            else
            {
                return("false");
            }
        }