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

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

/*-----------------------------------------------------------------------------------------------*/
// 설      명 : 영수증 호출 처리 기본 클래스
// 작  성  자 : 
// 변경  이력 : 
/*-----------------------------------------------------------------------------------------------*/
namespace Cosmos.Service
{
    class SaleTranCallBase
    {
        protected SManager sManager = new SManager();                                 // 이 객체를 통해 업무 Service 호출
        protected StateServer StateObject = (StateServer)StateServer.GetInstance();   // StateObject : StateServer Object (객체)
        protected PosStatus m_cPosStatus = new PosStatus();                           // 기본정보 참조
        protected TranStatus m_cTrnStatus = new TranStatus();                         // 거래정보 참조

        //#20180406 로컬, 서버에 저널데이터 없는 경우 재생성 start
        protected IPosReceipt m_cPosReceipt = null;
        //#20180406 로컬, 서버에 저널데이터 없는 경우 재생성 end

        protected IDatabaseSQL m_cSqlDbService = null;                                // 데이터베이스 관리
        protected IDataProcessUs m_cDataService = null;                               // 거래데이터 합계금액 계산 및 관리
        protected IMasterUs m_cMstService = null;                                     // 마스터 인터페이스
        protected IDataCommonUs m_cDataCommon = null;                                 // POS 공통함수 인터페이스
        protected ICampaignUs m_cCampaingMain = null;                                 // 캠페인 관리
        protected ICustDisplayUs m_cCustDisp = null;                                  // 고객용 화면 관리

        /// <summary>
        /// 생성자
        /// </summary>
        public SaleTranCallBase()
        {
            m_cPosStatus = (PosStatus)StateObject.POS;
            m_cTrnStatus = (TranStatus)StateObject.TRAN;

            m_cSqlDbService = (IDatabaseSQL)sManager.InitServiceInstance(ServiceLists.AGENT_DATABASE.DLL, ServiceLists.AGENT_DATABASE.DATABASE_MSSQL);
            m_cDataService = (IDataProcessUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_SERVICE);
            m_cMstService = (IMasterUs)sManager.InitServiceInstance(ServiceLists.ASV_MASTER.DLL, ServiceLists.ASV_MASTER.POS_MASTER);
            m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON);

            //#20180406 로컬, 서버에 저널데이터 없는 경우 재생성 start
            m_cPosReceipt = (IPosReceipt)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.POS_RECEIPT);
            //#20180406 로컬, 서버에 저널데이터 없는 경우 재생성 end

        }

        #region 저널 데이터 로딩
        /// <summary>
        /// 거래 영수증(저널) 조회
        /// </summary>
        /// <param name="sSaleDate"></param>
        /// <param name="sPosNo"></param>
        /// <param name="sTradeNo"></param>
        /// <returns></returns>
        public string SearchPrintSaleReceiptDetail(string sSaleDate, string sPosNo, string sTradeNo)
        {
            string sQuery = "";
            try
            {


                if (m_cPosStatus.Base.TrainingFlag == "1")
                {
                    // 로컬 저널데이터 조회
                    sQuery = " SELECT JOURNAL_DATA";
                    sQuery += "  FROM POSLOG..ETC_SALE_JOURNAL ";
                    sQuery += "  WHERE CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND SALE_DT = '" + sSaleDate + "'";
                    sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND POS_NO  = '" + sPosNo + "'";
                    sQuery += "    AND REG_NO  = '" + sTradeNo + "'";
                }
                else
                {
                    // 로컬 저널데이터 조회
                    sQuery = " SELECT JOURNAL_DATA";
                    sQuery += "  FROM POSLOG..TR_SALE_JOURNAL ";
                    sQuery += "  WHERE CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND SALE_DT = '" + sSaleDate + "'";
                    sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND POS_NO  = '" + sPosNo + "'";
                    sQuery += "    AND TRADE_NO  = '" + sTradeNo + "'";
                }

                DataTable dtJnl = m_cMstService.Select(new string[] { sQuery });

                if (dtJnl != null && dtJnl.Rows.Count > 0)
                {
                    DataRow drJnl = dtJnl.Rows[0];

                    return drJnl[0].ToString();
                }

                if (m_cPosStatus.Base.TrainingFlag == "1")
                {
                    return "";
                }
                else
                {
	
                    // 서버 저널데이터 조회

                    //#20180406 로컬, 서버에 저널데이터 없는 경우 재생성 start
                    //서버 조회 실패시 저널데이터 재생성을 위해 return 되지 안도록 변경
                    //기존
                    #region 주석
                    /*
                    Hashtable htRecvData = new Hashtable();

                    string sRet = ExecServerTranCallIrt(ItemConst.IRT_INQ_TYPE.JOURNAL_CALL, sSaleDate, sPosNo, sTradeNo, "", ref htRecvData);
                    if (sRet != UserCom.RST_OK) return "";

                    if (htRecvData[Column.IQ_TRAN_CALL_REQ.DATA.RES_CD].ToString() != "00") return "";

                    return htRecvData[Column.IQ_TRAN_CALL_REQ.DATA.TRAN_DATA].ToString();
                    */
                    #endregion
                    //변경
                    //적용시 주석 해제
                    
                    Hashtable htRecvData = new Hashtable();

                    string sRet = ExecServerTranCallIrt(ItemConst.IRT_INQ_TYPE.JOURNAL_CALL, sSaleDate, sPosNo, sTradeNo, "", ref htRecvData);

                    if (sRet == UserCom.RST_OK && htRecvData[Column.IQ_TRAN_CALL_REQ.DATA.RES_CD].ToString() == "00")
                    {
                        return htRecvData[Column.IQ_TRAN_CALL_REQ.DATA.TRAN_DATA].ToString();
                    }
                    
                    //#20180406 로컬, 서버에 저널데이터 없는 경우 재생성 end
                }

                //#20180406 로컬, 서버에 저널데이터 없는 경우 재생성 start

                #region 로컬, 서버에 저널 데이터 없는 경우 재생성 처리
                UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                     "JOURNAL DATA REMAKE - " + 
                     "SaleDate : " + sSaleDate +
                     "PosNo : " + sPosNo +
                     "TradeNo : " + sTradeNo);

                // 거래 데이터 로딩
                bool bRet = LoadLocalTran(sSaleDate, sPosNo, sTradeNo);
                if (bRet == false) return "";

                m_cDataService.UpdateTranAmount();

                m_cTrnStatus.Head.SaleDate  = sSaleDate;
                m_cTrnStatus.Head.PosNo     = sPosNo;
                m_cTrnStatus.Head.TradeNo   = sTradeNo;


                // 영수증 출력 데이터 생성
                string sJnlMakeRet = m_cPosReceipt.MakePosSaleReceipt(new string[] { });
                if (sJnlMakeRet != 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 + "() JnlMakeRet.", sJnlMakeRet);

                    return "";
                }

                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);//사용

                // 저널데이타 저장
                string sJnlSaveRet = m_cPosReceipt.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() 
                                                                               });
                // 데이터 초기화 처리
                m_cDataService.TranComplete();

                if (sJnlSaveRet != 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 + "() JnlSaveRet.", sJnlSaveRet);

                    return "";
                }

                if (m_cPosStatus.Base.TrainingFlag == "1")
                {
                    // 로컬 저널데이터 조회
                    sQuery = " SELECT JOURNAL_DATA";
                    sQuery += "  FROM POSLOG..ETC_SALE_JOURNAL ";
                    sQuery += "  WHERE CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND SALE_DT = '" + sSaleDate + "'";
                    sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND POS_NO  = '" + sPosNo + "'";
                    sQuery += "    AND REG_NO  = '" + sTradeNo + "'";
                }
                else
                {
                    // 로컬 저널데이터 조회
                    sQuery = " SELECT JOURNAL_DATA";
                    sQuery += "  FROM POSLOG..TR_SALE_JOURNAL ";
                    sQuery += "  WHERE CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND SALE_DT = '" + sSaleDate + "'";
                    sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND POS_NO  = '" + sPosNo + "'";
                    sQuery += "    AND TRADE_NO  = '" + sTradeNo + "'";
                }

                dtJnl = m_cMstService.Select(new string[] { sQuery });

                if (dtJnl != null && dtJnl.Rows.Count > 0)
                {
                    DataRow drJnl = dtJnl.Rows[0];

                    return drJnl[0].ToString();
                }
                #endregion

                //#20180406 로컬, 서버에 저널데이터 없는 경우 재생성 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 "";
        }
        #endregion

        #region 로컬 거래데이터 로딩
        /// <summary>
        /// 로컬 해더 아이템 상세 조회 후 설정
        /// </summary>
        /// <param name="sSaleDate"></param>
        /// <param name="sPosNo"></param>
        /// <param name="sTradeNo"></param>
        /// <returns></returns>
        protected bool LoadLocalTrHeader(string sSaleDate, string sPosNo, string sTradeNo)
        {
            string sQuery = "";
            try
            {
                sQuery += " SELECT '01' + '|' + '000000' + '|' + '0' + '|' + ISNULL(TRADE_DIV, '') + '|' + ISNULL(TRAIN_MODE_YN, '') + '|' + ISNULL(TRADE_KINDPER, '') + '|' + ISNULL(SYS_DT, '') + '|' + ISNULL(ORD_TIME, '') + '|' + ";
                sQuery += "        ISNULL(PAY_TIME, '') + '|' + ISNULL(PIC_NO, '') + '|' + ISNULL(ORD_PIC_NO, '') + '|' + ISNULL(STOR_OWN_PART_TIME_DIV, '') + '|' + ISNULL(ORG_BILL_POSNO, '') + '|' + ";
                sQuery += "        ISNULL(ORG_BILLDT, '') + '|' + ISNULL(ORG_BILL_NO, '') + '|' + ISNULL(RTN_RSN_CD, '') + '|' + ISNULL(RTN_RSN_MEMO, '') + '|' + ISNULL(NONSALES_RSN_CD, '') + '|' + ";
                sQuery += "        ISNULL(RESERV_NO, '') + '|' + ISNULL(RESERV_DT, '') + '|' + ISNULL(CUST_NO, '') + '|' + ISNULL(ORD_DIV, '') + '|' + ISNULL(FLOOR_CD, '') + '|' + ";
                sQuery += "        ISNULL(TBL_NO, '') + '|' + ISNULL(GUESTFLOOR, '') + '|' + ISNULL(FRGNR_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(CUSTCNT, 0)) + '|' + ISNULL(PAY_GNDR_DIV, '') + '|' + ";
                sQuery += "        CONVERT(VARCHAR, ISNULL(PAY_AGE, 0)) + '|' + CONVERT(VARCHAR, ISNULL(MAN_CMPNPSN_CNT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(WOMAN_CMPNPSN_CNT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(TOTSALE_AMT, 0)) + '|' + ";
                sQuery += "        CONVERT(VARCHAR, ISNULL(TOTDC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(NET_SALE_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ITEM_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPI_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(COOP_CARD_DC_AMT, 0)) + '|' + ";
                sQuery += "        CONVERT(VARCHAR, ISNULL(POINT_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPN_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(EMP_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SET_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ETC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(EXCEP_DC_AMT, 0)) + '|' + ";
                sQuery += "        CONVERT(VARCHAR, ISNULL(TOT_VAT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_VAT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ETC_VAT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AF_ACCUM_POINT_AMT, 0)) + '|' + ";
                sQuery += "        ISNULL(AF_ACCUM_POINT_INFO, '') + '|' + ISNULL(PPCARD_CUSTNM, '') + '|' + ISNULL(AMT_DUTCHPAY_YN, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_CNT, 0)) + '|'+ ISNULL(ORDER_NO, '') + '|' + ";
                

                //#20170828 해피포인트 적립 제외 버튼 추가 phj, start
                //기존
                //sQuery += "        ISNULL(SLACK_FIELD, '') + '|' + '' + '|' + ISNULL(PPCARD_CUSTID, '') + '|' + ISNULL(PACK_TRADE_DIV, '') + '|' + ISNULL(VIP_TY, '') AS TR_HEADER ";
                //변경                
                sQuery += "        ISNULL(SLACK_FIELD, '') + '|' + '' + '|' + ISNULL(PPCARD_CUSTID, '') + '|' + ISNULL(PACK_TRADE_DIV, '') + '|' + ISNULL(VIP_TY, '') + '|' + ISNULL(HP_EXCLUDE_YN, '0') AS TR_HEADER ";
                //#20170828 해피포인트 적립 제외 버튼 추가 phj, end

                if (m_cPosStatus.Base.TrainingFlag == "1")
                {
                    sQuery += "  FROM POSLOG..ETC_SALE_HEADER ";
                    sQuery += "  WHERE CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND SALE_DT = '" + sSaleDate + "'";
                    sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND POS_NO  = '" + sPosNo + "'";
                    sQuery += "    AND REG_NO  = '" + sTradeNo + "'";
                }
                else
                {
                    sQuery += "  FROM POSLOG..TR_SALE_HEADER ";
                    sQuery += "  WHERE CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND SALE_DT = '" + sSaleDate + "'";
                    sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND POS_NO  = '" + sPosNo + "'";
                    sQuery += "    AND TRADE_NO  = '" + sTradeNo + "'";
                }
                
                

                DataTable dtTrHeader = m_cMstService.Select(new string[] { sQuery });
                if (dtTrHeader == null || dtTrHeader.Rows.Count == 0) return false;

                DataRow dr = dtTrHeader.Rows[0];
                if (TranParserToHeader(dr[0].ToString()) == false) return false;

                return 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 false;
        }


        /// <summary>
        /// 로컬 상품 아이템 상세 조회 후 설정
        /// </summary>
        /// <param name="sSaleDate"></param>
        /// <param name="sPosNo"></param>
        /// <param name="sTradeNo"></param>
        /// <returns></returns>
        protected bool LoadLocalTrDetail(string sSaleDate, string sPosNo, string sTradeNo)
        {
            return LoadLocalTrDetail(sSaleDate, sPosNo, sTradeNo, false);
        }
        
        /// <summary>
        /// 로컬 상품 아이템 상세 조회 후 설정
        /// </summary>
        /// <param name="sSaleDate"></param>
        /// <param name="sPosNo"></param>
        /// <param name="sTradeNo"></param>
        /// <param name="bHoldYn"></param>
        /// <returns></returns>
        protected bool LoadLocalTrDetail(string sSaleDate, string sPosNo, string sTradeNo, bool bHoldYn)
        {
            string sQuery = "";
            try
            {
                sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranDetail + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(ORD_TIME, '') + '|' + ISNULL(FLOOR_CD, '') + '|' + ISNULL(TBL_NO, '') + '|' + ";
                sQuery += " ISNULL(SUB_SHOP_CD, '') + '|' + ISNULL(ITEM_PLU_CD, '') + '|' + ISNULL(ITEM_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(SALE_QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SALE_PRC, 0)) + '|' + ";
                sQuery += " CONVERT(VARCHAR, ISNULL(SALE_AMT, 0)) + '|' + ISNULL(FLAVOUR_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(FLAVOUR_WEIGHT, 0)) + '|' + ISNULL(ITEM_INPUT_DIV, '') + '|' + ISNULL(ITEM_BAR_CD, '') + '|' + ";
                sQuery += " ISNULL(TAKE_IN_OUT_DIV, '') + '|' + ISNULL(ITEM_TAX_DIV, '') + '|' + ISNULL(TAX_AMT_INCLUDE_YN, '') + '|' + ISNULL(TAXRATE_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(APPLY_TAX_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_VAT, 0)) + '|' + ";
                sQuery += " ISNULL(SVC_TAXREATE_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(BILL_AMT, 0)) + '|' + ISNULL(NONSALES_RSN_CD, '') + '|' + ISNULL(DC_DIV, '') + '|' + ISNULL(DC_TYPE, '') + '|' + CONVERT(VARCHAR, ISNULL(DC_RATE, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ITEM_DC_AMT, 0)) + '|' + ";
                sQuery += " CONVERT(VARCHAR, ISNULL(SUM_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPI_DC_QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPI_DC_AMT, 0)) + '|' + ISNULL(COOP_CARD_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(COOP_CARD_DC_AMT, 0)) + '|' + ISNULL(POINT_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(POINT_DC_AMT, 0)) + '|' + ";
                sQuery += " ISNULL(CPN_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(CPN_DC_AMT, 0)) + '|' + ISNULL(EMP_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(EMP_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SET_DC_AMT, 0)) + '|' + ISNULL(ETC_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(ETC_DC_AMT, 0)) + '|' + ";
                sQuery += " ISNULL(EXCEP_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(EXCEP_DC_AMT, 0)) + '|' + ISNULL(PACK_DIV, '') + '|' + ISNULL(SET_MENU_CD, '') + '|' + ISNULL(SUBPRC_MENU_KEY_DIV, '') + '|' + ";
                
                //#20180903 해피오더 매출 생성 시 tr_sale_detail에 구분자 추가 start
                //기존
                //sQuery += " ISNULL(CPI_PRESENT_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(SALE_GIFT_NO, '') + '|' + ISNULL(CPN_NO, '') + '|' + ISNULL(SLACK_FIELD, '') + '|' + ISNULL(DISPO_ITEM_DIV, '') + '|' + ISNULL(CANCEL_DIV, '')  + '|' + ISNULL(NOTAX_DIV, '0') AS TR_DETAIL"; 
                //변경
                sQuery += " ISNULL(CPI_PRESENT_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(SALE_GIFT_NO, '') + '|' + ISNULL(CPN_NO, '') + '|' + ISNULL(SLACK_FIELD, '') + '|' + ISNULL(DISPO_ITEM_DIV, '') + '|' + ISNULL(CANCEL_DIV, '')  + '|' + ISNULL(NOTAX_DIV, '0') + '|' + ISNULL(HPO_REG_YN, '0') AS TR_DETAIL";
                //#20180903 해피오더 매출 생성 시 tr_sale_detail에 구분자 추가 end
                
                //sQuery += " SELECT '#~' + '02' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(ORD_TIME, '') + '|' + ISNULL(FLOOR_CD, '') + '|' + ISNULL(TBL_NO, '') + '|' + ";
                //sQuery += " 	   ISNULL(SUB_SHOP_CD, '') + '|' + ISNULL(ITEM_PLU_CD, '') + '|' + ISNULL(ITEM_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(SALE_QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SALE_PRC, 0)) + '|' + ";
                //sQuery += " 	   CONVERT(VARCHAR, ISNULL(SALE_AMT, 0)) + '|' + ISNULL(FLAVOUR_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(FLAVOUR_WEIGHT, 0)) + '|' + ISNULL(ITEM_INPUT_DIV, '') + '|' + ISNULL(ITEM_BAR_CD, '') + '|' + ";
                //sQuery += " 	   ISNULL(TAKE_IN_OUT_DIV, '') + '|' + ISNULL(ITEM_TAX_DIV, '') + '|' + ISNULL(TAX_AMT_INCLUDE_YN, '') + '|' + ISNULL(TAXRATE_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(APPLY_TAX_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_VAT, 0)) + '|' + ";
                //sQuery += " 	   ISNULL(SVC_TAXREATE_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(BILL_AMT, 0)) + '|' + ISNULL(NONSALES_RSN_CD, '') + '|' + ISNULL(DC_DIV, '') + '|' + ISNULL(DC_TYPE, '') + '|' + CONVERT(VARCHAR, ISNULL(DC_RATE, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ITEM_DC_AMT, 0)) + '|' + ";
                //sQuery += " 	   CONVERT(VARCHAR, ISNULL(SUM_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPI_DC_AMT, 0)) + '|' + ISNULL(COOP_CARD_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(COOP_CARD_DC_AMT, 0)) + '|' + ISNULL(POINT_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(POINT_DC_AMT, 0)) + '|' + ";
                //sQuery += " 	   ISNULL(CPN_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(CPN_DC_AMT, 0)) + '|' + ISNULL(EMP_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(EMP_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SET_DC_AMT, 0)) + '|' + ISNULL(ETC_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(ETC_DC_AMT, 0)) + '|' + ";
                //sQuery += " ISNULL(EXCEP_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(EXCEP_DC_AMT, 0)) + '|' + ISNULL(PACK_DIV, '') + '|' +  ";
                //sQuery += " ISNULL(SET_MENU_CD, '') + '|' + ISNULL(CPI_PRESENT_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(SALE_GIFT_NO, '') + '|' + ISNULL(CPN_NO, '') + '|' + ISNULL(SLACK_FIELD, '') + '|' + ISNULL(DISPO_ITEM_DIV, '') + '|' + ISNULL(CANCEL_DIV, '') AS TR_DETAIL";

                if (m_cPosStatus.Base.TrainingFlag == "1" || bHoldYn == true)   //연습모드 이거나 보류면!
                {
                    sQuery += "   FROM POSLOG..ETC_SALE_DETAIL ";
                    sQuery += "  WHERE CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND SALE_DT = '" + sSaleDate + "'";
                    sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND POS_NO  = '" + sPosNo + "'";
                    sQuery += "    AND REG_NO  = '" + sTradeNo + "'";
                    sQuery += "    AND CANCEL_DIV = '" + ItemConst.PAY_CANCEL_DIV.NORMAL + "'";
                }
                else
                {
                    sQuery += "   FROM POSLOG..TR_SALE_DETAIL ";
                    sQuery += "  WHERE CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND SALE_DT = '" + sSaleDate + "'";
                    sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND POS_NO  = '" + sPosNo + "'";
                    sQuery += "    AND TRADE_NO  = '" + sTradeNo + "'";
                    sQuery += "    AND CANCEL_DIV = '" + ItemConst.PAY_CANCEL_DIV.NORMAL + "'";
                }
                
                DataTable dtTrDetail = m_cMstService.Select(new string[] { sQuery });
                if (dtTrDetail != null && dtTrDetail.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtTrDetail.Rows)
                    {
                        if (TranParserToDetail(dr[0].ToString()) == false) return false;
                    }
                }

                return 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 false;
        }

        /// <summary>
        /// 로컬 결제 아이템 상세 조회 후 설정
        /// </summary>
        /// <param name="sSaleDate"></param>
        /// <param name="sPosNo"></param>
        /// <param name="sTradeNo"></param>
        /// <returns></returns>
        protected bool LoadLocalTrPayment(string sSaleDate, string sPosNo, string sTradeNo)
        {
            string sQuery = "";
            try
            {
                sQuery += " SELECT '#~' + '03' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(PAY_WAY_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(PAY_AMT, 0)) + '|' + ISNULL(PAY_DTL_CD_01, '') + '|' + ISNULL(PAY_DTL_CD_02, '') + '|' + ";
                sQuery += " 	   ISNULL(PAY_DTL_CD_03, '') + '|' + ISNULL(PAY_DTL_CD_04, '') + '|' + ISNULL(PAY_DTL_CD_05, '') + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_02, 0)) + '|' + ";
                sQuery += " 	   CONVERT(VARCHAR, ISNULL(QTY_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_05, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_02, 0)) + '|' + ";
                sQuery += " 	   CONVERT(VARCHAR, ISNULL(AMT_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_05, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_06, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_07, 0)) + '|' + ";
                sQuery += " 	   CONVERT(VARCHAR, ISNULL(AMT_ENTRY_08, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_09, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_10, 0)) + '|' + ISNULL(OCCUR_ENTRY_01, '') + '|' + ISNULL(OCCUR_ENTRY_02, '') + '|' + ";
                sQuery += " 	   ISNULL(OCCUR_ENTRY_03, '') + '|' + ISNULL(OCCUR_ENTRY_04, '') + '|' + ISNULL(OCCUR_ENTRY_05, '') + '|' + ISNULL(OCCUR_ENTRY_06, '') + '|' + ISNULL(OCCUR_ENTRY_07, '') + '|' + ";
                sQuery += " 	   ISNULL(OCCUR_ENTRY_08, '') + '|' + ISNULL(OCCUR_ENTRY_09, '') + '|' + ISNULL(OCCUR_ENTRY_10, '') + '|' + ISNULL(OCCUR_ENTRY_11, '') + '|' + ISNULL(OCCUR_ENTRY_12, '') + '|' + ";
                sQuery += " 	   ISNULL(OCCUR_ENTRY_13, '') + '|' + ISNULL(OCCUR_ENTRY_14, '') + '|' + ISNULL(OCCUR_ENTRY_15, '') + '|' + ISNULL(OCCUR_ENTRY_16, '') + '|' + ISNULL(OCCUR_ENTRY_17, '') + '|' + ";
                sQuery += " 	   ISNULL(OCCUR_ENTRY_18, '') + '|' + ISNULL(OCCUR_ENTRY_19, '') + '|' + ISNULL(OCCUR_ENTRY_20, '') + '|' + ISNULL(OCCUR_ENTRY_21, '') + '|' + ISNULL(OCCUR_ENTRY_22, '') + '|' + ";
                sQuery += "        ISNULL(OCCUR_ENTRY_23, '') + '|' + ISNULL(OCCUR_ENTRY_24, '') + '|' + ISNULL(OCCUR_ENTRY_25, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(CANCEL_DIV, '') AS TR_PAY";

                if (m_cPosStatus.Base.TrainingFlag == "1")
                {
                    sQuery += "  FROM POSLOG..ETC_SALE_PAY ";
                    sQuery += "  WHERE CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND SALE_DT = '" + sSaleDate + "'";
                    sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND POS_NO  = '" + sPosNo + "'";
                    sQuery += "    AND REG_NO  = '" + sTradeNo + "'";
                    sQuery += "    AND CANCEL_DIV = '" + ItemConst.PAY_CANCEL_DIV.NORMAL + "'";
                }
                else
                {
                    sQuery += "  FROM POSLOG..TR_SALE_PAY ";
                    sQuery += "  WHERE CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND SALE_DT = '" + sSaleDate + "'";
                    sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND POS_NO  = '" + sPosNo + "'";
                    sQuery += "    AND TRADE_NO = '" + sTradeNo + "'";
                    sQuery += "    AND CANCEL_DIV = '" + ItemConst.PAY_CANCEL_DIV.NORMAL + "'";
                }
                
                

                DataTable dtTrPay = m_cMstService.Select(new string[] { sQuery });
                if (dtTrPay != null && dtTrPay.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtTrPay.Rows)
                    {
                        if (TranParserToPayment(dr[0].ToString()) == false) return false;
                    }
                }

                return 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 false;
        }

        /// <summary>
        /// 로컬 기타 아이템 상세 조회 후 설정
        /// </summary>
        /// <param name="sSaleDate"></param>
        /// <param name="sPosNo"></param>
        /// <param name="sTradeNo"></param>
        /// <returns></returns>
        protected bool LoadLocalTrEtc(string sSaleDate, string sPosNo, string sTradeNo)
        {
            string sQuery = "";
            try
            {
                sQuery += " SELECT '#~' + '06' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(ETC_WAY_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(ETC_AMT, 0)) + '|' + ";
                sQuery += "        ISNULL(ETC_DTL_CD_01, '') + '|' + ISNULL(ETC_DTL_CD_02, '') + '|' + ISNULL(ETC_DTL_CD_03, '') + '|' + ISNULL(ETC_DTL_CD_04, '') + '|' + ISNULL(ETC_DTL_CD_05, '') + '|' + ";
                sQuery += "        CONVERT(VARCHAR, ISNULL(QTY_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_02, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_05, 0)) + '|' + ";
                sQuery += "        CONVERT(VARCHAR, ISNULL(AMT_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_02, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_05, 0)) + '|' + ";
                sQuery += "        CONVERT(VARCHAR, ISNULL(AMT_ENTRY_06, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_07, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_08, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_09, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_10, 0)) + '|' + ";
                sQuery += "        ISNULL(OCCUR_ENTRY_01, '') + '|' + ISNULL(OCCUR_ENTRY_02, '') + '|' + ISNULL(OCCUR_ENTRY_03, '') + '|' + ISNULL(OCCUR_ENTRY_04, '') + '|' + ISNULL(OCCUR_ENTRY_05, '') + '|' + ";
                sQuery += "        ISNULL(OCCUR_ENTRY_06, '') + '|' + ISNULL(OCCUR_ENTRY_07, '') + '|' + ISNULL(OCCUR_ENTRY_08, '') + '|' + ISNULL(OCCUR_ENTRY_09, '') + '|' + ISNULL(OCCUR_ENTRY_10, '') + '|' + ";
                sQuery += "        ISNULL(OCCUR_ENTRY_11, '') + '|' + ISNULL(OCCUR_ENTRY_12, '') + '|' + ISNULL(OCCUR_ENTRY_13, '') + '|' + ISNULL(OCCUR_ENTRY_14, '') + '|' + ISNULL(OCCUR_ENTRY_15, '') + '|' + ";
                sQuery += "        ISNULL(OCCUR_ENTRY_16, '') + '|' + ISNULL(OCCUR_ENTRY_17, '') + '|' + ISNULL(OCCUR_ENTRY_18, '') + '|' + ISNULL(OCCUR_ENTRY_19, '') + '|' + ISNULL(OCCUR_ENTRY_20, '') + '|' + ";
                sQuery += "        ISNULL(OCCUR_ENTRY_21, '') + '|' + ISNULL(OCCUR_ENTRY_22, '') + '|' + ISNULL(OCCUR_ENTRY_23, '') + '|' + ISNULL(OCCUR_ENTRY_24, '') + '|' + ISNULL(OCCUR_ENTRY_25, '') + '|' + ";
                sQuery += "        CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(CANCEL_DIV, '') AS TR_ETC";

                if (m_cPosStatus.Base.TrainingFlag == "1")
                {
                    sQuery += "   FROM POSLOG..ETC_SALE_ETC ";
                    sQuery += "  WHERE CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND SALE_DT = '" + sSaleDate + "'";
                    sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND POS_NO  = '" + sPosNo + "'";
                    sQuery += "    AND REG_NO = '" + sTradeNo + "'";
                    sQuery += "    AND CANCEL_DIV = '" + ItemConst.PAY_CANCEL_DIV.NORMAL + "'";
                }
                else
                {
                    sQuery += "   FROM POSLOG..TR_SALE_ETC ";
                    sQuery += "  WHERE CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND SALE_DT = '" + sSaleDate + "'";
                    sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND POS_NO  = '" + sPosNo + "'";
                    sQuery += "    AND TRADE_NO = '" + sTradeNo + "'";
                    sQuery += "    AND CANCEL_DIV = '" + ItemConst.PAY_CANCEL_DIV.NORMAL + "'";
                }
                
                

                DataTable dtTrEtc = m_cMstService.Select(new string[] { sQuery });
                if (dtTrEtc != null && dtTrEtc.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtTrEtc.Rows)
                    {
                        if (TranParserToEtc(dr[0].ToString()) == false) return false;
                    }
                }

                // 추후 거래 내역
                sQuery = "";
                sQuery += " SELECT '#~' + '06' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(ETC_WAY_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(ETC_AMT, 0)) + '|' + ";
                sQuery += "        ISNULL(ETC_DTL_CD_01, '') + '|' + ISNULL(ETC_DTL_CD_02, '') + '|' + ISNULL(ETC_DTL_CD_03, '') + '|' + ISNULL(ETC_DTL_CD_04, '') + '|' + ISNULL(ETC_DTL_CD_05, '') + '|' + ";
                sQuery += "        CONVERT(VARCHAR, ISNULL(QTY_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_02, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_05, 0)) + '|' + ";
                sQuery += "        CONVERT(VARCHAR, ISNULL(AMT_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_02, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_05, 0)) + '|' + ";
                sQuery += "        CONVERT(VARCHAR, ISNULL(AMT_ENTRY_06, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_07, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_08, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_09, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_10, 0)) + '|' + ";
                sQuery += "        ISNULL(OCCUR_ENTRY_01, '') + '|' + ISNULL(OCCUR_ENTRY_02, '') + '|' + ISNULL(OCCUR_ENTRY_03, '') + '|' + ISNULL(OCCUR_ENTRY_04, '') + '|' + ISNULL(OCCUR_ENTRY_05, '') + '|' + ";
                sQuery += "        ISNULL(OCCUR_ENTRY_06, '') + '|' + ISNULL(OCCUR_ENTRY_07, '') + '|' + ISNULL(OCCUR_ENTRY_08, '') + '|' + ISNULL(OCCUR_ENTRY_09, '') + '|' + ISNULL(OCCUR_ENTRY_10, '') + '|' + ";
                sQuery += "        ISNULL(OCCUR_ENTRY_11, '') + '|' + ISNULL(OCCUR_ENTRY_12, '') + '|' + ISNULL(OCCUR_ENTRY_13, '') + '|' + ISNULL(OCCUR_ENTRY_14, '') + '|' + ISNULL(OCCUR_ENTRY_15, '') + '|' + ";
                sQuery += "        ISNULL(OCCUR_ENTRY_16, '') + '|' + ISNULL(OCCUR_ENTRY_17, '') + '|' + ISNULL(OCCUR_ENTRY_18, '') + '|' + ISNULL(OCCUR_ENTRY_19, '') + '|' + ISNULL(OCCUR_ENTRY_20, '') + '|' + ";
                sQuery += "        ISNULL(OCCUR_ENTRY_21, '') + '|' + ISNULL(OCCUR_ENTRY_22, '') + '|' + ISNULL(OCCUR_ENTRY_23, '') + '|' + ISNULL(OCCUR_ENTRY_24, '') + '|' + ISNULL(OCCUR_ENTRY_25, '') + '|' + ";
                sQuery += "        CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(CANCEL_DIV, '') AS TR_ETC";
                sQuery += " FROM ( SELECT B.* FROM POSLOG..ETC_SALE_HEADER A ";
                sQuery += "    JOIN POSLOG..ETC_SALE_ETC B ON A.CMP_CD=B.CMP_CD AND A.SALE_DT=B.SALE_DT AND A.STOR_CD=B.STOR_CD AND A.POS_NO=B.POS_NO AND A.REG_NO=B.REG_NO ";
                sQuery += " WHERE A.CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "' ";
                sQuery += "    AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' ";
                sQuery += "    AND A.TRADE_KINDPER IN('" + ItemConst.TRAN_KIND.AFTER.HP_SAVE + "','" + ItemConst.TRAN_KIND.AFTER.CASH_RECEIPT + "')  ";
                sQuery += "    AND A.ORG_BILLDT = '" + sSaleDate + "' ";
                sQuery += "    AND A.ORG_BILL_POSNO = '" + sPosNo + "' ";
                sQuery += "    AND A.ORG_BILL_NO = '" + sTradeNo + "' ";
                sQuery += "    AND B.CANCEL_DIV = '" + ItemConst.PAY_CANCEL_DIV.NORMAL + "' ) ETC_SALE_ETC ";

                DataTable dtEtcEtc = m_cMstService.Select(new string[] { sQuery });
                if (dtEtcEtc != null && dtEtcEtc.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtEtcEtc.Rows)
                    {
                        if (TranParserToEtc(dr[0].ToString()) == false) return false;
                    }
                }
                return 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 false;
        }

        /// <summary>
        /// 로컬 캠페인 아이템 상세 조회 후 설정
        /// </summary>
        /// <param name="sSaleDate"></param>
        /// <param name="sPosNo"></param>
        /// <param name="sTradeNo"></param>
        /// <returns></returns>
        protected bool LoadLocalTrCampaign(string sSaleDate, string sPosNo, string sTradeNo)
        {
            string sQuery = "";
            try
            {
                sQuery += " SELECT '#~' + '05' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(CPI_TYPE, '') + '|' + CONVERT(VARCHAR, ISNULL(NMTAX_SEQ, 0)) + '|' + ISNULL(CPI_CD, '') + '|' + ISNULL(SUB_SHOP_CD, '') + '|' + ";
                sQuery += "        ISNULL(ITEM_PLU_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(DC_QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(DC_SUM_AMT, 0)) + '|' + ISNULL(CPI_DIV, '') + '|' + ";
                sQuery += "        ISNULL(PAYMNT_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(ACCUM_POINT, 0)) + '|' + ISNULL(LTTR_NMPLAT_NO, '') + '|' + ISNULL(CPI_CUST_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ";
                sQuery += "        ISNULL(SLACK_FIELD, '') + '|' + ISNULL(CANCEL_DIV, '') AS TR_CPI_RSLT ";


                if (m_cPosStatus.Base.TrainingFlag == "1")
                {
                    sQuery += "  FROM POSLOG..ETC_SALE_CPI_RSLT ";
                    sQuery += "  WHERE CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND SALE_DT = '" + sSaleDate + "'";
                    sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND POS_NO  = '" + sPosNo + "'";
                    sQuery += "    AND REG_NO  = '" + sTradeNo + "'";
                    sQuery += "    AND CANCEL_DIV = '" + ItemConst.PAY_CANCEL_DIV.NORMAL + "'";
                }
                else
                {
                    sQuery += "  FROM POSLOG..TR_SALE_CPI_RSLT ";
                    sQuery += "  WHERE CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND SALE_DT = '" + sSaleDate + "'";
                    sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND POS_NO  = '" + sPosNo + "'";
                    sQuery += "    AND TRADE_NO = '" + sTradeNo + "'";
                    sQuery += "    AND CANCEL_DIV = '" + ItemConst.PAY_CANCEL_DIV.NORMAL + "'";
                }
                
                

                DataTable dtTrCpi = m_cMstService.Select(new string[] { sQuery });
                if (dtTrCpi != null && dtTrCpi.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtTrCpi.Rows)
                    {
                        if (TranParserToCampaign(dr[0].ToString()) == false) return false;
                    }
                }

                return 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 false;
        }

        /// <summary>
        /// 로컬 매출객수 상세 조회 후 설정
        /// </summary>
        /// <param name="sSaleDate"></param>
        /// <param name="sPosNo"></param>
        /// <param name="sTradeNo"></param>
        /// <returns></returns>
        protected bool LoadLocalTrGuestCnt(string sSaleDate, string sPosNo, string sTradeNo)
        {
            string sQuery = "";
            try
            {
                sQuery += " SELECT '#~' + '09' + '|' + '000000' + '|' + '0' + '|' + CONVERT(VARCHAR, ISNULL(MALE_10L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(MALE_20L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(MALE_30L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(MALE_40L, 0)) + '|' + ";
                sQuery += "        CONVERT(VARCHAR, ISNULL(MALE_50L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(FMALE_10L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(FMALE_20L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(FMALE_30L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(FMALE_40L, 0)) + '|' + ";
                sQuery += "        CONVERT(VARCHAR, ISNULL(FMALE_50L, 0)) AS TR_GUESTCNT ";

                if (m_cPosStatus.Base.TrainingFlag == "1")
                {
                    sQuery += "   FROM POSLOG..ETC_SALE_GUESTCNT ";
                    sQuery += "  WHERE CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND SALE_DT = '" + sSaleDate + "'";
                    sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND POS_NO  = '" + sPosNo + "'";
                    sQuery += "    AND REG_NO  = '" + sTradeNo + "'";
                }
                else
                {
                    sQuery += "   FROM POSLOG..TR_SALE_GUESTCNT ";
                    sQuery += "  WHERE CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND SALE_DT = '" + sSaleDate + "'";
                    sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND POS_NO  = '" + sPosNo + "'";
                    sQuery += "    AND TRADE_NO = '" + sTradeNo + "'";
                }
                
                
                
                
                DataTable dtTrGuest = m_cMstService.Select(new string[] { sQuery });
                if (dtTrGuest != null && dtTrGuest.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtTrGuest.Rows)
                    {
                        if (TranParserToGuestCnt(dr[0].ToString()) == false) return false;
                    }
                }

                return 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 false;
        }

        /// <summary>
        /// 로컬 예약 고객 정보 조회 후 설정
        /// </summary>
        /// <param name="sSaleDate"></param>
        /// <param name="sPosNo"></param>
        /// <param name="sTradeNo"></param>
        /// <returns></returns>
        protected bool LoadLocalTrReservInfo(string sSaleDate, string sPosNo, string sTradeNo)
        {
            string sQuery = "";
            try
            {

                sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranReservInfo + "' + '|' + '000000' + '|' + '0' + '|' + ISNULL(RESERV_NO, 0) + '|' +ISNULL(RESERV_REG_DT, 0) + '|' + ISNULL(RESERV_REG_TM, 0) + '|' + ISNULL(ONOFF_DIV, 0) + '|' + ";
                sQuery += " ISNULL(CUSTNM, 0) + '|' + ISNULL(CUST_PHN_NO, 0) + '|' + ISNULL(RESERV_DT, 0) + '|' + ISNULL(RESERV_TM, 0) + '|' + ISNULL(RESERV_MEMO, 0) AS TR_RESERVINFO ";
                

                if (m_cPosStatus.Base.TrainingFlag == "1")
                {
                    sQuery += " FROM POSLOG..ETC_RESERV_INFO ";
                    sQuery += "  WHERE CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND SALE_DT = '" + sSaleDate + "'";
                    sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND POS_NO  = '" + sPosNo + "'";
                    sQuery += "    AND REG_NO  = '" + sTradeNo + "'";
                }
                else
                {
                    sQuery += " FROM POSLOG..TR_RESERV_INFO ";
                    sQuery += "  WHERE CMP_CD  = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND SALE_DT = '" + sSaleDate + "'";
                    sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND POS_NO  = '" + sPosNo + "'";
                    sQuery += "    AND TRADE_NO = '" + sTradeNo + "'";
                }


                DataTable dtTrReservInfo = m_cMstService.Select(new string[] { sQuery });
                if (dtTrReservInfo != null && dtTrReservInfo.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtTrReservInfo.Rows)
                    {
                        if (TranParserToTrReservInfo(dr[0].ToString()) == false) return false;
                    }
                }

                return 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 false;
        }

        #endregion

        #region 서버 영수증 호출 IRT 처리
        /// <summary>
        /// 서버 영수증 호출 IRT 처리
        /// </summary>
        /// <param name="sInqType"></param>
        /// <param name="sSaleDate"></param>
        /// <param name="sPosNo"></param>
        /// <param name="sTradeNo"></param>
        /// <param name="SaleTime"></param>
        /// <param name="htRecvData"></param>
        /// <returns></returns>
        public string ExecServerTranCallIrt(string sInqType, string sSaleDate, string sPosNo, string sTradeNo, string SaleTime, ref Hashtable htRecvData)
        {
            return ExecServerTranCallIrt(sInqType, sSaleDate, sPosNo, sTradeNo, SaleTime, ref htRecvData, true);
        }

        public string ExecServerTranCallIrt(string sInqType, string sSaleDate, string sPosNo, string sTradeNo, string SaleTime, ref Hashtable htRecvData, bool VisibleMode)
        {
            string sStat = UserCom.RST_ERR;
            try
            {
                Hashtable htSendData = new Hashtable();

                htSendData.Add(Column.IQ_TRAN_CALL_REQ.DATA.INQ_TYPE, sInqType);
                htSendData.Add(Column.IQ_TRAN_CALL_REQ.DATA.STOR_CD, m_cPosStatus.Base.StoreNo);
                htSendData.Add(Column.IQ_TRAN_CALL_REQ.DATA.SALE_DT, sSaleDate);
                htSendData.Add(Column.IQ_TRAN_CALL_REQ.DATA.POS_NO, sPosNo);
                htSendData.Add(Column.IQ_TRAN_CALL_REQ.DATA.TRADE_NO, sTradeNo);
                htSendData.Add(Column.IQ_TRAN_CALL_REQ.DATA.PAY_TIME, SaleTime);
                htSendData.Add(Column.IQ_TRAN_CALL_REQ.DATA.RET_DIV, "");
                htSendData.Add(Column.IQ_TRAN_CALL_REQ.DATA.ADD_POINT_DIV, "");
                htSendData.Add(Column.IQ_TRAN_CALL_REQ.DATA.ADD_CASH_DIV, "");
                htSendData.Add(Column.IQ_TRAN_CALL_REQ.DATA.RET_SALE_DT, "");
                htSendData.Add(Column.IQ_TRAN_CALL_REQ.DATA.RET_POS_NO, "");
                htSendData.Add(Column.IQ_TRAN_CALL_REQ.DATA.RET_TRADE_NO, "");
                htSendData.Add(Column.IQ_TRAN_CALL_REQ.DATA.TRAN_LEN, "");
                htSendData.Add(Column.IQ_TRAN_CALL_REQ.DATA.TRAN_DATA, "");
                htSendData.Add(Column.IQ_TRAN_CALL_REQ.DATA.RES_CD, "");

                return m_cDataCommon.ExecutePosIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.TranInqPort, 10000, htSendData, ref htRecvData, VisibleMode);
            }
            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 sStat;
        }
        #endregion

        #region 거래 데이터 분해 처리
        /// <summary>
        /// 해더 아이템 분해
        /// </summary>
        /// <param name="sTrData"></param>
        /// <returns></returns>
        protected bool TranParserToHeader(string sTrData)
        {
            try
            {
                string[] aTrData = sTrData.Split('|');

                m_cTrnStatus.Head.TradeDiv = aTrData[Column.TRAN_HEADER.SEQ.TRADE_DIV];                 // TRADE_DIV
                m_cTrnStatus.Head.TrainModeYn = aTrData[Column.TRAN_HEADER.SEQ.TRAIN_MODE_YN];          // TRAIN_MODE_YN
                m_cTrnStatus.Head.TradeKind = aTrData[Column.TRAN_HEADER.SEQ.TRADE_KINDPER];            // TRADE_KINDPER
                m_cTrnStatus.Head.SysYmd = aTrData[Column.TRAN_HEADER.SEQ.SYS_DT];                      // SYS_DT
                m_cTrnStatus.Head.OrderHms = aTrData[Column.TRAN_HEADER.SEQ.ORD_TIME];                  // ORD_TIME
                m_cTrnStatus.Head.PayHms = aTrData[Column.TRAN_HEADER.SEQ.PAY_TIME];                    // PAY_TIME
                m_cTrnStatus.Head.CashierId = aTrData[Column.TRAN_HEADER.SEQ.PIC_NO];                   // PIC_NO
                m_cTrnStatus.Head.OrderPicNo = aTrData[Column.TRAN_HEADER.SEQ.ORD_PIC_NO];              // ORD_PIC_NO
                m_cTrnStatus.Head.OwnPartDiv = aTrData[Column.TRAN_HEADER.SEQ.STOR_OWN_PART_TIME_DIV];  // STOR_OWN_PART_TIME_DIV
                m_cTrnStatus.Head.OrgPosNo = aTrData[Column.TRAN_HEADER.SEQ.ORG_BILL_POSNO];            // ORG_BILL_POSNO
                m_cTrnStatus.Head.OrgSaleDate = aTrData[Column.TRAN_HEADER.SEQ.ORG_BILLDT];             // ORG_BILLDT
                m_cTrnStatus.Head.OrgTradeNo = aTrData[Column.TRAN_HEADER.SEQ.ORG_BILL_NO];             // ORG_BILL_NO
                m_cTrnStatus.Head.RtnReasonCd = aTrData[Column.TRAN_HEADER.SEQ.RTN_RSN_CD];             // RTN_RSN_CD
                m_cTrnStatus.Head.RtnReasonMemo = aTrData[Column.TRAN_HEADER.SEQ.RTN_RSN_MEMO];         // RTN_RSN_MEMO
                m_cTrnStatus.Head.NonSaleRsnCd = aTrData[Column.TRAN_HEADER.SEQ.NONSALES_RSN_CD];       // NONSALES_RSN_CD
                m_cTrnStatus.Head.ReserveNo = aTrData[Column.TRAN_HEADER.SEQ.RESERV_NO];                // RESERV_NO
                m_cTrnStatus.Head.ReserveYmd = aTrData[Column.TRAN_HEADER.SEQ.RESERV_DT];               // RESERV_DT
                m_cTrnStatus.Head.MemberCustNo = aTrData[Column.TRAN_HEADER.SEQ.CUST_NO];               // CUST_NO
                m_cTrnStatus.Head.OrderFlag = aTrData[Column.TRAN_HEADER.SEQ.ORD_DIV];                  // ORD_DIV
                m_cTrnStatus.Head.FloorCd = aTrData[Column.TRAN_HEADER.SEQ.FLOOR_CD];                   // FLOOR_CD
                m_cTrnStatus.Head.TableNo = aTrData[Column.TRAN_HEADER.SEQ.TBL_NO];                     // TBL_NO
                m_cTrnStatus.Head.CustFloor = aTrData[Column.TRAN_HEADER.SEQ.GUESTFLOOR];               // GUESTFLOOR
                m_cTrnStatus.Head.ForeignFlag = aTrData[Column.TRAN_HEADER.SEQ.FRGNR_DIV];              // FRGNR_DIV
                m_cTrnStatus.Head.CustCnt = CmUtil.LongParse(aTrData[Column.TRAN_HEADER.SEQ.CUSTCNT]);  // CUSTCNT
                m_cTrnStatus.Head.PayGndrDiv = aTrData[Column.TRAN_HEADER.SEQ.PAY_GNDR_DIV];            // PAY_GNDR_DIV
                m_cTrnStatus.Head.PayAge = CmUtil.LongParse(aTrData[Column.TRAN_HEADER.SEQ.PAY_AGE]);   // PAY_AGE
                m_cTrnStatus.Head.ManCmpnpsnCnt = CmUtil.LongParse(aTrData[Column.TRAN_HEADER.SEQ.MAN_CMPNPSN_CNT]);        // MAN_CMPNPSN_CNT
                m_cTrnStatus.Head.WomanCmpnpsnCnt = CmUtil.LongParse(aTrData[Column.TRAN_HEADER.SEQ.WOMAN_CMPNPSN_CNT]);    // WOMAN_CMPNPSN_CNT
                m_cTrnStatus.Head.TotQty = CmUtil.LongParse(aTrData[Column.TRAN_HEADER.SEQ.QTY]);                   // QTY
                m_cTrnStatus.Head.TotSaleAmt = CmUtil.DoubleParse(aTrData[Column.TRAN_HEADER.SEQ.TOTSALE_AMT]);     // TOTSALE_AMT
                m_cTrnStatus.Head.TotDcAmt = CmUtil.DoubleParse(aTrData[Column.TRAN_HEADER.SEQ.TOTDC_AMT]);         // TOTDC_AMT
                m_cTrnStatus.Head.NetSaleAmt = CmUtil.DoubleParse(aTrData[Column.TRAN_HEADER.SEQ.NET_SALE_AMT]);    // NET_SALE_AMT
                m_cTrnStatus.Head.ItemDcAmt = CmUtil.DoubleParse(aTrData[Column.TRAN_HEADER.SEQ.ITEM_DC_AMT]);      // ITEM_DC_AMT
                m_cTrnStatus.Head.CpiDcAmt = CmUtil.DoubleParse(aTrData[Column.TRAN_HEADER.SEQ.CPI_DC_AMT]);        // CPI_DC_AMT
                m_cTrnStatus.Head.CoopCardDcAmt = CmUtil.DoubleParse(aTrData[Column.TRAN_HEADER.SEQ.COOP_CARD_DC_AMT]); // CPI_DC_AMT
                m_cTrnStatus.Head.PointDcAmt = CmUtil.DoubleParse(aTrData[Column.TRAN_HEADER.SEQ.POINT_DC_AMT]);    // CPI_DC_AMT
                m_cTrnStatus.Head.CpnDcAmt = CmUtil.DoubleParse(aTrData[Column.TRAN_HEADER.SEQ.CPN_DC_AMT]);        // CPI_DC_AMT
                m_cTrnStatus.Head.EmpDcAmt = CmUtil.DoubleParse(aTrData[Column.TRAN_HEADER.SEQ.EMP_DC_AMT]);        // CPI_DC_AMT
                m_cTrnStatus.Head.SetDcAmt = CmUtil.DoubleParse(aTrData[Column.TRAN_HEADER.SEQ.SET_DC_AMT]);        // SET_DC_AMT
                m_cTrnStatus.Head.EtcDcAmt = CmUtil.DoubleParse(aTrData[Column.TRAN_HEADER.SEQ.ETC_AMT]);           // ETC_AMT
                m_cTrnStatus.Head.ExcepDcAmt = CmUtil.DoubleParse(aTrData[Column.TRAN_HEADER.SEQ.EXCEP_DC_AMT]);    // EXCEP_DC_AMT
                m_cTrnStatus.Head.TotVatAmt = CmUtil.DoubleParse(aTrData[Column.TRAN_HEADER.SEQ.TOT_VAT]);          // TOT_VAT
                m_cTrnStatus.Head.SvcFeeAmt = CmUtil.DoubleParse(aTrData[Column.TRAN_HEADER.SEQ.SVC_FEE_AMT]);      // SVC_FEE_AMT
                m_cTrnStatus.Head.SvcFeeVat = CmUtil.DoubleParse(aTrData[Column.TRAN_HEADER.SEQ.SVC_FEE_VAT]);      // SVC_FEE_VAT
                m_cTrnStatus.Head.EtcVatAmt = CmUtil.DoubleParse(aTrData[Column.TRAN_HEADER.SEQ.ETC_VAT]);          // ETC_VAT
                m_cTrnStatus.Head.AftSavePoint = CmUtil.DoubleParse(aTrData[Column.TRAN_HEADER.SEQ.AF_ACCUM_POINT_AMT]);    // AF_ACCUM_POINT_AMT
                m_cTrnStatus.Head.AftSaveAddInfo = aTrData[Column.TRAN_HEADER.SEQ.AF_ACCUM_POINT_INFO];
                m_cTrnStatus.Head.PpCardCustNm = aTrData[Column.TRAN_HEADER.SEQ.PPCARD_CUSTNM];
                m_cTrnStatus.Head.AmtDutchPayYn = aTrData[Column.TRAN_HEADER.SEQ.AMT_DUTCHPAY_YN];                  // AMT_DUTCHPAY_YN
                m_cTrnStatus.Head.BillSplitCnt = CmUtil.LongParse(aTrData[Column.TRAN_HEADER.SEQ.BILLSPR_CNT]);     // BILLSPR_CNT
                m_cTrnStatus.Head.OrderNo = aTrData[Column.TRAN_HEADER.SEQ.ORDER_NO];                               // ORDER_NO
                m_cTrnStatus.Head.MidCloseSeq = aTrData[Column.TRAN_HEADER.SEQ.MID_CLOSE_SEQ];                      // MID_CLOSE_SEQ
                m_cTrnStatus.Head.PpCardCustId = aTrData[Column.TRAN_HEADER.SEQ.PPCARD_CUSTID];                     // PPCARD_CUSTID
                m_cTrnStatus.Head.PackTradeDiv = aTrData[Column.TRAN_HEADER.SEQ.PACK_TRADE_DIV];                    // PACK_TRADE_DIV
                m_cTrnStatus.Head.VipTy = aTrData[Column.TRAN_HEADER.SEQ.VIP_TY];                                   // VIP_TY
                //#20170828 해피포인트 적립 제외 버튼 추가 phj, start
                m_cTrnStatus.Head.HP_EXCLUDE_YN = aTrData[Column.TRAN_HEADER.SEQ.HP_EXCLUDE_YN];                    //HP_EXCLUDE_YN
                //#20170828 해피포인트 적립 제외 버튼 추가 phj, end

                //#15149 PB 오목교 - 기부내역 불러온뒤 제품추가 후 결제하면 추가한수량 합계되지않는 증상 start
                //m_cTrnStatus.Head.NonSaleRsnCd = aTrData[Column.TRAN_HEADER.SEQ.NONSALES_RSN_CD];                  // NONSALES_RSN_CD
                //#15149 PB 오목교 - 기부내역 불러온뒤 제품추가 후 결제하면 추가한수량 합계되지않는 증상 end
                
                return 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 false;
        }

        /// <summary>
        /// 상품 아이템 분해
        /// </summary>
        /// <param name="sTrData"></param>
        /// <returns></returns>
        protected bool TranParserToDetail(string sTrData)
        {
            try
            {
                string[] aTrData = sTrData.Split('|');

                ArrayList m_alTrPluItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM);

                Column.TR_PLU.DATA cSaleItem = new Column.TR_PLU.DATA();

                cSaleItem.ORD_TIME = aTrData[Column.TR_PLU.SEQ.ORD_TIME];
                cSaleItem.FLOOR_CD = aTrData[Column.TR_PLU.SEQ.FLOOR_CD];
                cSaleItem.TBL_NO = aTrData[Column.TR_PLU.SEQ.TBL_NO];
                cSaleItem.SUB_SHOP_CD = aTrData[Column.TR_PLU.SEQ.SUB_SHOP_CD];
                cSaleItem.ITEM_PLU_CD = aTrData[Column.TR_PLU.SEQ.ITEM_PLU_CD];
                cSaleItem.ITEM_DIV = aTrData[Column.TR_PLU.SEQ.ITEM_DIV];
                cSaleItem.SALE_QTY = CmUtil.LongParse(aTrData[Column.TR_PLU.SEQ.SALE_QTY]);
                cSaleItem.SALE_PRC = CmUtil.DoubleParse(aTrData[Column.TR_PLU.SEQ.SALE_PRC]);
                cSaleItem.SALE_AMT = CmUtil.DoubleParse(aTrData[Column.TR_PLU.SEQ.SALE_AMT]);
                cSaleItem.FLAVOUR_DIV = aTrData[Column.TR_PLU.SEQ.FLAVOUR_DIV];
                cSaleItem.FLAVOUR_STOCK = CmUtil.DoubleParse(aTrData[Column.TR_PLU.SEQ.FLAVOUR_STOCK]);
                cSaleItem.ITEM_INPUT_DIV = aTrData[Column.TR_PLU.SEQ.ITEM_INPUT_DIV];
                cSaleItem.ITEM_BAR_CD = aTrData[Column.TR_PLU.SEQ.ITEM_BAR_CD];
                cSaleItem.TAKE_IN_OUT_DIV = aTrData[Column.TR_PLU.SEQ.TAKE_IN_OUT_DIV];
                cSaleItem.ITEM_TAX_DIV = aTrData[Column.TR_PLU.SEQ.ITEM_TAX_DIV];
                cSaleItem.TAX_AMT_INCLUDE_YN = aTrData[Column.TR_PLU.SEQ.TAX_AMT_INCLUDE_YN];
                cSaleItem.TAXRATE_CD = aTrData[Column.TR_PLU.SEQ.TAXRATE_CD];
                cSaleItem.APPLY_TAX_AMT = CmUtil.DoubleParse(aTrData[Column.TR_PLU.SEQ.APPLY_TAX_AMT]);
                cSaleItem.SVC_FEE_AMT = CmUtil.DoubleParse(aTrData[Column.TR_PLU.SEQ.SVC_FEE_AMT]);
                cSaleItem.SVC_FEE_VAT = CmUtil.DoubleParse(aTrData[Column.TR_PLU.SEQ.SVC_FEE_VAT]);
                cSaleItem.SVC_TAXREATE_CD = aTrData[Column.TR_PLU.SEQ.SVC_TAXREATE_CD];
                cSaleItem.BILL_AMT = CmUtil.DoubleParse(aTrData[Column.TR_PLU.SEQ.BILL_AMT]);
                cSaleItem.NONSALES_RSN_CD = aTrData[Column.TR_PLU.SEQ.NONSALES_RSN_CD];
                cSaleItem.DC_DIV = aTrData[Column.TR_PLU.SEQ.DC_DIV];
                cSaleItem.DC_TYPE = aTrData[Column.TR_PLU.SEQ.DC_TYPE];
                cSaleItem.DC_RATE = CmUtil.DoubleParse(aTrData[Column.TR_PLU.SEQ.DC_RATE]);
                cSaleItem.ITEM_DC_AMT = CmUtil.DoubleParse(aTrData[Column.TR_PLU.SEQ.ITEM_DC_AMT]);
                cSaleItem.SUM_DC_AMT = CmUtil.DoubleParse(aTrData[Column.TR_PLU.SEQ.SUM_DC_AMT]);
                cSaleItem.CPI_DC_QTY = CmUtil.LongParse(aTrData[Column.TR_PLU.SEQ.CPI_DC_QTY]);
                cSaleItem.CPI_DC_AMT = CmUtil.DoubleParse(aTrData[Column.TR_PLU.SEQ.CPI_DC_AMT]);
                cSaleItem.COOP_CARD_DC_DIV = aTrData[Column.TR_PLU.SEQ.COOP_CARD_DC_DIV];
                cSaleItem.COOP_CARD_DC_AMT = CmUtil.DoubleParse(aTrData[Column.TR_PLU.SEQ.COOP_CARD_DC_AMT]);
                cSaleItem.POINT_DC_DIV = aTrData[Column.TR_PLU.SEQ.POINT_DC_DIV];
                cSaleItem.POINT_DC_AMT = CmUtil.DoubleParse(aTrData[Column.TR_PLU.SEQ.POINT_DC_AMT]);
                cSaleItem.CPN_DC_DIV = aTrData[Column.TR_PLU.SEQ.CPN_DC_DIV];
                cSaleItem.CPN_DC_AMT = CmUtil.DoubleParse(aTrData[Column.TR_PLU.SEQ.CPN_DC_AMT]);
                cSaleItem.EMP_DC_DIV = aTrData[Column.TR_PLU.SEQ.EMP_DC_DIV];
                cSaleItem.EMP_DC_AMT = CmUtil.DoubleParse(aTrData[Column.TR_PLU.SEQ.EMP_DC_AMT]);
                cSaleItem.SET_DC_AMT = CmUtil.DoubleParse(aTrData[Column.TR_PLU.SEQ.SET_DC_AMT]);
                cSaleItem.ETC_DC_DIV = aTrData[Column.TR_PLU.SEQ.ETC_DC_DIV];
                cSaleItem.ETC_DC_AMT = CmUtil.DoubleParse(aTrData[Column.TR_PLU.SEQ.ETC_DC_AMT]);
                cSaleItem.EXCEP_DC_DIV = aTrData[Column.TR_PLU.SEQ.EXCEP_DC_DIV];  
                cSaleItem.EXCEP_DC_AMT = CmUtil.DoubleParse(aTrData[Column.TR_PLU.SEQ.EXCEP_DC_AMT]);
                cSaleItem.PACK_DIV = aTrData[Column.TR_PLU.SEQ.PACK_DIV];
                cSaleItem.SET_MENU_CD = aTrData[Column.TR_PLU.SEQ.SET_MENU_CD];
                cSaleItem.SUBPRC_MENU_KEY_DIV = aTrData[Column.TR_PLU.SEQ.SUBPRC_MENU_KEY_DIV];
                cSaleItem.CPI_PRESENT_DIV = aTrData[Column.TR_PLU.SEQ.CPI_PRESENT_DIV];
                cSaleItem.BILLSPR_NO = CmUtil.LongParse(aTrData[Column.TR_PLU.SEQ.BILLSPR_NO]);
                cSaleItem.SALE_GIFT_NO = aTrData[Column.TR_PLU.SEQ.SALE_GIFT_NO];
                cSaleItem.CPN_NO = aTrData[Column.TR_PLU.SEQ.CPN_NO];
                cSaleItem.DISPO_ITEM_DIV = aTrData[Column.TR_PLU.SEQ.DISPO_ITEM_DIV];

                cSaleItem.CANCEL_DIV = aTrData[Column.TR_PLU.SEQ.CANCEL_DIV];
                if (cSaleItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL_SUBTOT)
                {
                    cSaleItem.CANCEL_DIV = PosConst.CANCEL_DIV.CANCEL;
                }
                cSaleItem.NOTAX_DIV = aTrData[Column.TR_PLU.SEQ.NOTAX_DIV];
               
                cSaleItem.ORDER_OK_FLAG = PosConst.PLU_ORDER_OK_FLAG.ORDER_ING;

                cSaleItem.SLACK_FIELD = aTrData[Column.TR_PLU.SEQ.SLACK_FIELD];         // 선불카드권종(2017.06.27)

                //#20180903 해피오더 매출 생성 시 tr_sale_detail에 구분자 추가 start - 20180907 
                //기존
                /*
                //#20180903 해피오더 매출 생성 시 tr_sale_detail에 구분자 추가 start
                cSaleItem.HPO_REG_YN = aTrData[Column.TR_PLU.SEQ.HPO_REG_YN];
                //#20180903 해피오더 매출 생성 시 tr_sale_detail에 구분자 추가 end
                */
                //변경
                if (aTrData.Length >= 58) 
                { 
                    cSaleItem.HPO_REG_YN = aTrData[Column.TR_PLU.SEQ.HPO_REG_YN]; 
                }
                else 
                { 
                    cSaleItem.HPO_REG_YN = "0"; 
                }
                //#20180903 해피오더 매출 생성 시 tr_sale_detail에 구분자 추가 end - 20180907

                // 상품 마스터 조회 후 마스터 항목 설정
                SetTrDetailToMst(cSaleItem.SUB_SHOP_CD, cSaleItem.ITEM_PLU_CD, ref cSaleItem);

                m_cDataService.UpdatePluItemAmount(cSaleItem);

                m_alTrPluItem.Add(cSaleItem);                    // 등록 처리

                return 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 false;
        }

        /// <summary>
        /// 로컬 상품 마스터 조회 후 설정
        /// </summary>
        /// <param name="sSubStoreCode"></param>
        /// <param name="sItemCdoe"></param>
        /// <returns></returns>
        protected void SetTrDetailToMst(string sSubStoreCode, string sItemCdoe, ref Column.TR_PLU.DATA cPluItem)
        {
            try
            {
                // 상품 마스터 조회
                DataTable dtDataInfo = m_cDataCommon.SeletItemMstToItemCode(sSubStoreCode, sItemCdoe);
                if (dtDataInfo != null && dtDataInfo.Rows.Count > 0)
                {
                    DataRow drPlu = dtDataInfo.Rows[0];

                    cPluItem.SUB_SET_MNG_TYPE = CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.SUB_SET_MNG_TYPE);

                    // 상품추가 정보
                    if (cPluItem.ITEM_DIV == ItemConst.PLU_ITEM_DIV.OPT_MENU)
                    {
                        cPluItem.ITEM_NAME = ">>" + CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.SHTCUT_ITEMNM);
                    }
                    else if (cPluItem.ITEM_DIV == ItemConst.PLU_ITEM_DIV.SET_DETL)
                    {

                        cPluItem.ITEM_NAME = ">" + CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.SHTCUT_ITEMNM);

                    }
                    else if (cPluItem.FLAVOUR_DIV == ItemConst.PLU_FLAVOUR_DIV.FLAVOUR)
                    {
                        cPluItem.ITEM_NAME = ">" + CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.SHTCUT_ITEMNM);
                    }
                    else
                    {
                        cPluItem.ITEM_NAME = CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.SHTCUT_ITEMNM);
                    }
                    cPluItem.CANCEL_DIV_MAIN = "0";
                    cPluItem.FREE_GIFT_YN = CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.FREE_GIFT_YN);
                    cPluItem.DC_PRMT_YN = CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.DC_PRMT_YN);

                    cPluItem.ACCUM_PRMT_YN = CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.ACCUM_PRMT_YN);
                    cPluItem.SVC_FEE_TRGT_YN = CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.SVC_FEE_TRGT_YN);
                    cPluItem.COOP_CARD_DC_NOADM_YN = CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.COOP_CARD_DC_NOADM_YN);

                    cPluItem.L_CLSS = CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.L_CLSS);
                    cPluItem.M_CLSS = CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.M_CLSS);
                    cPluItem.S_CLSS = CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.S_CLSS);
                     
                    cPluItem.OPEN_ITEM_DIV = CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.OPEN_ITEM_DIV); //MoonSeokWoo 2017.09.11

                    cPluItem.ITEM_TAKE_IN_VAT_CD = CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.TAKE_IN_VAT_CD);
                    cPluItem.ITEM_TAKE_OUT_VAT_CD = CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.TAKE_OUT_VAT_CD);

                    //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 start
                    cPluItem.ITEM_INFO = CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.ITEM_INFO); // 영양성분 
                    cPluItem.ITEM_EXPLN = CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.ITEM_EXPLN); // 상품설명 
                    cPluItem.ALLERGY = CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.ALLERGY); // 알레르기성분 
                    cPluItem.PLACE_ORIGIN = CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.PLACE_ORIGIN); // 원산지
                    //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 end

                    cPluItem.TAX_RATE = m_cDataCommon.ItemTaxRate(cPluItem.TAXRATE_CD);
                }
                else if (cPluItem.ITEM_DIV == ItemConst.PLU_ITEM_DIV.OPT_MENU && cPluItem.SUBPRC_MENU_KEY_DIV == "1")
                {

                    dtDataInfo = m_cDataCommon.SeletSubPrcMenu(sSubStoreCode, sItemCdoe);

                    if (dtDataInfo != null && dtDataInfo.Rows.Count > 0)
                    {
                        DataRow drPlu = dtDataInfo.Rows[0];

                        cPluItem.ITEM_NAME = ">>" + CmUtil.GetDataRowStr(drPlu, PosMst.MST_SUBPRC_MENU_GRP.DATA.LABEL_NM);
                    }
                }

            }
            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>
        /// <param name="sTrData"></param>
        /// <returns></returns>
        protected bool TranParserToPayment(string sTrData)
        {
            try
            {
                string[] aTrData = sTrData.Split('|');

                ArrayList aPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);

                Column.TR_PAYMENT.DATA cPayItem = new Column.TR_PAYMENT.DATA();

                cPayItem.PAY_WAY_CD = aTrData[3];
                cPayItem.PAY_AMT = CmUtil.DoubleParse(aTrData[4]);

                cPayItem.PAY_DTL_CD_01 = aTrData[5];
                cPayItem.PAY_DTL_CD_02 = aTrData[6];
                cPayItem.PAY_DTL_CD_03 = aTrData[7];
                cPayItem.PAY_DTL_CD_04 = aTrData[8];
                cPayItem.PAY_DTL_CD_05 = aTrData[9];

                cPayItem.QTY_ENTRY_01 = CmUtil.DoubleParse(aTrData[10]);
                cPayItem.QTY_ENTRY_02 = CmUtil.DoubleParse(aTrData[11]);
                cPayItem.QTY_ENTRY_03 = CmUtil.DoubleParse(aTrData[12]);
                cPayItem.QTY_ENTRY_04 = CmUtil.DoubleParse(aTrData[13]);
                cPayItem.QTY_ENTRY_05 = CmUtil.DoubleParse(aTrData[14]);

                cPayItem.AMT_ENTRY_01 = CmUtil.DoubleParse(aTrData[15]);
                cPayItem.AMT_ENTRY_02 = CmUtil.DoubleParse(aTrData[16]);
                cPayItem.AMT_ENTRY_03 = CmUtil.DoubleParse(aTrData[17]);
                cPayItem.AMT_ENTRY_04 = CmUtil.DoubleParse(aTrData[18]);
                cPayItem.AMT_ENTRY_05 = CmUtil.DoubleParse(aTrData[19]);
                cPayItem.AMT_ENTRY_06 = CmUtil.DoubleParse(aTrData[20]);
                cPayItem.AMT_ENTRY_07 = CmUtil.DoubleParse(aTrData[21]);
                cPayItem.AMT_ENTRY_08 = CmUtil.DoubleParse(aTrData[22]);
                cPayItem.AMT_ENTRY_09 = CmUtil.DoubleParse(aTrData[23]);
                cPayItem.AMT_ENTRY_10 = CmUtil.DoubleParse(aTrData[24]);

                cPayItem.OCCUR_ENTRY_01 = aTrData[25];
                cPayItem.OCCUR_ENTRY_02 = aTrData[26];
                cPayItem.OCCUR_ENTRY_03 = aTrData[27];
                cPayItem.OCCUR_ENTRY_04 = aTrData[28];
                cPayItem.OCCUR_ENTRY_05 = aTrData[29];
                cPayItem.OCCUR_ENTRY_06 = aTrData[30];
                cPayItem.OCCUR_ENTRY_07 = aTrData[31];
                cPayItem.OCCUR_ENTRY_08 = aTrData[32];
                cPayItem.OCCUR_ENTRY_09 = aTrData[33];
                cPayItem.OCCUR_ENTRY_10 = aTrData[34];
                cPayItem.OCCUR_ENTRY_11 = aTrData[35];
                cPayItem.OCCUR_ENTRY_12 = aTrData[36];
                cPayItem.OCCUR_ENTRY_13 = aTrData[37];
                cPayItem.OCCUR_ENTRY_14 = aTrData[38];
                cPayItem.OCCUR_ENTRY_15 = aTrData[39];
                cPayItem.OCCUR_ENTRY_16 = aTrData[40];
                cPayItem.OCCUR_ENTRY_17 = aTrData[41];
                cPayItem.OCCUR_ENTRY_18 = aTrData[42];
                cPayItem.OCCUR_ENTRY_19 = aTrData[43];
                cPayItem.OCCUR_ENTRY_20 = aTrData[44];
                cPayItem.OCCUR_ENTRY_21 = aTrData[45];
                cPayItem.OCCUR_ENTRY_22 = aTrData[46];
                cPayItem.OCCUR_ENTRY_23 = aTrData[47];
                cPayItem.OCCUR_ENTRY_24 = aTrData[48];
                cPayItem.OCCUR_ENTRY_25 = aTrData[49];

                cPayItem.BILLSPR_NO = CmUtil.LongParse(aTrData[50]);
                cPayItem.CANCEL_DIV = aTrData[51];

                aPayItem.Add(cPayItem);

                return 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 false;
        }

        /// <summary>
        /// 기타 아이템 분해
        /// </summary>
        /// <param name="sTrData"></param>
        /// <returns></returns>
        protected bool TranParserToEtc(string sTrData)
        {
            try
            {
                string[] aTrData = sTrData.Split('|');

                ArrayList alEtcItem = (ArrayList)StateObject.GetItemObject(Column.TR_ETC.ITEM);  // 기타 내역 받아 오기

                Column.TR_ETC.DATA cEtcItem = new Column.TR_ETC.DATA();

                cEtcItem.ETC_WAY_CD = aTrData[3];
                cEtcItem.ETC_AMT = CmUtil.DoubleParse(aTrData[4]);

                cEtcItem.ETC_DTL_CD_01 = aTrData[5];
                cEtcItem.ETC_DTL_CD_02 = aTrData[6];
                cEtcItem.ETC_DTL_CD_03 = aTrData[7];
                cEtcItem.ETC_DTL_CD_04 = aTrData[8];
                cEtcItem.ETC_DTL_CD_05 = aTrData[9];

                cEtcItem.QTY_ENTRY_01 = CmUtil.DoubleParse(aTrData[10]);
                cEtcItem.QTY_ENTRY_02 = CmUtil.DoubleParse(aTrData[11]);
                cEtcItem.QTY_ENTRY_03 = CmUtil.DoubleParse(aTrData[12]);
                cEtcItem.QTY_ENTRY_04 = CmUtil.DoubleParse(aTrData[13]);
                cEtcItem.QTY_ENTRY_05 = CmUtil.DoubleParse(aTrData[14]);

                cEtcItem.AMT_ENTRY_01 = CmUtil.DoubleParse(aTrData[15]);
                cEtcItem.AMT_ENTRY_02 = CmUtil.DoubleParse(aTrData[16]);
                cEtcItem.AMT_ENTRY_03 = CmUtil.DoubleParse(aTrData[17]);
                cEtcItem.AMT_ENTRY_04 = CmUtil.DoubleParse(aTrData[18]);
                cEtcItem.AMT_ENTRY_05 = CmUtil.DoubleParse(aTrData[19]);
                cEtcItem.AMT_ENTRY_06 = CmUtil.DoubleParse(aTrData[20]);
                cEtcItem.AMT_ENTRY_07 = CmUtil.DoubleParse(aTrData[21]);
                cEtcItem.AMT_ENTRY_08 = CmUtil.DoubleParse(aTrData[22]);
                cEtcItem.AMT_ENTRY_09 = CmUtil.DoubleParse(aTrData[23]);
                cEtcItem.AMT_ENTRY_10 = CmUtil.DoubleParse(aTrData[24]);

                cEtcItem.OCCUR_ENTRY_01 = aTrData[25];
                cEtcItem.OCCUR_ENTRY_02 = aTrData[26];
                cEtcItem.OCCUR_ENTRY_03 = aTrData[27];
                cEtcItem.OCCUR_ENTRY_04 = aTrData[28];
                cEtcItem.OCCUR_ENTRY_05 = aTrData[29];
                cEtcItem.OCCUR_ENTRY_06 = aTrData[30];
                cEtcItem.OCCUR_ENTRY_07 = aTrData[31];
                cEtcItem.OCCUR_ENTRY_08 = aTrData[32];
                cEtcItem.OCCUR_ENTRY_09 = aTrData[33];
                cEtcItem.OCCUR_ENTRY_10 = aTrData[34];
                cEtcItem.OCCUR_ENTRY_11 = aTrData[35];
                cEtcItem.OCCUR_ENTRY_12 = aTrData[36];
                cEtcItem.OCCUR_ENTRY_13 = aTrData[37];
                cEtcItem.OCCUR_ENTRY_14 = aTrData[38];
                cEtcItem.OCCUR_ENTRY_15 = aTrData[39];
                cEtcItem.OCCUR_ENTRY_16 = aTrData[40];
                cEtcItem.OCCUR_ENTRY_17 = aTrData[41];
                cEtcItem.OCCUR_ENTRY_18 = aTrData[42];
                cEtcItem.OCCUR_ENTRY_19 = aTrData[43];
                cEtcItem.OCCUR_ENTRY_20 = aTrData[44];
                cEtcItem.OCCUR_ENTRY_21 = aTrData[45];
                cEtcItem.OCCUR_ENTRY_22 = aTrData[46];
                cEtcItem.OCCUR_ENTRY_23 = aTrData[47];
                cEtcItem.OCCUR_ENTRY_24 = aTrData[48];
                cEtcItem.OCCUR_ENTRY_25 = aTrData[49];

                cEtcItem.BILLSPR_NO = CmUtil.LongParse(aTrData[50]);
                cEtcItem.CANCEL_DIV = aTrData[51];

                alEtcItem.Add(cEtcItem);

                return 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 false;
        }

        /// <summary>
        /// 캠페인 아이템 분해
        /// </summary>
        /// <param name="sTrData"></param>
        /// <returns></returns>
        protected bool TranParserToCampaign(string sTrData)
        {
            try
            {
                string[] aTrData = sTrData.Split('|');

                ArrayList alTrCpiItem = (ArrayList)StateObject.GetItemObject(Column.TR_SALE_CPI_RSLT.ITEM);

                Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi = new Column.TR_SALE_CPI_RSLT.DATA();

                cTrSaleCpi.ITEM_APPLY_METHD = aTrData[Column.TR_SALE_CPI_RSLT.SEQ.ITEM_APPLY_METHD];
                cTrSaleCpi.NMTAX_SEQ = CmUtil.LongParse(aTrData[Column.TR_SALE_CPI_RSLT.SEQ.NMTAX_SEQ]);
                cTrSaleCpi.CPI_CD = aTrData[Column.TR_SALE_CPI_RSLT.SEQ.CPI_CD];
                cTrSaleCpi.SUB_SHOP_CD = aTrData[Column.TR_SALE_CPI_RSLT.SEQ.SUB_SHOP_CD];
                cTrSaleCpi.ITEM_PLU_CD = aTrData[Column.TR_SALE_CPI_RSLT.SEQ.ITEM_PLU_CD];
                cTrSaleCpi.DC_QTY = CmUtil.LongParse(aTrData[Column.TR_SALE_CPI_RSLT.SEQ.DC_QTY]);
                cTrSaleCpi.DC_SUM_AMT = CmUtil.DoubleParse(aTrData[Column.TR_SALE_CPI_RSLT.SEQ.DC_SUM_AMT]);
                cTrSaleCpi.CPI_CUST_BNFT_TYPE = aTrData[Column.TR_SALE_CPI_RSLT.SEQ.CPI_CUST_BNFT_TYPE];
                cTrSaleCpi.CUST_PAY_TYPE = aTrData[Column.TR_SALE_CPI_RSLT.SEQ.CUST_PAY_TYPE];
                cTrSaleCpi.ACCUM_POINT = CmUtil.LongParse(aTrData[Column.TR_SALE_CPI_RSLT.SEQ.ACCUM_POINT]);
                cTrSaleCpi.LTTR_NMPLAT_NO = aTrData[Column.TR_SALE_CPI_RSLT.SEQ.LTTR_NMPLAT_NO];
                cTrSaleCpi.TRGT_CUST_TYPE = aTrData[Column.TR_SALE_CPI_RSLT.SEQ.TRGT_CUST_TYPE];
                cTrSaleCpi.BILLSPR_NO = CmUtil.LongParse(aTrData[Column.TR_SALE_CPI_RSLT.SEQ.BILLSPR_NO]);
                cTrSaleCpi.SLACK_FIELD = aTrData[Column.TR_SALE_CPI_RSLT.SEQ.SLACK_FIELD];
                cTrSaleCpi.CANCEL_DIV = aTrData[Column.TR_SALE_CPI_RSLT.SEQ.CANCEL_DIV];

                alTrCpiItem.Add(cTrSaleCpi);

                return 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 false;
        }

        /// <summary>
        /// 입출금 아이템 분해
        /// </summary>
        /// <param name="sTrData"></param>
        /// <returns></returns>
        protected bool TranParserToDpst(string sTrData)
        {
            try
            {
                string[] aTrData = sTrData.Split('|');

                ArrayList alTrDpst = (ArrayList)StateObject.GetItemObject(Column.SALE_DPST_WTHDR.ITEM);

                Column.SALE_DPST_WTHDR.DATA cTrDpst = new Column.SALE_DPST_WTHDR.DATA();

                cTrDpst.DPST_WTHDR_TYPE = aTrData[Column.SALE_DPST_WTHDR.SEQ.DPST_WTHDR_TYPE];
                cTrDpst.DPST_WTHDR_CD = aTrData[Column.SALE_DPST_WTHDR.SEQ.DPST_WTHDR_CD];
                cTrDpst.DPST_WTHDR_QTY = CmUtil.IntParse(aTrData[Column.SALE_DPST_WTHDR.SEQ.DPST_WTHDR_QTY]);
                cTrDpst.DPST_WTHDR_AMT = CmUtil.DoubleParse(aTrData[Column.SALE_DPST_WTHDR.SEQ.DPST_WTHDR_AMT]);
                cTrDpst.DPST_WTHDR_NM = aTrData[Column.SALE_DPST_WTHDR.SEQ.DPST_WTHDR_NM];
                cTrDpst.CUST_NO = aTrData[Column.SALE_DPST_WTHDR.SEQ.CUST_NO];

                cTrDpst.STOR_PAY_TYPE = aTrData[Column.SALE_DPST_WTHDR.SEQ.STOR_PAY_TYPE];
                cTrDpst.ETC_REASON = aTrData[Column.SALE_DPST_WTHDR.SEQ.ETC_REASON];

                cTrDpst.SLACK_FIELD_01 = aTrData[Column.SALE_DPST_WTHDR.SEQ.SLACK_FIELD_01];
                cTrDpst.SLACK_FIELD_02 = aTrData[Column.SALE_DPST_WTHDR.SEQ.SLACK_FIELD_02];
                cTrDpst.SLACK_FIELD_03 = aTrData[Column.SALE_DPST_WTHDR.SEQ.SLACK_FIELD_03];
                cTrDpst.SLACK_FIELD_04 = aTrData[Column.SALE_DPST_WTHDR.SEQ.SLACK_FIELD_04];
                cTrDpst.SLACK_FIELD_05 = aTrData[Column.SALE_DPST_WTHDR.SEQ.SLACK_FIELD_05];

                alTrDpst.Add(cTrDpst);

                return 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 false;
        }


        /// <summary>
        /// 정산 아이템 분해
        /// </summary>
        /// <param name="sTrData"></param>
        /// <returns></returns>
        protected bool TranParserToAdmt(string sTrData)
        {
            try
            {
                string[] aTrData = sTrData.Split('|');

                ArrayList alTrAdmt= (ArrayList)StateObject.GetItemObject(Column.TR_ADMT.ITEM);

                Column.TR_ADMT.DATA cTrAdmt = new Column.TR_ADMT.DATA();

                cTrAdmt.ADMT_TYPE = CmUtil.IntParse(aTrData[Column.TR_ADMT.SEQ.ADMT_TYPE]);
                cTrAdmt.ADMT_CD = CmUtil.IntParse(aTrData[Column.TR_ADMT.SEQ.ADMT_CD]);
                cTrAdmt.QTY = CmUtil.IntParse(aTrData[Column.TR_ADMT.SEQ.QTY]);
                cTrAdmt.AMT = CmUtil.IntParse(aTrData[Column.TR_ADMT.SEQ.AMT]); 

                cTrAdmt.SLACK_FIELD_01 = CmUtil.IntParse(aTrData[Column.TR_ADMT.SEQ.SLACK_FIELD_01]);
                cTrAdmt.SLACK_FIELD_02 = CmUtil.IntParse(aTrData[Column.TR_ADMT.SEQ.SLACK_FIELD_02]);
                cTrAdmt.SLACK_FIELD_03 = CmUtil.IntParse(aTrData[Column.TR_ADMT.SEQ.SLACK_FIELD_03]);
                cTrAdmt.SLACK_FIELD_04 = CmUtil.IntParse(aTrData[Column.TR_ADMT.SEQ.SLACK_FIELD_04]);
                cTrAdmt.SLACK_FIELD_05 = CmUtil.IntParse(aTrData[Column.TR_ADMT.SEQ.SLACK_FIELD_05]);

                alTrAdmt.Add(cTrAdmt);

                return 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 false;
        }

        /// <summary>
        /// 매출객수 아이템 분해
        /// </summary>
        /// <param name="sTrData"></param>
        /// <returns></returns>
        protected bool TranParserToGuestCnt(string sTrData)
        {
            try
            {
                string[] aTrData = sTrData.Split('|');

                ArrayList alTrGuest = (ArrayList)StateObject.GetItemObject(Column.TR_GUEST.ITEM);

                Column.TR_GUEST.DATA cTrGuest = new Column.TR_GUEST.DATA();

                cTrGuest.MALE_10L = CmUtil.IntParse(aTrData[Column.TR_GUEST.SEQ.MALE_10L]);
                cTrGuest.MALE_20L = CmUtil.IntParse(aTrData[Column.TR_GUEST.SEQ.MALE_20L]);
                cTrGuest.MALE_30L = CmUtil.IntParse(aTrData[Column.TR_GUEST.SEQ.MALE_30L]);
                cTrGuest.MALE_40L = CmUtil.IntParse(aTrData[Column.TR_GUEST.SEQ.MALE_40L]);
                cTrGuest.MALE_50L = CmUtil.IntParse(aTrData[Column.TR_GUEST.SEQ.MALE_50L]);

                cTrGuest.FMALE_10L = CmUtil.IntParse(aTrData[Column.TR_GUEST.SEQ.FMALE_10L]);
                cTrGuest.FMALE_20L = CmUtil.IntParse(aTrData[Column.TR_GUEST.SEQ.FMALE_20L]);
                cTrGuest.FMALE_30L = CmUtil.IntParse(aTrData[Column.TR_GUEST.SEQ.FMALE_30L]);
                cTrGuest.FMALE_40L = CmUtil.IntParse(aTrData[Column.TR_GUEST.SEQ.FMALE_40L]);
                cTrGuest.FMALE_50L = CmUtil.IntParse(aTrData[Column.TR_GUEST.SEQ.FMALE_50L]);

                alTrGuest.Add(cTrGuest);

                return 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 false;
        }

        /// <summary>
        /// 예약 고객정보 아이템 분해
        /// </summary>
        /// <param name="sTrData"></param>
        /// <returns></returns>
        protected bool TranParserToTrReservInfo(string sTrData)
        {
            try
            {
                string[] aTrData = sTrData.Split('|');

                ArrayList alTrReservInfo = (ArrayList)StateObject.GetItemObject(Column.TR_RESERV_INFO.ITEM);

                Column.TR_RESERV_INFO.DATA cTrReservInfo = new Column.TR_RESERV_INFO.DATA();

                cTrReservInfo.RESERV_NO = aTrData[Column.TR_RESERV_INFO.SEQ.RESERV_NO];
                cTrReservInfo.RESERV_REG_DT = aTrData[Column.TR_RESERV_INFO.SEQ.RESERV_REG_DT];
                cTrReservInfo.RESERV_REG_TM = aTrData[Column.TR_RESERV_INFO.SEQ.RESERV_REG_TM];
                cTrReservInfo.ONOFF_DIV = aTrData[Column.TR_RESERV_INFO.SEQ.ONOFF_DIV];
                cTrReservInfo.CUSTNM = aTrData[Column.TR_RESERV_INFO.SEQ.CUSTNM];
                cTrReservInfo.CUST_PHN_NO = aTrData[Column.TR_RESERV_INFO.SEQ.CUST_PHN_NO];
                cTrReservInfo.RESERV_DT = aTrData[Column.TR_RESERV_INFO.SEQ.RESERV_DT];
                cTrReservInfo.RESERV_TM = aTrData[Column.TR_RESERV_INFO.SEQ.RESERV_TM];
                
                alTrReservInfo.Add(cTrReservInfo);

                return 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 false;
        }
        #endregion

        //#해피앱 추후적립 start, sskim
        #region 해피앱 추후적립 데이터 INSERT (ETC_SALE_HEADER)
        /// <summary>
        /// 해피앱 추후적립 데이터 INSERT (ETC_SALE_HEADER)
        /// </summary>
        /// <param name="sTrData"></param>
        /// <returns></returns>
        protected int InsertETC_SALE_HEADER(string sSaleDate, string sPosNo, string sTradeNo, string aRowDatas)
        {
            string sQuery = string.Empty;
            //string sInsQuery = string.Empty;
            //string sUpdQuery = string.Empty;
            string sSQL = string.Empty;
            string[] aParams = null;
            int dtInt = 0;

            try
            {
                #region INSERT Query
                sQuery = "INSERT INTO POSLOG..ETC_SALE_HEADER \n"
                       + "       ( CMP_CD,              SALE_DT,            STOR_CD,                POS_NO,             REG_NO                  \n"
                       + "       , TRADE_NO,            TRADE_DIV,          TRAIN_MODE_YN,          TRADE_KINDPER,      SYS_DT                  \n"
                       + "       , ORD_TIME,            PAY_TIME,           PIC_NO,                 ORD_PIC_NO,         STOR_OWN_PART_TIME_DIV  \n"
                       + "       , ORG_BILL_POSNO,      ORG_BILLDT,         ORG_BILL_NO,            RTN_RSN_CD,         RTN_RSN_MEMO            \n"
                       + "       , NONSALES_RSN_CD,     RESERV_NO,          RESERV_DT,              CUST_NO,            ORD_DIV                 \n"
                       + "       , FLOOR_CD,            TBL_NO,             GUESTFLOOR,             FRGNR_DIV,          CUSTCNT                 \n"
                       + "       , PAY_GNDR_DIV,        PAY_AGE,            MAN_CMPNPSN_CNT,        WOMAN_CMPNPSN_CNT,  QTY                     \n"
                       + "       , TOTSALE_AMT,         TOTDC_AMT,          NET_SALE_AMT,           ITEM_DC_AMT,        CPI_DC_AMT              \n"
                       + "       , COOP_CARD_DC_AMT,    POINT_DC_AMT,       CPN_DC_AMT,             EMP_DC_AMT,         SET_DC_AMT              \n"
                       + "       , ETC_AMT,             EXCEP_DC_AMT,       TOT_VAT,                SVC_FEE_AMT,        SVC_FEE_VAT             \n"
                       + "       , ETC_VAT,             AF_ACCUM_POINT_AMT, AF_ACCUM_POINT_INFO,    PPCARD_CUSTNM,      AMT_DUTCHPAY_YN         \n"
                       + "       , BILLSPR_CNT,         ORDER_NO,           SLACK_FIELD,            TRADE_STAT,         SEND_YN                 \n"
                       + "       , REG_DATE,            UPD_DATE,           MID_CLOSE_SEQ,          PPCARD_CUSTID,      PACK_TRADE_DIV          \n"
                       + "       , VIP_TY) \n"
                       + "VALUES \n"
                       + "       ( '{0}',  '{1}',  '{2}',   '{3}',   '{4}'  \n"
                       + "       , '{5}',  '{6}',  '{7}',   '{8}',   '{9}'  \n"
                       + "       , '{10}', '{11}', '{12}',  '{13}',  '{14}' \n"
                       + "       , '{15}', '{16}', '{17}',  '{18}', N'{19}' \n"
                       + "       , '{20}', '{21}', '{22}',  '{23}',  '{24}' \n"
                       + "       , '{25}', '{26}', '{27}',  '{28}',   {29}  \n"
                       + "       , '{30}',  {31},   {32},    {33},    {34}  \n"
                       + "       ,  {35},   {36},   {37},    {38},    {39}  \n"
                       + "       ,  {40},   {41},   {42},    {43},    {44}  \n"
                       + "       ,  {45},   {46},   {47},    {48},    {49}  \n"
                       + "       ,  {50},   {51},  '{52}', N'{53}',  '{54}' \n"
                       + "       ,  {55},  '{56}', '{57}',  '{58}',  '{59}' \n"
                       + "       , '{60}', '{61}', '{62}',  '{63}',  '{64}' \n"
                       + "       , '{65}') \n";
                #endregion INSERT Query

                if (aRowDatas.Length > 0)
                {
                    aParams = aRowDatas.Split('|');

                    //aParams[Column.TRAN_HEADER.SEQ.TRADE_DIV]

                    sSQL = string.Format(sQuery
                                         , m_cPosStatus.Base.CmpCd, sSaleDate, m_cPosStatus.Base.StoreNo, sPosNo, m_cPosStatus.Base.RegNo
                                         , sTradeNo,    aParams[3],  aParams[4],  aParams[5],  aParams[6]
                                         , aParams[7],  aParams[8],  aParams[9],  aParams[10], aParams[11]
                                         , aParams[12], aParams[13], aParams[14], aParams[15], aParams[16]
                                         , aParams[17], aParams[18], aParams[19], aParams[20], aParams[21]
                                         , aParams[22], aParams[23], aParams[24], aParams[25], aParams[26]
                                         , aParams[27], aParams[28], aParams[29], aParams[30], aParams[31]
                                         , aParams[32], aParams[33], aParams[34], aParams[35], aParams[36]
                                         , aParams[37], aParams[38], aParams[39], aParams[40], aParams[41]
                                         , aParams[42], aParams[43], aParams[44], aParams[45], aParams[46]
                                         , aParams[47], aParams[48], aParams[49], aParams[50], aParams[51]
                                         , aParams[52], aParams[53], aParams[54], aParams[55], aParams[56]
                                         , DateTime.Now.ToString("yyyyMMddHHmmsss"), DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[59], aParams[60], aParams[61]
                                         , aParams[62]);

                    dtInt = m_cMstService.Insert(new string[] { sQuery });

                }
            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.LOG_ERROR,
                                     System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                     System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                     ex.Message);

            }

            return dtInt;
        }
        #endregion

        #region 해피앱 추후적립 데이터 INSERT (ETC_SALE_ETC)
        /// <summary>
        /// 해피앱 추후적립 데이터 INSERT (ETC_SALE_ETC)
        /// </summary>
        /// <param name="sTrData"></param>
        /// <returns></returns>
        protected int InsertETC_SALE_ETC(string sSaleDate, string sPosNo, string sTradeNo, string aRowDatas)
        {
            string sQuery = string.Empty;
            //string sInsQuery = string.Empty;
            //string sUpdQuery = string.Empty;
            string sSQL = string.Empty;
            string[] aParams = null;
            int dtInt = 0;

            try
            {
                #region INSERT Query
                sQuery = "INSERT INTO POSLOG..ETC_SALE_ETC \n"
                       + "       ( CMP_CD,          SALE_DT,        STOR_CD,        POS_NO,         REG_NO          \n"
                       + "       , SEQ,             TRADE_NO,       ETC_WAY_CD,     ETC_AMT,        ETC_DTL_CD_01   \n"
                       + "       , ETC_DTL_CD_02,   ETC_DTL_CD_03,  ETC_DTL_CD_04,  ETC_DTL_CD_05,  QTY_ENTRY_01    \n"
                       + "       , QTY_ENTRY_02,    QTY_ENTRY_03,   QTY_ENTRY_04,   QTY_ENTRY_05,   AMT_ENTRY_01    \n"
                       + "       , AMT_ENTRY_02,    AMT_ENTRY_03,   AMT_ENTRY_04,   AMT_ENTRY_05,   AMT_ENTRY_06    \n"
                       + "       , AMT_ENTRY_07,    AMT_ENTRY_08,   AMT_ENTRY_09,   AMT_ENTRY_10,   OCCUR_ENTRY_01  \n"
                       + "       , OCCUR_ENTRY_02,  OCCUR_ENTRY_03, OCCUR_ENTRY_04, OCCUR_ENTRY_05, OCCUR_ENTRY_06  \n"
                       + "       , OCCUR_ENTRY_07,  OCCUR_ENTRY_08, OCCUR_ENTRY_09, OCCUR_ENTRY_10, OCCUR_ENTRY_11  \n"
                       + "       , OCCUR_ENTRY_12,  OCCUR_ENTRY_13, OCCUR_ENTRY_14, OCCUR_ENTRY_15, OCCUR_ENTRY_16  \n"
                       + "       , OCCUR_ENTRY_17,  OCCUR_ENTRY_18, OCCUR_ENTRY_19, OCCUR_ENTRY_20, OCCUR_ENTRY_21  \n"
                       + "       , OCCUR_ENTRY_22,  OCCUR_ENTRY_23, OCCUR_ENTRY_24, OCCUR_ENTRY_25, BILLSPR_NO      \n"
                       + "       , CANCEL_DIV,      REG_DATE,       UPD_DATE)                                       \n"
                       + "VALUES \n"
                       + "       (  '{0}',   '{1}',   '{2}',   '{3}',   '{4}'   \n"
                       + "       ,   {5},    '{6}',   '{7}',    {8},     {9}    \n"
                       + "       ,  '{10}',  '{11}',  '{12}',  '{13}',  '{14}'  \n"
                       + "       ,  '{15}',  '{16}',  '{17}',  '{18}',   {19}   \n"
                       + "       ,   {20},    {21},    {22},    {23},    {24}   \n"
                       + "       ,   {25},    {26},    {27},    {28},  N'{29}'  \n"
                       + "       , N'{30}', N'{31}', N'{32}', N'{33}', N'{34}'  \n"
                       + "       , N'{35}', N'{36}', N'{37}', N'{38}', N'{39}'  \n"
                       + "       , N'{40}', N'{41}', N'{42}', N'{43}', N'{44}'  \n"
                       + "       , N'{45}', N'{46}', N'{47}', N'{48}', N'{49}'  \n"
                       + "       , N'{50}', N'{51}', N'{52}', N'{53}',   {54}   \n"
                       + "       ,  '{55}',  '{56}',  '{57}' )                  \n";
                #endregion INSERT Query

                if (aRowDatas.Length > 0)
                {
                    aParams = aRowDatas.Split('|');

                    sSQL = string.Format(sQuery
                                         , m_cPosStatus.Base.CmpCd, sSaleDate, m_cPosStatus.Base.StoreNo, sPosNo, m_cPosStatus.Base.RegNo
                                         , aParams[2],  sTradeNo,    aParams[3], aParams[4], aParams[5]
                                         , aParams[6], aParams[7], aParams[8], aParams[9], aParams[10]
                                         , aParams[11], aParams[12], aParams[13], aParams[14], aParams[15]
                                         , aParams[16], aParams[17], aParams[18], aParams[19], aParams[20]
                                         , aParams[21], aParams[22], aParams[23], aParams[24], aParams[25]
                                         , aParams[26], aParams[27], aParams[28], aParams[29], aParams[30]
                                         , aParams[31], aParams[32], aParams[33], aParams[34], aParams[35]
                                         , aParams[36], aParams[37], aParams[38], aParams[39], aParams[40]
                                         , aParams[41], aParams[42], aParams[43], aParams[44], aParams[45]
                                         , aParams[46], aParams[47], aParams[48], aParams[49], aParams[50]
                                         , aParams[51], DateTime.Now.ToString("yyyyMMddHHmmsss"), DateTime.Now.ToString("yyyyMMddHHmmsss"));

                    dtInt = m_cMstService.Insert(new string[] { sQuery });

                }
            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.LOG_ERROR,
                                     System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                     System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                     ex.Message);

            }

            return dtInt;
        }
        #endregion

        #region 해피앱 추후적립 데이터 INSERT (TR_SALE_ETC)
        /// <summary>
        /// 해피앱 추후적립 데이터 INSERT (ETC_SALE_ETC)
        /// </summary>
        /// <param name="sTrData"></param>
        /// <returns></returns>
        protected bool InsertTR_SALE_ETC(string sSaleDate, string sPosNo, string sTradeNo, string aRowDatas)
        {
            string sQuery = string.Empty;
            //string sInsQuery = string.Empty;
            //string sUpdQuery = string.Empty;
            string sSQL = string.Empty;
            string[] aParams = null;

            try
            {
                #region INSERT Query
                sQuery = "INSERT INTO POSLOG..TR_SALE_ETC \n"
                       + "       ( CMP_CD,          SALE_DT,        STOR_CD,        POS_NO,         TRADE_NO        \n"
                       + "       , SEQ,             ETC_WAY_CD,     ETC_AMT,        ETC_DTL_CD_01,  ETC_DTL_CD_02   \n"
                       + "       , ETC_DTL_CD_03,   ETC_DTL_CD_04,  ETC_DTL_CD_05,  QTY_ENTRY_01,   QTY_ENTRY_02    \n"
                       + "       , QTY_ENTRY_03,    QTY_ENTRY_04,   QTY_ENTRY_05,   AMT_ENTRY_01,   AMT_ENTRY_02    \n"
                       + "       , AMT_ENTRY_03,    AMT_ENTRY_04,   AMT_ENTRY_05,   AMT_ENTRY_06,   AMT_ENTRY_07    \n"
                       + "       , AMT_ENTRY_08,    AMT_ENTRY_09,   AMT_ENTRY_10,   OCCUR_ENTRY_01, OCCUR_ENTRY_02  \n"
                       + "       , OCCUR_ENTRY_03,  OCCUR_ENTRY_04, OCCUR_ENTRY_05, OCCUR_ENTRY_06, OCCUR_ENTRY_07  \n"
                       + "       , OCCUR_ENTRY_08,  OCCUR_ENTRY_09, OCCUR_ENTRY_10, OCCUR_ENTRY_11, OCCUR_ENTRY_12  \n"
                       + "       , OCCUR_ENTRY_13,  OCCUR_ENTRY_14, OCCUR_ENTRY_15, OCCUR_ENTRY_16, OCCUR_ENTRY_17  \n"
                       + "       , OCCUR_ENTRY_18,  OCCUR_ENTRY_19, OCCUR_ENTRY_20, OCCUR_ENTRY_21, OCCUR_ENTRY_22  \n"
                       + "       , OCCUR_ENTRY_23,  OCCUR_ENTRY_24, OCCUR_ENTRY_25, BILLSPR_NO,     CANCEL_DIV      \n"
                       + "       , REG_DATE,        UPD_DATE)                                                       \n"
                       + "VALUES \n"
                       + "       (  '{0}',   '{1}',   '{2}',   '{3}',   '{4}'   \n"
                       + "       ,   {5},    '{6}',    {7},    '{8}',   '{9}'   \n"
                       + "       ,  '{10}',  '{11}',  '{12}',   {13},    {14}   \n"
                       + "       ,   {15},    {16},    {17},    {18},    {19}   \n"
                       + "       ,   {20},    {21},    {22},    {23},    {24}   \n"
                       + "       ,   {25},    {26},    {27},  N'{28}', N'{29}'  \n"
                       + "       , N'{30}', N'{31}', N'{32}', N'{33}', N'{34}'  \n"
                       + "       , N'{35}', N'{36}', N'{37}', N'{38}', N'{39}'  \n"
                       + "       , N'{40}', N'{41}', N'{42}', N'{43}', N'{44}'  \n"
                       + "       , N'{45}', N'{46}', N'{47}', N'{48}', N'{49}'  \n"
                       + "       , N'{50}', N'{51}', N'{52}',   {53},   '{54}'  \n"
                       + "       ,  '{55}',  '{56}')                            \n";
                #endregion INSERT Query

                if (aRowDatas.Length > 0)
                {
                    aParams = aRowDatas.Split('|');

                    if (aParams[3] == "80" && aParams[5] == "01")
                    {

                        sSQL = string.Format(sQuery
                                            , m_cPosStatus.Base.CmpCd, sSaleDate, m_cPosStatus.Base.StoreNo, sPosNo, sTradeNo
                                            , aParams[2],  aParams[3],  aParams[4],  aParams[5],  aParams[6]
                                            , aParams[7],  aParams[8],  aParams[9],  aParams[10], aParams[11]
                                            , aParams[12], aParams[13], aParams[14], aParams[15], aParams[16]
                                            , aParams[17], aParams[18], aParams[19], aParams[20], aParams[21]
                                            , aParams[22], aParams[23], aParams[24], aParams[25], aParams[26]
                                            , aParams[27], aParams[28], aParams[29], aParams[30], aParams[31]
                                            , aParams[32], aParams[33], aParams[34], aParams[35], aParams[36]
                                            , aParams[37], aParams[38], aParams[39], aParams[40], aParams[41]
                                            , aParams[42], aParams[43], aParams[44], aParams[45], aParams[46]
                                            , aParams[47], aParams[48], aParams[49], aParams[50], aParams[51]
                                            , DateTime.Now.ToString("yyyyMMddHHmmsss"), DateTime.Now.ToString("yyyyMMddHHmmsss"));

                        //dtInt = m_cMstService.Insert(new string[] { sQuery });
                        if (m_cSqlDbService.DBExecuteNonQuery(new string[] { sSQL }) != UserCom.OK)
                        {
                            m_cSqlDbService.Rollback();
                            return false;
                        }
                        {
                            m_cSqlDbService.Commit();
                            return true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.LOG_ERROR,
                                     System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                     System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                     ex.Message);

            }

            return false;

        }
        #endregion

        //#해피앱 추후적립 end, sskim

        //2017-06-02 dkshin 해피앱 추후적립
        //HPAPP_After_Save_Update_TranCallIrt
        public string HPAPP_After_Save_Update_TranCallIrt(string sInqType, string sSaleDate, string sPosNo, string sTradeNo, string SaleTime, ref Hashtable htRecvData)
        {
            string sStat = UserCom.RST_ERR;
            try
            {
                Hashtable htSendData = new Hashtable();

                htSendData.Add(Column.HPAPP_AFTER_SAVE_REQ.DATA.INQ_TYPE, sInqType);
                htSendData.Add(Column.HPAPP_AFTER_SAVE_REQ.DATA.CMP_CD, m_cPosStatus.Base.CmpCd);
                htSendData.Add(Column.HPAPP_AFTER_SAVE_REQ.DATA.STOR_CD, m_cPosStatus.Base.StoreNo);
                htSendData.Add(Column.HPAPP_AFTER_SAVE_REQ.DATA.SALE_DT, sSaleDate);
                htSendData.Add(Column.HPAPP_AFTER_SAVE_REQ.DATA.POS_NO, sPosNo);
                htSendData.Add(Column.HPAPP_AFTER_SAVE_REQ.DATA.TRADE_NO, sTradeNo);
                htSendData.Add(Column.HPAPP_AFTER_SAVE_REQ.DATA.SAVE_STATUS, "P");//판매POS에서 추후적립
                htSendData.Add(Column.HPAPP_AFTER_SAVE_REQ.DATA.RES_CD, "");

                return m_cDataCommon.ExecutePosHPAPPIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.PayInqPort, 10000, htSendData, ref htRecvData);
            }
            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 sStat;
        }

        //2017-06-02 dkshin 해피앱 추후적립
        public string Refund_HPAPP_After_Save_Update_TranCallIrt(string sInqType, string sSaleDate, string sPosNo, string sTradeNo, string SaleTime, ref Hashtable htRecvData)
        {
            string sStat = UserCom.RST_ERR;
            try
            {
                Hashtable htSendData = new Hashtable();

                htSendData.Add(Column.HPAPP_AFTER_SAVE_REQ.DATA.INQ_TYPE, sInqType);
                htSendData.Add(Column.HPAPP_AFTER_SAVE_REQ.DATA.CMP_CD, m_cPosStatus.Base.CmpCd);
                htSendData.Add(Column.HPAPP_AFTER_SAVE_REQ.DATA.STOR_CD, m_cPosStatus.Base.StoreNo);
                htSendData.Add(Column.HPAPP_AFTER_SAVE_REQ.DATA.SALE_DT, sSaleDate);
                htSendData.Add(Column.HPAPP_AFTER_SAVE_REQ.DATA.POS_NO, sPosNo);
                htSendData.Add(Column.HPAPP_AFTER_SAVE_REQ.DATA.TRADE_NO, sTradeNo);
                htSendData.Add(Column.HPAPP_AFTER_SAVE_REQ.DATA.SAVE_STATUS, "R");//판매POS에서 추후적립 영수증 반품
                htSendData.Add(Column.HPAPP_AFTER_SAVE_REQ.DATA.RES_CD, "");

                return m_cDataCommon.ExecutePosHPAPPIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.PayInqPort, 10000, htSendData, ref htRecvData);
            }
            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 sStat;
        }

        //#20180406 로컬, 서버에 저널데이터 없는 경우 재생성 start

        #region 영수증 반품 대상 로컬 거래 데이터 로딩
        /// <summary>
        /// 영수증 반품 대상 로컬 거래 데이터 로딩
        /// </summary>
        /// <param name="sSaleDate"></param>
        /// <param name="sPosNo"></param>
        /// <param name="sTradeNo"></param>
        /// <returns></returns>
        public bool LoadLocalTran(string sSaleDate, string sPosNo, string sTradeNo)
        {
            bool bRet = false;

            try
            {
                m_cDataService.TranComplete();

                // 해더정보 로딩
                if (LoadLocalTrHeader(sSaleDate, sPosNo, sTradeNo) == false)
                {
                    WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0248);
                    m_cDataService.TranComplete();
                    return bRet;
                }

                // 상품정보 로딩
                LoadLocalTrDetail(sSaleDate, sPosNo, sTradeNo);

                // 결제정보 로딩
                LoadLocalTrPayment(sSaleDate, sPosNo, sTradeNo);

                // 기타정보 로딩
                LoadLocalTrEtc(sSaleDate, sPosNo, sTradeNo);

                // 캠페인정보 로딩
                LoadLocalTrCampaign(sSaleDate, sPosNo, sTradeNo);

                // 매출객수정보 로딩
                LoadLocalTrGuestCnt(sSaleDate, sPosNo, sTradeNo);

                bRet = 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);
                m_cDataService.TranComplete();
            }
            return bRet;
        }
        #endregion

        #region 해피포인트 적립내역, 사용내역 조회
        /// <summary>
        /// 해피포인트 적립내역, 사용내역 조회
        /// </summary>
        /// <param name="sHpcType"></param>
        /// <param name="htHPCApprInfo"></param>
        /// <returns></returns>
        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;
        }
        #endregion
 
        //#20180406 로컬, 서버에 저널데이터 없는 경우 재생성 end
    }
}
