public JsonResult LoadContractDispatchBillDeliverPlansGrid(string sidx, string sord, int page, int rows, string dispatchBillId) { //读取数据 string strErrText; DispatchSystem dispatch = new DispatchSystem(); List<DispatchBillDeliverPlan> listDeliverPlan = dispatch.LoadDispatchBillDeliverPlans(long.Parse(dispatchBillId), LoginAccountId, LoginStaffName, out strErrText); if (listDeliverPlan == null) { throw new Exception(strErrText); } //清除自提的计划 listDeliverPlan.RemoveAll(delegate(DispatchBillDeliverPlan p) { return p.ReceiveType == InnoSoft.LS.Resources.Options.PickUpSelf; }); //提取当前页面数据 int nTotalRows = listDeliverPlan.Count; int nPageIndex = page; int nPageSize = rows; int nTotalPages = nTotalRows / nPageSize; if (nTotalRows % nPageSize > 0) nTotalPages++; string sortExpression = (sidx ?? "PlanNo") + " " + (sord ?? "ASC"); var data = listDeliverPlan.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.PlanId.ToString(), p.PlanNo, p.CustomerName, p.ShipmentNo, p.DeliveryNo, p.ReceiverName, p.ReceiverCity + p.ReceiverAddress, p.ReceiveType, p.PlanType, p.Packages.ToString(), p.Tunnages.ToString("#0.######"), p.Piles.ToString("#0.######"), p.TenThousands.ToString("#0.######"), p.TransportPrice.ToString("#0.######"), p.TransportCharges.ToString(), p.Remark, p.TransportChargeExpression, p.TransportPriceExpression, p.KM.ToString() } }).ToArray(), userdata = new { PlanNo = InnoSoft.LS.Resources.Labels.Total, Packages = data.Sum(s => s.Packages), Tunnages = data.Sum(s => s.Tunnages), Piles = data.Sum(s => s.Piles), TenThousands = data.Sum(s => s.TenThousands), TransportCharges = data.Sum(s => s.TransportCharges) } }; return Json(ret, JsonRequestBehavior.AllowGet); }
public JsonResult LoadContractDispatchBill(string dispatchBillId) { string strErrText; //读取调度单数据 DispatchSystem dispatch = new DispatchSystem(); DispatchBill bill = dispatch.LoadDispatchBill(long.Parse(dispatchBillId), LoginAccountId, LoginStaffName, out strErrText); if (bill == null) { throw new Exception(strErrText); } //读取调度计划数据 List<DispatchBillDeliverPlan> listDeliverPlan = dispatch.LoadDispatchBillDeliverPlans(long.Parse(dispatchBillId), LoginAccountId, LoginStaffName, out strErrText); if (listDeliverPlan == null) { throw new Exception(strErrText); } //读取调度货物数据 List<DispatchBillGoods> listGoods = dispatch.LoadDispatchBillAllGoods(long.Parse(dispatchBillId), LoginAccountId, LoginStaffName, out strErrText); if (listGoods == null) { throw new Exception(strErrText); } //清除自提的计划 foreach (DispatchBillDeliverPlan p in listDeliverPlan) { if (p.ReceiveType == InnoSoft.LS.Resources.Options.PickUpSelf) { listGoods.RemoveAll(delegate(DispatchBillGoods g) { return g.PlanId == p.PlanId; }); } } listDeliverPlan.RemoveAll(delegate(DispatchBillDeliverPlan p) { return p.ReceiveType == InnoSoft.LS.Resources.Options.PickUpSelf; }); //生成结果集 var ret = new { CarNo = bill.CarNo, TrailerNo = bill.TrailerNo, CarType = bill.CarType, DriverName = bill.DriverName, DriverLicenseNo = bill.DriverLicenseNo, DriverMobileTel = bill.DriverMobileTel, DriverHomeTel = bill.DriverHomeTel, CarrierId = bill.CarrierId, CarrierName = bill.CarrierName, GoodsName = (from g in listGoods select g.GoodsName).Distinct(), Packing = "", TotalPackages = listDeliverPlan.Sum(p => p.Packages), TotalTunnages = listDeliverPlan.Sum(p => p.Tunnages).ToString("#0.######"), TotalPiles = listDeliverPlan.Sum(p => p.Piles).ToString("#0.######"), TotalTenThousands = listDeliverPlan.Sum(p => p.TenThousands).ToString("#0.######"), StartPlace = (from p in listDeliverPlan select p.StartCity).Distinct(), DestPlace = (from p in listDeliverPlan select p.ReceiverCity).Distinct(), ShipmentTime = DateTime.Now.ToString("yyyy-MM-dd"), ArrivalTime = "", TotalTransportCharges = listDeliverPlan.Sum(p => p.TransportCharges).ToString("#0.00"), PrepayTransportCharges = "", ResidualTransportCharges = listDeliverPlan.Sum(p => p.TransportCharges).ToString("#0.00"), OriginalContractNo = "" }; return Json(ret, JsonRequestBehavior.AllowGet); }