示例#1
0
        public JsonResult LoadSearchDeliverPlansGrid(string sidx, string sord, int page, int rows, string startTime, string endTime, string customerName, string shipmentNo, string deliveryNo, string deliverType, string receiverName, string startCountry, string startProvince, string startCity, string destCountry, string destProvince, string destCity, string carNo, string goodsNo, string planNo)
        {
            //读取数据
            string strErrText;
            PlanSystem plan = new PlanSystem();
            List<DeliverPlan> listPlan = plan.LoadDeliverPlansByConditions(startTime, endTime, customerName, shipmentNo, deliveryNo, deliverType, receiverName, startCountry, startProvince, startCity, destCountry, destProvince, destCity, carNo, goodsNo, planNo, 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.ReceiverCountry + p.ReceiverProvince + p.ReceiverCity + p.ReceiverAddress,
                              p.StartCity,
                              p.ReceiverCity,
                              p.PlanType,
                              p.CreateTime.ToString("yyyy-MM-dd"),
                              p.PlanState,
                              p.IsDelete.ToString(),
                              p.IsContractReversed.ToString(),
                              p.IsCustomerTransportChargesSettled.ToString(),
                              p.IsCarrierTransportChargesSettled.ToString()
                          }
                      }).ToArray()
            };
            return Json(ret, JsonRequestBehavior.AllowGet);
        }