public ActionResult Qusss(int GType, string GName, int pageIndex) { var a = new GonhuoService(); //组合条件 Expression <Func <GonhuoShang, bool> > where = item => true; if (GType != 9999) { //当类型不是全部选中项,则按照类型组合条件 where = where.And(item => item.GType.Equals(GType)); } if (!string.IsNullOrEmpty(GName)) { where = where.And(item => item.GName.IndexOf(GName) != -1); } var pageCount = 0; var count = 0; var s = a.GetByWhereDesc(where, item => item.XTime, ref pageIndex, ref count, ref pageCount, 2); //格式转换 var newFormatList = s.Select(item => new { Gid = item.Gid, GName = item.GName, TypeName = item.Type.TName, Email = item.Email, Youbian = item.Youbian, Phone = item.Phone, TTime = item.TTime.ToString("yyyy-MM-dd HH:mm:ss"), XTime = item.XTime.ToString("yyyy-MM-dd HH:mm:ss") }); var result = new { PageIndex = pageIndex, PageCount = pageCount, Count = count, gonhuosInfor = newFormatList }; return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Query(QueryTJDto dto) { Expression <Func <GonhuoShang, bool> > where = i => i.TTime >= dto.State && i.TTime <= dto.End; if (dto.gType != 9999) { where = where.And(i => i.GType == dto.gType); } if (!string.IsNullOrEmpty(dto.gname)) { where = where.And(i => i.GName.IndexOf(dto.gname) != -1); } GetRequestPage(dto); var pageIndex = dto.PageIndex; var count = 0; var pageCount = 0; var aniBll = new GonhuoService(); var lis = aniBll.GetByWhereDesc(where, i => i.XTime, ref pageIndex, ref count, ref pageCount, 4); var aniType = new TypeService(); var type = aniType.GetAll(); type.Insert(0, new GonHuoSModel.Type() { Tid = 9999, TName = "全部" }); ViewBag.GType = new SelectList(type, "Tid", "TName"); ViewBag.PageIndex = pageIndex; ViewBag.Count = count; ViewBag.PageCount = pageCount; ViewBag.Gonhuo = lis; ViewBag.dto1 = dto; return(View()); }