Esempio n. 1
0
        public JsonResult LoadContractDeliverPlansGrid(string sidx, string sord, int page, int rows, string contractId)
        {
            //读取数据
            string strErrText;
            ContractSystem contract = new ContractSystem();
            List<ContractDeliverPlan> listPlan = contract.LoadContractDeliverPlans(long.Parse(contractId), 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.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);
        }