public JsonResult LoadPrintDeliverBillsCarNo() { //读取数据 string strErrText; DeliverSystem deliver = new DeliverSystem(); List<DeliverBill> listDeliverBill = deliver.LoadPrintDeliverBills(LoginAccountId, LoginStaffName, out strErrText); if (listDeliverBill == null) { throw new Exception(strErrText); } var ret = (from b in listDeliverBill where b.CarNo != null && b.CarNo != string.Empty select b.CarNo).Distinct(); return Json(ret, JsonRequestBehavior.AllowGet); }
public JsonResult LoadPrintDeliverBillsGrid(string sidx, string sord, int page, int rows, string carNo) { //读取数据 string strErrText; DeliverSystem deliver = new DeliverSystem(); List<DeliverBill> listDeliverBill = deliver.LoadPrintDeliverBills(LoginAccountId, LoginStaffName, out strErrText); if (listDeliverBill == null) { throw new Exception(strErrText); } if (carNo != null && carNo != string.Empty) { listDeliverBill = listDeliverBill.FindAll(delegate(DeliverBill b) { return b.CarNo == carNo; }); } //提取当前页面数据 int nTotalRows = listDeliverBill.Count; int nPageIndex = page; int nPageSize = rows; int nTotalPages = nTotalRows / nPageSize; if (nTotalRows % nPageSize > 0) nTotalPages++; string sortExpression = (sidx ?? "BillNo") + " " + (sord ?? "ASC"); var data = listDeliverBill.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.CustomerName, b.DeliveryNo, b.ReceiverName, b.ReceiverCity, b.CarNo, b.TrailerNo, b.TotalPackages.ToString(), b.TotalTunnages.ToString("#0.######"), b.TotalPiles.ToString("#0.######"), b.TotalTenThousands.ToString("#0.######") } }).ToArray() }; return Json(ret, JsonRequestBehavior.AllowGet); }
public ActionResult PrintDeliverBill(string id) { string strErrText; ViewData["DeliverBillId"] = id; //读取公司名称 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; //读取送货单数据 DeliverSystem deliver = new DeliverSystem(); List<DeliverBill> listDeliverBill = deliver.LoadPrintDeliverBills(LoginAccountId, LoginStaffName, out strErrText); if (listDeliverBill == null) { throw new Exception(strErrText); } listDeliverBill = listDeliverBill.FindAll(delegate(DeliverBill b) { return b.Id == long.Parse(id); }); //生成Model PrintDeliverBillViewModel model = new PrintDeliverBillViewModel(); model.bills = new List<DeliverBillViewModel>(); foreach (DeliverBill bill in listDeliverBill) { DeliverBillViewModel billVM = new DeliverBillViewModel(); billVM.Id = bill.Id; billVM.BillNo = bill.BillNo; billVM.PlanType = bill.PlanType; billVM.CustomerName = bill.CustomerName; billVM.ReceiverName = bill.ReceiverName; billVM.ReceiverCountry = bill.ReceiverCountry; billVM.ReceiverProvince = bill.ReceiverProvince; billVM.ReceiverCity = bill.ReceiverCity; billVM.ReceiverAddress = bill.ReceiverAddress; billVM.ReceiverContact = bill.ReceiverContact; billVM.ReceiverContactTel = bill.ReceiverContactTel; billVM.ReceiveType = bill.ReceiveType; billVM.OrderNo = bill.OrderNo; billVM.CarNo = bill.CarNo; billVM.TrailerNo = bill.TrailerNo; billVM.CreateTime = bill.CreateTime; billVM.TotalPackages = bill.TotalPackages; billVM.TotalTunnages = bill.TotalTunnages; billVM.TotalPiles = bill.TotalPiles; billVM.TotalTenThousands = bill.TotalTenThousands; billVM.Remark = bill.Remark; billVM.Goods = new List<DeliverBillGoodsViewModel>(); model.bills.Add(billVM); //读取送货单货物数据 List<DeliverBillGoods> listGoods = deliver.LoadDeliverBillAllGoods(bill.Id, LoginAccountId, LoginStaffName, out strErrText); if (listGoods == null) { throw new Exception(strErrText); } foreach (DeliverBillGoods goods in listGoods) { DeliverBillGoodsViewModel goodsVM = new DeliverBillGoodsViewModel(); goodsVM.GoodsName = goods.GoodsName; goodsVM.GoodsNo = goods.GoodsNo; goodsVM.SpecModel = goods.SpecModel; goodsVM.GWeight = goods.GWeight; goodsVM.Grade = goods.Grade; goodsVM.PieceWeight = goods.PieceWeight; goodsVM.Packing = goods.Packing; goodsVM.BatchNo = goods.BatchNo; goodsVM.Packages = goods.Packages; goodsVM.Tunnages = goods.Tunnages; goodsVM.Piles = goods.Piles; goodsVM.TenThousands = goods.TenThousands; billVM.Goods.Add(goodsVM); } } return View(model); }