public JsonResult LoadShipmentBillAllGoodsGrid(string sidx, string sord, int page, int rows, string shipmentBillId) { //读取数据 string strErrText; DeliverSystem deliver = new DeliverSystem(); List<ShipmentBillGoods> listGoods = deliver.LoadShipmentBillAllGoods(long.Parse(shipmentBillId), 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 ?? "GoodsNo") + " " + (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.GoodsId.ToString(), g.GoodsNo, g.GoodsName, g.Brand, g.SpecModel, g.GWeight, g.Grade, g.BatchNo, g.Packing, g.Warehouse, g.Location, g.Packages.ToString(), g.PieceWeight.ToString("#0.######"), g.Tunnages.ToString("#0.######"), g.Piles.ToString("#0.######"), g.TenThousands.ToString("#0.######"), g.ProductionDate, g.EnterWarehouseBillId.ToString(), g.EnterWarehouseBillNo, g.Location, g.Packages.ToString(), g.Tunnages.ToString("#0.######"), g.Piles.ToString("#0.######"), g.TenThousands.ToString("#0.######") } }).ToArray(), userdata = new { GoodsNo = InnoSoft.LS.Resources.Labels.Total, Packages = data.Sum(s => s.Packages), Tunnages = data.Sum(s => s.Tunnages), Piles = data.Sum(s => s.Piles), TenThousands = data.Sum(s => s.TenThousands), } }; return Json(ret, JsonRequestBehavior.AllowGet); }
public ActionResult ReprintShipmentBill(string id) { string strErrText; string[] shipmentBillIds = id.Split(','); //读取公司名称 OrganizationSystem organ = new OrganizationSystem(); List<Organization> listOrgan = organ.LoadOrganizations(LoginAccountId, LoginStaffName, out strErrText); if (listOrgan == null) { throw new Exception(strErrText); } Organization root = listOrgan.Find(delegate(Organization o) { return o.ParentId == 0; }); ViewData["CompanyName"] = root.Name; //生成Model PrintShipmentBillViewModel model = new PrintShipmentBillViewModel(); model.bills = new List<ShipmentBillViewModel>(); DeliverSystem deliver = new DeliverSystem(); PlanSystem plan = new PlanSystem(); foreach (string shipmentBillId in shipmentBillIds) { ShipmentBill bill = deliver.LoadShipmentBill(long.Parse(shipmentBillId), LoginAccountId, LoginStaffName, out strErrText); if (bill == null) { throw new Exception(strErrText); } List<ShipmentBillGoods> listGoods = deliver.LoadShipmentBillAllGoods(long.Parse(shipmentBillId), LoginAccountId, LoginStaffName, out strErrText); if (listGoods == null) { throw new Exception(strErrText); } DeliverPlan deliverPlan = plan.LoadDeliverPlan(bill.PlanId, LoginAccountId, LoginStaffName, out strErrText); if (deliverPlan == null) { throw new Exception(strErrText); } ShipmentBillViewModel modelBill = new ShipmentBillViewModel(); modelBill.BillNo = bill.BillNo; modelBill.PlanType = bill.PlanType; modelBill.PlanNo = bill.PlanNo; modelBill.CustomerName = bill.CustomerName; modelBill.PayerName = bill.PayerName; modelBill.DeliveryNo = bill.DeliveryNo; modelBill.OutType = bill.OutType; modelBill.ReceiverName = bill.ReceiverName; modelBill.ReceiverCountry = bill.ReceiverCountry; modelBill.ReceiverProvince = bill.ReceiverProvince; modelBill.ReceiverCity = bill.ReceiverCity; modelBill.ReceiverAddress = bill.ReceiverAddress; modelBill.ReceiverContact = bill.ReceiverContact; modelBill.ReceiverContactTel = bill.ReceiverContactTel; modelBill.OrderNo = bill.OrderNo; modelBill.ReceiveType = bill.ReceiveType; modelBill.CarNo = bill.CarNo; modelBill.TrailerNo = bill.TrailerNo; modelBill.Warehouse = bill.Warehouse; modelBill.TotalPackages = bill.TotalPackages; modelBill.TotalTunnages = bill.TotalTunnages; modelBill.TotalPiles = bill.TotalPiles; modelBill.TotalTenThousands = bill.TotalTenThousands; modelBill.Remark = bill.Remark; modelBill.CreateTime = bill.CreateTime.ToString("yyyy-MM-dd"); modelBill.CreatorName = deliverPlan.CreatorName; modelBill.Goods = new List<ShipmentBillGoodsViewModel>(); foreach (ShipmentBillGoods goods in listGoods) { ShipmentBillGoodsViewModel modelGoods = new ShipmentBillGoodsViewModel(); modelGoods.GoodsName = goods.GoodsName; modelGoods.GoodsNo = goods.GoodsNo; modelGoods.SpecModel = goods.SpecModel; modelGoods.GWeight = goods.GWeight; modelGoods.Grade = goods.Grade; modelGoods.PieceWeight = goods.PieceWeight; modelGoods.Packing = goods.Packing; modelGoods.BatchNo = goods.BatchNo; modelGoods.Location = goods.Location; modelGoods.Packages = goods.Packages; modelGoods.Tunnages = goods.Tunnages; modelGoods.Piles = goods.Piles; modelGoods.TenThousands = goods.TenThousands; modelBill.Goods.Add(modelGoods); } model.bills.Add(modelBill); } return View(model); }