Exemplo n.º 1
0
        private void PrintOrder(Resolver resolver, string[] region)
        {
            DetachedCriteria criteria = DetachedCriteria.For(typeof(OrderHead));

            criteria.Add(Expression.Eq("IsPrinted", false));
            criteria.Add(Expression.Eq("NeedPrintOrder", true));
            criteria.Add(Expression.Eq("Status", BusinessConstants.CODE_MASTER_STATUS_VALUE_INPROCESS));
            criteria.Add(Expression.In("Type", new string[] { BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER, BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT }));
            criteria.Add(Expression.In("PartyFrom.Code", region));

            IList <OrderHead> orderList = criteriaMgr.FindAll <OrderHead>(criteria);

            List <ReceiptNote> receiptNotes = new List <ReceiptNote>();

            if (orderList != null && orderList.Count > 0)
            {
                foreach (OrderHead orderHead in orderList)
                {
                    IList <object> list = new List <object>();
                    list.Add(orderHead);
                    list.Add(orderHead.OrderDetails);

                    string newUrl = reportMgr.WriteToFile(orderHead.OrderTemplate, list);
                    orderHead.IsPrinted = true;//to be refactored
                    orderHeadMgr.UpdateOrderHead(orderHead);
                    ReceiptNote receiptNote = Order2ReceiptNote(orderHead);
                    receiptNote.PrintUrl = newUrl;
                    receiptNotes.Add(receiptNote);
                }
            }

            if (resolver.ReceiptNotes == null)
            {
                resolver.ReceiptNotes = receiptNotes;
            }
            else
            {
                IListHelper.AddRange <ReceiptNote>(resolver.ReceiptNotes, receiptNotes);
            }
        }
        protected override bool FillValuesImpl(String templateFileName, IList <object> list)
        {
            try
            {
                if (list == null || list.Count < 2)
                {
                    return(false);
                }

                OrderHead           orderHead    = (OrderHead)(list[0]);
                IList <OrderDetail> orderDetails = (IList <OrderDetail>)(list[1]);


                if (orderHead == null ||
                    orderDetails == null || orderDetails.Count == 0)
                {
                    return(false);
                }

                this.barCodeFontName = this.GetBarcodeFontName(2, 8);
                //this.SetRowCellBarCode(0, 2, 8);
                this.CopyPage(orderDetails.Count);

                this.FillHead(orderHead);

                //自动换行
                //style.WrapText = true;

                int pageIndex = 1;
                int rowIndex  = 0;
                int rowTotal  = 0;
                foreach (OrderDetail orderDetail in orderDetails)
                {
                    // No.
                    this.SetRowCell(pageIndex, rowIndex, 0, "" + orderDetail.Sequence);

                    //零件号 Item Code
                    this.SetRowCell(pageIndex, rowIndex, 1, orderDetail.Item.Code);

                    //参考号 Ref No.
                    this.SetRowCell(pageIndex, rowIndex, 2, orderDetail.ReferenceItemCode);

                    //描述Description
                    this.SetRowCell(pageIndex, rowIndex, 3, orderDetail.Item.Description);

                    //单位Unit
                    this.SetRowCell(pageIndex, rowIndex, 4, orderDetail.Item.Uom.Code);

                    //单包装UC
                    this.SetRowCell(pageIndex, rowIndex, 5, orderDetail.UnitCount.ToString("0.########"));

                    //需求 Request	包装
                    int UCs = (int)Math.Ceiling(orderDetail.OrderedQty / orderDetail.UnitCount);
                    this.SetRowCell(pageIndex, rowIndex, 6, UCs.ToString());

                    //需求 Request	零件数
                    this.SetRowCell(pageIndex, rowIndex, 7, orderDetail.OrderedQty.ToString("0.########"));

                    //发货数
                    this.SetRowCell(pageIndex, rowIndex, 8, orderDetail.ShippedQty.HasValue ? orderDetail.ShippedQty.Value.ToString("0.########") : string.Empty);

                    //实收 Received	包装
                    this.SetRowCell(pageIndex, rowIndex, 9, "");

                    //实收 Received	零件数
                    this.SetRowCell(pageIndex, rowIndex, 10, orderDetail.ReceivedQty.HasValue ? orderDetail.ReceivedQty.Value.ToString("0.########") : string.Empty);

                    //批号/备注
                    this.SetRowCell(pageIndex, rowIndex, 11, "");

                    if (this.isPageBottom(rowIndex, rowTotal))    //页的最后一行
                    {
                        pageIndex++;
                        rowIndex = 0;
                    }
                    else
                    {
                        rowIndex++;
                    }
                    rowTotal++;
                }

                this.sheet.DisplayGridlines = false;
                this.sheet.IsPrintGridlines = false;

                if (orderHead.IsPrinted == null || orderHead.IsPrinted == false)
                {
                    orderHead.IsPrinted = true;
                    orderHeadMgr.UpdateOrderHead(orderHead);
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
        public override bool FillValues(String templateFileName, IList <object> list)
        {
            try
            {
                this.init(templateFileName, ROW_COUNT);
                if (list == null || list.Count < 3)
                {
                    return(false);
                }

                OrderHead           orderHead    = (OrderHead)(list[0]);
                IList <OrderDetail> orderDetails = (IList <OrderDetail>)(list[1]);
                IList <OrderLocationTransaction> orderLocationTransactions = (IList <OrderLocationTransaction>)(list[2]);

                int pageIndex = 1;
                int pageCount = this.getPageCount(FIRST_PAGE_DETAIL_ROW_COUNT, NO_FIRST_PAGE_DETAIL_ROW_COUNT, orderLocationTransactions.Count);


                this.SetRowCellBarCode(1, 1, 6);
                //加页删页
                this.CopyPage(pageCount, 12);

                #region 物料信息  Material Information
                //物料信息  Material Information
                if (orderLocationTransactions == null || orderLocationTransactions.Count == 0)
                {
                    //填充第一页;
                    this.FillHead(pageIndex, orderHead, orderDetails);
                    this.FillFooter(pageIndex, orderHead);
                }
                else
                {
                    int i = 1;
                    foreach (OrderLocationTransaction orderLocationTransaction in orderLocationTransactions)
                    {
                        if (orderLocationTransaction.IOType.Equals(BusinessConstants.IO_TYPE_OUT))
                        {
                            if (pageIndex == 1 && i == 1) //第一页,明细部分 第一行,不换页
                            {
                                this.FillHead(pageIndex, orderHead, orderDetails);
                                this.FillFooter(pageIndex, orderHead);
                            }

                            if ((pageIndex == 1 && i == 17) || //第一页,明细部分  16行换页
                                (pageIndex > 1 && ((i - 1 - 16) % 40) == 0))       //非第一页,明细部分 40行换页
                            {
                                pageIndex++;
                                this.FillHead(pageIndex, orderHead, orderDetails);
                                this.FillFooter(pageIndex, orderHead);
                            }

                            //零件号QAD Code
                            this.SetRowCell(pageIndex, 15 + i - 1, 1, orderLocationTransaction.Item.Code);
                            //零件名Description
                            this.SetRowCell(pageIndex, 15 + i - 1, 2, orderLocationTransaction.Item.Description);
                            // 单位Unit
                            this.SetRowCell(pageIndex, 15 + i - 1, 4, orderLocationTransaction.Uom.Code);

                            //"标准耗量Plan Qty.
                            this.SetRowCell(pageIndex, 15 + i - 1, 5, orderLocationTransaction.UnitQty.ToString("0.########"));

                            //"需求量Dmd Qty"
                            this.SetRowCell(pageIndex, 15 + i - 1, 6, orderLocationTransaction.OrderedQty.ToString("0.########"));


                            //领用数Request Qty.

                            //返回数Return Qty.

                            //废品数Scrap Qty.

                            //待处理Waiting Qty.

                            //备注Comment

                            i++;
                        }
                    }
                }
                #endregion

                //人员信息  People Information
                //空

                //生产记录  Production Information
                //空

                if (orderHead.IsPrinted == null || orderHead.IsPrinted == false)
                {
                    orderHead.IsPrinted = true;
                    orderHeadMgr.UpdateOrderHead(orderHead);
                }
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 4
0
        protected override bool FillValuesImpl(String templateFileName, IList <object> list)
        {
            try
            {
                if (list == null || list.Count < 2)
                {
                    return(false);
                }

                OrderHead           orderHead    = (OrderHead)(list[0]);
                IList <OrderDetail> orderDetails = (IList <OrderDetail>)(list[1]);


                if (orderHead == null ||
                    orderDetails == null || orderDetails.Count == 0)
                {
                    return(false);
                }


                //this.SetRowCellBarCode(0, 2, 8);
                this.barCodeFontName = this.GetBarcodeFontName(2, 8);
                this.CopyPage(orderDetails.Count);

                this.FillHead(orderHead);


                int pageIndex = 1;
                int rowIndex  = 0;
                int rowTotal  = 0;
                foreach (OrderDetail orderDetail in orderDetails)
                {
                    // No.
                    this.SetRowCell(pageIndex, rowIndex, 0, "" + orderDetail.Sequence);

                    //零件号 Item Code
                    this.SetRowCell(pageIndex, rowIndex, 1, orderDetail.Item.Code);

                    //参考号 Ref No.
                    this.SetRowCell(pageIndex, rowIndex, 2, orderDetail.ReferenceItemCode);

                    //描述Description
                    this.SetRowCell(pageIndex, rowIndex, 3, orderDetail.Item.Description);

                    //单位Unit
                    this.SetRowCell(pageIndex, rowIndex, 4, orderDetail.Item.Uom.Code);

                    //单包装UC
                    this.SetRowCell(pageIndex, rowIndex, 5, orderDetail.UnitCount.ToString("0.########"));

                    //需求 Request	包装
                    int UCs = (int)Math.Ceiling(orderDetail.OrderedQty / orderDetail.UnitCount);
                    this.SetRowCell(pageIndex, rowIndex, 6, UCs.ToString());

                    //需求 Request	零件数
                    this.SetRowCell(pageIndex, rowIndex, 7, orderDetail.OrderedQty.ToString("0.########"));

                    //发货数
                    this.SetRowCell(pageIndex, rowIndex, 8, orderDetail.ShippedQty.HasValue ? orderDetail.ShippedQty.Value.ToString("0.########") : string.Empty);

                    //实收 Received	包装
                    this.SetRowCell(pageIndex, rowIndex, 9, "");

                    //实收 Received	零件数
                    this.SetRowCell(pageIndex, rowIndex, 10, orderDetail.ReceivedQty.HasValue ? orderDetail.ReceivedQty.Value.ToString("0.########") : string.Empty);

                    //批号/备注
                    if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_TRANSFER)
                    {
                        IList <LocationLotDetail> locationLotDetailList = locationLotDetailMgr.GetHuLocationLotDetail(orderDetail.DefaultLocationFrom.Code, null, orderDetail.Item.Code, null, false);

                        decimal qty        = (from l in locationLotDetailList select l.Qty).Sum();
                        decimal shippedQty = orderDetail.ShippedQty.HasValue ? orderDetail.ShippedQty.Value : 0;
                        if (qty < orderDetail.OrderedQty - shippedQty)
                        {
                            string memo = languageMgr.TranslateMessage("MasterData.PickList.NotEnoughInventory", orderHead.CreateUser.Code);
                            this.SetRowCell(pageIndex, rowIndex, 11, memo);
                        }
                    }
                    else
                    {
                        this.SetRowCell(pageIndex, rowIndex, 11, string.Empty);
                    }
                    if (this.isPageBottom(rowIndex, rowTotal))//页的最后一行
                    {
                        pageIndex++;
                        rowIndex = 0;
                    }
                    else
                    {
                        rowIndex++;
                    }
                    rowTotal++;
                }

                this.sheet.DisplayGridlines = false;
                this.sheet.IsPrintGridlines = false;

                if (orderHead.IsPrinted == null || orderHead.IsPrinted == false)
                {
                    orderHead.IsPrinted = true;
                    orderHeadMgr.UpdateOrderHead(orderHead);
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 5
0
        public override bool FillValues(String templateFileName, IList <object> list)
        {
            try
            {
                this.init(templateFileName, ROW_COUNT);

                if (list == null || list.Count < 0)
                {
                    return(false);
                }

                OrderHead orderHead = (OrderHead)(list[0]);

                string userName = "";
                if (list.Count == 2)
                {
                    userName = (string)list[1];
                }

                /*
                 * this.sheet.DefaultRowHeightInPoints = 14.25F;
                 * //this.sheet.DefaultColumnWidth = 7;
                 * //this.sheet.SetColumnWidth(1, 100 * 256);
                 * sheet.DefaultColumnWidth = 7;
                 * //sheet.DefaultRowHeight = 30 * 20;
                 *
                 * //sheet.PrintSetup.PaperSize =
                 * sheet.SetColumnWidth(0, 60 * 32);
                 * sheet.SetColumnWidth(1, 60 * 32);
                 * sheet.SetColumnWidth(2, 60 * 32);
                 * sheet.SetColumnWidth(3, 60 * 32);
                 * sheet.SetColumnWidth(4, 58 * 32);
                 */
                this.sheet.DisplayGridlines = false;
                this.sheet.IsPrintGridlines = false;


                //this.sheet.DisplayGuts = false;

                //加页删页
                //this.CopyPage(pageCount, COLUMN_COUNT, 1);
                this.barCodeFontName = this.GetBarcodeFontName(0, 0);

                CellStyle cellStyleT = workbook.CreateCellStyle();
                Font      fontT      = workbook.CreateFont();
                fontT.FontHeightInPoints = (short)9;
                fontT.FontName           = "宋体";
                fontT.Boldweight         = (short)NPOI.SS.UserModel.FontBoldWeight.BOLD;
                cellStyleT.SetFont(fontT);

                int pageIndex = 1;


                string barCode = Utility.BarcodeHelper.GetBarcodeStr(orderHead.OrderNo, this.barCodeFontName);
                this.SetRowCell(pageIndex, 0, 0, barCode);

                this.SetRowCell(pageIndex, 1, 0, orderHead.OrderNo);

                //生产线编号
                Flow flow = this.flowMgr.LoadFlow(orderHead.Flow);
                this.SetRowCell(pageIndex, 3, 0, flow.Code);

                //班次编号
                this.SetRowCell(pageIndex, 3, 2, orderHead.Shift == null ? string.Empty : orderHead.Shift.Code);

                //生产线名称
                this.SetRowCell(pageIndex, 4, 0, flow.Description);

                //产品描述
                if (orderHead.OrderDetails != null && orderHead.OrderDetails.Count > 0)
                {
                    this.SetRowCell(pageIndex, 6, 0, orderHead.OrderDetails[0].Item.Description);
                }

                //开始时间
                this.SetRowCell(pageIndex, 8, 0, orderHead.WindowTime.ToString("yyyy-MM-dd HH:mm"));

                //Printed Date:
                this.SetRowCell(pageIndex, 9, 3, DateTime.Now.ToString("MM/dd/yy"));

                this.sheet.SetRowBreak(this.GetRowIndexAbsolute(pageIndex, ROW_COUNT - 1));

                if (orderHead.IsPrinted == null || orderHead.IsPrinted == false)
                {
                    orderHead.IsPrinted = true;
                    orderHeadMgr.UpdateOrderHead(orderHead);
                }
            }
            catch (Exception e)
            {
                return(false);
            }

            return(true);
        }
        public override bool FillValues(String templateFileName, IList <object> list)
        {
            try
            {
                this.init(templateFileName, ROW_COUNT);

                OrderHead           orderHead    = (OrderHead)(list[0]);
                IList <OrderDetail> orderDetails = (IList <OrderDetail>)(list[1]);
                int rowNum = 2;

                #region 报表头

                this.SetRowCellBarCode(1, 2, 8);

                //订单号:
                string orderCode = Utility.BarcodeHelper.GetBarcodeStr(orderHead.OrderNo, this.barCodeFontName);
                this.SetRowCell(rowNum++, 8, orderCode);
                //Order No.:
                this.SetRowCell(rowNum++, 8, orderHead.OrderNo);

                if ("Normal".Equals(orderHead.Priority))
                {
                    this.SetRowCell(4, 5, "");
                }
                else
                {
                    this.SetRowCell(3, 5, "");
                }
                //发出时间 Issue Time:
                this.SetRowCell(rowNum++, 9, orderHead.StartDate.ToString());

                //供应商代码 Supplier Code:
                this.SetRowCell(++rowNum, 3, orderHead.PartyFrom != null ? orderHead.PartyFrom.Code : String.Empty);

                //交货日期 Delivery Date:getDemandDeliverDate
                this.SetRowCell(rowNum, 8, orderHead.WindowTime.ToLongDateString());


                //供应商名称 Supplier Name:
                this.SetRowCell(++rowNum, 3, orderHead.PartyFrom != null ? orderHead.PartyFrom.Name : String.Empty);
                //窗口时间 Window Time:
                this.SetRowCell(rowNum, 8, orderHead.WindowTime.ToLongTimeString());

                //供应商地址 Address:
                this.SetRowCell(++rowNum, 3, orderHead.ShipFrom != null ? orderHead.ShipFrom.Address : String.Empty);
                //交货道口 Delivery Dock:
                this.SetRowCell(rowNum, 8, orderHead.DockDescription);

                //供应商联系人 Contact:
                this.SetRowCell(++rowNum, 3, orderHead.ShipFrom != null ? orderHead.ShipFrom.ContactPersonName : String.Empty);
                //物流协调员 Follow Up:
                this.SetRowCell(rowNum, 8, orderHead.ShipTo != null ? orderHead.ShipTo.ContactPersonName : String.Empty);

                //供应商电话 Telephone:
                this.SetRowCell(++rowNum, 3, orderHead.ShipFrom != null ? orderHead.ShipFrom.TelephoneNumber : String.Empty);
                //YFV电话 Telephone:
                this.SetRowCell(rowNum, 8, orderHead.ShipTo != null ? orderHead.ShipTo.TelephoneNumber : String.Empty);

                //供应商传真 Fax:
                this.SetRowCell(++rowNum, 3, orderHead.ShipFrom != null ? orderHead.ShipFrom.Fax : String.Empty);
                //YFV传真 Fax:
                this.SetRowCell(rowNum, 8, orderHead.ShipTo != null ? orderHead.ShipTo.Fax : String.Empty);

                //系统号 SysCode:
                this.SetRowCell(++rowNum, 3, "");
                //版本号 Version:
                this.SetRowCell(rowNum, 8, "");

                #endregion

                #region 明细部分

                rowNum++; //指向13
                rowNum++; //指向14
                rowNum++; //指向15

                for (int detailRowCount = 33, i = 0; i < orderDetails.Count; i++, rowNum++)
                {
                    OrderDetail orderDetail = orderDetails[i];

                    // No.
                    this.SetRowCell(rowNum, 0, "" + orderDetail.Sequence);

                    //零件号 Item Code
                    this.SetRowCell(rowNum, 1, orderDetail.Item.Code);

                    //参考号 Ref No.
                    this.SetRowCell(rowNum, 2, orderDetail.ReferenceItemCode);

                    //描述Description
                    this.SetRowCell(rowNum, 3, orderDetail.Item.Description);

                    //单位Unit
                    this.SetRowCell(rowNum, 4, orderDetail.Item.Uom.Code);

                    //单包装UC
                    this.SetRowCell(rowNum, 5, orderDetail.UnitCount.ToString("0.########"));

                    //需求 Request	包装
                    int UCs = (int)Math.Ceiling(orderDetail.OrderedQty / orderDetail.UnitCount);
                    this.SetRowCell(rowNum, 6, UCs.ToString());

                    //需求 Request	零件数
                    this.SetRowCell(rowNum, 7, orderDetail.OrderedQty.ToString("0.########"));

                    //发货数
                    this.SetRowCell(rowNum, 8, orderDetail.ShippedQty.HasValue ? orderDetail.ShippedQty.Value.ToString("0.########") : string.Empty);

                    //实收 Received	包装
                    this.SetRowCell(rowNum, 9, "");

                    //实收 Received	零件数
                    this.SetRowCell(rowNum, 10, orderDetail.ReceivedQty.HasValue ? orderDetail.ReceivedQty.Value.ToString("0.########") : string.Empty);

                    //批号/备注
                    this.SetRowCell(rowNum, 11, "");


                    if (i != 0 && // 第一行,模版有一页,所以不处理
                        (i % detailRowCount == 0 ||    // 非第一页,当页最后一行
                         (i > detailRowCount && i == (orderDetails.Count - 1))))      // 非第一页,明细最后一条
                    {
                        //非第一页,明细最后一条
                        if (i > detailRowCount && i == (orderDetails.Count - 1))
                        {// 补足空行
                            //需要补白的行数
                            rowNum = this.FillBlankLine(detailRowCount, rowNum, i);
                        }
                        if (i == detailRowCount)
                        {// 第一页
                            rowNum += 3;
                        }
                        else
                        {
                            // 第一页的尾部三行模版中有了,第二页以后需要手动加入
                            rowNum = this.FillPagefooting(rowNum);
                        }
                    }
                    else if (i == 0)
                    {
                        this.SetRowCellFormula(49, 6, "SUM(G16:G49)");
                    }
                }
                #endregion

                if (orderHead.IsPrinted == null || orderHead.IsPrinted == false)
                {
                    orderHead.IsPrinted = true;
                    orderHeadMgr.UpdateOrderHead(orderHead);
                }
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 7
0
        protected override bool FillValuesImpl(String templateFileName, IList <object> list)
        {
            try
            {
                if (list == null || list.Count < 2)
                {
                    return(false);
                }

                OrderHead           orderHead    = (OrderHead)(list[0]);
                IList <OrderDetail> orderDetails = (IList <OrderDetail>)(list[1]);


                if (orderHead == null ||
                    orderDetails == null || orderDetails.Count == 0)
                {
                    return(false);
                }

                this.CopyPage(orderDetails.Count);

                this.FillHead(orderHead);

                //自动换行
                //style.WrapText = true;

                int pageIndex = 1;
                int rowIndex  = 0;
                int rowTotal  = 0;
                foreach (OrderDetail orderDetail in orderDetails)
                {
                    //Item
                    this.SetRowCell(pageIndex, rowIndex, 0, "" + (rowIndex + 1));

                    //Part No.
                    this.SetRowCell(pageIndex, rowIndex, 1, orderDetail.ReferenceItemCode);
                    //QAD
                    this.SetRowCell(pageIndex, rowIndex, 2, orderDetail.Item.Code);
                    //Description
                    this.SetRowCell(pageIndex, rowIndex, 3, orderDetail.Item.Description);
                    //Quantity
                    this.SetRowCell(pageIndex, rowIndex, 4, orderDetail.OrderedQty.ToString("0.########"));
                    this.SetRowCell(pageIndex, rowIndex, 5, orderDetail.Uom.Code);
                    //Unit Price
                    this.SetRowCell(pageIndex, rowIndex, 6, orderDetail.PriceListDetailFrom == null ? "" : orderDetail.PriceListDetailFrom.UnitPrice.ToString("0.########"));
                    //Total //=G3*E3
                    this.SetRowCell(pageIndex, rowIndex, 7, orderDetail.PriceListDetailFrom == null ? 0 : Double.Parse((orderDetail.OrderedQty * orderDetail.PriceListDetailFrom.UnitPrice).ToString("0.########")));

                    if (this.isPageBottom(rowIndex, rowTotal))//页的最后一行
                    {
                        this.SetRowCellFormula(this.GetRowIndexAbsolute(pageIndex, this.pageDetailRowCount), 7, "SUBTOTAL(9,H" + (this.GetRowIndexAbsolute(pageIndex, 0) + 1) + ":H" + (this.GetRowIndexAbsolute(pageIndex, this.pageDetailRowCount)) + ")");

                        pageIndex++;
                        rowIndex = 0;
                    }
                    else
                    {
                        rowIndex++;
                    }
                    rowTotal++;
                }

                this.sheet.DisplayGridlines = false;
                this.sheet.IsPrintGridlines = false;

                if (orderHead.IsPrinted == null || orderHead.IsPrinted == false)
                {
                    orderHead.IsPrinted = true;
                    orderHeadMgr.UpdateOrderHead(orderHead);
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }