public JsonResult LoadDispatchedPaperPlansGrid(string sidx, string sord, int page, int rows, string carNo) { //读取数据 string strErrText; DispatchSystem dispatch = new DispatchSystem(); List<DispatchBillDeliverPlan> listPlan = dispatch.LoadDispatchBillDeliverPlansByCarNo(carNo, LoginAccountId, LoginStaffName, out strErrText); if (listPlan == null) { throw new Exception(strErrText); } //提取当前页面数据 int nTotalRows = listPlan.Count; int nPageIndex = page; int nPageSize = rows; int nTotalPages = nTotalRows / nPageSize; if (nTotalRows % nPageSize > 0) nTotalPages++; string sortExpression = (sidx ?? "PlanNo") + " " + (sord ?? "ASC"); var data = listPlan.OrderBy(sortExpression).Skip((nPageIndex - 1) * nPageSize).Take(nPageSize).ToList(); //生成表格数据 var ret = new { total = nTotalPages, page = nPageIndex, records = nTotalRows, rows = ( from p in data select new { id = p.Id, cell = new string[] { p.Id.ToString(), p.PlanNo, p.CustomerName, p.ShipmentNo, p.DeliveryNo, p.ReceiverName, p.ReceiverCity, p.PlanType, p.Tunnages.ToString("#0.######"), p.TransportPrice.ToString("#0.######"), p.TransportCharges.ToString(), p.Remark } }).ToArray(), userdata = new { PlanNo = InnoSoft.LS.Resources.Labels.Total, Tunnages = data.Sum(s => s.Tunnages), TransportCharges = data.Sum(s => s.TransportCharges) } }; return Json(ret, JsonRequestBehavior.AllowGet); }