Пример #1
0
        public static void printModel(string content, BluetoothPrinter bluetoothPrinter)
        {
            if (string.IsNullOrEmpty(content) && bluetoothPrinter == null)
            {
                return;
            }
            List <PrintEntity> printEntities = JsonConvert.DeserializeObject <List <PrintEntity> >(content);

            if (printEntities != null && printEntities.Count > 0)
            {
                if (!bluetoothPrinter.isConnected())
                {
                    bluetoothPrinter.openConnection();
                }

                for (int i = 0; i < printEntities.Count; i++)
                {
                    if (string.IsNullOrEmpty(printEntities[i].isQRCode) || printEntities[i].isQRCode == "0")
                    {
                        logger.Info("bluetooth print:" + printEntities[i].content);
                        //add 2018年9月10日 增加换行
                        bluetoothPrinter.PrintString(printEntities[i].content + "\n");
                    }
                    else
                    {
                        //usb打印二维码可能会出现问题 所以直接不打印
                        //usbPrinter.printQRCode(printEntities[i].content);
                    }
                }
            }
            bluetoothPrinter.PrintString("\n\n\n\n\n\n");
            //bluetoothPrinter.PrintString(content);
        }
Пример #2
0
        internal static void printNote(StatisticsVM statisticsVM, BluetoothPrinter mPrinter)
        {
            if (statisticsVM == null)
            {
                return;
            }
            if (mPrinter == null)
            {
                return;
            }
            if (mPrinter.CurrentPrintType == PrinterType.TIII || mPrinter.CurrentPrintType == PrinterType.T5)
            {
                mPrinter.PrintString("             收银对账             \n");
            }
            else
            {
                mPrinter.PrintString("                      收银对账                    \n");
            }
            StringBuilder sb = new StringBuilder();

            if (mPrinter.CurrentPrintType == PrinterType.TIII || mPrinter.CurrentPrintType == PrinterType.T5)
            {
                sb.Append("------------------------------\n");
            }
            else
            {
                sb.Append("----------------------------------------------\n");
            }
            sb.Append(Resources.R.branch_name + statisticsVM.branchname + "\n");
            sb.Append(Resources.R.time + DateTime.Now.ToString("D") + "\n");
            sb.Append(Resources.R.date_time + statisticsVM.starttime + "至" + statisticsVM.endtime + "\n");
            sb.Append(Resources.R.shop_cashier_num + statisticsVM.cashiername + "\n");
            sb.Append(Resources.R.ticketnums + statisticsVM.ticketnums + "\n");
            sb.Append(Resources.R.ticketamount + statisticsVM.ticketamount + "\n");
            sb.Append(Resources.R.returnnums + statisticsVM.returnnums + "\n");
            sb.Append(Resources.R.returnamount + statisticsVM.returnamount + "\n");
            sb.Append(Resources.R.rechargeamount + statisticsVM.rechargeamount + "\n");
            sb.Append(Resources.R.subtotal + statisticsVM.subtotal + "\n");
            if (mPrinter.CurrentPrintType == PrinterType.TIII || mPrinter.CurrentPrintType == PrinterType.T5)
            {
                sb.Append("------------------------------\n");
            }
            else
            {
                sb.Append("----------------------------------------------\n");
            }
            mPrinter.PrintString(sb.ToString());

            StringBuilder sbtb = new StringBuilder();

            sbtb.Append(tableFormat(Resources.R.payType, true, 15, false));
            sbtb.Append(tableFormat(Resources.R.mumber, false, 8, false));
            sbtb.Append(tableFormat(Resources.R.money, false, 8, false));
            sbtb.Append("\n");
            sbtb.Append(tableFormat("现金", true, 15, false));
            sbtb.Append(tableFormat(statisticsVM.cashnums, false, 8, true));
            sbtb.Append(tableFormat(statisticsVM.cashamount, false, 8, true));
            sbtb.Append("\n");
            sbtb.Append(tableFormat("支付宝", true, 15, false));
            sbtb.Append(tableFormat(statisticsVM.alinums, false, 8, true));
            sbtb.Append(tableFormat(statisticsVM.aliamount, false, 8, true));
            sbtb.Append("\n");
            sbtb.Append(tableFormat("微信", true, 15, false));
            sbtb.Append(tableFormat(statisticsVM.wxnums, false, 8, true));
            sbtb.Append(tableFormat(statisticsVM.wxamount, false, 8, true));
            sbtb.Append("\n");

            foreach (ZidingyizhifuBean zidingyizhifuBean in statisticsVM.zidingyizhifu)
            {
                sbtb.Append(tableFormat(zidingyizhifuBean.zidingyiname, true, 15, false));
                sbtb.Append(tableFormat(zidingyizhifuBean.zidingyinums, false, 8, true));
                sbtb.Append(tableFormat(zidingyizhifuBean.zidingyiamount, false, 8, true));
                sbtb.Append("\n");
            }
            sbtb.Append(tableFormat("合计", true, 15, false));
            sbtb.Append(tableFormat("", false, 8, true));
            sbtb.Append(tableFormat(statisticsVM.subtotal, false, 8, true));
            sbtb.Append("\n\n\n");
            mPrinter.PrintString(sbtb.ToString());
            mPrinter.PrintString("\n\n\n\n\n");
        }