public ActionResult Logistics_Page(string StartTime, string EndTime, string LogisticsType, string LogisticsNo, int pageIndex, int pageSize)
{
string json = "[]";
try
{
int total = 0;
int allPage = 1;
DataTable dt = sugar._db.Queryable<LogisticsNoImport, WdtStockoutOrder, WdtStockoutDetails>((a, b, c) => new JoinQueryInfos(
JoinType.Left, a.LogisticsNo == b.LogisticsNo,
JoinType.Left, c.StockoutId == b.StockoutId))
.Select((a, b, c) => new
{
运单号 = a.LogisticsNo,
京仓云仓 = a.LogisticsType,
导入时间 = a.UpdateTime,
所属店铺 = b.ShopName,
ERP系统订单编号 = b.SrcOrderNo,
原始订单号 = c.SrcTid,
原始子订单号 = c.SrcOid,
出库时间 = b.ConsignTime
})
.Distinct()
//可选查询条件
//.WhereIF(!string.IsNullOrWhiteSpace(LogisticsType), " a.LogisticsType = '" + LogisticsType + "' ")
//.WhereIF(!string.IsNullOrWhiteSpace(LogisticsNo), " a.LogisticsNo = '" + LogisticsNo + "' ")
.WhereIF(!string.IsNullOrWhiteSpace(LogisticsType), " a.LogisticsType LIKE '%" + LogisticsType + "%' ")
.WhereIF(!string.IsNullOrWhiteSpace(LogisticsNo), " a.LogisticsNo IN (" + FormatLogisticsNo(LogisticsNo) + ") ")
//必须查询条件
.Where(" a.UpdateTime >='" + DateTime.Parse(StartTime).ToString("yyyy-MM-dd") + "'")
.Where(" a.UpdateTime < '" + DateTime.Parse(EndTime).AddDays(1).ToString("yyyy-MM-dd") + "'")
.OrderBy("a.LogisticsNo asc")
.ToDataTablePage(pageIndex, pageSize, ref total, ref allPage);
json = JsonConvert.SerializeObject(new { total = total, allPage = allPage, data = dt, });
}
catch { }
return Content(json);
}
我写给我自己看的,我能看懂就行,下次遇到同样的问题,我自己翻出来复制一下再改改