Пример #1
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 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);
        }