Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="printText"></param>
        /// <param name="printJournal"></param>
        /// <returns></returns>
        public int PrintNormal(string printText, int printOpt)
        {
            if (printOpt == 0 || printOpt == 2)
            {
                string journalText = printText;
                journalText = journalText.Replace(FXConsts.PRINT_LOGO, string.Empty);
                journalText = journalText.Replace(FXConsts.PRINT_BOLDWIDE_DOUBLE, string.Empty);
                journalText = journalText.Replace(FXConsts.PRINT_BOLDWIDE_NORMAL, string.Empty);
                journalText = journalText.Replace(FXConsts.PRINT_CENTER, string.Empty);
                journalText = journalText.Replace(FXConsts.PRINT_HEIGHT_DOUBLE, string.Empty);
                journalText = journalText.Replace(FXConsts.PRINT_WH_DOUBLE, string.Empty);
                journalText = journalText.Replace(FXConsts.PRINT_NORMAL, string.Empty);

                string[] lines = journalText.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
                foreach (var line in lines)
                {
                    TraceHelper.Instance.JournalWrite(m_receiptName, line);

                    //여전법 추가 0808(KSK)
                    m_receiptName = string.Empty;
                }
            }

            if (printOpt == 1 || printOpt == 2)
            {
                // REPLACE CONTROL CHARACTER
                printText = printText.Replace(FXConsts.PRINT_LOGO, FXConsts.PRINT_LOGO_CHAR);
                printText = printText.Replace(FXConsts.PRINT_BOLDWIDE_DOUBLE, FXConsts.PRINT_BOLDWIDE_DOUBLE_CHAR);
                printText = printText.Replace(FXConsts.PRINT_BOLDWIDE_NORMAL, FXConsts.PRINT_BOLDWIDE_NORMAL_CHAR);
                printText = printText.Replace(FXConsts.PRINT_CENTER, FXConsts.PRINT_CENTER_CHAR);

                // 정광호 추가(2015.06.26)
                printText = printText.Replace(FXConsts.PRINT_HEIGHT_DOUBLE, FXConsts.PRINT_HEIGHT_DOUBLE_CHAR); //세로확대
                printText = printText.Replace(FXConsts.PRINT_WH_DOUBLE, FXConsts.PRINT_WH_DOUBLE_CHAR);         //가로세로확대
                printText = printText.Replace(FXConsts.PRINT_NORMAL, FXConsts.PRINT_NORMAL_CHAR);               //일반

                m_device.RecLineChars   = 44;
                m_device.RecLineSpacing = 30;
                m_device.PrintNormal((int)OPOSPOSPrinterConstants.PTR_S_RECEIPT, printText);

                //여전법 추가 0808(KSK)
                printText = "";
                printText = string.Empty;
            }

            return(0);
        }
Esempio n. 2
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            var Printer = new OPOSPOSPrinter();
            // Open the printer.
            int nRC = Printer.Open("DefaultPOSPrinter");

            // If succeeded, then claim.
            if (nRC == (int)OPOS_Constants.OPOS_SUCCESS)
            {
                nRC = Printer.ClaimDevice(1000);

                // If succeeded, then enable.
                if (nRC == (int)OPOS_Constants.OPOS_SUCCESS)
                {
                    Printer.DeviceEnabled = true;
                    nRC = Printer.ResultCode;
                }

                nRC = Printer.PrintNormal(2, "\x1B|cA\x1B|2COPOS POSPrinter\x1B|1C\nvia Microsoft.NET\n\n");
            }

            Printer.ReleaseDevice();
            nRC = Printer.Close();
        }
        public static void PrintNow(Model.ReceiptPrint rp)
        {
            OPOSPOSPrinter myPrinter = new OPOSPOSPrinter();

            myPrinter.Open("TM-T82MU");
            myPrinter.ClaimDevice(100);
            myPrinter.DeviceEnabled = true;

            if (myPrinter.DeviceEnabled == false)
            {
                Console.WriteLine(" ********* Printer Not Detect **********");
            }
            char ESC = (char)13;

            myPrinter.PrintNormal(2, rp.CompanyName + " " + rp.CompanyBranch + ESC);
            myPrinter.PrintNormal(2, rp.CompanyAddress + ESC);
            myPrinter.PrintNormal(2, rp.CompanyTel + " " + rp.CompanyFax + ESC);
            myPrinter.PrintNormal(2, rp.CompanyLineId + ESC);
            myPrinter.PrintNormal(2, "ใบกำกับภาษีอย่างย่อ" + ESC);
            myPrinter.PrintNormal(2, rp.CompanyTaxId + ESC);
            myPrinter.PrintNormal(2, rp.CompanyRegId + ESC);
            myPrinter.PrintNormal(2, "ราคารวมภาษีมูลค่าเพิ่มแล้ว                     #ยกเว้น" + ESC);
            myPrinter.PrintNormal(2, "------------------------------------------------" + ESC);
            foreach (var item in rp.ProductInReceipts)
            {
                myPrinter.PrintNormal(2, item.Name + ESC);
                string space1 = GetSpace(23, item.Code);
                string space2 = GetSpace(27, item.Qty + " X " + item.SalePrice + item.Total + item.ProductVatType);
                myPrinter.PrintNormal(2, item.Code + space1 + item.Qty + " X " + item.SalePrice + space2 + item.Total + item.ProductVatType + ESC);
            }
            int termSpace = 49;

            myPrinter.PrintNormal(2, "------------------------------------------------" + ESC);

            string space3 = GetSpace(termSpace, rp.TotalBalance + "รวม");

            myPrinter.PrintNormal(2, "รวม" + space3 + rp.TotalBalance + ESC);

            string space4 = GetSpace(termSpace, rp.TotalCash + "รับเงิน", 2);

            myPrinter.PrintNormal(2, "รับเงิน" + space4 + rp.TotalCash + ESC);

            string space5 = GetSpace(termSpace, rp.TotalChange + "ทอน");

            myPrinter.PrintNormal(2, "ทอน" + space5 + rp.TotalChange + ESC);

            termSpace = 20;
            string space = GetSpace(termSpace, "รหัสสมาชิก", 2);

            myPrinter.PrintNormal(2, "รหัสสมาชิก" + space + rp.MemberId + ESC);

            space = GetSpace(termSpace, "ชื่อสมาชิก", 3);
            myPrinter.PrintNormal(2, "ชื่อสมาชิก" + space + rp.MemberName + ESC);

            space = GetSpace(termSpace, "สินค้าไม่มีภาษี", 5);
            myPrinter.PrintNormal(2, "สินค้าไม่มีภาษี" + space + rp.TotalUnVat + ESC);

            space = GetSpace(termSpace, "สินค้ามีภาษี", 4);
            myPrinter.PrintNormal(2, "สินค้ามีภาษี" + space + rp.TotalHasVat + ESC);

            space = GetSpace(termSpace, "ภาษี", 1);
            myPrinter.PrintNormal(2, "ภาษี" + space + rp.TotalVat + ESC);

            space = GetSpace(termSpace, "รวมรายการ", 0);
            myPrinter.PrintNormal(2, "รวมรายการ" + space + rp.TotalList + ESC);

            space = GetSpace(termSpace, "รวมชิ้น", 2);
            myPrinter.PrintNormal(2, "รวมชิ้น" + space + rp.TotalUnit + ESC);

            myPrinter.PrintNormal(2, "          Thank you for shopping with us" + ESC);

            space = GetSpace(termSpace, "พนักงานขาย", 1);
            myPrinter.PrintNormal(2, "พนักงานขาย " + space + rp.CashierName + ESC);
            myPrinter.PrintNormal(2, "เลขที่ใบกำกับภาษี " + " " + rp.OrderNo + " " + rp.OrderDate + ESC);

            myPrinter.PrintNormal(2, "                 ขอบคุณที่ใช้บริการ" + ESC);

            myPrinter.PrintNormal(2, (char)27 + "|fP");

            myPrinter.DeviceEnabled = false;
            myPrinter.ReleaseDevice();
            myPrinter.Close();
        }