Exemplo n.º 1
0
        /// <summary>
        /// 打印某张申请单的外箱
        /// </summary>
        /// <param name="billId"></param>
        /// <returns></returns>
        public List <PrintOuterBoxModels> GetOuterBoxes4Print(int billId)
        {
            List <PrintOuterBoxModels> boxes = new List <PrintOuterBoxModels>();
            var dr = new DRSv().GetDRBill(billId);

            if (dr == null)
            {
                throw new Exception("单据不存在");
            }
            string supplierName   = dr.supplier_name;
            string supplierNumber = dr.supplier_number;

            foreach (var bp in new DRSv().GetBoxAndPo(billId))
            {
                foreach (var boxNumber in bp.box.box_number_long.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    boxes.Add(new PrintOuterBoxModels()
                    {
                        batchNo       = bp.box.batch,
                        boxNumber     = boxNumber,
                        brand         = bp.box.brand,
                        companyName   = MyUtils.GetCurrentCompany(bp.box.account).accountName,
                        grossWeight   = string.Format("{0:0.####}", bp.box.every_gross_weight),
                        itemModel     = bp.box.item_model,
                        itemName      = bp.box.item_name,
                        itemNumber    = bp.box.item_number,
                        keepCondition = bp.box.keep_condition,
                        expireDate    = bp.box.expire_date == null ? ((DateTime)bp.box.produce_date).AddMonths((int)bp.box.safe_period).AddDays(-1).ToString("yyyy-MM-dd") : ((DateTime)bp.box.expire_date).ToString("yyyy-MM-dd"),
                        madeBy        = bp.box.made_by,
                        madeIn        = bp.box.made_in,
                        netWeight     = string.Format("{0:0.####}", bp.box.every_net_weight),
                        poNumber      = bp.po.po_number,
                        produceCircle = bp.box.produce_circle,
                        produceDate   = bp.box.produce_date == null ? "" : ((DateTime)bp.box.produce_date).ToString("yyyy-MM-dd"),
                        qtyAndUnit    = string.Format("{0:0.####}", bp.po.send_num) + bp.box.unit_name + (bp.box.backup_number == null || bp.box.backup_number == 0 ? "" : (";备件:" + string.Format("{0:0.####}", bp.box.backup_number))),
                        rohs          = bp.box.rohs,
                        supplierName  = supplierName,
                        tradeTypeName = bp.box.trade_type_name,
                        qrcodeContent = string.Format("{11};{0};{1};{2};{3};{4:0.####};{5:0.####};{6};{7};{8};{9:yyyy-MM-dd};{10};{12};",
                                                      boxNumber, bp.po.po_number, bp.po.po_entry_id, bp.box.item_number, bp.po.send_num,
                                                      bp.box.backup_number, bp.box.unit_number, supplierNumber, "", "", bp.box.account, bp.box.outer_box_id, bp.po.out_box_po_id
                                                      )
                                        //qrcodeContent = bp.box.outer_box_id + ";" + boxNumber
                    });
                }
            }

            return(boxes.OrderBy(b => b.boxNumber).ToList());
        }
Exemplo n.º 2
0
        public PrintApplyModels GetData4Print(int billId, string account)
        {
            DRSv             sv = new DRSv();
            PrintApplyModels m  = new PrintApplyModels();

            m.h         = sv.GetDRBill(billId);
            m.es        = sv.GetDRBillDetails(billId);
            m.boxAndPos = sv.GetBoxAndPo(billId);

            m.boxAndPos = UnionBoxAndPo(m.boxAndPos); //2018-12-24 同一PO,同一分录,同一数量,没有合并箱的情况下,将行合并起来,件数汇总

            m.supplierInfo = new ItemSv().GetSupplierInfo(m.h.supplier_number, account);

            return(m);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 打印某张申请单的内箱
        /// </summary>
        /// <param name="billId"></param>
        /// <returns></returns>
        public List <PrintInnerBoxModel> GetInnerBoxes4Print(int billId)
        {
            List <PrintInnerBoxModel> boxes = new List <PrintInnerBoxModel>();
            var dr = new DRSv().GetDRBill(billId);

            if (dr == null)
            {
                throw new Exception("单据不存在");
            }
            string supplierName   = dr.supplier_name;
            string supplierNumber = dr.supplier_number;

            var m = (from o in db.OuterBoxes
                     join i in db.InneBoxes on o.outer_box_id equals i.outer_box_id
                     join et in db.InnerBoxesExtra on i.inner_box_id equals et.inner_box_id into etp
                     from e in etp.DefaultIfEmpty()
                     where o.bill_id == billId
                     select new
            {
                o,
                i,
                e
            }).ToList();

            foreach (var b in m)
            {
                var outerBoxes = b.o.box_number_long.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                var innerBoxes = b.i.box_number_long.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                for (var i = 0; i < innerBoxes.Count(); i++)
                {
                    var outerBoxNum = outerBoxes[i / ((int)b.i.pack_num / (int)b.o.pack_num)];
                    if (b.e == null)
                    {
                        boxes.Add(new PrintInnerBoxModel()
                        {
                            batchNo        = b.o.batch,
                            boxNumber      = innerBoxes[i],
                            brand          = b.o.brand,
                            expireDate     = b.o.expire_date == null ? ((DateTime)b.o.produce_date).AddMonths((int)b.o.safe_period).AddDays(-1).ToString("yyyy-MM-dd") : ((DateTime)b.o.expire_date).ToString("yyyy-MM-dd"),
                            itemModel      = b.o.item_model,
                            itemName       = b.o.item_name,
                            itemNumber     = b.o.item_number,
                            keepCondition  = b.o.keep_condition,
                            madeBy         = b.o.made_by,
                            produceDate    = b.o.produce_date == null ? "" : ((DateTime)b.o.produce_date).ToString("yyyy-MM-dd"),
                            qtyAndUnit     = string.Format("{0:0.####}{1}", b.i.every_qty, b.o.unit_name),
                            rohs           = b.o.rohs,
                            supplierName   = supplierName,
                            tradeTypeName  = b.o.trade_type_name,
                            outerBoxNumber = outerBoxNum,
                            //qrcodeContent = string.Format("{9};{0};{1};{2:0.####};{3};{4};{5};{6:yyyy-MM-dd};{7};{8}",
                            //innerBoxes[i], b.o.item_number, b.i.every_qty, b.o.unit_number, supplierNumber, b.o.batch, b.o.produce_date, outerBoxNum, b.o.account == "S" ? "zb" : "gd",b.i.inner_box_id
                            //)
                            qrcodeContent = string.Format("{0};{1};{2};{3};{4:0.####}", b.i.inner_box_id, innerBoxes[i], outerBoxNum, b.o.item_number, b.i.every_qty)
                        });
                    }
                    else
                    {
                        boxes.Add(new PrintInnerBoxModel()
                        {
                            batchNo        = b.e.batch,
                            boxNumber      = innerBoxes[i],
                            brand          = b.e.brand,
                            expireDate     = b.e.expire_date == null ? ((DateTime)b.e.produce_date).AddMonths((int)b.e.safe_period).AddDays(-1).ToString("yyyy-MM-dd") : ((DateTime)b.e.expire_date).ToString("yyyy-MM-dd"),
                            itemModel      = b.e.item_model,
                            itemName       = b.e.item_name,
                            itemNumber     = b.e.item_number,
                            keepCondition  = b.e.keep_condition,
                            madeBy         = b.e.made_by,
                            produceDate    = b.e.produce_date == null ? "" : ((DateTime)b.e.produce_date).ToString("yyyy-MM-dd"),
                            qtyAndUnit     = string.Format("{0:0.####}{1}", b.i.every_qty, b.e.unit_name),
                            rohs           = b.e.rohs,
                            supplierName   = supplierName,
                            tradeTypeName  = b.e.trade_type_name,
                            outerBoxNumber = outerBoxNum,
                            //qrcodeContent = string.Format("{9};{0};{1};{2:0.####};{3};{4};{5};{6:yyyy-MM-dd};{7};{8}",
                            //innerBoxes[i], b.o.item_number, b.i.every_qty, b.o.unit_number, supplierNumber, b.o.batch, b.o.produce_date, outerBoxNum, b.o.account == "S" ? "zb" : "gd",b.i.inner_box_id
                            //)
                            qrcodeContent = string.Format("{0};{1};{2};{3};{4:0.####}", b.i.inner_box_id, innerBoxes[i], outerBoxNum, b.e.item_number, b.i.every_qty)
                        });
                    }
                }
            }

            return(boxes.OrderBy(b => b.boxNumber).ToList());
        }
Exemplo n.º 4
0
        /// <summary>
        /// 保存内箱
        /// </summary>
        /// <param name="outerBoxId">外箱id</param>
        /// <param name="everyQty">内箱每件数量</param>
        /// <param name="packNum">内箱件数</param>
        /// <returns>内箱箱号</returns>
        public string[] SaveInnerBox(InneBoxes ib)
        {
            var outerBox = db.OuterBoxes.Where(o => o.outer_box_id == ib.outer_box_id).FirstOrDefault();

            if (outerBox == null)
            {
                throw new Exception("外箱不存在,操作失败");
            }

            if (outerBox.bill_id != null)
            {
                var dr = new DRSv().GetDRBill((int)outerBox.bill_id);
                if (dr != null && dr.p_status != "未提交" && dr.p_status != "已拒绝")
                {
                    throw new Exception("已使用并提交的箱子不能再添加内箱");
                }
            }

            //此外箱已有的内箱数量
            var outerNum        = outerBox.every_qty * outerBox.pack_num;
            var existedInnerNum = db.InneBoxes.Where(i => i.outer_box_id == outerBox.outer_box_id).Sum(i => i.every_qty * i.pack_num) ?? 0m;

            if (ib.every_qty > outerBox.every_qty)
            {
                throw new Exception("内箱每件数量不能大于外箱每件数量");
            }

            if (ib.pack_num % outerBox.pack_num != 0)
            {
                throw new Exception("内箱件数必须是外箱件数的整数倍,否则不能被平均分摊到每个外箱中");
            }

            if (ib.every_qty * ib.pack_num > outerNum - existedInnerNum)
            {
                throw new Exception(string.Format("内箱每件数量*内箱件数不能大于可做数量:{0:0.####}", outerNum - existedInnerNum));
            }

            var innerBoxNumber = new ItemSv().GetBoxNumber("I", (int)ib.pack_num);

            ib.box_number      = innerBoxNumber[0];
            ib.box_number_long = innerBoxNumber[1];

            db.InneBoxes.InsertOnSubmit(ib);
            db.SubmitChanges();

            //保存内箱明细
            var innerBoxArr = ib.box_number_long.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            var outerBoxArr = outerBox.box_number_long.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            for (var j = 0; j < innerBoxArr.Count(); j++)
            {
                db.InnerBoxesDetail.InsertOnSubmit(new InnerBoxesDetail()
                {
                    inner_box_id     = ib.inner_box_id,
                    outer_box_id     = outerBox.outer_box_id,
                    inner_box_number = innerBoxArr[j],
                    outer_box_number = outerBoxArr[j / (innerBoxArr.Count() / outerBoxArr.Count())]
                });
            }
            db.SubmitChanges();

            return(new string[] { ib.box_number, ib.inner_box_id.ToString() });
        }