Exemple #1
0
        public JsonResult LoadPrintDispatchedShipmentBillsGrid(string sidx, string sord, int page, int rows)
        {
            //读取数据
            string strErrText;
            DeliverSystem deliver = new DeliverSystem();
            List<ShipmentBill> listShipmentBill = deliver.LoadPrintDispatchedShipmentBills(LoginAccountId, LoginStaffName, out strErrText);
            if (listShipmentBill == null)
            {
                throw new Exception(strErrText);
            }

            //提取当前页面数据
            int nTotalRows = listShipmentBill.Count;
            int nPageIndex = page;
            int nPageSize = rows;
            int nTotalPages = nTotalRows / nPageSize;
            if (nTotalRows % nPageSize > 0)
                nTotalPages++;

            string sortExpression = (sidx ?? "CarNo") + " " + (sord ?? "ASC");
            var data = listShipmentBill.OrderBy(sortExpression).Skip((nPageIndex - 1) * nPageSize).Take(nPageSize).ToList();

            //生成表格数据
            var ret = new
            {
                total = nTotalPages,
                page = nPageIndex,
                records = nTotalRows,
                rows = (
                      from b in data
                      select new
                      {
                          id = b.Id,
                          cell = new string[] {
                              b.Id.ToString(),
                              b.BillNo,
                              b.PlanId.ToString(),
                              b.PlanNo,
                              b.DispatchBillId.ToString(),
                              b.DispatchBillNo,
                              b.CustomerName,
                              b.ShipmentNo,
                              b.DeliveryNo,
                              b.ReceiverName,
                              b.ReceiverCity + b.ReceiverAddress,
                              b.CarNo,
                              b.TrailerNo,
                              b.DriverName,
                              b.DriverMobileTel,
                              b.TotalPackages.ToString(),
                              b.TotalTunnages.ToString("#0.######"),
                              b.TotalPiles.ToString("#0.######"),
                              b.TotalTenThousands.ToString("#0.######")
                          }
                      }).ToArray()
            };
            return Json(ret, JsonRequestBehavior.AllowGet);
        }