using System;
using System.Collections;
using System.Data;

using Cosmos.UserFrame;
using Cosmos.ServiceProvider;
using Cosmos.Common;
using Cosmos.CommonManager;

/*-----------------------------------------------------------------------------------------------*/
// 설      명 : 거래 완료 처리
// 작  성  자 : 
// 변경  이력 : 
/*-----------------------------------------------------------------------------------------------*/
namespace Cosmos.Service
{
    public class SaleComplete : ISaleCompleteUs
    {
        private SManager sManager = new SManager();                                 //0 객체를 통해 업무 Service 호출
        private StateServer StateObject = (StateServer)StateServer.GetInstance();   //StateObject:StateServer Object(객체)
        private PosStatus m_cPosStatus = new PosStatus();                           //기본정보 참조
        private TranStatus m_cTrnStatus = new TranStatus();                         //거래정보 참조
        private DeviceStatus m_cDevStatus = new DeviceStatus();

        private DataService m_cDataService = null;
        private MakeTranLog m_cTranService = null;
        private PosSaleExact m_cExactService = null;
        private IDatabaseSQL m_cSqlDbService = null;
        private ICashdrawerUs m_cCashDrawer = null;

        private IDataCommonUs m_cDataCommon = null;                                 // POS 공통함수 인터페이스

        private PosReceipt m_cRecService = null;
        private PosReceiptOpenClose m_cRecOpenClose = null;
        private PosReceiptOrderSheet m_cRecOrderSheet = null;                       // Add, 2017.02.13, 주문서-영수증프린터 출력

        //#20180202 결제영수증 발행 안해도 직전영수증 발행시 해당 영수증 출력 start
        private PosReceiptBase m_cPosRecBase = null;
        //#20180202 결제영수증 발행 안해도 직전영수증 발행시 해당 영수증 출력 end

        /// <summary>
        /// 생성자
        /// </summary>
        public SaleComplete()
        {
            m_cPosStatus = (PosStatus)StateObject.POS;      // POS 기본정보
            m_cTrnStatus = (TranStatus)StateObject.TRAN;    // POS 거래정보
            m_cDevStatus = (DeviceStatus)StateObject.DEVICE;

            m_cDataService = (DataService)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_SERVICE);
            m_cTranService = (MakeTranLog)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.MAKE_TRANLOG);

            m_cExactService = (PosSaleExact)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.POS_SALE_EXACT);
            m_cSqlDbService = (IDatabaseSQL)sManager.InitServiceInstance(ServiceLists.AGENT_DATABASE.DLL, ServiceLists.AGENT_DATABASE.DATABASE_MSSQL);

            m_cRecService = (PosReceipt)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.POS_RECEIPT);
            m_cRecOpenClose = (PosReceiptOpenClose)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.POS_RECEIPTOPENCLOSE);
            m_cRecOrderSheet = (PosReceiptOrderSheet)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.POS_RECEIPT_ORDERSHEET);         // Add, 2017.02.13

            m_cCashDrawer = (ICashdrawerUs)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_CASHDRAWER);
            m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON);

            //#20180202 결제영수증 발행 안해도 직전영수증 발행시 해당 영수증 출력 start
            m_cPosRecBase = (PosReceiptBase)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.POS_RECEIPT_BASE);
            //#20180202 결제영수증 발행 안해도 직전영수증 발행시 해당 영수증 출력 end

        }

        /// <summary>
        /// 거래완료 처리()
        /// </summary>
        /// <returns></returns>
        public string Execute(string[] aParam)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                m_cDataService.SetTranBaseToHead();            //트란 헤더 정보 재설정

                //영수증 데이터 생성

                //거래데이터 저장

                //영수증 출력 처리

                //저널 데이터 저장

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }

        /// <summary>
        /// 거래완료 처리(영업개시,영업종료,로그온,로그오프...)
        /// </summary>
        /// <returns></returns>
        public string OpenCloseExecute(string[] aParam)
        {
            string sRet = UserCom.RST_ERR;
            string sPrintFlag = "1";
            try
            {
                m_cDataService.SetTranBaseToHead();            //트란 헤더 정보 재설정

                //  2019-04-24 - 1997fx11 : 마감시 정산지 출력여부 수정요망
                if (aParam.Length > 0)
                {
                    sPrintFlag = aParam[0];
                }

                if (sPrintFlag != "0")
                {
                    // 영수증 출력 데이터 생성
                    sRet = m_cRecOpenClose.MakeOpenClose(new string[] { });
                    if (sRet != UserCom.RST_OK)
                    {
                        UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                            System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() MakePrt.", sRet);
                    }
                }

                // 거래데이터 저장
                sRet = m_cTranService.SaveTranExecute(new string[] { "0" });
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() SaveTran.", sRet);

                    WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0004);
                    return sRet;
                }

                if (sPrintFlag != "0")
                {
                    // 영수증 출력
                    sRet = m_cRecOpenClose.ExecutePrint( aParam );
                    if (sRet != UserCom.RST_OK)
                    {
                        UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                            System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() ExecPrt.", sRet);
                    }

                    // 저널데이터 저장
                    sRet = m_cRecOpenClose.SaveJnlExecute(new string[] { });
                    if (sRet != UserCom.RST_OK)
                    {
                        UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                            System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() SaveJnl.", sRet);
                    }
                }

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }

        /// <summary>
        /// 거래완료 처리(판매)
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public string PosSaleExecute(string[] aParam)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                m_cDataService.SetTranBaseToHead();            //트란 헤더 정보 재설정

                UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                        "MakePosSaleReceipt" + " - TradeDiv : " + m_cTrnStatus.Head.TradeDiv + " ,TradeNo : " + m_cTrnStatus.Head.TradeNo);
 
                // 영수증 출력 데이터 생성
                sRet = m_cRecService.MakePosSaleReceipt(new string[] { });
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() MakeRec.", sRet);
                }

                UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "SaveTranExecute" + " - TradeDiv : " + m_cTrnStatus.Head.TradeDiv + " ,TradeNo : " + m_cTrnStatus.Head.TradeNo);

                // 거래데이터 저장
                sRet = m_cTranService.SaveTranExecute(new string[] { "0" });
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() SaveTran.", sRet);

                    WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0004);
                    return sRet;
                }

                // 돈통 오픈 처리
                //bool bOpenDrawer = false;
                //ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
                //foreach (Column.TR_PAYMENT.DATA cPayItem in alPayItem)
                //{
                //    if (cPayItem.CANCEL_DIV == ItemConst.PAY_CANCEL_DIV.CANCEL) continue;

                //    switch (cPayItem.PAY_WAY_CD)
                //    {
                //        case ItemConst.TR_ITEM_ID.CASH_ITEM:
                //        case ItemConst.TR_ITEM_ID.GIFT_ITEM:
                //        case ItemConst.TR_ITEM_ID.CHECK_ITEM:
                //            bOpenDrawer = true;
                //            break;
                //    }
                //    if (bOpenDrawer == true) break;
                //}

                //if (bOpenDrawer == true)
                //{
                //    if (m_cPosStatus.Base.TrainingFlag != "1")  //연습모드가 아니면!
                //        m_cCashDrawer.OpenCashDrawer(); // 돈통 OPEN 처리
                //}

                UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "SaveJnlExecute" + " - TradeDiv : " + m_cTrnStatus.Head.TradeDiv + " ,TradeNo : " + m_cTrnStatus.Head.TradeNo);

                //grayber@20180212 해피포인트 전자영수증 I/F 개선 #13924 start
                // 추가
                Hashtable htHPC_APPR_INFO = new Hashtable();
                TrHpcInfoSave(ItemConst.TR_ITEM_ID.ETC_INFO.SAVEPOINT, ref htHPC_APPR_INFO);//적립
                TrHpcInfoSave(ItemConst.TR_ITEM_ID.POINT_USE.HAPPY_POINT, ref htHPC_APPR_INFO);//사용

                // 저널데이터 저장
                // 기존
                //sRet = m_cRecService.SaveJnlExecute(new string[] { });
                // 변경
                sRet = m_cRecService.SaveJnlExecute(new string[] { htHPC_APPR_INFO["HPC_SAVE_APPR_DT"].ToString()
                                                                  ,htHPC_APPR_INFO["HPC_SAVE_APPR_NO"].ToString()
                                                                  ,htHPC_APPR_INFO["HPC_USE_APPR_DT"].ToString()
                                                                  ,htHPC_APPR_INFO["HPC_USE_APPR_NO"].ToString()});

                //grayber@20180212 해피포인트 전자영수증 I/F 개선 #13924 end
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() SaveJnl.", sRet);
                }

                //170811 dkshin 돈통 오픈 처리 시점 변경(현금영수증 전)
                // 돈통 오픈 처리
                /*if (FinishTradeOpenDrawer() == true)
                {
                    UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "OpenCashDrawer");

                    m_cCashDrawer.OpenCashDrawer(); // 돈통 OPEN 처리
                }*/

                UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "bExecBillPrint");

                bool bExecBillPrint = true;
                if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.LOG.HOLD_DEAL || m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.LOG.STOP)
                {
                    //보류 및 거래 중지(취소) 아니면 처리 요청사항!
                    bExecBillPrint = false;
                }
                else if (BillPrintRequiredCheck() == true)
                {
                    // 필수출력(캠페인할인, 영수증 이벤트)
                }
                //17.08.22 dkshin SS 해피오더 - 매출 처리 영수증 출력 하지 않음.
                else if (m_cTrnStatus.Sale.SSHappyOrderSalePrint)
                {
                    bExecBillPrint = false;
                }
                else
                {
                    //#20171017 전자영수증 발행 start, phj
                    //기존
                    /*
                    if (PosMstManager.GetPosOption(POS_OPTION.OPT416) == "2")         // 영수증 발행 유무(0 : 미 출력, 1 : 출력, 2: 확인)
                    {
                        bExecBillPrint = WinManager.CountDownQuestionMessage(POS_MESSAGE.ERROR.MSG_0369);
                    }
                    else if (PosMstManager.GetPosOption(POS_OPTION.OPT416) == "0")    // 영수증 발행 유무(0 : 미 출력, 1 : 출력, 2: 확인)
                    {
                        double nBillAmt = CmUtil.DoubleParse(PosMstManager.GetPosOption(POS_OPTION.OPT417));
                        if (m_cTrnStatus.Head.NetSaleAmt <= nBillAmt) bExecBillPrint = false;
                    }           
                    */

                    //변경
                    //(HP고객)해피앱 조회 전문 결과에 따른 영수증 발행/미발행 처리
                    //(HP 비고객) 결제 완료 시 판매사원에 의한 영수증 발행/미발행 처리

                    //전자영수증발행여부체크
                    string ElectronicReceiptYN = CheckElectronic_Receipt().ToString();

                    if ((PosMstManager.GetPosOption(POS_OPTION.OPT429) == "1") &&//전자영수증발행여부체크
                        (m_cTrnStatus.Head.TradeDiv != ItemConst.TRAN_DIV.REFUND) &&//일반
                        (ElectronicReceiptYN == "1"))// 1 : 전자영수증설정 (판매영수증미발행) , 0 : 미설정 (판매영수증발행)
                    {
                        //#20180226 영수증 미출력시 기타영수증 출력 되도록 수정 start
                        //소스 위치 변경
                        /*
                        // grayber@20180110 전자영수증 주문(대기)번호표 출력 start - 주문 대기표 출력
                        // 추가
                        // grayber@20180112 전자영수증 주문(대기)번호표 출력 start - 인터페이스 처리
                        //sRet = m_cRecService.ExcuteElectroBillOrderNoReceipt();   // 인터페이스에 추가하여 수정
                        sRet = ExcuteElectroBillOrderNoReceipt();
                        // grayber@20180112 전자영수증 주문(대기)번호표 출력 end

                        if (sRet.Equals(UserCom.RST_OK) != true)
                        {
                            UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                            System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() ExcuteElectroBillOrderNoReceipt.", sRet);
                        }
                        // grayber@20180110 전자영수증 주문(대기)번호표 출력 end
                        */
                        //#20180226 영수증 미출력시 기타영수증 출력 되도록 수정 end

                        bExecBillPrint = false;

                        //#14941 스마트영수증 대상고객 안내기능 도입 start
                        WinManager.CountDownConfirmMessage(POS_MESSAGE.ERROR.MSG_0806);
                        //#14941 스마트영수증 대상고객 안내기능 도입 end
                    }
                    else
                    {
                        if (PosMstManager.GetPosOption(POS_OPTION.OPT416) == "2")         // 영수증 발행 유무(0 : 미 출력, 1 : 출력, 2: 확인)
                        {
                            bExecBillPrint = WinManager.CountDownQuestionMessage(POS_MESSAGE.ERROR.MSG_0369);
                        }
                        else if (PosMstManager.GetPosOption(POS_OPTION.OPT416) == "0")    // 영수증 발행 유무(0 : 미 출력, 1 : 출력, 2: 확인)
                        {
                            double nBillAmt = CmUtil.DoubleParse(PosMstManager.GetPosOption(POS_OPTION.OPT417));
                            if (m_cTrnStatus.Head.NetSaleAmt <= nBillAmt) bExecBillPrint = false;
                        }
                    }
                    //#20171017 전자영수증 발행 end, phj
                }

                if (bExecBillPrint == true)
                {
                    UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "ExecutePrint" + " - TradeDiv : " + m_cTrnStatus.Head.TradeDiv + " ,TradeNo : " + m_cTrnStatus.Head.TradeNo);

                    // 영수증 출력
                    sRet = m_cRecService.ExecutePrint(new string[] { "SALE" });
                    if (sRet != UserCom.RST_OK)
                    {
                        UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                            System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() ExecPrt.", sRet);
                    }
                    //#20181024 대기(주문)번호표 출력 start
                    /*
                    if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.NORMAL.SALE)
                    {
                        if (PosMstManager.GetPosOption(POS_OPTION.OPT432).Equals("1") == true)
                        {
                            System.Threading.Thread.Sleep(3000);

                            //대기번호 영수증 데이터 생성
                            sRet = ExcuteElectroBillOrderNoReceipt(true);

                            if (sRet.Equals(UserCom.RST_OK) != true)
                            {
                                UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "ExcuteElectroBillOrderNoReceipt : " + sRet);
                            }

                            // 영수증 출력 RecPrtNo인 경우 m_aEtcPrintBuf만 출력
                            sRet = m_cRecService.ExecutePrint(new string[] { "SALE", "RecPrtNo" });
                            if (sRet != UserCom.RST_OK)
                            {
                                UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() ExecPrt.", sRet);
                            }
                        }
                    }
                    */
                    //#20181024 대기(주문)번호표 출력 end
                }
                //#20180202 결제영수증 발행 안해도 직전영수증 발행시 해당 영수증 출력 start
                
                else
                {
                    //#20180226 영수증 미출력시 기타영수증 출력 되도록 수정 start
                    //ex) 스탬프캠페인, 명판캠페인, 대기번호 등
                    //기존
                    //m_cPosRecBase.SaveReceiptFile();
                    //변경
                    UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "ExecutePrint : false" + " - TradeDiv : " + m_cTrnStatus.Head.TradeDiv + " ,TradeNo : " + m_cTrnStatus.Head.TradeNo);

                    //#20180228 매출거래인 경우만 영수증 미출력인 경우 기타영수증 출력 start
                    //해피포인트 추후적립이나 현금영수증 추후발행도 기타영수증에 포함되어 미출력인 경우 출력됨
                    if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.NORMAL.SALE)
                    {
                    //#20180228 매출거래인 경우만 영수증 미출력인 경우 기타영수증 출력 end

                        //grayber@20180227 대기번호표 출력 옵션 추가 start
                        if (PosMstManager.GetPosOption(POS_OPTION.OPT432).Equals("1") == true)
                        {
                            //대기번호 영수증 데이터 생성
                            //grayber@20180226  대기번호표 조건 변경 start - 파라매터 추가
                            // 기존
                            //sRet = ExcuteElectroBillOrderNoReceipt();
                            // 변경
                            sRet = ExcuteElectroBillOrderNoReceipt(true);
                            //grayber@20180226  대기번호표 조건 변경 end
                            if (sRet.Equals(UserCom.RST_OK) != true)
                            {
                                UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "ExcuteElectroBillOrderNoReceipt : " + sRet);
                            }
                        }

                        //grayber@20180227 대기번호표 출력 옵션 추가 end


                        // 영수증 출력 RecPrtNo인 경우 m_aEtcPrintBuf만 출력
                        sRet = m_cRecService.ExecutePrint(new string[] { "SALE", "RecPrtNo" });
                        if (sRet != UserCom.RST_OK)
                        {
                            UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() ExecPrt.", sRet);
                        }
                        //#20180226 영수증 미출력시 기타영수증 출력 되도록 수정 end
                    //#20180228 매출거래인 경우만 영수증 미출력인 경우 기타영수증 출력 start
                    }
                    //#20180228 매출거래인 경우만 영수증 미출력인 경우 기타영수증 출력 end

                }
                
                //#20180202 결제영수증 발행 안해도 직전영수증 발행시 해당 영수증 출력 end

                //// 저널데이터 저장
                //sRet = m_cRecService.SaveJnlExecute(new string[] { });
                //if (sRet != UserCom.RST_OK)
                //{
                //    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                //        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() SaveJnl.", sRet);
                //}
                
                #region 테이블 인터페이스용

                // 결제완료로 설정
                m_cPosStatus.Base.PaymentCompleteFlag = "1";

                #endregion

                //20171025 dkshin 전문 영수증번호 전거래의 영수증번호로 중복등록되는 문제 수정-> 거래 완료(PosSaleExecute) 후 처리
                IHappyAppStamp m_cHappyAppStamp = (IHappyAppStamp)sManager.InitServiceInstance(ServiceLists.BSV_SALE.DLL, ServiceLists.BSV_SALE.HPAPP_STAMP);
                m_cTrnStatus.Sale.HappyAppMemNo = m_cHappyAppStamp.CheckHappyAppStamp();
                //20171107 dkshin 정상,반품거래일때만 해피앱 스탬프 등록 가능하게 start
                /*if (m_cPosStatus.Base.TrainingFlag == "0" &&                  // 운영모드
                    PosMstManager.GetPosOption(POS_OPTION.OPT327) == "1" &&   // 해피앱 스탬프 사용
                    m_cTrnStatus.Sale.HappyAppMemNo != "")                    // 해피앱 회원번호 존재(해피앱 고객) 
                */
                if (m_cPosStatus.Base.TrainingFlag == "0" &&                  // 운영모드
                    PosMstManager.GetPosOption(POS_OPTION.OPT327) == "1" &&   // 해피앱 스탬프 사용
                    m_cTrnStatus.Sale.HappyAppMemNo != "" &&                  // 해피앱 회원번호 존재(해피앱 고객)
                    m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.NORMAL.SALE)
                {
                    // 해피앱 스탬프 등록
                    m_cHappyAppStamp.SetHappyAppStamp();
                }

                UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "TranComplete" + " - TradeDiv : " + m_cTrnStatus.Head.TradeDiv + " ,TradeNo : " + m_cTrnStatus.Head.TradeNo);

                // 거래데이터 완료 후 데이터 초기화 처리
                bool bIncTradeNo = m_cDataCommon.TradeNoAddCheck("");
                //bool bIncTradeNo = m_cTranService.TradeNoAddCheck();
                m_cDataService.TranComplete();
                m_cDataService.SetMsgNoInc(true, !bIncTradeNo, bIncTradeNo);      // 거래번호 증가

                UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "RecOrderSheet");

                // Add, 2017.02.13, 주방프린터와 영수증프린터가 동일 장비일때, 로컬영수증프린터에 주문서 출력 
                //m_cRecOrderSheet.Execute(null);

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }

        #region 거래 완료 돈통 열림 체크
        /// <summary>
        /// 거래 완료 돈통 열림 체크
        /// </summary>
        /// <returns></returns>
        private bool FinishTradeOpenDrawer()
        {
            return FinishTradeOpenDrawer(false);
        }
        
        /// <summary>
        /// 거래 완료 돈통 열림 체크
        /// </summary>
        /// <returns></returns>
        private bool FinishTradeOpenDrawer(bool bDutchPay)
        {

            bool bOpenDrawer = false;

            try
            {
                if (m_cPosStatus.Base.TrainingFlag != "1")  //연습모드가 아니면...
                {
                    // 판매완료시 돈통열림 설정(0:안열림, 1:현금성거래만, 2:전체열림)
                    string sOpt = CmUtil.IsNull(PosMstManager.GetPosOption(POS_OPTION.OPT021), "1");

                    //UserLog.WriteLogFile(UserCom.LOG_DEBUG, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    //    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "sOpt : " + sOpt);


                    if (sOpt == "1")    //현금성 거래만
                    {
                        ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
                        foreach (Column.TR_PAYMENT.DATA cPayItem in alPayItem)
                        {
                            if (cPayItem.CANCEL_DIV == ItemConst.PAY_CANCEL_DIV.CANCEL) continue;

                            if (bDutchPay == true)  //더치페이 체크
                            {
                                if (cPayItem.DutchPayPrtDiv == "1") continue;
                            }

                            switch (cPayItem.PAY_WAY_CD)
                            {
                                case ItemConst.TR_ITEM_ID.CASH_ITEM:        //현금
                                case ItemConst.TR_ITEM_ID.GIFT_ITEM:        //상품권
                                case ItemConst.TR_ITEM_ID.CHECK_ITEM:       //수표
                                case ItemConst.TR_ITEM_ID.FOREIGNEX_ITEM:	//외환
                                case ItemConst.TR_ITEM_ID.PAYETC_ITEM:	    //기타(잔액교환권, 식권)
                                    bOpenDrawer = true;
                                    break;
                            }
                            if (bOpenDrawer == true) break;
                        }
                    }
                    else if (sOpt == "2")    //전체열림
                    {
                        bOpenDrawer = true;
                    }
                }
                
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return bOpenDrawer;
        }
        
        #endregion

        #region 영수증 필수 출력 여부 체크
        /// <summary>
        /// 영수증 필수 출력 여부 체크
        /// </summary>
        /// <returns></returns>
        private bool BillPrintRequiredCheck()
        {

            bool bRet = false;

            try
            {
                if (m_cTrnStatus.Head.TradeDiv == ItemConst.TRAN_DIV.REFUND) return bRet;
                
                //캠페인 할인 체크
                ArrayList alTrPluItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM);                   // 상품 아이템
                foreach (Column.TR_PLU.DATA cPluItem in alTrPluItem)
                {
                    if (cPluItem.BILLSPR_NO != m_cTrnStatus.Sale.BillSplitNo) continue;

                    if (cPluItem.CANCEL_DIV == ItemConst.PAY_CANCEL_DIV.NORMAL && cPluItem.CPI_DC_AMT > 0)
                    {
                        bRet = true;
                        break;
                    }
                }

                //추가 출력 데이터 체크
                if (bRet == false)
                {
                    // 영수 캠페인 출력 데이터 설정
                    ICampaignUs cCampaingMain = (ICampaignUs)sManager.InitServiceInstance(ServiceLists.ASV_CAMPAIGN.DLL, ServiceLists.ASV_CAMPAIGN.CAMPAIGN_MAIN);

                    // 복권 명판 캠페인 출력 데이터 설정
                    ArrayList alTrSaleCpi = (ArrayList)StateObject.GetItemObject(Column.TR_SALE_CPI_RSLT.ITEM);         // 캠페인트란 아이템
                    foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in alTrSaleCpi)
                    {
                        if (cTrSaleCpi.CANCEL_DIV == "1") continue;

                        if (cTrSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.LOTTERY || cTrSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.LOTT_REC
                            || cTrSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.ENTRY || cTrSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.ENTR_REC)
                        {
                            if (cTrSaleCpi.LTTR_NMPLAT_NO.Trim() == "") continue;

                            bRet = true;
                            break;

                        }
                        else if (cTrSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.HP_STAMP)
                        {
                            if (cTrSaleCpi.HP_STAMP_COUPON.Trim() == "") continue;

                            // 캠페인별 구분자 파싱
                            string[] saCouponNo = cTrSaleCpi.HP_STAMP_COUPON.Split(new string[] { "," }, StringSplitOptions.None);
                            for (int i = 0; i < saCouponNo.Length; i++)
                            {
                                if (saCouponNo[i].Trim() == "") continue;
                                bRet = true;
                                break;
                            }
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return bRet;
        }
        #endregion

        /// <summary>
        /// 간이영수증 완료 처리
        /// </summary>
        /// <returns></returns>
        public string PosEtcReceiptExecute(object oParam)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                DataTable pEtcReceipt = (DataTable)oParam;

                //m_cDataService.SetTranBaseToHead();            //트란 헤더 정보 재설정

                // 영수증 출력 데이터 생성
                sRet = m_cRecOpenClose.MakePosEtcReceipt(pEtcReceipt);
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() MakeRec.", sRet);
                }

                // 영수증 출력
                sRet = m_cRecOpenClose.ExecutePrint(new string[] { });
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() ExecPrt.", sRet);
                }                // 거래데이터 완료 후 데이터 초기화 처리
                m_cDataService.TranComplete();

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }

        /// <summary>
        /// 고객 불만 영수증 출력 처리
        /// </summary>
        /// <returns></returns>
        public string PosClaimReceiptExecute()
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                // 영수증 출력 데이터 생성
                sRet = m_cRecOpenClose.MakePosClaimReceipt();
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() MakeRec.", sRet);
                }

                // 영수증 출력
                sRet = m_cRecOpenClose.ExecutePrint(new string[] { });
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() ExecPrt.", sRet);
                }                // 거래데이터 완료 후 데이터 초기화 처리
                m_cDataService.TranComplete();

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }

        /// <summary>
        /// 직전 영수증 재출력
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public string PosSaleLastRePrint(string[] aParam)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                // 직전영수증 재출력
                sRet = m_cRecService.ExecuteRePrint(new string[] { });
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", sRet);
                }

                //거래번호 구하기
                string sTradeNo = "";

                if (m_cTrnStatus.Head.TradeNo == "00001")
                {
                    sTradeNo = "99999";
                }
                else
                {
                    int iTradeNo = CmUtil.IntParse(m_cTrnStatus.Head.TradeNo);
                    iTradeNo--;
                    sTradeNo = iTradeNo.ToString().PadLeft(5, '0');
                }

                //기타 헤더 저장!
                EtcLogTrSave(ItemConst.TRAN_KIND.LOG.RE_PRINT, false, m_cTrnStatus.Head.SaleDate, m_cTrnStatus.Head.PosNo, sTradeNo);

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return sRet;
        }

        /// <summary>
        /// 영수증 재 출력
        /// </summary>
        /// <param name="sPrtData"></param>
        /// <param name="bTitle"></param>
        /// <returns></returns>
        public bool PosSaleRePrint(string sPrtData, bool bTitle)
        {
            return m_cRecService.PosSaleRePrint(sPrtData, bTitle);
        }

        /// <summary>
        /// 영수증 재 출력
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public bool PosSaleRePrint(string sPrtData)
        {
            return m_cRecService.PosSaleRePrint(sPrtData);

        }

        /// <summary>
        /// 기념일 배송 출력
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public bool PosRembOrderPrint(string sPrtData)
        {
            return m_cRecService.PosRembOrderPrint(sPrtData);

        }

        /// <summary>
        /// 해피오더 주문서 출력
        /// </summary>
        /// <param name="aPrtData"></param>
        /// <param name="bHPOAutoPrintYN"></param>
        /// <param name="sPrtGubun"> M : 당월 , D : 당일</param>
        /// <returns></returns>
        //#16366 해피오더 당월누적주문내역 + 당일 해피오더주문 상세내역 자동 출력기능 start
        //기존
        /*
        public bool PosPrint(string[] aPrtData)
        {
            return m_cRecService.PosPrint(aPrtData);
        }
        */
        //변경
        public bool PosPrint(string[] aPrtData, bool bHPOAutoPrintYN, string sPrtGubun)
        {
            return m_cRecService.PosPrint(aPrtData, bHPOAutoPrintYN, sPrtGubun);
        }
        //#16366 해피오더 당월누적주문내역 + 당일 해피오더주문 상세내역 자동 출력기능 end

        //17.08.22 dkshin SS 해피오더
        /// <summary>
        /// 해피오더 KDS 전송 실패 시 출력
        /// </summary>
        /// <param name="aPrtData"></param>
        /// <returns></returns>
        public bool HappyOrderKDSPrint(ArrayList aPrtData)
        {
            return m_cRecService.HappyOrderKDSPrint(aPrtData);
        }

        /// <summary>
        /// 해피포인트(인카드쿠폰) 내역 출력
        /// </summary>
        /// <returns></returns>
        public string ExecuteInCardCpnReceipt(object oEctItem, object oParam)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                Column.TR_ETC.DATA cEtcItem = (Column.TR_ETC.DATA)oEctItem;
                DataTable dtCpnList = (DataTable)oParam;

                // 영수증 출력 데이터 생성
                sRet = m_cRecOpenClose.MakeInCardCpnReceipt(cEtcItem, dtCpnList);
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() MakeRec.", sRet);
                }

                // 영수증 출력
                sRet = m_cRecOpenClose.ExecutePrint(new string[] { });
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() ExecPrt.", sRet);
                }

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }

        /// <summary>
        /// 행사 주문 취합 내역 조회 출력
        /// </summary>
        /// <returns></returns>
        public string PosSearchEventExecute(string sPrintData)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                //DataTable pEtcReceipt = (DataTable)oParam;

                //m_cDataService.SetTranBaseToHead();            //트란 헤더 정보 재설정

                // 영수증 출력 데이터 생성
                sRet = m_cRecOpenClose.MakePosSearchEvent(sPrintData);
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() MakeRec.", sRet);
                }

                //// 출력이 아니라면 여기서 값을 리턴해 줌
                //if (sFlag == "0")
                //{
                //    return sRet;
                //}

                // 영수증 출력
                sRet = m_cRecOpenClose.ExecutePrint(new string[] { });
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() ExecPrt.", sRet);
                }                // 거래데이터 완료 후 데이터 초기화 처리
                //m_cDataService.TranComplete();

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }


        /// <summary>
        /// 당일 거래 복구
        /// </summary>
        /// <returns></returns>
        public string TranDataRestore(string[] aParam)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                // 거래데이터 저장
                sRet = m_cTranService.SaveTranExecute(new string[] { "1" });
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() SaveTran.", sRet);
                }

                // 저널데이터 저장 
                sRet = m_cRecOpenClose.SaveJnlDataExecute(aParam);
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() SaveJnl.", sRet);
                }

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }


        /// <summary>
        /// 더치페이 영수증 건출력
        /// </summary>
        /// <returns></returns>
        public string DutchPayReceiptPrint(string[] aParam)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                m_cDataService.SetTranBaseToHead();            //트란 헤더 정보 재설정

                // 돈통 오픈 처리
                if (FinishTradeOpenDrawer(true) == true)
                    m_cCashDrawer.OpenCashDrawer(); // 돈통 OPEN 처리
                
                // 영수증 출력 데이터 생성
                sRet = m_cRecService.MakePosSaleReceipt(new string[] { });
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() MakeRec.", sRet);
                }
                
                // 영수증 출력
                sRet = m_cRecService.ExecutePrint(new string[] { "SALE" });//더치페이
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() ExecPrt.", sRet);
                }

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }

        /// <summary>
        /// 지정취소 데이터 저장 처리
        /// </summary>
        /// <returns></returns>
        public string ItemCancelExecute(string[] aParam)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                m_cDataService.SetTranBaseToHead();                     // 트란 헤더 정보 재설정

                // 지정취소 거래데이터 저장
                sRet = m_cTranService.ItemCancelSaveData();
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() SaveTran.", sRet);

                    WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0004);
                    return sRet;
                }
                m_cDataService.SetMsgNoInc(true, true, false);          // 거래번호 증가

                m_cTrnStatus.Head.RegNo = m_cPosStatus.Base.RegNo;      // REG_NO
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }

        /// <summary>
        /// 정산지 내역 출력
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public string ExecuteADMTReceipt(string[] aParam)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                m_cDataService.SetTranBaseToHead();            //트란 헤더 정보 재설정

                // 영수증 출력 데이터 생성
                //sRet = m_cRecOpenClose.MakeOpenClose(new string[] { });
                //if (sRet != UserCom.RST_OK)
                //{
                //    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                //        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() MakePrt.", sRet);
                //}

                // 영수증 출력
                m_cRecOpenClose.PrintBufClear();        // 영수증 출력버퍼 초기화

                sRet = m_cRecOpenClose.ExecutePrint(new string[] { "SALE", aParam[0] });
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() ExecPrt.", sRet);
                }

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }

        /// <summary>
        /// 기타입출금 조회 내역 출력 처리
        /// </summary>
        /// <returns></returns>
        public string AccEtcListReceipt(string sFromDate, string sToDate)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                // 영수증 출력 데이터 생성
                sRet = m_cRecOpenClose.AccEtcReceipt(sFromDate, sToDate);
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() MakeRec.", sRet);
                }

                // 영수증 출력
                sRet = m_cRecOpenClose.ExecutePrint(new string[] { });
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() ExecPrt.", sRet);
                }                // 거래데이터 완료 후 데이터 초기화 처리
                m_cDataService.TranComplete();

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }

        /// <summary>
        /// 준비금 등록 내역 출력 처리
        /// </summary>
        /// <returns></returns>
        public string AccRemoneyListReceipt(DataTable dtData, string sFromDate)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                // 영수증 출력 데이터 생성
                sRet = m_cRecOpenClose.AccRemoneyListReceipt(dtData, sFromDate);
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() MakeRec.", sRet);
                }

                // 영수증 출력
                sRet = m_cRecOpenClose.ExecutePrint(new string[] { });
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() ExecPrt.", sRet);
                }                // 거래데이터 완료 후 데이터 초기화 처리
                m_cDataService.TranComplete();

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }

        /// <summary>
        /// 준비점검 공지사항 내역 출력 처리
        /// </summary>
        /// <returns></returns>
        public string PrepStoreReceipt(DataTable dtData)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                //DataTable pEtcReceipt = (DataTable)oParam;

                //m_cDataService.SetTranBaseToHead();            //트란 헤더 정보 재설정

                m_cTrnStatus.Head.TradeKind = ItemConst.TRAN_KIND.NORMAL.DELIMITER;

                // 영수증 출력 데이터 생성
                sRet = m_cRecOpenClose.PrepStorNoticeReceipt(dtData);
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() MakeRec.", sRet);
                }

                // 영수증 출력
                sRet = m_cRecOpenClose.ExecutePrint(new string[] { });
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() ExecPrt.", sRet);
                }                // 거래데이터 완료 후 데이터 초기화 처리
                m_cDataService.TranComplete();

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }

        /// <summary>
        /// 돈통 오픈(수동)
        /// </summary>
        /// <returns></returns>
        public string OpenManualCashdrawer()
        {
            string sRet = UserCom.RST_ERR;

            try
            {
                ////디비 저장
                //m_cDataService.SetTranBaseToHead();                     // 트란 헤더 정보 재설정

                //// 지정취소 돈통 오픈 
                //sRet = m_cTranService.EtcHeaderSaveData(ItemConst.TRAN_DIV.NORMAL, ItemConst.TRAN_KIND.LOG.OPEN_CASH_DRAWER, new string[] { "" });

                //if (sRet != UserCom.RST_OK)
                //{
                //    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                //        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() SaveTran.", sRet);

                //    WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0004);
                //    return sRet;
                //}

                //m_cDataService.SetMsgNoInc(true, true, false);          // 거래번호 증가

                //m_cTrnStatus.Head.RegNo = m_cPosStatus.Base.RegNo;      // REG_NO

                EtcLogTrSave(ItemConst.TRAN_KIND.LOG.OPEN_CASH_DRAWER, false, "", "", "");

                //돈통오픈
                m_cCashDrawer.OpenCashDrawer();
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }

        /// <summary>
        /// 돈통 오픈(수동)
        /// </summary>
        /// <returns></returns>
        public string EtcLogTrSave(string sTradeKind, bool bErrShow, string sOrgSaleDt, string sOrgPosNo, string sOrgTradeNo)
        {
            string sRet = UserCom.RST_ERR;

            try
            {
                //디비 저장
                //m_cDataService.SetTranBaseToHead();                     // 트란 헤더 정보 재설정

                //m_cTrnStatus.Head.OrgSaleDate = sOrgSaleDt;
                //m_cTrnStatus.Head.OrgPosNo = sOrgPosNo;
                //m_cTrnStatus.Head.OrgTradeNo = sOrgTradeNo;

                // 지정취소 돈통 오픈 
                sRet = m_cTranService.EtcHeaderSaveData(ItemConst.TRAN_DIV.NORMAL, sTradeKind, new string[] { sOrgSaleDt, sOrgPosNo, sOrgTradeNo });

                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() SaveTran.", sRet);

                    if (bErrShow == true)
                        WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0004);
                    return sRet;
                }

               //m_cDataService.SetTranBaseToHead();

                m_cDataService.SetMsgNoInc(true, true, false);          // 거래번호 증가

                m_cTrnStatus.Head.RegNo = m_cPosStatus.Base.RegNo;      // REG_NO

            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }
        


        /// <summary>
        /// 원거래에 해피포인트 추후적립 내역 출력정보 ADD
        /// </summary>
        /// <param name="sSaleDate"></param>
        /// <param name="sPosNo"></param>
        /// <param name="sTradeNo"></param>
        /// <returns></returns>
        public string AddHappyPointAfterSave(string sSaleDate, string sPosNo, string sTradeNo)
        {
            try
            {
                return m_cRecService.AddHappyPointAfterSave(sSaleDate, sPosNo, sTradeNo);
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return "";
        }

        //#해피앱 추후적립 start, sskim
        /// <summary>
        /// 원거래에 해피포인트 추후적립 내역 출력정보 ADD
        /// </summary>
        /// <param name="sSaleDate"></param>
        /// <param name="sPosNo"></param>
        /// <param name="sTradeNo"></param>
        /// <returns></returns>
        public string AddHappyPointHpAppAfterSave(string sSaleDate, string sPosNo, string sTradeNo)
        {
            try
            {
                return m_cRecService.AddHappyPointHpAppAfterSave(sSaleDate, sPosNo, sTradeNo);
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return "";
        }
        //#해피앱 추후적립 end, sskim

        /// <summary>
        /// 화면에 표시된는 영수증 출력 데이터 생성
        /// </summary>
        /// <param name="sSaleDate"></param>
        /// <param name="sPosNo"></param>
        /// <param name="sTradeNo"></param>
        /// <returns></returns>
        public string GetDisplayPrintData(string sSaleDate, string sPosNo, string sTradeNo)
        {
            try
            {
                return m_cRecService.GetDisplayPrintData(sSaleDate, sPosNo, sTradeNo);
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return "";
        }

        /// <summary>
        /// 보류 거래 저장
        /// </summary>
        /// <param name="sHoldStat"></param>
        /// <param name="sRegNo"></param>
        /// <param name="sOrgRegNo"></param>
        /// <param name="dQty"></param>
        /// <param name="dSaleAmt"></param>
        public void EtcHoldLogSvae(string sHoldStat, string sOrgRegNo, double dQty, double dSaleAmt)
        {
            try
            {
                m_cTranService.SaveHoldLog(sHoldStat, sOrgRegNo, dQty, dSaleAmt);
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
        }

        /// <summary>
        /// 주문내역서 출력 처리
        /// </summary>
        /// <returns></returns>
        public string ExecuteOrderBillReceipt()
        {
            return m_cRecService.ExecuteOrderBillReceipt();
        }

        //17.05.18 dkshin 쇼킹박스 추가
        /// <summary>
        /// 쇼킹박스처리
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public string PosShockingBoxExecute()
        {
            string sRet = UserCom.RST_ERR;

            try
            {
                m_cDataService.SetTranBaseToHead();            //트란 헤더 정보 재설정

                // 영수증 출력 데이터 생성
                sRet = m_cRecService.MakePosSaleReceipt(new string[] { });
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() MakeRec.", sRet);
                }

                // 거래데이터 저장
                sRet = m_cTranService.SaveTranExecute(new string[] { "0" });
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() SaveTran.", sRet);

                    WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0004);
                    return sRet;
                } 

                // 돈통 오픈 처리
                //if (FinishTradeOpenDrawer() == true)
                //    m_cCashDrawer.OpenCashDrawer(); // 돈통 OPEN 처리

                // 영수증 출력
                sRet = m_cRecService.ExecutePrint(new string[] { "SALE" });//쇼킹박스
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() ExecPrt.", sRet);
                }


                //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 start

                #region 불필요해보여서 주석처리
                /*
                //grayber@20180212 해피포인트 전자영수증 I/F 개선 #13924 start
                // 추가
                Hashtable htHPC_APPR_INFO = new Hashtable();
                TrHpcInfoSave(ItemConst.TR_ITEM_ID.ETC_INFO.SAVEPOINT, ref htHPC_APPR_INFO);//적립
                TrHpcInfoSave(ItemConst.TR_ITEM_ID.POINT_USE.HAPPY_POINT, ref htHPC_APPR_INFO);//사용

                // 저널데이타 저장
                // 기존
                //sRet = m_cRecService.SaveJnlExecute(new string[] { });
                // 변경
                sRet = m_cRecService.SaveJnlExecute(new string[] { htHPC_APPR_INFO["HPC_SAVE_APPR_DT"].ToString()
                                                                  ,htHPC_APPR_INFO["HPC_SAVE_APPR_NO"].ToString()
                                                                  ,htHPC_APPR_INFO["HPC_USE_APPR_DT"].ToString()
                                                                  ,htHPC_APPR_INFO["HPC_USE_APPR_NO"].ToString() 
                                                                  });
                //grayber@20180212 해피포인트 전자영수증 I/F 개선 #13924 end
                
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() SaveJnl.", sRet);
                }
                */
                #endregion

                //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 end

                // 거래데이터 완료 후 데이터 초기화 처리
                bool bIncTradeNo = m_cDataCommon.TradeNoAddCheck("");
                //bool bIncTradeNo = m_cTranService.TradeNoAddCheck();
                m_cDataService.TranComplete();
                m_cDataService.SetMsgNoInc(true, !bIncTradeNo, bIncTradeNo);      // 거래번호 증가

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return sRet;
        }

        //17.05.18 dkshin 쇼킹박스 추가
        /// <summary>
        /// 쇼킹박스처리
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public string PosShockingBoxSearch(string sInPutData)
        {
            string sRet = UserCom.RST_ERR;

            try
            {
                sRet = m_cTranService.PosShockingBoxSerch(sInPutData);
                //#20180309 바코드 스캔마다 쇼킹박스 로그 생성되서 제거 start
                /*
                if (sRet != UserCom.RST_OK)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "() PosShockingBoxSearch.", sRet);

                    //WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0004);
                    return sRet;
                }
                */
                //#20180309 바코드 스캔마다 쇼킹박스 로그 생성되서 제거 end
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return sRet;
        }

        // Add, 2017.09.04, 근무시간 확인서 출력
        /// <summary>
        /// 근무시간 확인서 출력
        /// </summary>
        /// <param name="empNo">직원코드</param>
        /// <param name="empNm">직원성명</param>
        /// <param name="strTime">출근일시 (yyyy.MM.dd HH:mm:ss)</param>
        /// <param name="endTime">퇴근일시 (yyyy.MM.dd HH:mm:ss)</param>
        /// <returns></returns>
        public string ExecuteWorkTimeReceipt(string empNo, string empNm, string strTime, string endTime)
        {
            var ret = UserCom.RST_ERR; 
            try
            {
                ret = m_cRecService.ExecuteWorkTimeReceipt(empNo, empNm, strTime, endTime);
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);

                ret = UserCom.RST_ERR; 
            }
            return ret; 
        }

        //#20170918 기념일 배송 출력 start
        public string ExecuteAnniversary(string aParam)
        {
            return m_cRecService.ExecuteAnniversary(aParam);
        }
        //#20170918 기념일 배송 출력 end

        //#17142 [해피오더]POS로그인 시 영수증프린터로 장부재고 자동 출력 start
        public string BookInventoryPrint(string aParam)
        {
            return m_cRecService.BookInventoryPrint(aParam);
        }
        //#17142 [해피오더]POS로그인 시 영수증프린터로 장부재고 자동 출력 end

        //#20171017 전자영수증 발행 start, phj
        public int CheckElectronic_Receipt()
        {
            int Electronic_Receipt = -1;

            string Electronic_ReceiptYN = string.Empty;

            try
            {
                ArrayList alEtcItem = (ArrayList)StateObject.GetItemObject(Column.TR_ETC.ITEM);
                foreach (Column.TR_ETC.DATA cEtcItem in alEtcItem)
                {
                    if (cEtcItem.ETC_WAY_CD == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM && cEtcItem.ETC_DTL_CD_01 == ItemConst.TR_ITEM_ID.ETC_INFO.SAVEPOINT)
                    {
                        if (cEtcItem.CANCEL_DIV == ItemConst.PAY_CANCEL_DIV.CANCEL) continue;
                        if (cEtcItem.OCCUR_ENTRY_12 == "Y")
                        {
                            //해피앱 전자발행설정유무 값 
                            if (cEtcItem.OCCUR_ENTRY_23 == "Y")
                            {
                                Electronic_Receipt = 1;
                            }
                            else
                            {
                                Electronic_Receipt = 0;
                            }
                            break;
                        }
                    }
                }

                if (Electronic_Receipt == 1) return Electronic_Receipt;

                ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
                foreach (Column.TR_PAYMENT.DATA cPayItem in alPayItem)
                {
                    if (cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.POINT_ITEM && cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.POINT_USE.HAPPY_POINT)
                    {
                        if (cPayItem.CANCEL_DIV == ItemConst.PAY_CANCEL_DIV.CANCEL) continue;
                        if (cPayItem.OCCUR_ENTRY_12 == "Y")
                        {
                            if (cPayItem.OCCUR_ENTRY_23 == "Y")
                            {
                                Electronic_Receipt = 1;
                            }
                            else
                            {
                                Electronic_Receipt = 0;
                            }
                            break;
                        }
                    }
                }

                return Electronic_Receipt;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "Electronic_Receipt : " + Electronic_Receipt.ToString() + "", ex.Message);

                return Electronic_Receipt;
            }
        }
        //#20171017 전자영수증 발행 end, phj

        //#20171227, 예약증 양식 출력 Start
        /// <summary>
        /// 예약증 양식 출력
        /// </summary>
        /// <returns></returns>
        public string ExecuteReservationForm()
        {
            var ret = UserCom.RST_ERR;
            try
            {
                ret = m_cRecService.ExecuteReservationForm();
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);

                ret = UserCom.RST_ERR;
            }
            return ret;
        }
        //#20171227, 예약증 양식 출력 End

        // grayber@20180112 전자영수증 주문(대기)번호표 출력 start - 인터페이스 처리
        /// <summary>
        /// 대기번호표 출력
        /// </summary>
        /// <returns></returns>
        public string ExcuteElectroBillOrderNoReceipt(bool bForce = false)
        {
            var ret = UserCom.RST_ERR;
            try
            {
                //grayber@20180226 대기번호표 개선 start- 반품 시 출력 안하도록 처리
                //기존
                //ret = m_cRecService.ExcuteElectroBillOrderNoReceipt();
                //개선 - 반품 시 출력 제거
                if(m_cTrnStatus.Head.TradeDiv != ItemConst.TRAN_DIV.REFUND)
                {
                    ret = m_cRecService.ExcuteElectroBillOrderNoReceipt(bForce);
                }
                //grayber@20180226 대기번호표 개선 end
                
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);

                ret = UserCom.RST_ERR;
            }
            return ret;
        }
        // grayber@20180112 전자영수증 주문(대기)번호표 출력 end

        //grayber@20180212 해피포인트 전자영수증 I/F 개선 #13924 start
        // 추가
        private string TrHpcInfoSave(string sHpcType, ref Hashtable htHPCApprInfo )
        {
            string sRet = UserCom.RST_ERR;
            
            var alItem = new ArrayList();

            //#20180302 해피포인트 적립내역, 사용내역 조회시 try catch 적용 start
            try
            {
                UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "TrHpcInfoSave" + " - sHpcType : " + sHpcType);
            //#20180302 해피포인트 적립내역, 사용내역 조회시 try catch 적용 end

                if (sHpcType.Equals(ItemConst.TR_ITEM_ID.ETC_INFO.SAVEPOINT) == true)
                {
                    alItem = (ArrayList)StateObject.GetItemObject(Column.TR_ETC.ITEM);
                    htHPCApprInfo.Add("HPC_SAVE_APPR_NO", string.Empty);
                    htHPCApprInfo.Add("HPC_SAVE_APPR_DT", string.Empty);
                }
                else
                {
                    alItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
                    htHPCApprInfo.Add("HPC_USE_APPR_NO", string.Empty);
                    htHPCApprInfo.Add("HPC_USE_APPR_DT", string.Empty);
                }

                foreach (var cItem in alItem)
                {
                    if (sHpcType.Equals(ItemConst.TR_ITEM_ID.ETC_INFO.SAVEPOINT) == true)   // 적립
                    {
                        if (((Column.TR_ETC.DATA)cItem).CANCEL_DIV == ItemConst.PAY_CANCEL_DIV.CANCEL) continue;
                        if (((Column.TR_ETC.DATA)cItem).ETC_WAY_CD == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM
                        && ((Column.TR_ETC.DATA)cItem).ETC_DTL_CD_01 == ItemConst.TR_ITEM_ID.ETC_INFO.SAVEPOINT)
                        {
                            htHPCApprInfo["HPC_SAVE_APPR_NO"] = ((Column.TR_ETC.DATA)cItem).OCCUR_ENTRY_02;
                            htHPCApprInfo["HPC_SAVE_APPR_DT"] = ((Column.TR_ETC.DATA)cItem).OCCUR_ENTRY_03;
                            sRet = UserCom.RST_OK;
                            break;
                        }
                    }
                    else if (sHpcType.Equals(ItemConst.TR_ITEM_ID.POINT_USE.HAPPY_POINT) == true)   // 사용
                    {
                        if (((Column.TR_PAYMENT.DATA)cItem).CANCEL_DIV == ItemConst.PAY_CANCEL_DIV.CANCEL) continue;
                        if (((Column.TR_PAYMENT.DATA)cItem).PAY_WAY_CD == ItemConst.TR_ITEM_ID.POINT_ITEM
                            && ((Column.TR_PAYMENT.DATA)cItem).PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.POINT_USE.HAPPY_POINT)
                        {
                            htHPCApprInfo["HPC_USE_APPR_NO"] = ((Column.TR_PAYMENT.DATA)cItem).OCCUR_ENTRY_02;
                            htHPCApprInfo["HPC_USE_APPR_DT"] = ((Column.TR_PAYMENT.DATA)cItem).OCCUR_ENTRY_03;
                            sRet = UserCom.RST_OK;
                            break;
                        }
                    }
                }

            //#20180302 해피포인트 적립내역, 사용내역 조회시 try catch 적용 start
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            //#20180302 해피포인트 적립내역, 사용내역 조회시 try catch 적용 end

            return sRet;
        }
        //grayber@20180212 해피포인트 전자영수증 I/F 개선 #13924 end
    }
}
