Beispiel #1
0
        public JsonResult LoadDeliverBillAllGoodsGrid(string sidx, string sord, int page, int rows, string deliverBillId)
        {
            //读取数据
            string strErrText;
            DeliverSystem deliver = new DeliverSystem();
            List<DeliverBillGoods> listGoods = deliver.LoadDeliverBillAllGoods(long.Parse(deliverBillId), 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.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);
        }
Beispiel #2
0
        public ActionResult ReprintDeliverBill(string id)
        {
            string strErrText;
            string[] deliverBillIds = 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
            PrintDeliverBillViewModel model = new PrintDeliverBillViewModel();
            model.bills = new List<DeliverBillViewModel>();

            DeliverSystem deliver = new DeliverSystem();
            foreach (string deliverBillId in deliverBillIds)
            {
                DeliverBill data = deliver.LoadDeliverBill(long.Parse(deliverBillId), LoginAccountId, LoginStaffName, out strErrText);
                if (data == null)
                {
                    throw new Exception(strErrText);
                }

                List<DeliverBillGoods> listGoods = deliver.LoadDeliverBillAllGoods(long.Parse(deliverBillId), LoginAccountId, LoginStaffName, out strErrText);
                if (listGoods == null)
                {
                    throw new Exception(strErrText);
                }

                DeliverBillViewModel billVM = new DeliverBillViewModel();
                billVM.Id = data.Id;
                billVM.BillNo = data.BillNo;
                billVM.PlanType = data.PlanType;
                billVM.CustomerName = data.CustomerName;
                billVM.ReceiverName = data.ReceiverName;
                billVM.ReceiverCountry = data.ReceiverCountry;
                billVM.ReceiverProvince = data.ReceiverProvince;
                billVM.ReceiverCity = data.ReceiverCity;
                billVM.ReceiverAddress = data.ReceiverAddress;
                billVM.ReceiverContact = data.ReceiverContact;
                billVM.ReceiverContactTel = data.ReceiverContactTel;
                billVM.ReceiveType = data.ReceiveType;
                billVM.OrderNo = data.OrderNo;
                billVM.CarNo = data.CarNo;
                billVM.TrailerNo = data.TrailerNo;
                billVM.CreateTime = data.CreateTime;
                billVM.TotalPackages = data.TotalPackages;
                billVM.TotalTunnages = data.TotalTunnages;
                billVM.TotalPiles = data.TotalPiles;
                billVM.TotalTenThousands = data.TotalTenThousands;
                billVM.Remark = data.Remark;

                billVM.Goods = new List<DeliverBillGoodsViewModel>();
                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);
                }
                model.bills.Add(billVM);
            }
            return View(model);
        }