Ejemplo n.º 1
0
        public void StartPrinting()
        {
            char ESC = '\u001B';

            _printer.TransactionPrint(PrinterStation.Receipt, PrinterTransactionControl.Transaction);
            _printer.PrintNormal(PrinterStation.Receipt, ESC + "|N");
        }
Ejemplo n.º 2
0
 public void ImprimirVenta(Cventa oVenta, Ccaja_diaria oCaja)
 {
     try
     {
         string strDate = DateTime.Now.ToString("dd/MM/yyyy  HH:mm");
         if (_oPrinter.CapRecPresent == true)
         {
             _oPrinter.TransactionPrint(PrinterStation.Receipt, PrinterTransactionControl.Transaction);
             _oPrinter.PrintNormal(PrinterStation.Receipt, "\u001b|cA" + "X\n");
             _oPrinter.PrintNormal(PrinterStation.Receipt, "\u001b|cA" + "Documento no valido como factura\n");
             _oPrinter.PrintNormal(PrinterStation.Receipt, "\u001b|N" + "Caja:" + oCaja.ID + " " + oVenta.ID);
             _oPrinter.PrintNormal(PrinterStation.Receipt, "\u001b|rA" + strDate + "\n");
             _oPrinter.PrintNormal(PrinterStation.Receipt, "\u001b|200uF");
             foreach (Citem oItem in oVenta.Items())
             {
                 _oPrinter.PrintNormal(PrinterStation.Receipt, "\u001b|N" + oItem.Cantidad + " " + oItem.Articulo.Descripcion);
                 _oPrinter.PrintNormal(PrinterStation.Receipt, "\u001b|rA" + "$" + oItem.Total + "\n");
             }
             _oPrinter.PrintNormal(PrinterStation.Receipt, "\u001b|200uF");
             if (oVenta.DescRecargo != 0)
             {
                 _oPrinter.PrintNormal(PrinterStation.Receipt, "\u001b|N" + "Subtotal:");
                 _oPrinter.PrintNormal(PrinterStation.Receipt, "\u001b|rA" + "$" + oVenta.Subtotal + "\n");
                 if (oVenta.DescRecargo > 0)
                 {
                     _oPrinter.PrintNormal(PrinterStation.Receipt, "\u001b|N" + "Recargo:");
                 }
                 else
                 {
                     _oPrinter.PrintNormal(PrinterStation.Receipt, "\u001b|N" + "Descuento:");
                 }
                 _oPrinter.PrintNormal(PrinterStation.Receipt, "\u001b|rA" + "$" + oVenta.DescRecargo + "\n");
             }
             _oPrinter.PrintNormal(PrinterStation.Receipt, "\u001b|N" + "Total:");
             _oPrinter.PrintNormal(PrinterStation.Receipt, "\u001b|bC" + "\u001b|rA" + "$" + oVenta.Total + "\n");
             _oPrinter.PrintNormal(PrinterStation.Receipt, "\u001b|3000uF");
             if (_oPrinter.CapRecPaperCut == true)
             {
                 _oPrinter.CutPaper(100);
             }
             _oPrinter.TransactionPrint(PrinterStation.Receipt, PrinterTransactionControl.Normal);
         }
     }
     catch (PosControlException ex)
     {
         throw new Exception("Error al imprimir una venta." + ex.Message);
     }
 }
Ejemplo n.º 3
0
 private void TransactionPrintButton_Click(object sender, System.EventArgs e)
 {
     try
     {
         _printer.TransactionPrint(CurrentStation, CurrentTransaction);
     }
     catch (Exception ae)
     {
         ShowException(ae);
     }
 }
        public void PrintKeys(List <BarcodeItem> bItems)
        {
            //Batch processing mode
            m_Printer.TransactionPrint(PrinterStation.Receipt, PrinterTransactionControl.Transaction);

            foreach (BarcodeItem bItem in bItems)
            {
                PrintKey(bItem.GUID, bItem.KeyName, bItem.Minutes, false);
            }

            //print all the buffer data. and exit the batch processing mode.
            m_Printer.TransactionPrint(PrinterStation.Receipt, PrinterTransactionControl.Normal);
        }
Ejemplo n.º 5
0
 public void TransactionStart()
 {
     m_Printer.TransactionPrint(PrinterStation.Receipt, PrinterTransactionControl.Transaction);
 }
Ejemplo n.º 6
0
        public bool print(int printNum)  //打印内容
        {
            bool status    = false;
            int  mPrintNum = 1;

            //foreach (Contract.Order inf in infoList)
            //{

            mPrintNum = printNum;
            //Initialization
            string iHeader  = @"***功夫团膳***";
            string iOrderid = inf.orderID;
            //iOrderid = "TS02000201506060020";
            string iConsumer      = "顾客:" + inf.userName;
            string iAddress       = "地址:" + inf.userAddress;
            string iTelephone     = "电话:" + inf.userTelephone;
            string iRemark        = "备注:" + inf.ext;
            string iSalesSlip     = "发票: " + inf.invoiceTitle;
            string iSubmitTime    = "订单提交时间:" + inf.addTime;
            string iDeliveredTime = "预计送达时间:" + inf.bookTime;

            string iDivisionLine = "************************************************";
            /**************************************************/
            string iItemTitle = @"名称                      数量       原价(元) ";
            /****************************************************/
            string iItemDisTitle = @"优惠名称                  数量       优惠(元)";
            /*****************************************************/

            string iFreight        = "外 送 费:" + inf.freight;
            string iTotalAmount    = "订单合计:" + inf.totalAmount;
            string iDiscountAmount = "优惠金额:" + inf.discountAmount;
            string iPayAmount      = "应付金额:" + inf.payAmount;


            string payTypeStr = "";

            if (inf.payType.Equals(POS.Data.Contract.PAY_TYPE_WX))
            {
                payTypeStr = POS.Properties.Resources.PAY_TYPE_WX_str;
            }
            else if (inf.payType.Equals(POS.Data.Contract.PAY_TYPE_ALIPAY))
            {
                payTypeStr = POS.Properties.Resources.PAY_TYPE_ALIPAY_str;
            }
            else if (inf.payType.Equals(POS.Data.Contract.PAY_TYPE_BANK))
            {
                payTypeStr = POS.Properties.Resources.PAY_TYPE_BANK_str;
            }
            else if (inf.payType.Equals(POS.Data.Contract.PAY_TYPE_BALANCE))
            {
                payTypeStr = POS.Properties.Resources.PAY_TYPE_BALANCE_str;
            }
            else if (inf.payType.Equals(POS.Data.Contract.PAY_TYPE_CASH))
            {
                payTypeStr = POS.Properties.Resources.PAY_TYPE_CASH_str;
            }
            else if (inf.payType.Equals(POS.Data.Contract.PAY_TYPE_DEBT))
            {
                payTypeStr = POS.Properties.Resources.PAY_TYPE_DEBT_str;
            }

            string iPayType = "支付方式:" + payTypeStr;

            string iCash = "应收现金:" + inf.payAmount;

            /***************   订单编码  ************/
            string foot1 = "感谢惠顾功夫团膳";
            string foot2 = "功夫团膳餐厅" + inf.storeID;
            string foot3 = "查询电话:" + inf.storeTelephone;

            int[] RecLineChars = new int[MAX_LINE_WIDTHS] {
                0, 0
            };
            //When outputting to a printer,a mouse cursor becomes like a hourglass.
            //Cursor.Current = Cursors.WaitCursor;

            for (int i = 0; i < mPrintNum; i++)
            {
                if (m_Printer.CapRecPresent)
                {
                    if (async == true)
                    {
                        m_Printer.AsyncMode = true;
                    }

                    try
                    {
                        //for (int i = 0; i < printNum; i++ )
                        //{
                        //<<<step6>>>--Start
                        //Batch processing mode
                        m_Printer.TransactionPrint(PrinterStation.Receipt
                                                   , PrinterTransactionControl.Transaction);

                        //<<<step3>>>--Start
                        //m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|1B");
                        //<<<step3>>>--End

                        m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|cA" + "\u001b|bC" + "\u001b|2C"
                                              + iHeader + "\n");
                        m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|200uF");
                        m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|cA" + "\u001b|bC"
                                              + iOrderid + "\n");

                        m_Printer.PrintNormal(PrinterStation.Receipt, iConsumer + "\n");
                        m_Printer.PrintNormal(PrinterStation.Receipt, iAddress + "\n");
                        m_Printer.PrintNormal(PrinterStation.Receipt, iTelephone + "\n");
                        m_Printer.PrintNormal(PrinterStation.Receipt, iRemark + "\n");
                        m_Printer.PrintNormal(PrinterStation.Receipt, iSalesSlip + "\n");


                        //m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|80uF");
                        m_Printer.PrintNormal(PrinterStation.Receipt, iSubmitTime + "\n");
                        m_Printer.PrintNormal(PrinterStation.Receipt, iDeliveredTime + "\n");
                        m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|300uF");

                        m_Printer.PrintNormal(PrinterStation.Receipt, iDivisionLine + "\n");
                        m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|100uF");
                        m_Printer.PrintNormal(PrinterStation.Receipt, iItemTitle + "\n");
                        //foreach (Contract.Product p in inf.productList)
                        //{
                        //    string printData = MakePrintString(m_Printer.RecLineChars, p.productName, p.productNum, p.totalPrice);
                        //    m_Printer.PrintNormal(PrinterStation.Receipt, printData + "\n");
                        //}
                        //m_Printer.PrintNormal(PrinterStation.Receipt, iDivisionLine + "\n");
                        //m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|100uF");
                        //m_Printer.PrintNormal(PrinterStation.Receipt, iItemDisTitle + "\n");
                        //foreach (Contract.DiscountProduct p in inf.discountProductList)
                        //{
                        //    string printData = MakePrintString(m_Printer.RecLineChars, p.discountName, p.discountNum, p.discountAmount);
                        //    m_Printer.PrintNormal(PrinterStation.Receipt, printData + "\n");
                        //}
                        m_Printer.PrintNormal(PrinterStation.Receipt, iDivisionLine + "\n");
                        m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|100uF");

                        m_Printer.PrintNormal(PrinterStation.Receipt, iFreight + "\n");
                        m_Printer.PrintNormal(PrinterStation.Receipt, iTotalAmount + "\n");
                        m_Printer.PrintNormal(PrinterStation.Receipt, iDiscountAmount + "\n");
                        m_Printer.PrintNormal(PrinterStation.Receipt, iPayAmount + "\n");
                        m_Printer.PrintNormal(PrinterStation.Receipt, iPayType + "\n");
                        m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|200uF");
                        m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|4C" + "\u001b|bC"
                                              + iCash + "\n");

                        m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|200uF");

                        if (m_Printer.CapRecBarCode == true)
                        {
                            //Barcode printing
                            //Barcode CODE128 MAX LENGTH IS <=23
                            m_Printer.PrintBarCode(PrinterStation.Receipt,
                                                   iOrderid,
                                                   BarCodeSymbology.Code128, 1000,
                                                   m_Printer.RecLineWidth, PosPrinter.PrinterBarCodeCenter,
                                                   BarCodeTextPosition.None);
                        }
                        m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|200uF");
                        m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|cA" + "\u001b|4C"
                                              + foot1 + "\n");
                        m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|100uF");
                        m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|cA"
                                              + foot2 + "\n");
                        m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|300uF");
                        m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|cA"
                                              + foot3 + "\n");

                        m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|fP");

                        //print all the buffer data. and exit the batch processing mode.
                        m_Printer.TransactionPrint(PrinterStation.Receipt
                                                   , PrinterTransactionControl.Normal);
                        status = true;

                        //<<<step6>>>--End
                    }
                    // }
                    catch (PosControlException e)
                    {
                        status = false;
                        Console.WriteLine("**********************************");
                        Console.WriteLine(e.ErrorCode);
                        Console.WriteLine("+++++++++++++++++++++++++++++++++++");
                        System.IO.File.AppendAllText(@"C:\hot.txt", DateTime.Now.ToString() + ": " + e.ToString() + "\r\n");
                    }
                    if (status)
                    {
                        //string suffix = DateTime.Today.ToString(SQLiteHelper.DateSuffixFormat);
                        //mSQLiteHelper.UpdateOrder(iOrderid, POS.Data.Contract.ORDER_STATUS_PRODUCING);
                        //mForm.RefreshDisplay();
                    }
                }
                m_Printer.AsyncMode = false;
            }

            //<<<step6>>>--Start
            // When a cursor is back to its default shape, it means the process ends
            //Cursor.Current = Cursors.Default;
            //<<<step6>>>--End
        }