Пример #1
0
        public ActionResult ToExcel()
        {
            PageInfo pageInfo = new Git.Framework.DataTypes.PageInfo()
            {
                PageIndex = 1, PageSize = Int32.MaxValue
            };
            string               roleName   = WebUtil.GetFormValue <string>("roleName", string.Empty);
            SysRoleProvider      provider   = new SysRoleProvider();
            SysRoleEntity        entity     = new SysRoleEntity();
            List <SysRoleEntity> list       = provider.GetList();
            List <SysRoleEntity> listResult = new List <SysRoleEntity>();

            if (!list.IsNullOrEmpty())
            {
                listResult = list.Where(a => a.RoleNum.Contains(roleName) || a.RoleName.Contains(roleName)).OrderByDescending(a => a.ID).ToList();
            }

            if (!listResult.IsNullOrEmpty())
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("序号"));
                dt.Columns.Add(new DataColumn("角色编号"));
                dt.Columns.Add(new DataColumn("角色名"));
                dt.Columns.Add(new DataColumn("创建时间"));
                dt.Columns.Add(new DataColumn("备注"));
                int count = 1;
                foreach (SysRoleEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0] = count;
                    row[1] = t.RoleNum;
                    row[2] = t.RoleName;
                    row[3] = t.CreateTime;
                    row[4] = t.Remark;
                    count++;
                    dt.Rows.Add(row);
                }
                string filePath = Server.MapPath("~/UploadFiles/");
                if (!System.IO.Directory.Exists(filePath))
                {
                    System.IO.Directory.CreateDirectory(filePath);
                }
                string filename = string.Format("角色管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));

                NPOIExcel excel = new NPOIExcel("角色管理", "角色", System.IO.Path.Combine(filePath, filename));
                excel.ToExcel(dt);
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
            }
            else
            {
                this.ReturnJson.AddProperty("d", "无数据导出!")
                ;
            }

            return(Content(this.ReturnJson.ToString()));
        }
Пример #2
0
        /// <summary>
        /// 查询角色列表
        /// </summary>
        /// <returns></returns>
        public ActionResult GetList()
        {
            string                         CompanyID = WebUtil.GetFormValue <string>("CompanyID");
            SysRoleProvider                provider  = new SysRoleProvider(CompanyID);
            List <SysRoleEntity>           list      = provider.GetList();
            DataListResult <SysRoleEntity> result    = new DataListResult <SysRoleEntity>()
            {
                Code = (int)EResponseCode.Success, Message = "响应成功", Result = list
            };

            return(Content(JsonHelper.SerializeObject(result)));
        }
Пример #3
0
        public ActionResult RoleList(int pageIndex, int pageSize, string roleName)
        {
            SysRoleProvider      provider   = new SysRoleProvider();
            List <SysRoleEntity> list       = provider.GetList();
            List <SysRoleEntity> listResult = new List <SysRoleEntity>();
            List <SysRoleEntity> returnList = new List <SysRoleEntity>();

            if (!list.IsNullOrEmpty())
            {
                listResult = list.Where(a => a.RoleNum.Contains(roleName) || a.RoleName.Contains(roleName)).ToList();
                returnList = listResult.Skip((pageIndex - 1) * pageSize).Take(pageSize).OrderByDescending(a => a.ID).ToList();
            }
            this.ReturnJson.AddProperty("Data", ConvertJson.ListToJson <SysRoleEntity>(returnList, "List"));
            this.ReturnJson.AddProperty("RowCount", listResult.Count);
            return(Content(this.ReturnJson.ToString()));
        }
Пример #4
0
        /// <summary>
        /// 获得角色的下拉列表
        /// </summary>
        /// <param name="roleNum">角色编号</param>
        /// <returns></returns>
        public static string GetRoleList(string roleNum)
        {
            SysRoleProvider      provider = new SysRoleProvider();
            List <SysRoleEntity> list     = provider.GetList();
            StringBuilder        sb       = new StringBuilder();
            string roleTemplate           = "<option value='{0}' {1}>{2}</option>";

            sb.AppendFormat(roleTemplate, "", "", "请选择角色");
            if (!list.IsNullOrEmpty())
            {
                foreach (SysRoleEntity role in list)
                {
                    sb.AppendFormat(roleTemplate, role.RoleNum, role.RoleNum == roleNum ? "selected='selected'" : string.Empty, role.RoleName);
                }
            }
            return(sb.ToString());
        }
Пример #5
0
        /// <summary>
        /// 查询分页
        /// </summary>
        /// <returns></returns>
        public ActionResult GetPage()
        {
            string        CompanyID = WebUtil.GetFormValue <string>("CompanyID");
            int           PageIndex = WebUtil.GetFormValue <int>("PageIndex", 1);
            int           PageSize  = WebUtil.GetFormValue <int>("PageSize", 10);
            string        RoleName  = WebUtil.GetFormValue <string>("RoleName", string.Empty);
            string        Remark    = WebUtil.GetFormValue <string>("Remark", string.Empty);
            SysRoleEntity entity    = new SysRoleEntity();

            entity.RoleName = RoleName;
            entity.Remark   = Remark;
            PageInfo pageInfo = new PageInfo();

            pageInfo.PageIndex = PageIndex;
            pageInfo.PageSize  = PageSize;
            SysRoleProvider                provider = new SysRoleProvider(CompanyID);
            List <SysRoleEntity>           list     = provider.GetList(entity, ref pageInfo);
            DataListResult <SysRoleEntity> result   = new DataListResult <SysRoleEntity>()
            {
                Code = (int)EResponseCode.Success, Message = "响应成功", Result = list, PageInfo = pageInfo
            };

            return(Content(JsonHelper.SerializeObject(result)));
        }