Ejemplo n.º 1
0
        public int CreateBarcode(string strBarcode, string strBarcodeHeader)
        {
            //initiate BarcodeWriter
            var barcodeWriter = new BarcodeWriter
            {
                //set barcode format
                Format = BarcodeFormat.CODE_128
            };
            int    PageNo    = 0;
            string imagefile = AppDomain.CurrentDomain.BaseDirectory + @"\Utilities\HTML\Barcodes\barcode-";

            if (BarcodeType.ToUpper() == "TXN")
            {
                // Taking a string
                String str = strBarcode;

                char[] spearator = { ',' };

                String[] strlist      = str.Split(spearator, StringSplitOptions.None);
                int      totalBarcode = strlist.Count() - 1; // removed last comma ,

                if (totalBarcode % 33 == 0)                  /*Get MOD*/
                {
                    PageNo = totalBarcode / 33;
                }
                else
                {
                    PageNo = totalBarcode / 33 + 1;
                }

                int i = 1;
                //to create barcode images in template
                foreach (String s in strlist)
                {
                    if (!string.IsNullOrWhiteSpace(s))
                    {
                        barcodeWriter
                        .Write(s)
                        .Save(imagefile + i + ".bmp");

                        i++;
                    }
                }
                //to create blank images for remaining barcodes in template of 99 barcodes
                for (; i <= PageNo * 33; i++)
                {
                    CreateHeaderFile("", imagefile + i + ".bmp");
                }
            }
            else if (BarcodeType.ToUpper() == "EOS")
            {
                barcodeWriter
                .Write(strBarcode)
                .Save(imagefile + "EOS.bmp");
            }
            else if (BarcodeType.ToUpper() == "DOC" || BarcodeType.ToUpper() == "APP")
            {
                barcodeWriter
                .Write(strBarcode)
                .Save(imagefile + "DOC.bmp");

                CreateHeaderFile(strBarcodeHeader, "");
            }
            else if (BarcodeType.ToUpper() == "CIF")
            {
                barcodeWriter
                .Write("BE" + strBarcode)
                .Save(imagefile + "CIFBarcode.bmp");

                // Taking a string
                String strCIFInfo = CIFInformation;
                CreateCIFBarcode(strCIFInfo, imagefile);
            }

            return(PageNo);
        }