public void PrintTest() { m_Printer.PrintBarCode(PrinterStation.Receipt, "{BpoJ2Kav5gUmX6+m/9zTQSQ", BarCodeSymbology.Code128, 2400, m_Printer.RecLineWidth, PosPrinter.PrinterBarCodeCenter, BarCodeTextPosition.None); m_Printer.PrintNormal(PrinterStation.Receipt, "\u001b|fP"); }
private void btnPrintBarcode_Click(object sender, System.EventArgs e) { try { int alignment; if (cbAlignment.Text == "Left") { alignment = PosPrinter.PrinterBarCodeLeft; } else if (cbAlignment.Text == "Center") { alignment = PosPrinter.PrinterBarCodeCenter; } else if (cbAlignment.Text == "Right") { alignment = PosPrinter.PrinterBarCodeRight; } else { alignment = int.Parse(cbAlignment.Text); } _printer.PrintBarCode(CurrentStation, TextToPrint.Text, (BarCodeSymbology)Enum.Parse(typeof(BarCodeSymbology), cbSymbology.Text), int.Parse(tbHeight.Text), int.Parse(tbWidth.Text), alignment, (BarCodeTextPosition)Enum.Parse(typeof(BarCodeTextPosition), cbTextPosition.Text)); } catch (Exception ae) { ShowException(ae); } }
public void Execute(PosPrinter printer, PrinterStation station) { if (!printer.CapRecBarCode && station == PrinterStation.Receipt || !printer.CapSlpBarCode && station == PrinterStation.Slip) { return; } var alignment = 0; switch (Alignment) { case Alignment.Center: alignment = PosPrinter.PrinterBarCodeCenter; break; case Alignment.Left: alignment = PosPrinter.PrinterBarCodeLeft; break; case Alignment.Right: alignment = PosPrinter.PrinterBarCodeRight; break; } printer.PrintBarCode(station, Data, Symbology, Height, Width, alignment, TextPosition); }
public void Execute(PosPrinter printer) { var alignment = 0; switch (Alignment) { case Alignment.Center: alignment = PosPrinter.PrinterBarCodeCenter; break; case Alignment.Left: alignment = PosPrinter.PrinterBarCodeLeft; break; case Alignment.Right: alignment = PosPrinter.PrinterBarCodeRight; break; } printer.PrintBarCode(PrinterStation.Receipt, Data, Symbology, Height, Width, alignment, TextPosition); }
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 }