Beispiel #1
0
        public ActionResult UserIndex()
        {
            DicManager dm        = new DicManager();
            var        companies = dm.GetDicByType("公司");

            ViewBag.Companies = companies;

            var contents = GetStandardMenuTree(false);

            ViewBag.treeNodes = JsonConvert.SerializeObject(contents);

            return(View());
        }
Beispiel #2
0
        public void GetAllUsers()
        {
            //用于序列化实体类的对象
            JavaScriptSerializer jss = new JavaScriptSerializer();

            //请求中携带的条件
            string order     = HttpContext.Request.Params["order"];
            string sort      = HttpContext.Request.Params["sort"];
            string searchKey = HttpContext.Request.Params["search"];
            int    offset    = Convert.ToInt32(HttpContext.Request.Params["offset"]); //0
            int    pageSize  = Convert.ToInt32(HttpContext.Request.Params["limit"]);

            int               total = 0;
            UserManager       um    = new UserManager();
            List <UserEntity> list  = um.GetSearch(searchKey, sort, order, offset, pageSize, out total);

            DicManager                  dm          = new DicManager();
            List <DicEntity>            companyDicE = dm.GetDicByType("公司");
            Dictionary <string, string> companyDic  = new Dictionary <string, string>();

            foreach (var item in companyDicE)
            {
                companyDic.Add(item.iKey, item.iValue);
            }
            List <UserViewModel> listView = new List <UserViewModel>();

            foreach (var item in list)
            {
                listView.Add(new UserViewModel {
                    iCompanyCode = item.iCompanyCode, iCompanyName = companyDic[item.iCompanyCode], iEmployeeCodeId = item.iEmployeeCodeId, iPassWord = item.iPassWord, iUserName = item.iUserName, iUserType = item.iUserType, iUpdatedOn = item.iUpdatedOn.ToString("yyyyMMdd HH:mm")
                });
            }

            //给分页实体赋值
            PageModels <UserViewModel> model = new PageModels <UserViewModel>();

            model.total = total;
            if (total % pageSize == 0)
            {
                model.page = total / pageSize;
            }
            else
            {
                model.page = (total / pageSize) + 1;
            }

            model.rows = listView;

            //将查询结果返回
            HttpContext.Response.Write(jss.Serialize(model));
        }