Beispiel #1
0
        public JsonResult LoadPrintAllocateShipmentBillsGrid(string sidx, string sord, int page, int rows)
        {
            //读取数据
            string strErrText;
            DeliverSystem deliver = new DeliverSystem();
            List<ShipmentBill> listShipmentBill = deliver.LoadPrintAllocateShipmentBills(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 ?? "BillNo") + " " + (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 p in data
                      select new
                      {
                          id = p.Id,
                          cell = new string[] {
                              p.Id.ToString(),
                              p.BillNo,
                              p.PlanNo,
                              p.CustomerName,
                              p.DeliveryNo,
                              p.ReceiverName,
                              p.TotalPackages.ToString(),
                              p.TotalTunnages.ToString("#0.######")
                          }
                      }).ToArray()
            };
            return Json(ret, JsonRequestBehavior.AllowGet);
        }