コード例 #1
0
ファイル: TaskInForm.cs プロジェクト: SaintLoong/PFK
        private void btnBarcode_Click(object sender, EventArgs e)
        {
            if (dgvMaster.CurrentRow != null)
            {
                DataRow masterRow = ((DataRowView)dgvMaster.CurrentRow.DataBoundItem).Row;
                DataTable barcodeTable = new ProductStateDal().GetBarcodes(masterRow["BILLNO"].ToString());
                BarcodePrinter printer = new BarcodePrinter();

                DialogResult dr = THOKUtil.ShowQuery2("ѡ����(Y)����ӡѡ����ⵥ��ѡ�񡰷�(N)����ӡѡ����ǩ��ѡ��ȡ������ִ�д�ӡ������");
                switch (dr)
                {
                    case DialogResult.Yes:
                        printer.Print(barcodeTable);

                        break;
                    case DialogResult.No:
                        if (dgvDetail.CurrentRow != null)
                        {
                            DataRow detailRow = ((DataRowView)dgvDetail.CurrentRow.DataBoundItem).Row;
                            printer.Print(barcodeTable, detailRow["BARCODE"].ToString());
                        }
                        break;

                }
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            // Prepare Barcode object that will generate barcodes for printing
            var barcode = new Barcode();

            barcode.RegistrationName = "demo";
            barcode.RegistrationKey  = "demo";
            barcode.Symbology        = SymbologyType.EAN13;
            barcode.DrawCaption      = true;
            barcode.BarHeight        = 50;
            barcode.DrawQuietZones   = false;
            barcode.Margins          = new Margins(20, 20, 20, 20);

            // Prepare BarcodePrinter object
            var barcodePrinter = new BarcodePrinter();

            // Set printer paper size
            barcodePrinter.SetPaperSize("A4");
            // Set number of barcodes on a page: 4 lines of 4 barcodes per line = 16 barcodes per page
            barcodePrinter.SetGrid(4, 4);
            // Fit barcodes into the grid cell size
            barcodePrinter.FitBarcodesIntoGrid = true;
            // Set some optional printing params
            //barcodePrinter.SetMargins(20, 0, 0, 20);
            //barcodePrinter.Copies = 2;
            //barcodePrinter.Collate = true;
            //barcodePrinter.Color = false;

            // Generate 25 barcode values in EAN13 format "5901234NNNNN"
            // and add them to the BarcodePrinter
            var barcodeValues = Enumerable.Range(1, 25).Select(n => "5901234" + n.ToString("00000")).ToList();

            barcodePrinter.AddBarcodeValues(barcodeValues);

            // Print barcodes to the specified printer
            barcodePrinter.Print(barcode, "Microsoft Print to PDF");
        }
コード例 #3
0
        public void PrintParkingTicket()
        {
            try
            {
                if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto)
                {
                    MessageBox.Show("Sorry this option is not applicable for Auto-Print receipt.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
                    return;
                }
                if (!mboIsInTransaction)
                {
                    MessageBox.Show("No active transaction is found! Please transact first.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
                    return;
                }
                DialogResult loginresult = GetWriteAccess(mclsSalesTransactionDetails.CashierID, AccessTypes.CloseTransaction);

                if (loginresult == DialogResult.None)
                {
                    LogInWnd login = new LogInWnd();

                    login.AccessType = AccessTypes.CloseTransaction;
                    login.Header = "Print Parking Ticket Access Validation";
                    login.TerminalDetails = mclsTerminalDetails;
                    login.ShowDialog(this);
                    loginresult = login.Result;
                    login.Close();
                    login.Dispose();
                }
                if (loginresult == DialogResult.OK)
                {
                    PrintingPreference oldCONFIG_AutoPrint = mclsTerminalDetails.AutoPrint;
                    mclsTerminalDetails.AutoPrint = PrintingPreference.Normal;

                    PrintReportHeaderSection(true, DateTime.MinValue);
                    mboIsItemHeaderPrinted = true;

                    AceSoft.BarcodePrinter clsBarcodePrinter = new BarcodePrinter();
                    if (mclsTerminalDetails.IsPrinterDotMatrix)
                    {
                        msbToPrint.Append(clsBarcodePrinter.GenerateBarCode(mclsSalesTransactionDetails.TransactionNo, AceSoft.printerModel.EpsonTest, barcodeType.EAN13) + Environment.NewLine);
                        msbToPrint.Append(CenterString("-/- PARKING TICKET -/-", mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                        msbToPrint.Append(CenterString("NOT VALID AS RECEIPT", mclsTerminalDetails.MaxReceiptWidth) + Environment.NewLine);
                    }
                    else
                    {
                        msbToPrint.Append(clsBarcodePrinter.GenerateBarCode(mclsSalesTransactionDetails.TransactionNo, AceSoft.printerModel.Epson, barcodeType.EAN13) + Environment.NewLine);
                        msbToPrint.Append(RawPrinterHelper.escBoldHOn + CenterString("-/- PARKING TICKET -/-", mclsTerminalDetails.MaxReceiptWidth) + RawPrinterHelper.escBoldHOff + Environment.NewLine);
                        msbToPrint.Append(RawPrinterHelper.escBoldHOn + CenterString("NOT VALID AS RECEIPT", mclsTerminalDetails.MaxReceiptWidth) + RawPrinterHelper.escBoldHOff + Environment.NewLine);
                    }
                    PrintReportPageHeaderSection(true);

                    msbToPrint.Append(Environment.NewLine + RawPrinterHelper.escEmphasizedOn + CenterString("TIME IN: " + mclsSalesTransactionDetails.TransactionDate.ToString("MM/dd/yyyy hh:mm tt"), mclsTerminalDetails.MaxReceiptWidth) + RawPrinterHelper.escEmphasizedOff + Environment.NewLine + Environment.NewLine);

                    PrintReportFooterSection(false, TransactionStatus.ParkingTicket, mclsSalesTransactionDetails.ItemSold, mclsSalesTransactionDetails.QuantitySold, mclsSalesTransactionDetails.SubTotal, mclsSalesTransactionDetails.Discount, mclsSalesTransactionDetails.Charge, 0, 0, 0, 0, 0, 0, 0, 0, 0, null, null, null, null);

                    mboIsItemHeaderPrinted = false;
                    mclsTerminalDetails.AutoPrint = oldCONFIG_AutoPrint;
                }
            }
            catch (Exception ex)
            {
                InsertErrorLogToFile(ex, "ERROR!!! Printing Parking Slip: ");
            }
            Cursor.Current = Cursors.Default;
        }
コード例 #4
0
ファイル: AlcoholizeForm.cs プロジェクト: SaintLoong/PFK
 private void btnBarcode_Click(object sender, EventArgs e)
 {
     if (dgvMaster.CurrentRow != null)
     {
         DataRow masterRow = ((DataRowView)dgvMaster.CurrentRow.DataBoundItem).Row;
         DataTable barcodeTable = new ProductStateDal().GetBarcodes(masterRow["BILLNO"].ToString(), UserID);
         BarcodePrinter printer = new BarcodePrinter();
         printer.Print(barcodeTable);
     }
 }