Exemple #1
0
        public JsonResult LoadForeignDeliverPlansGrid(string sidx, string sord, int page, int rows)
        {
            string strErrText;

            //读取数据
            PlanSystem plan = new PlanSystem();
            List<DeliverPlan> listPlan = plan.LoadForeignDeliverPlans(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 ?? "CreateTime") + " " + (sord ?? "DESC");
            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.StartCity,
                              p.CarNo,
                              p.DriverName,
                              p.DriverMobileTel,
                              p.ArrivalTime,
                              p.PlanType,
                              p.TotalTunnages.ToString("#0.######"),
                              p.TotalPiles.ToString("#0.######"),
                              p.CreateTime.ToString("yyyy-MM-dd")
                          }
                      }).ToArray(),
                userdata = new
                {
                    PlanNo = InnoSoft.LS.Resources.Labels.Total,
                    TotalTunnages = data.Sum(s => s.TotalTunnages),
                    TotalPiles = data.Sum(s => s.TotalPiles)
                }
            };
            return Json(ret, JsonRequestBehavior.AllowGet);
        }