protected void DataInfoBind() { int total = 0; TljInfoCondition cond = condition(); var list = bllTljInfo.GetList(1, int.MaxValue, ref total, cond, t => t.ID) .GroupBy(m => new { m.ActiveCode, m.item_id, m.goodsname, m.item_pic }).OrderByDescending(m => m.Key.ActiveCode).Select(m => new ModelActCode { ActiveCode = m.Key.ActiveCode, goodsname = m.Key.goodsname, item_id = m.Key.item_id, item_pic = m.Key.item_pic, count = m.Count() }).ToList(); foreach (var item in list) { item.Link = string.Format("{0}/mdtishi.aspx?qid={待补充群号}&hdcode={1}", strQunmanageUrl, item.ActiveCode); item.qunLink = string.Format("{0}/adm/GroupActList.aspx?json={1}", strQunmanageUrl, Server.UrlEncode(Newtonsoft.Json.JsonConvert.SerializeObject(item))); } total = list.Count(); var listRes = list.Skip((ShowPager.CurrentPageIndex - 1) * ShowPager.PageSize).Take(ShowPager.PageSize).ToList(); ShowPager.RecordCount = total; this.rpData.DataSource = listRes; this.rpData.DataBind(); }
protected TljInfoCondition condition() { DateTime dtNow = DateTime.Now; DateTime dtToday = DateTime.Parse(dtNow.ToShortDateString()); TljInfoCondition con = new TljInfoCondition { ifget = false, Ifok = "已生成", statStartTime = dtToday, ifActiveCode = "1" }; return(con); }
/// <summary> /// 获取列表 /// </summary> /// <typeparam name="Tkey">类型</typeparam> /// <param name="pageIndex">页索引</param> /// <param name="pageSize">页数量</param> /// <param name="whereLambda">查询条件</param> /// <param name="orderLambda">排序条件</param> /// <param name="total">总记录数量</param> /// <returns></returns> public List <Model.TljInfo> GetList <Tkey>(int pageIndex, int pageSize, ref int total, TljInfoCondition con, Expression <Func <Model.TljInfo, Tkey> > orderLambda, bool isASC = true) { Expression <Func <Model.TljInfo, bool> > whereLambda = Where(con); return(dal.GetPagedList(pageIndex, pageSize, ref total, whereLambda, orderLambda, isASC)); }
protected Expression <Func <Model.TljInfo, bool> > Where(TljInfoCondition con) { var searchPredicate = PredicateBuilder.True <Model.TljInfo>(); if (!string.IsNullOrEmpty(con.KeyWords)) { searchPredicate = searchPredicate.And(m => m.goodsname.Contains(con.KeyWords)); } if (!string.IsNullOrEmpty(con.KeyWords)) { searchPredicate = searchPredicate.Or(m => m.item_id.Contains(con.KeyWords)); } if (con.isstat) { searchPredicate = searchPredicate.And(m => m.dotime.HasValue == true); } if (con.statStartTime.HasValue) { searchPredicate = searchPredicate.And(m => m.dotime >= con.statStartTime); } if (con.statEndTime.HasValue) { searchPredicate = searchPredicate.And(m => m.dotime <= con.statEndTime); } if (con.startTime.HasValue) { searchPredicate = searchPredicate.And(m => m.send_start_time >= con.startTime); } if (con.endTime.HasValue) { searchPredicate = searchPredicate.And(m => m.send_end_time <= con.endTime); } if (con.ifget.HasValue) { searchPredicate = searchPredicate.And(m => m.ifget == con.ifget); } if (!string.IsNullOrEmpty(con.Ifok)) { searchPredicate = searchPredicate.And(m => m.ifok == con.Ifok); } if (!string.IsNullOrEmpty(con.Ifsingle)) { searchPredicate = searchPredicate.And(m => con.Ifsingle == "1" ? m.total_num != 1 : m.total_num == 1); } if (!string.IsNullOrEmpty(con.AppName)) { searchPredicate = searchPredicate.And(m => dal.db.appkeys.FirstOrDefault(a => a.ID == m.AppKeyID && a.AppName.Contains(con.AppName)) != null); } if (!string.IsNullOrEmpty(con.setName)) { searchPredicate = searchPredicate.And(m => dal.db.appkeys.FirstOrDefault(a => a.ID == m.AppKeyID && a.TbAccount.Contains(con.setName)) != null); } if (!string.IsNullOrEmpty(con.setName)) { searchPredicate = searchPredicate.And(m => dal.db.appkeys.FirstOrDefault(a => a.ID == m.AppKeyID && a.TbAccount.Contains(con.setName)) != null); } if (con.goodstype != "-1") { searchPredicate = searchPredicate.And(m => (string.IsNullOrEmpty(con.goodstype) && m.goodstype == null) || m.goodstype == con.goodstype); } if (con.ifActiveCode != "-1") { if (con.ifActiveCode == "1") { searchPredicate = searchPredicate.And(m => m.ActiveCode != null && m.ActiveCode != string.Empty); } else if (con.ifActiveCode == "0") { searchPredicate = searchPredicate.And(m => m.ActiveCode == null || m.ActiveCode == string.Empty); } } return(searchPredicate); }