public static List <AssembleSearchDto> list = new List <AssembleSearchDto>();// { get; set; } // 页面初次加载 public ActionResult Index(ForAssemblyModel model, int?PageIndex, int?PageSize = 30) { try { ViewBag.totalcount = 0; ViewBag.Line = CommonHelp.list; if (PageIndex == null && model.StartTime < model.EndTime && !string.IsNullOrEmpty(model.Area)) { model.EndTime = Convert.ToDateTime(model.EndTime); model.StartTime = Convert.ToDateTime(model.StartTime); model.Area = model.Area; list = GetAssemblyList(model); foreach (var item in list) { item.area = model.Area; } ViewBag.totalcount = list.Count; ViewBag.list = list.Take(30).ToList(); } if (PageIndex != null) { var model1 = new PageInfoModel <AssembleSearchDto>(); model1.List = list;; model1.PageSize = PageSize; model1.PageIndex = PageIndex; var res = CommonHelp.PageList(model1); return(Json(res, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { } return(View()); }
//查询方法 public List <AssembleSearchDto> GetAssemblyList(ForAssemblyModel model) { var list = new List <AssembleSearchDto>(); ViewBag.table = null; var forassemlymodel = new AssembleSearchModel(); forassemlymodel.Area = model.Area; forassemlymodel.StarTime = model.StartTime; forassemlymodel.EndTime = model.EndTime; if (model.StartTime < model.EndTime) { Session["indexnew"] = forassemlymodel; list = DapperService.SqlHelp.AssemblySearch(forassemlymodel).OrderByDescending(p => p.end_time) .ToList(); ViewBag.list = list.Take(30).ToList(); ViewBag.count = DapperService.SqlHelp.AssemblySearch(forassemlymodel).Count; } else { ViewBag.count = 0; } return(list); }