Exemplo n.º 1
0
        /**
         * 填充报表
         *
         * Param list [0]huDetailList
         */
        public override bool FillValues(String templateFileName, IList <object> list)
        {
            try
            {
                this.init(templateFileName, ROW_COUNT);

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

                IList <Hu> huList   = (IList <Hu>)list[0];
                string     userName = "";
                if (list.Count == 2)
                {
                    userName = (string)list[1];
                }

                int count = 0;
                foreach (Hu hu in huList)
                {
                    if (hu.Item.Type.Equals("M") || hu.Item.Type.Equals("P"))
                    {
                        count++;
                    }
                }
                if (count == 0)
                {
                    return(false);
                }

                this.barCodeFontName = this.GetBarcodeFontName(0, 0);

                int pageCount = (int)Math.Ceiling(count / (PAGE_DETAIL_ROW_COUNT * 1.0));

                /*
                 * for (int rowNum = 0; rowNum < 25; rowNum += 12)
                 * {
                 *  this.SetRowCellBarCode(1, rowNum, 0);
                 *  this.SetRowCellBarCode(1, rowNum, 7);
                 *  this.SetRowCellBarCode(1, rowNum, 14);
                 * }
                 */
                this.CopyPage(pageCount, COLUMN_COUNT, 1);


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

                /*
                 * 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;
                int num       = 1;

                string companyCode = entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_COMPANY_CODE).Value;
                if (companyCode == null)
                {
                    companyCode = string.Empty;
                }

                //成品
                cellStyle1 = workbook.CreateCellStyle();
                Font font = workbook.CreateFont();
                font.FontName           = "宋体";
                font.FontHeightInPoints = 24;
                font.Boldweight         = (short)NPOI.SS.UserModel.FontBoldWeight.BOLD;
                cellStyle1.SetFont(font);
                cellStyle1.Alignment         = NPOI.SS.UserModel.HorizontalAlignment.CENTER;
                cellStyle1.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.TOP;
                cellStyle1.Rotation          = (short)-90;

                //原材料画方框
                cellStyle2 = workbook.CreateCellStyle();
                cellStyle2.BorderBottom = NPOI.SS.UserModel.CellBorderType.NONE;
                cellStyle2.BorderLeft   = NPOI.SS.UserModel.CellBorderType.THIN;
                cellStyle2.BorderRight  = NPOI.SS.UserModel.CellBorderType.THIN;
                cellStyle2.BorderTop    = NPOI.SS.UserModel.CellBorderType.THIN;

                //原材料画方框
                cellStyle3              = workbook.CreateCellStyle();
                cellStyle3.BorderLeft   = NPOI.SS.UserModel.CellBorderType.THIN;
                cellStyle3.BorderRight  = NPOI.SS.UserModel.CellBorderType.THIN;
                cellStyle3.BorderBottom = NPOI.SS.UserModel.CellBorderType.THIN;
                cellStyle3.BorderTop    = NPOI.SS.UserModel.CellBorderType.NONE;

                foreach (Hu hu in huList)
                {
                    //3行每行3个
                    if (hu.Item.Type.Equals("M") || hu.Item.Type.Equals("P"))
                    {
                        this.writeContent(companyCode, userName, pageIndex, num, hu);

                        if (num == count || num % PAGE_DETAIL_ROW_COUNT == 0)
                        {
                            pageIndex++;
                        }
                        num++;
                    }

                    /*
                     * if ( num == huList.Count + 1)
                     * {
                     *  for (int i = 1; i <= (PAGE_DETAIL_ROW_COUNT - (num % PAGE_DETAIL_ROW_COUNT)); i++)
                     *  {
                     *      //YFKSS
                     *      //this.SetRowCell(pageIndex - 1, 1, 4, string.Empty, i);
                     *      //PART NO.
                     *      this.CopyCell(pageIndex - 1, this.getRowIndex(2, num - 1 + i), 0, "");
                     *      this.SetRowCell(pageIndex - 1, 2, 0, string.Empty, num - 1 + i);
                     *      //LOT/SERIAL NO.
                     *      this.CopyCell(pageIndex - 1, this.getRowIndex(4, num - 1 + i), 0, "");
                     *      this.SetRowCell(pageIndex - 1, 4, 0, string.Empty, num - 1 + i);
                     *      //PRINTED DATE:
                     *      this.CopyCell(pageIndex - 1, this.getRowIndex(10, num - 1 + i), 0, "");
                     *      this.SetRowCell(pageIndex - 1, 10, 0, string.Empty, num - 1 + i);
                     *      //PRINTER USER:
                     *      this.CopyCell(pageIndex - 1, this.getRowIndex(10, num - 1 + i), 2, "");
                     *      this.SetRowCell(pageIndex - 1, 10, 2, string.Empty, num - 1 + i);
                     *  }
                     *
                     * }
                     */
                }


                foreach (Hu hu in huList)
                {
                    if (hu.Item.Type.Equals("P") || hu.Item.Type.Equals("M")) //原材料
                    {
                        huMgr.UpdateHu(hu);
                    }
                }
            }
            catch (Exception e)
            {
                return(false);
            }

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

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

                IList <Hu> huList   = (IList <Hu>)list[0];
                string     userName = "";
                if (list.Count == 2)
                {
                    userName = (string)list[1];
                }

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

                //this.sheet.DisplayGuts = false;

                int count = 0;
                foreach (Hu hu in huList)
                {
                    if (hu.Item.Type.Equals("M") ||  //成品
                        hu.Item.Type.Equals("P"))            //原材料
                    {
                        count++;
                    }
                }

                if (count == 0)
                {
                    return(false);
                }

                this.barCodeFontName = this.GetBarcodeFontName(0, 0);

                //加页删页
                this.CopyPage(count, COLUMN_COUNT, 1);

                int pageIndex = 1;

                string companyCode = entityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_COMPANY_CODE).Value;
                if (companyCode == null)
                {
                    companyCode = string.Empty;
                }

                foreach (Hu hu in huList)
                {
                    if (hu.Item.Type.Equals("M"))     //成品
                    {
                        if (hu.PrintCount > 1)
                        {
                            this.SetRowCell(pageIndex, 1, 3, "(R)");
                        }
                        hu.PrintCount += 1;

                        //YFKSS
                        int rowIndexAbsolute = this.GetRowIndexAbsolute(pageIndex, 1);
                        this.SetMergedRegion(pageIndex, 1, 4, 9, 4);
                        this.SetRowCell(pageIndex, 1, 4, companyCode);
                        Cell      cell      = this.GetCell(rowIndexAbsolute, 4);
                        CellStyle cellStyle = workbook.CreateCellStyle();
                        Font      font      = workbook.CreateFont();
                        font.FontName           = "宋体";
                        font.FontHeightInPoints = 24;
                        font.Boldweight         = (short)NPOI.SS.UserModel.FontBoldWeight.BOLD;
                        cellStyle.SetFont(font);
                        cellStyle.Alignment         = NPOI.SS.UserModel.HorizontalAlignment.CENTER;
                        cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.TOP;
                        cellStyle.Rotation          = (short)-90;
                        cell.CellStyle = workbook.CreateCellStyle();
                        cell.CellStyle.CloneStyleFrom(cellStyle);

                        //hu id内容
                        string barCode = Utility.BarcodeHelper.GetBarcodeStr(hu.HuId, this.barCodeFontName);
                        this.SetRowCell(pageIndex, 0, 0, barCode);

                        //hu id内容
                        this.SetRowCell(pageIndex, 1, 0, hu.HuId);

                        //PART NO.内容
                        this.SetRowCell(pageIndex, 3, 0, hu.Item.Code);

                        //SHIFT
                        this.SetRowCell(pageIndex, 4, 2, "SHIFT");

                        //QUANTITY.
                        this.SetRowCell(pageIndex, 4, 3, "QUANTITY.");

                        //批号LotNo
                        this.SetRowCell(pageIndex, 5, 0, hu.LotNo);


                        //SHIFT内容
                        this.SetRowCell(pageIndex, 5, 2, Utility.BarcodeHelper.GetShiftCode(hu.HuId));

                        //QUANTITY内容
                        this.SetRowCell(pageIndex, 5, 3, hu.Qty.ToString("0.########"));

                        //CUSTPART
                        this.SetRowCell(pageIndex, 6, 0, "CUSTPART");

                        //WO DATE
                        this.SetRowCell(pageIndex, 6, 3, "WO DATE");

                        //CUSTPART内容
                        IList <ItemReference> itemReferenceList = itemReferenceMgr.GetItemReference(hu.Item.Code);
                        if (itemReferenceList != null && itemReferenceList.Count > 0)
                        {
                            this.SetRowCell(pageIndex, 7, 0, itemReferenceList[0].ReferenceCode);
                        }
                        //WO DATE内容
                        this.SetRowCell(pageIndex, 7, 3, hu.ManufactureDate.ToString("MM/dd/yy"));

                        //DESCRIPTION.
                        this.SetRowCell(pageIndex, 8, 0, "DESCRIPTION.");

                        //DESCRIPTION内容
                        this.SetRowCell(pageIndex, 9, 0, hu.Item.Description);

                        //PRINTED DATE:内容
                        this.SetRowCell(pageIndex, 10, 1, DateTime.Now.ToString("MM/dd/yy"));

                        //print name 内容
                        this.SetRowCell(pageIndex, 10, 3, userName);



                        this.sheet.SetRowBreak(this.GetRowIndexAbsolute(pageIndex, ROW_COUNT - 1));
                        pageIndex++;
                    }
                    else if (hu.Item.Type.Equals("P"))     //原材料
                    {
                        if (hu.PrintCount > 1)
                        {
                            this.SetRowCell(pageIndex, 1, 3, "(R)");
                        }
                        hu.PrintCount += 1;

                        //hu id内容
                        string barCode = Utility.BarcodeHelper.GetBarcodeStr(hu.HuId, this.barCodeFontName);
                        this.SetRowCell(pageIndex, 0, 0, barCode);


                        //hu id内容
                        this.SetRowCell(pageIndex, 1, 0, hu.HuId);


                        //画方框
                        int       rowIndexAbsolute = this.GetRowIndexAbsolute(pageIndex, 2);
                        Cell      cell1            = this.GetCell(rowIndexAbsolute, 4);
                        CellStyle cellStyle1       = workbook.CreateCellStyle();
                        cellStyle1.BorderBottom = NPOI.SS.UserModel.CellBorderType.NONE;

                        cellStyle1.BorderLeft  = NPOI.SS.UserModel.CellBorderType.THIN;
                        cellStyle1.BorderRight = NPOI.SS.UserModel.CellBorderType.THIN;
                        cellStyle1.BorderTop   = NPOI.SS.UserModel.CellBorderType.THIN;
                        cell1.CellStyle        = workbook.CreateCellStyle();
                        cell1.CellStyle.CloneStyleFrom(cellStyle1);


                        //PART NO.内容
                        this.SetRowCell(pageIndex, 3, 0, hu.Item.Code);

                        //画方框
                        rowIndexAbsolute = this.GetRowIndexAbsolute(pageIndex, 3);
                        CellStyle cellStyle2 = workbook.CreateCellStyle();
                        Cell      cell2      = this.GetCell(rowIndexAbsolute, 4);
                        cellStyle2.BorderLeft   = NPOI.SS.UserModel.CellBorderType.THIN;
                        cellStyle2.BorderRight  = NPOI.SS.UserModel.CellBorderType.THIN;
                        cellStyle2.BorderBottom = NPOI.SS.UserModel.CellBorderType.THIN;
                        cellStyle2.BorderTop    = NPOI.SS.UserModel.CellBorderType.NONE;
                        cell2.CellStyle         = workbook.CreateCellStyle();
                        cell2.CellStyle.CloneStyleFrom(cellStyle2);


                        //QUANTITY.
                        this.SetRowCell(pageIndex, 4, 2, "QUANTITY.");

                        //批号LotNo
                        this.SetRowCell(pageIndex, 5, 0, hu.LotNo);

                        //QUANTITY.
                        this.SetRowCell(pageIndex, 5, 2, hu.Qty.ToString("0.########"));


                        //DESCRIPTION.
                        this.SetRowCell(pageIndex, 6, 0, "DESCRIPTION.");

                        //DESCRIPTION内容
                        this.SetRowCell(pageIndex, 7, 0, hu.Item.Description);

                        //SUPPLIER.
                        this.SetRowCell(pageIndex, 8, 0, "SUPPLIER.");

                        //SUPPLIER内容
                        this.SetRowCell(pageIndex, 9, 0, hu.ManufactureParty == null ? string.Empty : hu.ManufactureParty.Name);

                        //PRINTED DATE:内容
                        this.SetRowCell(pageIndex, 10, 1, DateTime.Now.ToString("MM/dd/yy"));

                        //print name 内容
                        this.SetRowCell(pageIndex, 10, 3, userName);

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

                foreach (Hu hu in huList)
                {
                    if (hu.Item.Type.Equals("M") || hu.Item.Type.Equals("P"))     //成品  //原材料
                    {
                        huMgr.UpdateHu(hu);
                    }
                }
            }
            catch (Exception e)
            {
                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 == 0)
                {
                    return(false);
                }

                IList <Hu> huList = (IList <Hu>)list[0];

                /*
                 * this.sheet.DefaultRowHeightInPoints = 12.00F;
                 * //this.sheet.DefaultColumnWidth = 7;
                 * //this.sheet.SetColumnWidth(1, 100 * 256);
                 * sheet.DefaultColumnWidth = 7;
                 * //sheet.DefaultRowHeight = 30 * 20;
                 *
                 * //sheet.PrintSetup.PaperSize =
                 * sheet.SetColumnWidth(0, 68 * 32);
                 * sheet.SetColumnWidth(1, 68 * 32);
                 * sheet.SetColumnWidth(2, 68 * 32);
                 * sheet.SetColumnWidth(3, 68 * 32);
                 * sheet.SetColumnWidth(4, 24 * 32);
                 */

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

                int count = 0;
                foreach (Hu hu in huList)
                {
                    if (hu.Item.Type.Equals("P"))     //原材料
                    {
                        count++;
                    }
                }

                if (count == 0)
                {
                    return(false);
                }

                this.barCodeFontName = this.GetBarcodeFontName(0, 0);

                //加页删页
                this.CopyPage(count, COLUMN_COUNT, 1);

                int pageIndex = 1;
                foreach (Hu hu in huList)
                {
                    if (hu.Item.Type.Equals("P"))     //原材料
                    {
                        if (hu.PrintCount > 1)
                        {
                            this.SetRowCell(pageIndex, 1, 4, "(R)");
                        }
                        hu.PrintCount += 1;

                        //hu id内容
                        string barCode = Utility.BarcodeHelper.GetBarcodeStr(hu.HuId, this.barCodeFontName);
                        this.SetRowCell(pageIndex, 0, 0, barCode);

                        //hu id内容
                        this.SetRowCell(pageIndex, 1, 0, hu.HuId);

                        //PRINTED DATE:内容
                        this.SetRowCell(pageIndex, 2, 3, DateTime.Now.ToString("MM/dd/yy"));

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

                foreach (Hu hu in huList)
                {
                    if (hu.Item.Type.Equals("P"))     //原材料
                    {
                        huMgr.UpdateHu(hu);
                    }
                }
            }
            catch (Exception e)
            {
                return(false);
            }

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

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

                IList <Hu> huList = (IList <Hu>)list[0];


                int pageCount = huList.Count;

                this.SetRowCellBarCode(0, 0, 0);

                //加页删页
                this.CopyPage(pageCount, COLUMN_COUNT, 1);

                int pageIndex = 1;
                foreach (Hu hu in huList)
                {
                    hu.PrintCount += 1;

                    string barCode = Utility.BarcodeHelper.GetBarcodeStr(hu.HuId, this.barCodeFontName);
                    //hu id
                    this.SetRowCell(pageIndex, 0, 0, barCode);

                    //hu id
                    this.SetRowCell(pageIndex, 1, 0, hu.HuId);

                    //零件号ItemNo
                    this.SetRowCell(pageIndex, 2, 1, hu.Item.Code);

                    //描述Desc
                    this.SetRowCell(pageIndex, 3, 1, hu.Item.Description);

                    //批号LotNo
                    this.SetRowCell(pageIndex, 4, 1, hu.LotNo);

                    //数量quantity
                    this.SetRowCell(pageIndex, 5, 1, hu.Qty.ToString("0.########"));

                    //单位Unit
                    this.SetRowCell(pageIndex, 5, 3, hu.Uom.Code);

                    //生产日期Manufacture date
                    this.SetRowCell(pageIndex, 6, 1, hu.ManufactureDate.ToString("yyyyMMdd"));

                    //生产商Manufacture
                    this.SetRowCell(pageIndex, 6, 3, hu.ManufactureParty == null ? string.Empty : hu.ManufactureParty.Name);

                    this.sheet.SetRowBreak(this.GetRowIndexAbsolute(pageIndex, 6));
                    pageIndex++;
                }

                foreach (Hu hu in huList)
                {
                    huMgr.UpdateHu(hu);
                }

                this.sheet.DisplayGridlines = false;
                this.sheet.IsPrintGridlines = false;
            }
            catch (Exception e)
            {
                return(false);
            }

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

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

                IList <Hu> huList   = (IList <Hu>)list[0];
                string     userName = "";
                if (list.Count == 2)
                {
                    userName = (string)list[1];
                }

                int count = 0;
                foreach (Hu hu in huList)
                {
                    if (hu.Item.Type.Equals("P"))
                    {
                        count++;
                    }
                }
                if (count == 0)
                {
                    return(false);
                }
                int pageCount = (int)Math.Ceiling(count / (PAGE_DETAIL_ROW_COUNT * 1.0));

                /*
                 * //十行 二个
                 * for (int rowNum = 0; rowNum < 37; rowNum += 4)
                 * {
                 *  this.SetRowCellBarCode(1, rowNum, 0);
                 *  this.SetRowCellBarCode(1, rowNum, 6);
                 * }
                 */

                this.barCodeFontName = this.GetBarcodeFontName(0, 0);

                //加页删页
                this.CopyPage(pageCount, COLUMN_COUNT, 1);

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

                int pageIndex = 1;
                int num       = 1;
                foreach (Hu hu in huList)
                {
                    //10行每行2个   //原材料
                    if (hu.Item.Type.Equals("P"))
                    {
                        this.writeContent(userName, pageIndex, num, hu);

                        if (num == count || num % PAGE_DETAIL_ROW_COUNT == 0)
                        {
                            pageIndex++;
                        }
                        num++;
                    }

                    /*
                     * if (num == huList.Count + 1)
                     * {
                     *  for (int i = 1; i <= (PAGE_DETAIL_ROW_COUNT - (num % PAGE_DETAIL_ROW_COUNT)); i++)
                     *  {
                     *      //PRINTED DATE:
                     *
                     *      this.CopyCell(pageIndex - 1, this.getRowIndex(2, num - 1 + i), 2, "");
                     *      this.SetRowCell(pageIndex - 1, 2, 2, string.Empty, num - 1 + i);
                     *  }
                     * }*/
                }

                foreach (Hu hu in huList)
                {
                    if (hu.Item.Type.Equals("P"))     //原材料
                    {
                        huMgr.UpdateHu(hu);
                    }
                }
            }
            catch (Exception e)
            {
                return(false);
            }

            return(true);
        }