public void PrintLineItem(OposPOSPrinter_CCO.OPOSPOSPrinter printer, string itemCode, int quantity, double unitPrice)
 {
     PrintText(printer, TruncateAt(itemCode.PadRight(9), 9));
     PrintText(printer, TruncateAt(quantity.ToString("#0.00").PadLeft(9), 9));
     PrintText(printer, TruncateAt(unitPrice.ToString("#0.00").PadLeft(10), 10));
     PrintTextLine(printer, TruncateAt((quantity * unitPrice).ToString("#0.00").PadLeft(10), 10));
 }
Esempio n. 2
0
        public Boolean PrintOPOS(string strPrinterName, string strData)
        {
            Boolean bRet   = true;
            string  strErr = "";

            try
            {
                if (axOPOSPOSPrinter1 == null)
                {
                    axOPOSPOSPrinter1 = new OposPOSPrinter_CCO.OPOSPOSPrinter();
                }
                int lRet = axOPOSPOSPrinter1.Open(strPrinterName); // LDN

                if (lRet == OPOS_SUCCESS)
                {
                    lRet = axOPOSPOSPrinter1.ClaimDevice(0);
                    if (lRet == OPOS_SUCCESS)
                    {
                        axOPOSPOSPrinter1.DeviceEnabled = true;
                        axOPOSPOSPrinter1.FlagWhenIdle  = true;

                        string strCharLists = axOPOSPOSPrinter1.RecBarCodeRotationList;
                        //StrCharLists is pair (Font A, Font B)//F312 48,64
                        //m_ctlPosPrinter1.SetRecLineChars(48); //select a Font A
                        axOPOSPOSPrinter1.RecLineChars = 64; //select a Font B

                        axOPOSPOSPrinter1.AsyncMode = false;
                        axOPOSPOSPrinter1.PrintNormal(PTR_S_RECEIPT, strData);

                        axOPOSPOSPrinter1.CutPaper(95);
                    }
                    else
                    {
                        strErr = "OPOSPrinter Claim Error : " + axOPOSPOSPrinter1.ErrorString;
                        //AfxMessageBox(strErr);
                        // return FALSE;
                    }
                    axOPOSPOSPrinter1.Close();
                }
                else
                {
                    strErr = "OPOSPrinter Open Error : " + axOPOSPOSPrinter1.ErrorString;
                    // AfxMessageBox(strErr);
                    //return FALSE;
                }
            }
            catch (Exception e)
            {
                if (axOPOSPOSPrinter1 != null)
                {
                    strErr = "OPOSPrinter Open Error : " + axOPOSPOSPrinter1.ErrorString;
                }
                else
                {
                    strErr = "OPOSPrinter is null Error :" + e.Message;
                }
            }
            return(bRet);
        }
 public void PrintText(OposPOSPrinter_CCO.OPOSPOSPrinter printer, string text)
 {
     if (text.Length <= printer.RecLineChars)
     {
         printer.PrintNormal(PTR_S_RECEIPT, text); //Print text
     }
     else if (text.Length > printer.RecLineChars)
     {
         printer.PrintNormal(PTR_S_RECEIPT, TruncateAt(text, printer.RecLineChars)); //Print exactly as many characters as the printer allows, truncating the rest.
     }
 }
 public void PrintTextLine(OposPOSPrinter_CCO.OPOSPOSPrinter printer, string text)
 {
     if (text.Length < printer.RecLineChars)
     {
         printer.PrintNormal(PTR_S_RECEIPT, text + Environment.NewLine); //Print text, then a new line character.
     }
     else if (text.Length > printer.RecLineChars)
     {
         printer.PrintNormal(PTR_S_RECEIPT, TruncateAt(text, printer.RecLineChars)); //Print exactly as many characters as the printer allows, truncating the rest, no new line character (printer will probably auto-feed for us)
     }
     else if (text.Length == printer.RecLineChars)
     {
         printer.PrintNormal(PTR_S_RECEIPT, text + Environment.NewLine); //Print text, no new line character, printer will probably auto-feed for us.
     }
 }
        public Boolean PrintOPOS(string strPrinterName, string parameter, int flag)
        {
            Boolean bRet   = true;
            string  strErr = "";

            try
            {
                if (axOPOSPOSPrinter1 == null)
                {
                    axOPOSPOSPrinter1 = new OposPOSPrinter_CCO.OPOSPOSPrinter();
                }
                int lRet = axOPOSPOSPrinter1.Open(strPrinterName); // LDN

                if (lRet == OPOS_SUCCESS)
                {
                    lRet = axOPOSPOSPrinter1.ClaimDevice(0);
                    if (lRet == OPOS_SUCCESS)
                    {
                        axOPOSPOSPrinter1.DeviceEnabled = true;
                        axOPOSPOSPrinter1.FlagWhenIdle  = true;

                        string strCharLists = axOPOSPOSPrinter1.RecBarCodeRotationList;
                        //StrCharLists is pair (Font A, Font B)//F312 48,64
                        //m_ctlPosPrinter1.SetRecLineChars(48); //select a Font A
                        axOPOSPOSPrinter1.RecLineChars = 64; //select a Font B
                        axOPOSPOSPrinter1.AsyncMode    = false;

                        ///////////////////////////////////////////////////////
                        //Constants.LOGGER_MAIN.Info("flag : " + flag + "-->" + parameter);
                        JObject json = JObject.Parse(parameter);

                        if (flag == 1 || flag == 3) // Issue
                        {
                            if (flag == 3)
                            {
                                axOPOSPOSPrinter1.PrintNormal(PTR_S_RECEIPT, ESC + "|2C" + ESC + "|cA" + "** Re-print **" + CRLF);
                            }

                            PrintHeader();
                            PrintRetailerDetails(json["retailer_name"].ToString(), json["gst_no"].ToString());
                            PrintDocIdDetails(json["doc_id"].ToString(), json["issue_date"].ToString());
                            TouristPassportDetails(json["passport_number"].ToString(), json["country_code"].ToString());
                            PurchaseDetails(json["purchase_list"].ToString());
                            TotalAmountDetails(json["sales_amt"].ToString(), json["gst_amt"].ToString(), json["service_amt"].ToString(), json["refund_amt"].ToString());
                            Identifier(json["doc_id"].ToString(), json["token_type"].ToString(), json["token_display"].ToString());
                            PrintFooter(json["doc_id"].ToString());
                        }
                        else if (flag == 2)         // Void
                        {
                            axOPOSPOSPrinter1.PrintNormal(PTR_S_RECEIPT, CRLF);
                            axOPOSPOSPrinter1.PrintNormal(PTR_S_RECEIPT, ESC + "|2C" + ESC + "|cA" + "** Void **" + CRLF);
                            PrintRetailerDetails(json["retailer_name"].ToString(), json["gst_no"].ToString());
                            Void_PrintDocIdDetails(json["doc_id"].ToString(), json["issue_date"].ToString());
                            Void_PurchaseDetails(json["purchase_list"].ToString());
                            Void_TotalAmountDetails(json["sales_amt"].ToString(), json["gst_amt"].ToString(), json["service_amt"].ToString(), json["refund_amt"].ToString());
                            axOPOSPOSPrinter1.PrintNormal(PTR_S_RECEIPT, CRLF + CRLF + CRLF + CRLF + CRLF + CRLF);
                        }
                        ///////////////////////////////////////////////////////

                        axOPOSPOSPrinter1.CutPaper(95);
                    }
                    else
                    {
                        strErr = "OPOSPrinter Claim Error : " + axOPOSPOSPrinter1.ErrorString;
                        //AfxMessageBox(strErr);
                        // return FALSE;
                    }
                    axOPOSPOSPrinter1.Close();
                }
                else
                {
                    strErr = "OPOSPrinter Open Error : " + axOPOSPOSPrinter1.ErrorString;
                    // AfxMessageBox(strErr);
                    //return FALSE;
                }
            }
            catch (Exception ex)
            {
                if (axOPOSPOSPrinter1 != null)
                {
                    strErr = "OPOSPrinter Open Error : " + axOPOSPOSPrinter1.ErrorString;
                }
                else
                {
                    strErr = "OPOSPrinter is null Error :" + ex.Message;
                }

                Constants.LOGGER_MAIN.Error(strErr);
                Constants.LOGGER_MAIN.Error(ex.StackTrace);
            }
            return(bRet);
        }