示例#1
0
        public JsonResult LoadSearchConsigningDeliverPlansGrid(string sidx, string sord, int page, int rows, string consigningDeliveryNo)
        {
            //读取数据
            string strErrText;
            StockSystem stock = new StockSystem();
            List<ConsigningDeliverPlanDeliverGoods> listGoods = stock.LoadConsigningDeliverPlanDeliverGoodsByConditions(consigningDeliveryNo, LoginAccountId, LoginStaffName, out strErrText);
            if (listGoods == null)
            {
                throw new Exception(strErrText);
            }

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

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

            //生成表格数据
            var ret = new
            {
                total = nTotalPages,
                page = nPageIndex,
                records = nTotalRows,
                rows = (
                      from g in data
                      select new
                      {
                          id = g.Id,
                          cell = new string[] {
                              g.Id.ToString(),
                              g.ConsignedDeliveryNo,
                              g.GoodsNo,
                              g.GoodsName,
                              g.Brand,
                              g.SpecModel,
                              g.GWeight,
                              g.Grade,
                              g.PieceWeight.ToString("#0.######"),
                              g.BatchNo,
                              g.ProductionDate,
                              g.Warehouse,
                              g.CreateTime,
                              g.OutWarehouseBillNo,
                              g.DeliveryNo,
                              g.ReceiverName,
                              g.Packages > 0 ? g.Packages.ToString() : string.Empty,
                              g.Tunnages > 0 ? g.Tunnages.ToString("#0.######") : string.Empty,
                              g.BalancePackages.ToString(),
                              g.BalanceTunnages.ToString("#0.######")
                          }
                      }).ToArray()
            };
            return Json(ret, JsonRequestBehavior.AllowGet);
        }