예제 #1
0
        private void PrintDocument1_PrintPage(object sender, PrintPageEventArgs e)
        {
            string strBarcode = txtMa_Vt.Text;
            string strTen1    = txtTen_Vt2.Text;
            //string strTen2 = txtTen_Vt.Text;
            //string strTen2 = String.Format("{0:0,0 vnđ}", numGia_Ban.Value);
            string strTen2 = txtTen_Vt.Text + "\n" + String.Format("{0:0,0 vnđ}", numGia_Ban.Value);

            try
            {
                Graphics g    = e.Graphics;
                float    left = e.MarginBounds.Left;
                float    num3 = 10f;
                float    num5 = 0f;
                Ean13    ean  = new Ean13
                {
                    CountryCode      = strBarcode.Substring(0, 2),
                    ManufacturerCode = strBarcode.Substring(2, 5),
                    ProductCode      = strBarcode.Substring(7, 5),
                    strChecksumDigit = strBarcode.Substring(12, 1),
                    _fScale          = 1f
                };
                int   num  = 0;
                int   numH = 0;
                float a    = 0.5f;
                do
                {
                    num5 = num3 + (num * 0x16);
                    Point pt = new Point((int)Math.Round((double)(left + 50f)), (int)Math.Round((double)num5));
                    ean.DrawEan13BarcodeView(g, pt, strTen1, strTen2, 7, 0f);
                    //PointF pt = new PointF((int)Math.Round((double)(left + 50f)), (int)Math.Round((double)num5)-a*numH);
                    //ean.DrawEan13BarcodeView(g, pt, strTen1, strTen2, 5, 0f);
                    num++;
                    numH += 2;
                }while (num <= 12);
                g.Dispose();
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
            }
        }
예제 #2
0
        private void DrawEan13(string S, ref string BARCODE)
        {
            //string strTen1 = txtTen_Vt2.Text;
            ////string strTen2 = txtTen_Vt.Text;
            ////string strTen2 = String.Format("{0:0,0 vnđ}", numGia_Ban.Value);
            //string strTen2 = txtTen_Vt.Text + "\n" + String.Format("{0:0,0 vnđ}", numGia_Ban.Value);
            //try
            //{
            //    Graphics g = this.picBarCode.CreateGraphics();
            //    Rectangle rect = new Rectangle(0, 0, this.picBarCode.Width, this.picBarCode.Height);
            //    g.FillRectangle(new SolidBrush(Color.White), rect);
            //    BARCODEClassEAN13 sean = new BARCODEClassEAN13
            //    {
            //        CountryCode = S.Substring(0, 2),
            //        ManufacturerCode = S.Substring(2, 5),
            //        ProductCode = S.Substring(7),
            //        _fScale = 1.5f
            //    };
            //    Point pt = new Point(0, 4);
            //    sean.DrawEan13Barcode(ref g, pt, ref BARCODE, strTen1, strTen2);



            //    g.Dispose();
            //}
            //catch (Exception exception1)
            //{

            //    Exception exception = exception1;
            //}


            string strBarcode = txtMa_Vt.Text;
            string strTen1    = txtTen_Vt2.Text;
            //string strTen2 = txtTen_Vt.Text;
            //string strTen2 = String.Format("{0:0,0 vnđ}", numGia_Ban.Value);
            string strTen2 = txtTen_Vt.Text + "\n" + String.Format("{0:0,0 vnđ}", numGia_Ban.Value);

            try
            {
                Graphics  g    = this.picBarCode.CreateGraphics();
                Rectangle rect = new Rectangle(0, 0, this.picBarCode.Width, this.picBarCode.Height);
                g.FillRectangle(new SolidBrush(Color.White), rect);

                Ean13 ean = new Ean13
                {
                    CountryCode      = strBarcode.Substring(0, 2),
                    ManufacturerCode = strBarcode.Substring(2, 5),
                    ProductCode      = strBarcode.Substring(7, 5),
                    strChecksumDigit = strBarcode.Substring(12, 1),
                    _fScale          = 1f
                };


                Point pt = new Point(0, 0);
                ean.DrawEan13BarcodeView(g, pt, strTen1, strTen2, 1, 0f);

                g.Dispose();
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
            }
        }