Ejemplo n.º 1
0
        /// <summary>
        /// 获取信息
        /// </summary>
        /// <returns></returns>
        public ActionResult GetDepart(string DepartNum, int pageIndex)
        {
            Departmanager service = new Departmanager();

            //组合条件
            Expression <Func <Depart, bool> > where = item => item.IsDelete == 0;

            if (!string.IsNullOrEmpty(DepartNum))
            {
                //当类型不是全部选中项,则按照类型组合条件
                where = where.And(item => item.DepartNum.IndexOf(DepartNum) != -1 || item.DepartName.IndexOf(DepartNum) != -1);
            }


            var pageCount = 0;
            var count     = 0;
            var list      = service.GetByWhereDesc(where, item => item.CreateTime, ref pageIndex, ref count, ref pageCount, PageSize);
            //返回数据
            //Actionresult  常用响应类型  ViewResult ContentResult JsonResult
            // Json数据格式 { 名称:值 } 数组 [{},{}]
            // 格式转换
            var newFormatList = list.Select(item => new { Id = item.Id, DepartNum = item.DepartNum, DepartName = item.DepartName, IsDelete = item.IsDelete, CreateTime = item.CreateTime.ToString("yyyy-MM-dd HH:mm:ss") });

            //将数据构建打包给前台
            var result = new
            {
                PageIndex  = pageIndex,
                PageCount  = pageCount,
                Count      = count,
                RoleInfies = newFormatList
            };


            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        // GET: Employee
        public ActionResult Index()
        {
            Departmanager Departmanager = new Departmanager();
            var           Depart        = Departmanager.GetAll();

            Depart.Insert(0, new Depart()
            {
                Id = 0, DepartName = "请选择部门类型"
            });
            ViewBag.DepartId = new SelectList(Depart, "Id", "DepartName");

            Rolemanager Rolemanager = new Rolemanager();
            var         Role        = Rolemanager.GetAll();

            Role.Insert(0, new Role()
            {
                Id = 0, RoleName = "请选择角色类型"
            });
            ViewBag.RoleId = new SelectList(Role, "Id", "RoleName");

            return(View());
        }