using System;
using System.Text;
using System.Collections;
using System.Data;
using System.Runtime.InteropServices;

using Cosmos.BaseFrame;
using Cosmos.UserFrame;
using Cosmos.ServiceProvider;
using Cosmos.Common;
using Cosmos.CommonManager;
using System.Drawing;
using System.Threading;

//#20180322 휴게소pos매출연동 start,phj
using System.IO;
using System.Diagnostics;
using System.Collections.Generic;
using System.Management;
//#20180322 휴게소pos매출연동 end,phj

/*-----------------------------------------------------------------------------------------------*/
// 설      명 : 공통함수 처리
// 작  성  자 : 
// 변경  이력 : 
/*-----------------------------------------------------------------------------------------------*/

namespace Cosmos.Service
{
    class DataCommon : IDataCommonUs
    {
        private SManager sManager = new SManager();                                 // 이 객체를 통해 업무 Service 호출
        private StateServer StateObject = (StateServer)StateServer.GetInstance();   // StateObject : StateServer Object (객체)
        private PosStatus m_cPosStatus = new PosStatus();                           // 기본정보 참조
        private TranStatus m_cTrnStatus = new TranStatus();                         // 거래정보 참조
        private DeviceStatus m_cDevStatus = new DeviceStatus();                     // POS Device 참조

        private IMasterUs m_cMstService = null;                                     // 마스터 관리
        private DataService m_cDataService = null;                                  // 거래데이터 합계금액 계산 및 관리
        private INetworkVanSPCN m_cNetService = null;                               // SPCN 네트워크 공통 모듈
        private IDatabaseSQL m_cSqlDbService = null;                                // 데이터베이스 관리

#if !FORKIOSK
       
#endif

        frmPosIrtMessage m_cfPosIrtMsg = new frmPosIrtMessage();                    // 내부통신(제이슨)
        frmExIrtMessage m_cfExIrtMsg = new frmExIrtMessage();                       // 외부통신(TCP - ACK, 가변길이)
        frmTcpClientMsg m_cTcpClientMsg = new frmTcpClientMsg();                    // 기타통신(TCP)

        private INetworkJSON m_cNetJSONService = null;

        private bool m_bIRTComplete = false;                                        // 통신 완료 상태
        Hashtable m_htRecvData = null;                                              // 통신 수신 데이터 (JSON)

        //frmIrtMessage m_cfIrtMsg = new frmIrtMessage();
        [DllImport("SPCNSecuCom.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, SetLastError = true)]
        //public static extern int SPCNRequestApproval(string ipAddr, int uiPort, int uiMedia, string RequestMsg, int uiLen,
        public static extern int SPCNRequestApproval(byte[] ipAddr, int uiPort, int uiMedia, byte[] RequestMsg, int uiLen,
             byte[] ResponseMsg, int uiReadTimeOut, int uiConnectOption);

        public DataCommon()
        {
            m_cPosStatus = (PosStatus)StateObject.POS;          // POS 기본정보
            m_cTrnStatus = (TranStatus)StateObject.TRAN;        // POS 거래정보
            m_cDevStatus = (DeviceStatus)StateObject.DEVICE;    // POS Device 정보;

            m_cMstService = (IMasterUs)sManager.InitServiceInstance(ServiceLists.ASV_MASTER.DLL, ServiceLists.ASV_MASTER.POS_MASTER);
            m_cDataService = (DataService)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_SERVICE);
            m_cNetService = (INetworkVanSPCN)sManager.InitServiceInstance(ServiceLists.AGENT_NETWORK.DLL, ServiceLists.AGENT_NETWORK.NETWORK_VAN_SPCN);
            m_cNetJSONService = (INetworkJSON)sManager.InitServiceInstance(ServiceLists.AGENT_NETWORK.DLL, ServiceLists.AGENT_NETWORK.NETWORK_JSON);
            m_cSqlDbService = (IDatabaseSQL)sManager.InitServiceInstance(ServiceLists.AGENT_DATABASE.DLL, ServiceLists.AGENT_DATABASE.DATABASE_MSSQL);
        }

        #region 마스터 조회 
        //#20171018 상품등록 유통기한 체크하기 start, phj 
        /// <summary>
        /// 상품 마스터 조회
        /// </summary>
        /// <param name="sSubStoreNo"></param>
        /// <param name="sItemCode"></param>
        /// <param name="sScanCode"></param>
        /// <returns></returns>
        //기존
        //public DataTable SearchItemCode(string sSubStoreNo, string sItemCode, string sScanCode)

        //변경
        public DataTable SearchItemCode(string sSubStoreNo, string sItemCode, string sScanCode, bool TimeStampBarCodeYn = false)
        //#20171018 상품등록 유통기한 체크하기 end, phj
        {
            try
            {
                //#20171018 상품등록 유통기한 체크하기 start, phj
                //기존
                //if (sScanCode.Trim() != "")
                //변경
                if ((sScanCode.Trim() != "") && (TimeStampBarCodeYn == false))
                //#20171018 상품등록 유통기한 체크하기 end, phj
                {
                    // 스캔코드
                    DataTable dtDataInfo = SeletItemMstToScanCode(sSubStoreNo, sScanCode);
                    if (dtDataInfo == null || dtDataInfo.Rows.Count == 0) return null;

                    foreach (DataRow dr in dtDataInfo.Rows)
                    {
                        sSubStoreNo = CmUtil.GetDataRowStr(dr, PosMst.MST_BARCODE.DATA.SUB_STOR_CD);
                        sItemCode = CmUtil.GetDataRowStr(dr, PosMst.MST_BARCODE.DATA.ITEM_CD);

                        DataTable dtPluInfo = SeletItemMstToItemCode(sSubStoreNo, sItemCode);
                        if (dtPluInfo != null && dtPluInfo.Rows.Count > 0)
                        {
                            return dtPluInfo;
                        }
                    }
                }
                else
                {
                    return SeletItemMstToItemCode(sSubStoreNo, sItemCode);
                }
            }
            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 null;
        }


        /// <summary>
        /// 2019-05-08 - 1997fx11 : NHS 부가옵션을 조회
        /// </summary>
        /// <param name="sSubStoreNo"></param>
        /// <param name="sSubItemCode"></param>
        /// <returns></returns>
        public DataTable SearchNHSOption(string sSubStoreNo, string sSubItemCode)
        {
            string sQuery = "";
            sQuery = "";
            sQuery += " SELECT * ";
            sQuery += " FROM POSMST..NHS_OPTN_MST WITH(NOLOCK) ";
            sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
            sQuery += " AND ITEM_OPTN_CD = '" + sSubItemCode + "'";

            try
            {
                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }


        /// <summary>
        /// 상품 마스터 조회(상품코드로 조회)
        /// </summary>
        /// <param name="sSubStoreNo">서브점포</param>
        /// <param name="sItemCode">상품코드</param>
        /// <returns></returns>
        public DataTable SeletItemMstToItemCode(string sSubStoreNo, string sItemCode)
        {
            string sQuery = "";
            try
            {
                if (sSubStoreNo == "") sSubStoreNo = m_cPosStatus.Base.StoreNo;

                //#Rhee, 20180209 미국 상품검색 후 상품 추가시 상품의 중분류로 이동 Start
                // 기존
                //// 상품코드로 상품 마스터 조회
                //sQuery = "";
                //sQuery += " SELECT * FROM POSMST..MST_ITEM WITH(NOLOCK) ";
                //sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                //sQuery += "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                ////#20180103 복합매장 해피오더 픽업 완료시 상품마스터 조회 안되는 증상 수정 start
                ////#20180108 복합매장 중복 상품코드 있는 경우 서브점포코드 정상적으로 들어가지 않아 원복
                //sQuery += "   AND SUB_STOR_CD = '" + sSubStoreNo + "'";
                ////#20180103 복합매장 해피오더 픽업 완료시 상품마스터 조회 안되는 증상 수정 end
                //sQuery += "   AND ITEM_CD = '" + sItemCode + "'";
                //sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                // 변경
                if (m_cPosStatus.Base.CmpCd.ToUpper().Equals(PosConst.POS_COMPANY_CODE.PCUS))
                {
                    // 상품코드로 상품 마스터 조회
                    sQuery = "";
                    sQuery += " SELECT A.STOR_CD + A.L_CLSS_CD + '           0' + CAST( A.GRP_SEQ AS VARCHAR(2)) AS GRP_SEQ";
                    sQuery += " , B.* FROM POSMST..MST_ITEM_KEY A WITH(NOLOCK) JOIN POSMST..MST_ITEM B WITH(NOLOCK) ON ";
                    sQuery += " A.CMP_CD=B.CMP_CD AND A.STOR_CD=B.STOR_CD AND A.SUB_STOR_CD = B.SUB_STOR_CD AND A.ITEM_CD = B.ITEM_CD ";
                    sQuery += " WHERE A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "   AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    //#20180103 복합매장 해피오더 픽업 완료시 상품마스터 조회 안되는 증상 수정 start
                    //#20180108 복합매장 중복 상품코드 있는 경우 서브점포코드 정상적으로 들어가지 않아 원복
                    sQuery += "   AND A.SUB_STOR_CD = '" + sSubStoreNo + "'";
                    //#20180103 복합매장 해피오더 픽업 완료시 상품마스터 조회 안되는 증상 수정 end
                    sQuery += "   AND A.ITEM_CD = '" + sItemCode + "'";
                    sQuery += "   AND A.USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                }
                else
                {
                    // 상품코드로 상품 마스터 조회
                    sQuery = "";
                    sQuery += " SELECT * FROM POSMST..MST_ITEM WITH(NOLOCK) ";
                    sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    //#20180103 복합매장 해피오더 픽업 완료시 상품마스터 조회 안되는 증상 수정 start
                    //#20180108 복합매장 중복 상품코드 있는 경우 서브점포코드 정상적으로 들어가지 않아 원복
                    sQuery += "   AND SUB_STOR_CD = '" + sSubStoreNo + "'";
                    //#20180103 복합매장 해피오더 픽업 완료시 상품마스터 조회 안되는 증상 수정 end
                    sQuery += "   AND ITEM_CD = '" + sItemCode + "'";
                    sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                }
                //#Rhee, 20180209 미국 상품검색 후 상품 추가시 상품의 중분류로 이동 End

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }

        //#15945 해피오더 자동주문 상세기능 start
        /// <summary>
        /// 해피오더자동출하상품체크
        /// </summary>
        public DataTable AutomaticShipmentItemCheck(string sSubStoreNo, string sItemCode)
        {
            string sQuery = "";
            try
            {
                if (sSubStoreNo == "") sSubStoreNo = m_cPosStatus.Base.StoreNo;

                sQuery = "";
                sQuery += " SELECT * FROM POSMST..MST_ITEM WITH(NOLOCK) ";
                sQuery += " WHERE CMP_CD      = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "   AND STOR_CD     = '" + m_cPosStatus.Base.StoreNo + "'";
                sQuery += "   AND SUB_STOR_CD = '" + sSubStoreNo + "'";
                sQuery += "   AND ITEM_CD     = '" + sItemCode + "'";
                sQuery += "   AND HP_ORD_DIV  = '1'";
                sQuery += "   AND USE_YN      = '" + PosConst.MST_USE_YN.YES + "'";

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        //#15945 해피오더 자동주문 상세기능 end

        /// <summary>
        /// 상품 마스터 조회(스캔코드로 조회)
        /// </summary>
        /// <param name="sSubStoreNo">서브점포</param>
        /// <param name="sScanCode">스캔코드</param>
        /// <returns></returns>
        public DataTable SeletItemMstToScanCode(string sSubStoreNo, string sScanCode)
        {
            string sQuery = "";

            try
            {
                // 스켄코드로 상품 마스터 조회

                //#20180620 바코드 스캔시 조건 변경 start
                //상품마스터(MST_ITEM)의 FILLER1 값이 취급종료('2'), 임시불가('3')가 아닌 경우엔 입력 가능
                //취급종료('2'), 임시불가('3')인 경우엔 터치키가 있다면 입력 가능
                //기존
                /*
                sQuery = "";
                sQuery += " SELECT * FROM POSMST..MST_ITEM_BAR_CD WITH(NOLOCK) ";
                sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                //sQuery += "   AND SUB_STOR_CD = '" + sSubStoreNo + "'";
                sQuery += "   AND BAR_CD_NO = '" + sScanCode + "'";
                sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                */
                //변경
                sQuery = "";
                sQuery += " SELECT A.SUB_STOR_CD, A.ITEM_CD ";
                sQuery += "   FROM POSMST..MST_ITEM_BAR_CD A ";
                sQuery += "        INNER JOIN POSMST..MST_ITEM B ";
                sQuery += "        ON A.CMP_CD = B.CMP_CD AND A.STOR_CD = B.STOR_CD AND A.SUB_STOR_CD = B.SUB_STOR_CD AND A.ITEM_CD = B.ITEM_CD ";
                sQuery += "  WHERE A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "    AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                sQuery += "    AND A.BAR_CD_NO = '" + sScanCode + "'";
                sQuery += "    AND A.USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                sQuery += "    AND B.USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                sQuery += "    AND B.FILLER1 IN ('0','1') ";
                sQuery += "  UNION ALL ";
                sQuery += " SELECT A.SUB_STOR_CD, A.ITEM_CD ";
                sQuery += "   FROM POSMST..MST_ITEM_BAR_CD A ";
                sQuery += "        INNER JOIN POSMST..MST_ITEM B ";
                sQuery += "        ON A.CMP_CD = B.CMP_CD AND A.STOR_CD = B.STOR_CD AND A.SUB_STOR_CD = B.SUB_STOR_CD AND A.ITEM_CD = B.ITEM_CD ";
                sQuery += "        INNER JOIN POSMST..MST_ITEM_KEY C ";
                sQuery += "        ON A.CMP_CD = C.CMP_CD AND A.STOR_CD = C.STOR_CD AND A.SUB_STOR_CD = C.SUB_STOR_CD AND A.ITEM_CD = C.ITEM_CD ";
                sQuery += " WHERE A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "   AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                sQuery += "   AND A.BAR_CD_NO = '" + sScanCode + "'";
                sQuery += "   AND A.USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                sQuery += "   AND B.USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                sQuery += "   AND C.USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                sQuery += "   AND B.FILLER1 IN ('2','3') ";

                //#20180620 바코드 스캔시 조건 변경 end

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

            }
            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 null;
        }
        #region public DataTable SeletItemMstNmoScanCode(string sSubStoreNo, string sScanCode)
        //----------------------------------------------
        // 바코드 중복 처리를 위한 상품 마스터 조회 함수
        //----------------------------------------------
        public DataTable SeletItemMstNmToScanCode(string sSubStoreNo, string sScanCode)
        {
            string sQuery = "";

            try
            {
                // 스켄코드로 상품 마스터 조회

                //#13732 바코드 리딩 시 팝업 조건 변경요청 start
                //기존
                /*
                sQuery = "";
                sQuery += "\r\n" + " SELECT ROW_NUMBER() OVER (ORDER BY (select null)) AS NO,";
                sQuery += "\r\n" + " A.STOR_CD, A.ITEM_CD,";
                sQuery += "\r\n" + " (SELECT B.ITEM_NM FROM dbo.MST_ITEM B WHERE B.ITEM_CD = A.ITEM_CD) AS ITEM_NM,";
                sQuery += "\r\n" + " (SELECT B.TAKE_IN_SALE_AMT FROM dbo.MST_ITEM B WHERE B.ITEM_CD = A.ITEM_CD) AS SALE_AMT";
                sQuery += "\r\n" + " FROM POSMST..MST_ITEM_BAR_CD A WITH(NOLOCK) ";
                sQuery += "\r\n" + " WHERE A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "\r\n" + "   AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                sQuery += "\r\n" + "   AND A.BAR_CD_NO = '" + sScanCode + "'";
                sQuery += "\r\n" + "   AND A.USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                */
                //변경

                sQuery = "";
                sQuery += "\r\n" + " SELECT ROW_NUMBER() OVER (ORDER BY (select null)) AS NO,";
                sQuery += "\r\n" + "        X.STOR_CD, X.ITEM_CD, X.ITEM_NM, X.SALE_AMT";
                sQuery += "\r\n" + "   FROM (";
                sQuery += "\r\n" + "        SELECT A.SUB_STOR_CD AS STOR_CD, A.ITEM_CD, B.ITEM_NM, B.TAKE_IN_SALE_AMT AS SALE_AMT";
                sQuery += "\r\n" + "          FROM POSMST..MST_ITEM_BAR_CD A ";
                sQuery += "\r\n" + "               INNER JOIN POSMST..MST_ITEM B ";
                sQuery += "\r\n" + "               ON A.CMP_CD = B.CMP_CD AND A.STOR_CD = B.STOR_CD AND A.SUB_STOR_CD = B.SUB_STOR_CD AND A.ITEM_CD = B.ITEM_CD ";
                sQuery += "\r\n" + "         WHERE A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "\r\n" + "           AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                sQuery += "\r\n" + "           AND A.BAR_CD_NO = '" + sScanCode + "'";
                sQuery += "\r\n" + "           AND A.USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                sQuery += "\r\n" + "           AND B.USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                sQuery += "\r\n" + "           AND B.FILLER1 IN ('0','1') ";
                sQuery += "\r\n" + "         UNION ALL ";
                sQuery += "\r\n" + "        SELECT A.SUB_STOR_CD AS STOR_CD, A.ITEM_CD, B.ITEM_NM, B.TAKE_IN_SALE_AMT AS SALE_AMT ";
                sQuery += "\r\n" + "          FROM POSMST..MST_ITEM_BAR_CD A ";
                sQuery += "\r\n" + "               INNER JOIN POSMST..MST_ITEM B ";
                sQuery += "\r\n" + "               ON A.CMP_CD = B.CMP_CD AND A.STOR_CD = B.STOR_CD AND A.SUB_STOR_CD = B.SUB_STOR_CD AND A.ITEM_CD = B.ITEM_CD ";
                sQuery += "\r\n" + "               INNER JOIN POSMST..MST_ITEM_KEY C ";
                sQuery += "\r\n" + "               ON A.CMP_CD = C.CMP_CD AND A.STOR_CD = C.STOR_CD AND A.SUB_STOR_CD = C.SUB_STOR_CD AND A.ITEM_CD = C.ITEM_CD ";
                sQuery += "\r\n" + "         WHERE A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "\r\n" + "           AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                sQuery += "\r\n" + "           AND A.BAR_CD_NO = '" + sScanCode + "'";
                sQuery += "\r\n" + "           AND A.USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                sQuery += "\r\n" + "           AND B.USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                sQuery += "\r\n" + "           AND C.USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                sQuery += "\r\n" + "           AND B.FILLER1 = '2' ";
                sQuery += "\r\n" + "        ) X ";

                //#13732 바코드 리딩 시 팝업 조건 변경요청 end

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

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

        //#20171018 상품등록 유통기한 체크하기 start, phj 
        
        public string TimeStampBarCodeCheck(string sSubStoreNo, string sScanCode, ref string sRetItemCd)
        {
            string sRet = UserCom.RST_ERR;
            sRetItemCd = string.Empty;
            try
            {
                string TempDate = string.Empty;
                string TodayDate = string.Empty;
                TempDate = CmUtil.IntParse(DateTime.Now.ToString("yyMMdd")).ToString();
                TodayDate = TempDate.Substring(1, 5);

                if (CmUtil.IntParse(CmUtil.MidH(sScanCode, 7, 5)) < Convert.ToInt32(TodayDate))
                {
                    WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0739); //유통기한이 경과된 상품입니다.    
                    return sRet;
                }

                sRetItemCd = sScanCode.Substring(1, 6);
                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return sRet;
        }
        
        //#20171018 상품등록 유통기한 체크하기 end, phj 

        /// <summary>
        /// 스캔 바코드 상품 조회
        /// </summary>
        /// <param name="sScanCode">스캔코드</param>
        /// <returns></returns>
        public string SeletItemMstToBarCode(string sSubStoreNo, string sScanCode, ref string sRetItemCd, ref string sRetScanCode, ref string sShtcutItemNm)
        {
            //string sQuery = "";
            string sRet = UserCom.RST_ERR;

            sRetItemCd = ""; sRetScanCode = "";

            try
            {
                if (sScanCode.Length >= 6)
                {
                    if (m_cPosStatus.Mst.CorpDiv == ItemConst.CORP_DIV.BR)
                    {
                        // grayber@20180108 [BR] 바코드 18자리 인식 추가 start 
                        // 기존
                        //if (sScanCode.Length == 16)
                        //{
                        //    if (CmUtil.MidH(sScanCode, 10, 6) == "N9999X")
                        //    {
                        //        sRetItemCd = CmUtil.MidH(sScanCode, 4, 6);
                        //    }
                        //    else
                        //    {
                        //        sRetItemCd = CmUtil.MidH(sScanCode, 10, 6);
                        //    }

                        //    //유통기한 체크
                        //    if (ScanBarcodeCheck(sSubStoreNo, sScanCode, sRetItemCd, ref sShtcutItemNm) == true)
                        //    {
                        //        sRet = UserCom.RST_OK;
                        //    }
                        //}

                        // 변경
                        if (sScanCode.Length == 16
                            || sScanCode.Length == 18
                            )
                        {
                            if (CmUtil.RightH(sScanCode, 6) == "N9999X")
                            {
                                if (sScanCode.Length == 16)
                                {
                                    sRetItemCd = CmUtil.MidH(sScanCode, 4, 6);
                                }
                                else if (sScanCode.Length == 18)
                                {
                                    sRetItemCd = CmUtil.MidH(sScanCode, 4 + 2, 6 + 2);
                                }
                            }
                            else
                            {
                                sRetItemCd = CmUtil.RightH(sScanCode, 6);
                            }

                            //유통기한 체크
                            if (ScanBarcodeCheck(sSubStoreNo, sScanCode, sRetItemCd, ref sShtcutItemNm) == true)
                            {
                                sRet = UserCom.RST_OK;
                            }
                        }
                        // grayber@20180108 [BR] 바코드 18자리 인식 추가 end


                        // grayber@20171129 필터 추가 및 바코드 상품 검색 조건 개선 start
                        else if (sScanCode.Length == 6  && sScanCode.StartsWith("N") == true )
                        {
                            sRetScanCode = sRetItemCd = sScanCode;

                            if (ScanBarcodeCheck(sSubStoreNo, sScanCode, sRetItemCd, ref sShtcutItemNm) == true)
                            {
                                sRet = UserCom.RST_OK;
                            };
                        }
                        // grayber@20171129 필터 추가 및 바코드 상품 검색 조건 개선 end
                        else
                        {
                            sRet = UserCom.RST_IGNORE;
                        }

                    }
                    else if (m_cPosStatus.Mst.CorpDiv == ItemConst.CORP_DIV.PC && m_cPosStatus.Mst.CntryDiv == ItemConst.CNTRY_DIV.KR)
                    {
                        //PC
                        if (sScanCode.Length == 15)
                        {
                            //#16401 해피오더)주문내역 바코드 리딩 시 자동 완료처리 start - 20180829
                            if (sScanCode.StartsWith("999") == true)
                            {
                                //string sHappyOrderNum = CmUtil.MidH(sScanCode.Trim(), 3, 12);
                                //sRetItemCd = sHappyOrderNum;
                                sShtcutItemNm = "HP_ORD";
                                return sRet;
                            }
                            else 
                            //#16401 해피오더)주문내역 바코드 리딩 시 자동 완료처리 end - 20180829
                            if (sScanCode.StartsWith("S88") == false)
                            {
                                WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0523);    //등록되지 않은 바코드 입니다.
                                return sRet;
                            }
                            else
                            {
                                if (CmUtil.IntParse(CmUtil.MidH(sScanCode, 9, 6)) < CmUtil.IntParse(DateTime.Now.ToString("yyMMdd")))
                                {
                                    //에러 선택 메세지 유통기한 확인 바랍니다. 제품을 등록하시겠습니까? 
                                    if (WinManager.QuestionMessage(POS_MESSAGE.ERROR.MSG_0524) == false) return sRet;
                                }
                                sRetItemCd = CmUtil.MidH(sScanCode, 3, 6);
                                sRet = UserCom.RST_OK;
                            }
                        }
                        //#15897 요청)점포생산제품 바코드 출력기능 수정요청 start
                        
                        else if (sScanCode.Length == 18)
                        {
                            //구분자(2)+제품코드(6)+년(1)+월일시분(8)+체크(1)
                            //구분자(2) : '22'
                            //년(1)     : 년도 마지막 자리 ex) 2018 -> 8
                            //체크(1)   : bdataCheckNum(년+월일시분)

                            if (sScanCode.StartsWith("22") == false)
                            {
                                WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0523);    //등록되지 않은 바코드 입니다.
                                return sRet;
                            }

                            //구분자(2)+제품코드(6)+년(1)+월일시분(8)+체크(1)
                            string sCheckDigit = CmUtil.MidH(sScanCode, 17, 1);
                            string sRetCheckDigit = LabelBarCodeCheck(CmUtil.MidH(sScanCode, 8, 9));
                            if (sCheckDigit != sRetCheckDigit)
                            {
                                WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0794));
                                return sRet;
                            }

                            sRetItemCd = CmUtil.MidH(sScanCode, 2, 6);
                            sRet = UserCom.RST_OK;
                        }
                        //#15897 요청)점포생산제품 바코드 출력기능 수정요청 end
                        else
                        {
                            sRet = UserCom.RST_IGNORE;
                        }
                    }
                    else if (m_cPosStatus.Mst.CorpDiv == ItemConst.CORP_DIV.PC &&
                        (m_cPosStatus.Mst.CntryDiv == ItemConst.CNTRY_DIV.US || m_cPosStatus.Mst.CntryDiv == ItemConst.CNTRY_DIV.FR ||
                        m_cPosStatus.Mst.CntryDiv == ItemConst.CNTRY_DIV.VN || m_cPosStatus.Mst.CntryDiv == ItemConst.CNTRY_DIV.SG)
                        )
                    {
                        //미국, 프랑스, 배트남, 싱가포르
                        if (sScanCode.Length <= 10)
                        {
                            //제품
                            sRetItemCd = sScanCode;
                            sRet = UserCom.RST_OK;
                        }
                        else
                        {
                            sRet = UserCom.RST_IGNORE;
                        }

                    }
                    else if (m_cPosStatus.Mst.CorpDiv == ItemConst.CORP_DIV.PC && m_cPosStatus.Mst.CntryDiv == ItemConst.CNTRY_DIV.CN)
                    {
                        //중국
                        if (sScanCode.Length != 18)
                        {
                            //제품
                            sRetItemCd = sScanCode;
                            sRet = UserCom.RST_OK;
                        }
                        else
                        {
                            sRet = UserCom.RST_IGNORE;
                        }

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

        #region 바코드 유통기간 체크
        /// <summary>
        /// 바코드스캔 코드 체크
        /// </summary>
        /// <param name="sScanCode"></param>
        /// <returns></returns>
        private bool ScanBarcodeCheck(string sSubStoreNo, string sScanCode, string sItemCode, ref string sShtcutItemNm)
        {

            bool bRet = true;

            string sMsg = "";
            string sCreateDate = string.Empty;  //생산일자
            string sExpireDt = string.Empty;    //유통기한
            string sProduceDt = string.Empty;

            try
            {
                //유통기한 가져오기
                DataTable dtDataInfo = SeletItemMstToItemCode(sSubStoreNo, sItemCode);
                if (dtDataInfo == null || dtDataInfo.Rows.Count == 0)
                {
                    WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0010));
                    bRet = false;
                }
                else
                {
                    DataRow dr = dtDataInfo.Rows[0];

                    int iExpire = CmUtil.GetDataRowInt(dr, PosMst.MST_ITEM.DATA.DISTBT_EXPIRE_NOD);
                    sShtcutItemNm = CmUtil.GetDataRowStr(dr, PosMst.MST_ITEM.DATA.SHTCUT_ITEMNM);

                    if (iExpire > 0)
                    {

                        // 년 2byte                                  월 2byte                                   일 2byte
                        sProduceDt = "20" + AlphaToDate(sScanCode.Substring(0, 1)) + AlphaToDate(sScanCode.Substring(1, 1)) + AlphaToDate(sScanCode.Substring(2, 1));

                        if (sProduceDt.Length != 8)
                        {
                            UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "InputBarCodeToDate = " + sProduceDt);
                        }
                        else
                        {
                            //유통기간 날짜구하기!
                            sExpireDt = GetExpireDate(sProduceDt, iExpire);

                            if (sExpireDt != "")
                            {
                                if (CmUtil.LongParse(DateTime.Now.ToString("yyyyMMdd")) > CmUtil.LongParse(sExpireDt))
                                {
                                    sCreateDate = string.Format("{0}-{1}-{2}", sProduceDt.Substring(0, 4), sProduceDt.Substring(4, 2), sProduceDt.Substring(6, 2));
                                    sExpireDt = string.Format("{0}-{1}-{2}", sExpireDt.Substring(0, 4), sExpireDt.Substring(4, 2), sExpireDt.Substring(6, 2));
                                    sMsg = string.Format(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0525), CmUtil.GetDataRowStr(dr, PosMst.MST_ITEM.DATA.SHTCUT_ITEMNM), sCreateDate, sExpireDt);

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

            return bRet;
        }

        /// <summary>
        /// 유통기간 문자열 날짜 변환
        /// </summary>
        /// <param name="sScanCode"></param>
        /// <returns></returns>
        private string AlphaToDate(string sScanCode)
        {

            string sRet = "";

            try
            {
                string[] aAlpha = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "A"
                                               , "B", "C", "D", "E", "F", "G", "H", "I", "J", "K"
                                               , "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U"
                                               , "V" };

                for (int iRow = 0; iRow <= aAlpha.Length - 1; iRow++)
                {
                    if (aAlpha[iRow] == sScanCode)
                    {
                        sRet = (iRow + 1).ToString().PadLeft(2, '0');
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return sRet;
        }

        /// <summary>
        /// 유통기간 일자 및 체크
        /// </summary>
        /// <param name="sExpireDt"></param>
        /// <returns></returns>
        private string GetExpireDate(string sCreateDate, int iExpireDay)
        {
            string EDate = "";

            try
            {
                string SDate = string.Format("{0}-{1}-{2}", sCreateDate.Substring(0, 4), sCreateDate.Substring(4, 2), sCreateDate.Substring(6, 2));

                DateTime T1 = DateTime.Parse(SDate);
                DateTime T2 = T1.AddDays(iExpireDay);

                EDate = T2.Date.ToString("yyyyMMdd");

            }
            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 EDate;
        }
        #endregion 바코드 유통기간 체크

        /// <summary>
        /// 기능키 그룹 조회
        /// </summary>
        /// <param name="sFuncGroupID">기능그룹ID</param>
        /// <returns></returns>
        public DataTable SeletFuncKeyGroup(string sFuncGroupID)
        {
            string sQuery = "";
            try
            {
                // 기능키 그룹 조회
                sQuery += " SELECT * FROM POSMST..MST_FUNC_KEY_GRP ";
                sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";

                if (sFuncGroupID != "")
                    sQuery += "   AND FUNC_GRP_ID = '" + sFuncGroupID + "'";

                sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                sQuery += " ORDER BY FUNC_GRP_ID, DISP_SEQ ";

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }

        /// <summary>
        /// 기능키 조회
        /// </summary>
        /// <param name="sFuncID"></param>
        /// <returns></returns>
        public DataTable SeletFuncKey(string sFuncID)
        {
            string sQuery = "";
            try
            {
                // 기능키 그룹 조회
                sQuery += " SELECT * FROM POSMST..MST_FUNC_KEY ";
                sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";

                if (sFuncID != "")
                    sQuery += "   AND FUNC_ID = '" + sFuncID + "'";

                sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                //sQuery += " ORDER BY FUNC_ID, DISP_SEQ ";

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }

        //#15169 임직원 해피App 바코드리딩 시 자동할인적용 개선요청 start
        /// <summary>
        /// 기능키 배치 여부 조회
        /// </summary>
        /// <param name="sFuncID"></param>
        /// <returns></returns>
        public DataTable SeletFuncKeyGroupArr(string sFuncID)
        {
            string sQuery = "";
            try
            {
                // 기능키 배치 여부 조회
                sQuery += " SELECT * FROM POSMST..MST_FUNC_KEY_GRP ";
                sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                sQuery += "   AND FUNC_ID = '" + sFuncID + "'";
                sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                sQuery += " ORDER BY FUNC_GRP_ID, DISP_SEQ ";

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        //#15169 임직원 해피App 바코드리딩 시 자동할인적용 개선요청 end

        /// <summary>
        /// 공통코드 조회
        /// </summary>
        /// <param name="sCommCodeGroup">공통코드그룹(PosCont.COMMON_CODE_GROUP)</param>
        /// <param name="sCommCode">공통코드</param>
        /// <returns></returns>
        public DataTable SeletCommonCode(string sCommCodeGroup, string sCommCode)
        {
            string sQuery = "";
            try
            {
                // 공통코드 조회
                sQuery += " SELECT * FROM POSMST..MST_CMM ";
                sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";


                if (sCommCodeGroup != "")
                    sQuery += "   AND CMM_GRP_CD = '" + sCommCodeGroup + "'";
                if (sCommCode != "")
                    sQuery += "   AND CMM_CD = '" + sCommCode + "'";

                sQuery += "   AND LANG_TYPE = '" + m_cPosStatus.Base.Country + "'";
                sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                sQuery += " ORDER BY CMM_GRP_CD, DISP_SEQ, CMM_CD ";

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }

        /// <summary>
        /// 상품부가세율 구하기
        /// </summary>
        /// <param name="sTaxRateCode"></param>
        /// <returns></returns>
        public double ItemTaxRate(string sTaxRateCode)
        {
            DataTable dt = null;
            double dTaxRate = 0;

            try
            {
                dt = SeletCommonCode(PosConst.COMMON_CODE_GROUP.M0101, sTaxRateCode);

                if (!(dt == null || dt.Rows.Count == 0))
                {
                    DataRow dr = dt.Rows[0];
                    dTaxRate = CmUtil.GetDataRowDouble(dr, PosMst.MST_COMMON.DATA.NUM_VAL_TITLE_VAL_01);
                }
            }
            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 dTaxRate;
        }

        /// <summary>
        /// MOT 마스터 조회
        /// </summary>
        /// <param name="sTableName"></param>
        /// <param name="sMsgType"></param>
        /// <param name="sCnntID"></param>
        /// <returns></returns>
        public DataTable SelectMOT(string sTableName, string sMsgType, string sCnntID, string sSeqNo)
        {
            string sQuery = "";
            try
            {

                if (sTableName == PosMst.MST_MOT_MSG.TABLE_NAME)
                {
                    // MOT 해더 마스터
                    sQuery += " SELECT * FROM POSMST..MST_MOT_MSG ";
                    sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "   AND MSG_TYPE = '" + sMsgType + "'";

                    if (sCnntID != "")
                        sQuery += "   AND CNNT_ID = '" + sCnntID + "'";

                    sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                    sQuery += " ORDER BY SEQ_NO ";

                }

                if (sTableName == PosMst.MST_MOT_MSG_DTL.TABLE_NAME)
                {
                    // MOT 상세 마스터
                    //sQuery += " SELECT * FROM POSMST..MST_MOT_MSG_DTL ";
                    //sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                    //sQuery += "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    //sQuery += "   AND MSG_TYPE = '" + sMsgType + "'";
                    //sQuery += "   AND CNNT_ID = '" + sCnntID + "'";
                    //if (sSeqNo != "")
                    //    sQuery += "   AND SEQ_NO  = '" + sSeqNo + "'";
                    //sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                    //sQuery += " ORDER BY SEQ ";

                    sQuery += " SELECT B.* ";
                    sQuery += " FROM POSMST..MST_MOT_MSG A ";
                    sQuery += "  INNER JOIN  POSMST..MST_MOT_MSG_DTL B ";
                    sQuery += "     ON A.CMP_CD   = B.CMP_CD ";
                    sQuery += "    AND A.STOR_CD  = B.STOR_CD ";
                    sQuery += "    AND A.MSG_TYPE = B.MSG_TYPE ";
                    sQuery += "    AND A.CNNT_ID  = B.CNNT_ID ";
                    sQuery += "    AND A.SEQ_NO   = B.SEQ_NO ";
                    sQuery += "    AND A.USE_YN   = '" + PosConst.MST_USE_YN.YES + "'";
                    sQuery += "  WHERE B.CMP_CD   = '" + m_cPosStatus.Base.CmpCd + "'";
                    sQuery += "    AND B.STOR_CD  = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "    AND B.MSG_TYPE = '" + sMsgType + "'";
                    sQuery += "    AND B.CNNT_ID  = '" + sCnntID + "'";
                    if (sSeqNo != "")
                        sQuery += "   AND B.SEQ_NO  = '" + sSeqNo + "'";
                    sQuery += "   AND B.USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                    sQuery += " ORDER BY B.SEQ ";
                }
                return m_cMstService.Select(new string[] { sQuery });

            }
            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 null;

        }

        /// <summary>
        /// 서브 매장 마스터 조회
        /// </summary>
        /// <param name="sTableName"></param>
        /// <returns></returns>
        public DataTable SelectSubStr(string sTableName)
        {
            string sQuery = "";
            try
            {
                sQuery += " SELECT * FROM POSMST.dbo.MST_COMPLEX_SHOP_STOR ";
                sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";

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

            }
            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 null;

        }

        /// <summary>
        /// 입출금 계정 디테일 마스터
        /// </summary>
        /// <param name="sDpstWthdrType">입출금유형</param>
        /// <param name="sAccCd">계정코드</param>
        /// <returns></returns>
        public DataTable SeletMstDpstWthdrAccDtl(string sDpstWthdrType, string sAccCd)
        {
            string sQuery = "";

            try
            {
                // 입출금 계정 디테일 마스터
                sQuery = "";
                sQuery += " SELECT DPST_WTHDR_ACC_NM, DPST_WTHDR_TYPE, DPST_WTHDR_ACC_CD, SPPLR_INPUT_TYPE ";
                sQuery += " FROM POSMST..MST_DPST_WTHDR_ACC ";
                sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "   AND DRT_FRCS_DIV = '" + m_cPosStatus.Mst.DrtFrcsDiv + "'";      //직가맹 구분
                sQuery += "   AND DPST_WTHDR_TYPE = '" + sDpstWthdrType + "'";
                sQuery += "   AND SALE_POS_USE_YN = '1' ";
                sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";

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

            }
            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 null;
        }

        /// <summary>
        /// WEB_LINK 마스터 조회
        /// </summary>
        /// <returns></returns>
        public DataTable SeletMstWebLinkMst(string sDiv)
        {
            string sQuery = "";

            try
            {
                sQuery = "";
                sQuery += " SELECT * FROM POSMST..MST_WEB_LNKAGE ";
                sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                sQuery += "   AND DISP_YN = '1'";
                sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                sQuery += "   ORDER BY DISP_SEQ ASC  ";

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }


        /// <summary>
        /// 기능키 그룹 조회
        /// </summary>
        /// <param name="sFuncGroupID">기능그룹ID</param>
        /// <returns></returns>
        public DataTable SeletSubPrcMenu(string sSubStoreNo, string sItemCode)
        {
            string sQuery = "";
            try
            {
                // 상품코드로 상품 마스터 조회
                sQuery = "";
                sQuery += " SELECT DISTINCT * FROM POSMST..MST_SUBPRC_MENU_GRP ";
                sQuery += " WHERE CMP_CD             = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "   AND STOR_CD            = '" + m_cPosStatus.Base.StoreNo + "'";
                sQuery += "   AND SUB_STOR_CD        = '" + sSubStoreNo + "'";
                sQuery += "   AND SUBPRC_MENU_KEY_CD = '" + sItemCode + "'";
                sQuery += "   AND USE_YN             = '" + PosConst.MST_USE_YN.YES + "'";

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }


        #endregion

        #region 카드 승인 헤더 IRT 전문 생성(SPC VAN 공용사용)
        /// <summary>
        /// 카드 승인 헤더 IRT 전문 생성(카드,OCB포인트,콘 공용사용)
        /// </summary>
        /// <param name="sMsgID"></param>
        /// <param name="nIRTBodyLen"></param>
        /// <param name="sCmpApprID">업체정보</param>
        /// <param name="sApprID">단말기번호</param>
        /// <returns></returns>
        public string MakeCreditCardHeader(string sMsgID, long nIRTBodyLen, string sCmpApprID, string sApprID)
        {
            string sSendData = "";
            try
            {
                // 카드 승인 헤더
                string[] aIrtHead = new string[Column.POS_VAN_HEADER.LEN.Length];

                aIrtHead[Column.POS_VAN_HEADER.SEQ.HdrTrDiv] = sMsgID;

                aIrtHead[Column.POS_VAN_HEADER.SEQ.HdrLen] = (ItemColumn.LenMessage(Column.POS_VAN_HEADER.LEN) + nIRTBodyLen - 4).ToString();       //-4헤더에서 길이항목을 빼준다.
                aIrtHead[Column.POS_VAN_HEADER.SEQ.HdrSTX] = PosConst.VAN_HEXA.STX;

                aIrtHead[Column.POS_VAN_HEADER.SEQ.HdrCatNo] = sApprID;                                 // 단말기번호(터미널ID) => "PCR0000001" 
                aIrtHead[Column.POS_VAN_HEADER.SEQ.HdrCompany] = sCmpApprID;                            // 업체정보=> "BR31"
                aIrtHead[Column.POS_VAN_HEADER.SEQ.HdrDocSeq] = DateTime.Now.ToString("HHmmss");        // 전문일련번호*///m_cPosStatus.Base.MsgSeqNo;

                // 신용카드 승인 요청 헤더 전문 생성
                sSendData = ItemColumn.MakeMessage(aIrtHead, Column.POS_VAN_HEADER.LEN, Column.POS_VAN_HEADER.TYPE);
            }
            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 sSendData;
        }
        #endregion 카드 승인 헤더 IRT 전문 생성(SPC VAN 공용사용)

        #region SPC VAN 공통 전문 송/수신
        /// <summary>
        /// SPC VAN 공통 전문 송/수신
        /// </summary>
        /// <param name="sSendItem"></param>
        /// <param name="sRecvItem"></param>
        /// <param name="bShowMsg"></param>
        /// <returns></returns>
        //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 start, 20180503
        //해피쿠폰 발송시 승인 메시지 변경 '포인트 조회중입니다.' -> '쿠폰 발송중입니다.'
        //기존
        /*
        public string ExecuteCardIrt(string sTradID, string sSendItem, ref string sRecvItem, bool bShowMsg, string sAuthInfo)
        {
            return ExecuteCardIrt(sTradID, sSendItem, ref sRecvItem, bShowMsg, "", "", "", sAuthInfo);

        }
        */
        //변경
        public string ExecuteCardIrt(string sTradID, string sSendItem, ref string sRecvItem, bool bShowMsg, string sAuthInfo, string sPAY_WAY_CD = "", string sPAY_DTL_CD_01 = "")
        {
            return ExecuteCardIrt(sTradID, sSendItem, ref sRecvItem, bShowMsg, "", "", "", sAuthInfo, sPAY_WAY_CD, sPAY_DTL_CD_01);

        }
        //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 end, 20180503

        //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 start, 20180503
        //해피쿠폰 발송시 승인 메시지 변경 '포인트 조회중입니다.' -> '쿠폰 발송중입니다.'
        //기존
        //public string ExecuteCardIrt(string sTradID, string sSendItem, ref string sRecvItem, bool bShowMsg, string sChipData, string sSingData, string sLastRecvData, string sAuthInfo)
        //변경
        public string ExecuteCardIrt(string sTradID, string sSendItem, ref string sRecvItem, bool bShowMsg, string sChipData, string sSingData, string sLastRecvData, string sAuthInfo, string sPAY_WAY_CD = "", string sPAY_DTL_CD_01 = "")
        //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 end, 20180503
        {
            string sRet = UserCom.RST_ERR;
            int nRet = -99;
            string sRecvData = "";
            string sDspName = "";
            try
            {
                // 화면 표시 메세지 설정 부분
                switch (sTradID)
                {
                    case PosConst.POS_VAN_MASTER.TRADE_ID.VAN_BILL_CHECK:
                        sDspName = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0060);
                        break;
                    case PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_QRY_A:
                        sDspName = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0252);
                        break;
                    case PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CARD_AGREE:
                        sDspName = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0058);
                        break;
                    case PosConst.POS_VAN_MASTER.TRADE_ID.VAN_CASH_AGREE:
                        sDspName = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0065);
                        break;
                    case PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_LINE_CANCEL:
                        sDspName = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0096);
                        break;
                    default:
                        break;
                }
                sDspName = string.Format(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0231), sDspName);

                //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 start, 20180503
                //해피쿠폰 발송시 승인 메시지 변경 '포인트 조회중입니다.' -> '쿠폰 발송중입니다.'
                if (sPAY_WAY_CD == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM && sPAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.ETC_INFO.HAPPYCPN_SEND)
                {
                    sDspName = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0783);
                }
                //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 end, 20180503

                //UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                //                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                //                    CmUtil.RPadH("[SEND" + ": VAN(SPCN)", 27) + "] " + sSendItem);

#if KIOSKSTART_OFF
                using (var m_cfVanMsg = new frmVanMessage())
                {
                    m_cfVanMsg.PosMessageStr = sDspName;
                    m_cfVanMsg.SendData = sSendItem;
                    m_cfVanMsg.ICData = sChipData;
                    m_cfVanMsg.SignData = sSingData;
                    m_cfVanMsg.LastRecvData = sLastRecvData;    //망취소용
                    m_cfVanMsg.AuthInfo = sAuthInfo;
                    m_cfVanMsg.ShowDialog();

                    sRecvData = m_cfVanMsg.RecvData;

                    nRet = m_cfVanMsg.RecvRet;
                    if (nRet < 0) sRet = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0158) + "\n" + m_cfVanMsg.RecvData;
                }
#else
                var iCReader = (IICReaderUs)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_ICREADER);
                if (sLastRecvData.Trim() != "") //망취소
                    nRet = iCReader.SpcnCommPosForNetCancel(sSendItem, sLastRecvData, ref sRecvData);
                else
                    nRet = iCReader.SpcnCommPos(sSendItem, sSingData, sChipData, string.Empty, sAuthInfo, ref sRecvData);
                if (nRet < 0) sRet = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0158) + "\n" + sRecvData;
                iCReader = null;
#endif

                if (nRet < 0)
                {
                    // 통신 실패 로그
                    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 + "()",
                        string.Format("SPCN SOCKET ERROR, RET = {0} => {1}", nRet, sRecvData));
                    return sRet;
                }

                //UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                //                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                //                    CmUtil.RPadH("[RECV" + ": VAN(SPCN)", 27) + "] " + sRecvData);

                byte[] bytes = Encoding.Default.GetBytes(sRecvData);
                int nNowPos = 0;

                // 공통해더 전문 체크
                string[] aCommHead = new string[Column.POS_VAN_HEADER.LEN.Length];
                ItemColumn.ParseMessage(Column.POS_VAN_HEADER.LEN, Column.POS_VAN_HEADER.TYPE, bytes, ref nNowPos, ref aCommHead);

                // POS번호+전문순번 정합성 체크
                if (CmUtil.MidH(sSendItem, 25, 6) != aCommHead[Column.POS_VAN_HEADER.SEQ.HdrDocSeq])
                {
                    sRet = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0158);
                    // 통신 실패 로그
                    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 + "()",
                        string.Format("SPCN SOCKET ERROR, SEQNO => {0} != {1}", CmUtil.MidH(sSendItem, 25, 6), aCommHead[Column.POS_VAN_HEADER.SEQ.HdrDocSeq]));
                    return sRet;
                }

                // 바디 체크
                if (bytes.Length - nNowPos <= 0)
                {
                    sRet = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0158);
                    // 통신 실패 로그
                    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 + "()",
                        "SPCN SOCKET ERROR, NO DATA");
                    return sRet;
                }

                if (sTradID == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_ICCARD_AGREE)
                {
                    //신용IC 승인은 망취소 때문에 헤더 자르는 없이 그대로 전송함!
                    sRecvItem = sRecvData;
                }
                else
                {
                    // 수신데이터(공통해더 제거)
                    sRecvItem = Encoding.Default.GetString(bytes, nNowPos, bytes.Length - nNowPos);
                }

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

            }
            return sRet;
        }
        #endregion SPC VAN 공통 전문 송/수신

        #region 기능키 유효성 검사
        /// <summary>
        /// 기능키 유효성 검사
        /// </summary>
        /// <param name="sFuncKey"></param>
        /// <returns></returns>
        public bool FunctionKeyValidity(string sFuncKey)
        {

            bool bRet = false;

            try
            {

                DataTable dtFuncKey = SeletFuncKey(sFuncKey);
                if (dtFuncKey == null || dtFuncKey.Rows.Count <= 0)
                {
                    //거래 기능 정의 없음! - Err   
                    return bRet;
                }
                else
                {

                    foreach (DataRow dr in dtFuncKey.Rows)
                    {
                        //거래 구분 체크
                        switch (m_cTrnStatus.Head.TradeDiv)
                        {
                            case ItemConst.TRAN_DIV.NORMAL:
                                if (CmUtil.GetDataRowStr(dr, PosMst.MST_FUNC_KEY.DATA.NORMAL) != "1")
                                    return bRet;
                                break;
                            case ItemConst.TRAN_DIV.REFUND:
                                if (CmUtil.GetDataRowStr(dr, PosMst.MST_FUNC_KEY.DATA.REFUND) != "1")
                                    return bRet;
                                break;
                        }

                        //거래 유형 체크
                        switch (CmUtil.MidH(m_cTrnStatus.Head.TradeKind, 0, 1))
                        {
                            case ItemConst.TRAN_KIND.NORMAL.DELIMITER:
                                if (CmUtil.GetDataRowStr(dr, PosMst.MST_FUNC_KEY.DATA.TRN_MODE_0) != "1")
                                    return bRet;
                                break;
                            case ItemConst.TRAN_KIND.UNDECIDED.DELIMITER:
                                if (CmUtil.GetDataRowStr(dr, PosMst.MST_FUNC_KEY.DATA.TRN_MODE_1) != "1")
                                    return bRet;
                                break;
                            case ItemConst.TRAN_KIND.FORIGN.DELIMITER:
                                if (CmUtil.GetDataRowStr(dr, PosMst.MST_FUNC_KEY.DATA.TRN_MODE_2) != "1")
                                    return bRet;
                                break;
                            case ItemConst.TRAN_KIND.AFTER.DELIMITER:
                                if (CmUtil.GetDataRowStr(dr, PosMst.MST_FUNC_KEY.DATA.TRN_MODE_3) != "1")
                                    return bRet;
                                break;
                            case ItemConst.TRAN_KIND.CHARGESALE.DELIMITER:
                                if (CmUtil.GetDataRowStr(dr, PosMst.MST_FUNC_KEY.DATA.TRN_MODE_4) != "1")
                                    return bRet;
                                break;
                            case ItemConst.TRAN_KIND.ETC.DELIMITER:
                                if (CmUtil.GetDataRowStr(dr, PosMst.MST_FUNC_KEY.DATA.TRN_MODE_5) != "1")
                                    return bRet;
                                break;
                            case ItemConst.TRAN_KIND.STATEMENT.DELIMITER:
                                if (CmUtil.GetDataRowStr(dr, PosMst.MST_FUNC_KEY.DATA.TRN_MODE_8) != "1")
                                    return bRet;
                                break;
                            case ItemConst.TRAN_KIND.LOG.DELIMITER:
                                if (CmUtil.GetDataRowStr(dr, PosMst.MST_FUNC_KEY.DATA.TRN_MODE_9) != "1")
                                    return bRet;
                                break;
                            default:
                                //알수 없는 거래 유형!
                                break;
                        }

                        break;
                    }
                }

                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);
            }

            return bRet;
        }

        /// <summary>
        /// 기능키 서브 메뉴 처리
        /// </summary>
        /// <param name="sFuncKey"></param>
        /// <returns></returns>
        public bool FunctionKeySubMenuLoad(string sFuncKey)
        {
            bool bRet = false;

            try
            {
                DataTable dtFuncKey = SeletFuncKey(sFuncKey);
                if (dtFuncKey == null || dtFuncKey.Rows.Count <= 0)
                {
                    //거래 기능 정의 없음! - Err                    
                }
                else
                {
                    foreach (DataRow dr in dtFuncKey.Rows)
                    {
                        if (CmUtil.GetDataRowStr(dr, PosMst.MST_FUNC_KEY.DATA.MENU_GRP) == "1")
                            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);
            }

            return bRet;
        }
        #endregion

        #region 쿠폰할인 기능키 조회
        /// <summary>
        /// 쿠폰할인 기능키 조회
        /// </summary>
        /// <param name="sFuncID"></param>
        /// <returns></returns>
        public DataTable SeletCouponDCFuncKey(string sPay_Dc_Grp_Type, string sPay_Dc_Cd)
        {
            try
            {
                // 쿠폰할인 조회

                string sQuery = "";
                sQuery += " SELECT ";
                sQuery += "         ROW_NUMBER() OVER( ORDER BY BRAND_CD DESC, CPN_DC_CD)   SEQ";
                sQuery += " 	,	CMP_CD                                                  CMP_CD ";
                sQuery += " 	,	STOR_CD                                                 STOR_CD ";
                sQuery += " 	,	BRAND_CD                                                BRAND_CD ";
                sQuery += " 	,	ISNULL(CPN_DC_CD, '')                                   CPN_DC_CD ";
                sQuery += " 	,	ISNULL(CPN_DC_NM, '')                                   CPN_DC_NM ";
                sQuery += " 	,	ISNULL(DC_DIV, '1')									    CPN_TYPE ";     // 할인구분 (1:율, 2:금액)
                sQuery += " 	,	ISNULL(DC_RATE, 0)					                    DC_RATE ";
                sQuery += " 	,	'WHITE'                                                 BACKGR_COLOR ";
                sQuery += " 	,	'10'                                                    FONT_SIZE ";
                sQuery += " 	,	'0'                                                     BTN_SIZE ";
                sQuery += " 	,	''                                                      BTN_ITEM_IMG ";
                sQuery += " FROM POSMST..MST_DC_DTL ";
                sQuery += " WHERE ";
                sQuery += " 	CMP_CD			= '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += " AND STOR_CD			= '" + m_cPosStatus.Base.StoreNo + "'";
                sQuery += " AND BRAND_CD		IN ('0000', '" + m_cPosStatus.Base.BrandCd + "') ";
                sQuery += " AND PAY_DC_GRP_TYPE = '" + sPay_Dc_Grp_Type + "' ";
                sQuery += " AND PAY_DC_CD		= '" + sPay_Dc_Cd + "' ";
                sQuery += " AND USE_YN			= '" + PosConst.MST_USE_YN.YES + "'";
                sQuery += " ORDER BY 1";

                sQuery = sQuery.Replace("\t", " ");

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion


        #region 환율 조회
        /// <summary>
        /// 환율 조회
        /// </summary>
        /// <param name="sFuncID"></param>
        /// <returns></returns>
        public DataTable SelectForeign()
        {
            try
            {
                // 조회

                string sQuery = "";
                sQuery += " SELECT \n";
                sQuery += "         EXCHG_RATE_CD                       EXCHG_RATE_CD \n";
                sQuery += " 	,	EXCHG_RATE_NM                       EXCHG_RATE_NM  \n";
                sQuery += " 	,	ISNULL(EXCHG_RATE_AMT, 0)           EXCHG_RATE_AMT  \n";
                sQuery += " 	,	ISNULL(EXCHG_RATE_UNIT, 0)          EXCHG_RATE_UNIT  \n";
                sQuery += " FROM POSMST..MST_EXCHG_RATE  \n";
                sQuery += " WHERE  \n";
                sQuery += " 	EXCHG_RATE_REG_DT   = CONVERT(VARCHAR(8), DATEADD(DAY, -1, '" + m_cPosStatus.Base.SaleDate + "'), 112)  \n";
                sQuery += " AND EXCHG_RATE_REG_DGRE = (SELECT ISNULL(MAX(EXCHG_RATE_REG_DGRE), 0)  \n";
                sQuery += "                              FROM POSMST..MST_EXCHG_RATE  \n";
                sQuery += "                             WHERE EXCHG_RATE_REG_DT = CONVERT(VARCHAR(8), DATEADD(DAY, -1, '" + m_cPosStatus.Base.SaleDate + "'), 112) \n";
                sQuery += "                               AND USE_YN			= '" + PosConst.MST_USE_YN.YES + "') \n";
                sQuery += " AND USE_YN			    = '" + PosConst.MST_USE_YN.YES + "' \n";
                sQuery += " ORDER BY 1 \n";

                sQuery = sQuery.Replace("\t", " ");

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion

        #region 환율 단위 조회
        /// <summary>
        /// 환율 단위 조회
        /// </summary>
        /// <param name="sSaleDate"></param>
        /// <returns></returns>
        public DataTable SelectExchangeRate(string sSaleDate)
        {
            try
            {
                // 조회

                string sQuery = "";

                sQuery += "SELECT \n";
                sQuery += "		CONVERT(VARCHAR(5), CMM.DISP_SEQ)                                   DISP_SEQ  \n";
                sQuery += "	,	RTRIM(CMM.ENTRY_NM)													EXCHG_RATE_CD  \n";
                sQuery += "	,	ISNULL(CMM.EXPLN, '')												EXCHG_RATE_NM  \n";
                sQuery += "	,	ISNULL(EXR.EXCHG_RATE_AMT, '0')										EXCHG_RATE_AMT   \n";
                sQuery += "	,	ISNULL(EXR.EXCHG_RATE_UNIT, ISNULL(CMM.CHAR_VAL_TITLE_VAL_05, '0'))	EXCHG_RATE_UNIT   \n";
                sQuery += "FROM POSMST..MST_CMM														CMM \n";
                sQuery += "	LEFT JOIN	( \n";
                sQuery += "	  SELECT   \n";
                sQuery += "			EXCHG_RATE_CD													EXCHG_RATE_CD  \n";
                sQuery += "  		,	ISNULL(EXCHG_RATE_NM, '')									EXCHG_RATE_NM  \n";
                sQuery += "  		,	CONVERT(VARCHAR(17), ISNULL(EXCHG_RATE_AMT, '0'))			EXCHG_RATE_AMT   \n";
                sQuery += "  		,	CONVERT(VARCHAR(17), ISNULL(EXCHG_RATE_UNIT, '0'))			EXCHG_RATE_UNIT    \n";
                sQuery += "	  FROM POSMST..MST_EXCHG_RATE    \n";
                sQuery += "	  WHERE    \n";
                sQuery += "  		EXCHG_RATE_REG_DT   = '" + sSaleDate + "' \n";
                sQuery += "	  AND EXCHG_RATE_REG_DGRE = (SELECT ISNULL(MAX(EXCHG_RATE_REG_DGRE), 0)  \n";
                sQuery += "								   FROM POSMST..MST_EXCHG_RATE  \n";
                sQuery += "								  WHERE EXCHG_RATE_REG_DT = '" + sSaleDate + "' \n";
                sQuery += "									AND USE_YN			= '" + PosConst.MST_USE_YN.YES + "') \n";
                sQuery += "	  AND USE_YN			    = '" + PosConst.MST_USE_YN.YES + "' \n";
                sQuery += "  )																			EXR \n";
                sQuery += "  ON EXR.EXCHG_RATE_CD	= RTRIM(CMM.ENTRY_NM) \n";
                sQuery += "WHERE \n";
                sQuery += "	CMM.CMP_CD		    = '" + m_cPosStatus.Base.CmpCd + "' \n";
                sQuery += "AND CMM.CMM_GRP_CD	= '" + PosConst.COMMON_CODE_GROUP.Z0004 + "' \n";
                sQuery += "AND CMM.LANG_TYPE	= '" + m_cPosStatus.Base.Country + "' \n";
                sQuery += "AND CMM.CMM_CD		IN ('31', '32', '33', '34') \n";
                sQuery += "AND CMM.USE_YN		= '" + PosConst.MST_USE_YN.YES + "' \n";
                sQuery += "ORDER BY CONVERT(VARCHAR(5), CMM.DISP_SEQ) \n";

                sQuery = sQuery.Replace("\t", " ");

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion

        #region 환율등록
        /// <summary>
        /// 환율등록
        /// </summary>
        /// <param name="sFuncID"></param>
        /// <returns></returns>
        public DataTable SaveExchangeRate(string[] aRet)
        {
            try
            {
                // 조회
                string sQuery = "";

                sQuery += "INSERT INTO POSMST.dbo.MST_EXCHG_RATE \n";
                sQuery += " ( EXCHG_RATE_REG_DT, EXCHG_RATE_REG_DGRE, EXCHG_RATE_CD, EXCHG_RATE_NM, EXCHG_RATE_AMT, EXCHG_RATE_UNIT, FILLER1, FILLER2, FILLER3, FILLER4, FILLER5, UPD_DT, REG_DT, USE_YN ) \n";
                sQuery += "SELECT  \n";
                sQuery += "		    CONVERT(VARCHAR(8), DATEADD(DAY, -1, '" + aRet[0] + "'), 112)   EXCHG_RATE_REG_DT \n";
                sQuery += "	    ,	'" + aRet[5] + "'	EXCHG_RATE_REG_DGRE \n";
                sQuery += "     ,	'" + aRet[1] + "'	EXCHG_RATE_CD \n";
                sQuery += "     ,	'" + aRet[2] + "'	EXCHG_RATE_NM \n";
                sQuery += "	    ,	'" + aRet[3] + "'	EXCHG_RATE_AMT  \n";
                sQuery += "	    ,	'" + aRet[4] + "'	EXCHG_RATE_UNIT \n";
                sQuery += "	    ,	''					FILLER1 \n";
                sQuery += "	    ,	''					FILLER2 \n";
                sQuery += "	    ,	''					FILLER3 \n";
                sQuery += "	    ,	''					FILLER4 \n";
                sQuery += "	    ,	''					FILLER5 \n";
                sQuery += "     ,	''					UPD_DT \n";
                sQuery += "	    ,	CONVERT(VARCHAR(8), GETDATE(), 112) + REPLACE(CONVERT(VARCHAR(8), GETDATE(), 114), ':', '')	REG_DT \n";
                sQuery += "	    ,	'" + PosConst.MST_USE_YN.YES + "'       USE_YN  \n";
                sQuery += "SELECT @@ROWCOUNT \n";

                sQuery = sQuery.Replace("\t", " ");

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion

        #region 환율 차수 조회
        /// <summary>
        /// 환율 차수 조회
        /// </summary>
        /// <param name="sSaleDate"></param>
        /// <returns></returns>
        public DataTable SelectExchangeRateChasu(string sSaleDate)
        {
            try
            {
                // 조회
                string sQuery = "";

                sQuery += "	SELECT ISNULL(MAX(EXCHG_RATE_REG_DGRE), 0) + 1  MAX_CHASU \n";
                sQuery += " FROM POSMST..MST_EXCHG_RATE   \n";
                sQuery += " WHERE EXCHG_RATE_REG_DT = CONVERT(VARCHAR(8), DATEADD(DAY, -1, '" + sSaleDate + "'), 112)   \n";
                sQuery += " AND USE_YN              = '" + PosConst.MST_USE_YN.YES + "'  \n";

                sQuery = sQuery.Replace("\t", " ");

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion

        #region 식권 기능키 조회
        /// <summary>
        /// 식권 기능키 조회
        /// </summary>
        /// <param name="sFuncID"></param>
        /// <returns></returns>
        public DataTable SeletMealTicketFuncKey(string sPay_Dc_Grp_Type, string sPay_Dc_Cd)
        {
            try
            {
                // 쿠폰할인 조회

                string sQuery = "";

                sQuery += "  SELECT ";
                sQuery += " 		ROW_NUMBER() OVER( ORDER BY MEAL_TCKT_ID)				SEQ ";
                sQuery += " 	,	CMP_CD                                                  CMP_CD ";
                sQuery += " 	,	STOR_CD                                                 STOR_CD ";
                sQuery += " 	,	'1'														BRAND_CD ";
                sQuery += " 	,	ISNULL(MEAL_TCKT_ID, '')                                MEALTICKET_CD ";
                sQuery += " 	,	ISNULL(MEAL_TCKT_NM, '')                                MEALTICKET_NM ";
                sQuery += " 	,	ISNULL(BLNC_AMT_EXCHNG_CPN_ISSUE_YN, '0')               MEALTICKET_TYPE ";
                sQuery += " 	,	ISNULL(MEAL_TCKT_FACE_AMT, 0)							MEALTICKET_AMOUNT ";
                sQuery += " 	,	'WHITE'                                                 BACKGR_COLOR ";
                sQuery += " 	,	'10'                                                    FONT_SIZE ";
                sQuery += " 	,	'0'                                                     BTN_SIZE ";
                sQuery += " 	,	''                                                      BTN_ITEM_IMG ";
                sQuery += " 	,	ISNULL(CHANGE_PAYMNT_YN, '0')							CHANGE_PAYMNT_YN ";
                sQuery += " 	,	ISNULL(FILLER1, '0')							        NO_INPUT_YN ";
                sQuery += " FROM ";
                sQuery += " 	POSMST..MST_MEAL_TCKT ";
                sQuery += " WHERE ";
                sQuery += " 	CMP_CD			= '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += " AND STOR_CD			= '" + m_cPosStatus.Base.StoreNo + "'";
                sQuery += " AND USE_YN			= '" + PosConst.MST_USE_YN.YES + "'";
                sQuery += " ORDER BY 1";

                sQuery = sQuery.Replace("\t", " ");

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion

        #region 선불카드 판매 기능키 조회
        /// <summary>
        /// 선불카드 판매 기능키 조회
        /// </summary>
        /// <param name="sFuncID"></param>
        /// <returns></returns>
        public DataTable SeletSalePreCardFuncKey(double nAmount)
        {
            try
            {
                // 조회

                string sQuery = "";

                sQuery += "  SELECT \n";
                sQuery += " 		SORT_QUE				                                SEQ  \n";
                sQuery += " 	,	CMP_CD                                                  CMP_CD  \n";
                sQuery += " 	,	STOR_CD                                                 STOR_CD  \n";
                sQuery += " 	,	'1'														BRAND_CD  \n";
                sQuery += " 	,	ISNULL(PRECARD_ID, '')                                  CODE  \n";
                sQuery += " 	,	ISNULL(PRECARD_SHORT_NM, '')                            NAME  \n";
                sQuery += " 	,	ISNULL(PRECARD_AMT, 0)							        AMOUNT  \n";
                sQuery += " 	,	'WHITE'                                                 BACKGR_COLOR  \n";
                sQuery += " 	,	'10'                                                    FONT_SIZE  \n";
                sQuery += " 	,	'0'                                                     BTN_SIZE  \n";
                sQuery += " 	,	''                                                      BTN_ITEM_IMG  \n";
                sQuery += " FROM  \n";
                sQuery += " 	POSMST..MST_PRECARD  \n";
                sQuery += " WHERE  \n";
                sQuery += " 	CMP_CD			= '" + m_cPosStatus.Base.CmpCd + "'  \n";
                sQuery += " AND STOR_CD			= '" + m_cPosStatus.Base.StoreNo + "'  \n";
                sQuery += " AND USE_YN			= '" + PosConst.MST_USE_YN.YES + "'  \n";
                if (nAmount != 0)
                    sQuery += " AND ISNULL(PRECARD_AMT, 0)  = " + nAmount + "  \n";
                sQuery += " ORDER BY SORT_QUE  \n";

                sQuery = sQuery.Replace("\t", " ");

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion

        #region 상품권 기능키 조회
        /// <summary>
        /// 상품권 기능키 조회
        /// </summary>
        /// <param name="sFuncID"></param>
        /// <returns></returns>
        public DataTable SeletGiftFuncKey(string sPay_Dc_Grp_Type, string sPay_Dc_Cd)
        {
            try
            {
                //  조회

                string sQuery = "";

                sQuery += " SELECT \n";
                sQuery += " 		ROW_NUMBER() OVER( ORDER BY SORT_QUE, GIF_CD)	    SEQ \n";
                sQuery += " 	, '" + m_cPosStatus.Base.CmpCd + "'                     CMP_CD \n";
                sQuery += "     , '" + m_cPosStatus.Base.StoreNo + "'                   STOR_CD \n";
                sQuery += "     , ISNULL(GIF_FIX_BRAND_CD, '')                          BRAND_CD \n";
                sQuery += "     , ISNULL(GIF_CD, '')									GIFT_CD \n";
                sQuery += "     , ISNULL(GIF_SHORT_NM, '')	                            GIFT_NM \n";
                sQuery += "     , ISNULL(APPR_SVR_DIV, '0')								APPR_SVR_DIV \n";
                sQuery += "     , ISNULL(APPR_YN, '0')								    APPR_TYPE \n";
                sQuery += "     , ISNULL(HP_ACCUM_YN, '0')								HPPOINT_TYPE \n";
                sQuery += "     , ISNULL(MNDTRY_INPUT_YN, '0')							MNDTRY_INPUT_YN \n";
                sQuery += "     , ISNULL(GIF_AMT, 0)									GIFT_AMT \n";
                sQuery += "     , 'WHITE'												BACKGR_COLOR \n";
                sQuery += "     , '10'													FONT_SIZE \n";
                sQuery += "     , '0'													BTN_SIZE \n";
                sQuery += "     , ISNULL(HPY_GIF_DIV, '0')								HPY_GIF_DIV \n";
                sQuery += "     , (CASE ISNULL(IMG_USE_YN, '0') WHEN '1' THEN ISNULL(IMG_PATH, '') ELSE '' END) BTN_ITEM_IMG \n";
                sQuery += "     , ISNULL(CHANGE_PAYMNT_YN, '0')                         CHANGE_PAYMNT_YN \n";
                sQuery += " FROM POSMST..MST_GIF \n";
                sQuery += " WHERE USE_YN   = '" + PosConst.MST_USE_YN.YES + "' \n";
                sQuery += " ORDER BY ISNULL(APPR_YN, '0') DESC, SORT_QUE ASC, GIF_CD ASC \n";

                sQuery = sQuery.Replace("\t", " ");

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion

        //#15533 상품권(승인) 시 PREFIX 리딩을 통한 승인기능도입 요청 start
        
        #region 상품권 권종 조회
        /// <summary>
        /// 상품권 권종 조회
        /// </summary>
        /// <param name="sGiftCd"></param>
        /// <returns></returns>
        public DataTable SeletGiftCd(string sGiftCd)
        {
            try
            {
                //  조회

                string sQuery = "";

                sQuery += " SELECT \n";
                sQuery += " 		ROW_NUMBER() OVER( ORDER BY SORT_QUE, GIF_CD)	    SEQ \n";
                sQuery += " 	, '" + m_cPosStatus.Base.CmpCd + "'                     CMP_CD \n";
                sQuery += "     , '" + m_cPosStatus.Base.StoreNo + "'                   STOR_CD \n";
                sQuery += "     , ISNULL(GIF_FIX_BRAND_CD, '')                          BRAND_CD \n";
                sQuery += "     , ISNULL(GIF_CD, '')									GIFT_CD \n";
                sQuery += "     , ISNULL(GIF_SHORT_NM, '')	                            GIFT_NM \n";
                sQuery += "     , ISNULL(APPR_SVR_DIV, '0')								APPR_SVR_DIV \n";
                sQuery += "     , ISNULL(APPR_YN, '0')								    APPR_TYPE \n";
                sQuery += "     , ISNULL(HP_ACCUM_YN, '0')								HPPOINT_TYPE \n";
                sQuery += "     , ISNULL(MNDTRY_INPUT_YN, '0')							MNDTRY_INPUT_YN \n";
                sQuery += "     , ISNULL(GIF_AMT, 0)									GIFT_AMT \n";
                sQuery += "     , 'WHITE'												BACKGR_COLOR \n";
                sQuery += "     , '10'													FONT_SIZE \n";
                sQuery += "     , '0'													BTN_SIZE \n";
                sQuery += "     , ISNULL(HPY_GIF_DIV, '0')								HPY_GIF_DIV \n";
                sQuery += "     , (CASE ISNULL(IMG_USE_YN, '0') WHEN '1' THEN ISNULL(IMG_PATH, '') ELSE '' END) BTN_ITEM_IMG \n";
                sQuery += "     , ISNULL(CHANGE_PAYMNT_YN, '0')                         CHANGE_PAYMNT_YN \n";
                sQuery += " FROM POSMST..MST_GIF \n";
                sQuery += " WHERE USE_YN   = '" + PosConst.MST_USE_YN.YES + "' \n";
                sQuery += "   AND GIF_CD   = '" + sGiftCd + "' \n";
                sQuery += " ORDER BY ISNULL(APPR_YN, '0') DESC, SORT_QUE ASC, GIF_CD ASC \n";

                sQuery = sQuery.Replace("\t", " ");

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion 상품권 권종 조회
        
        //#15533 상품권(승인) 시 PREFIX 리딩을 통한 승인기능도입 요청 end

        #region Prefix에 의한 사용 VAN 정보 조회
        /// <summary>
        /// Prefix에 의한 사용 VAN 정보 조회
        /// </summary>
        /// <param name="sPrefixNo"></param>
        /// <returns></returns>
        public DataTable SeletPrefixToPayTypeInfo(string sPrefixNo)
        {
            string sQuery = "";
            try
            {
                if (sPrefixNo.Length == 0) return null;

                // Prefix에 검색하여 결제 수단을 조회 한다.
                sQuery = "";
                sQuery += " SELECT ";
                sQuery += " 		TOP 1 ";
                sQuery += " 		PX.PAY_DC_GRP_TYPE";
                sQuery += " 	,	PX.PAY_DC_CD";
                sQuery += " FROM ";
                sQuery += " 	POSMST..MST_PAY_DC_PRFX					PX";
                sQuery += " WHERE ";
                sQuery += " 	PX.CMP_CD		= '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += " AND PX.PRFX_INFO	IN ( ";
                sQuery += " 							SUBSTRING('" + sPrefixNo.Trim() + "', 1, 3)";
                sQuery += " 						,	SUBSTRING('" + sPrefixNo.Trim() + "', 1, 4)";
                sQuery += " 						,	SUBSTRING('" + sPrefixNo.Trim() + "', 1, 5)";
                sQuery += " 						,	SUBSTRING('" + sPrefixNo.Trim() + "', 1, 6)";
                sQuery += " 						,	SUBSTRING('" + sPrefixNo.Trim() + "', 1, 7)";
                sQuery += " 						,	SUBSTRING('" + sPrefixNo.Trim() + "', 1, 8)";
                sQuery += " 						)";
                sQuery += " AND PX.USE_YN		= '" + PosConst.MST_USE_YN.YES + "'";

                sQuery = sQuery.Replace("\t", " ");

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion

        #region  프로덕트 ID로 상품 조회
        /// <summary>
        ///  프로덕트 ID로 상품 조회
        /// </summary>
        /// <param name="sFuncID"></param>
        /// <returns></returns>
        public DataTable SeletProductIDToItemCD(string sProductID)
        {
            string sQuery = "";
            try
            {
                // 조회
                sQuery += " SELECT \n";
                sQuery += " 		CP.PRODUCT_CD \n";
                sQuery += " 	,	CP.PAY_DC_GRP_TYPE \n";
                sQuery += " 	,	CP.PAY_DC_CD \n";
                sQuery += " 	,	CP.SALE_START_DT \n";
                sQuery += " 	,	CP.SALE_FNSH_DT \n";
                sQuery += " 	,	CP.ITEM_CHECK_YN \n";
                sQuery += " 	,	ISNULL(CP.LMT_QTY, 0)		        LMT_QTY \n";
                sQuery += " 	,	ISNULL(CI.ITEM_CD, '')				ITEM_CD \n";
                sQuery += " 	,	ISNULL(CI.QTY, 0)					QTY \n";
                sQuery += " 	,	ISNULL(CI.DC_AMT, 0)				DC_AMT \n";
                sQuery += " FROM  \n";
                sQuery += " 	POSMST..MST_PAY_DC_CPN					CP \n";
                sQuery += " 	LEFT JOIN POSMST..MST_PAY_DC_CPN_ITEM	CI \n";
                sQuery += " 		ON	CI.CMP_CD				= CP.CMP_CD \n";
                sQuery += " 		AND CI.STOR_CD				= CP.STOR_CD \n";
                sQuery += " 		AND CI.MOBILE_CPN_MNG_NO	= CP.MOBILE_CPN_MNG_NO \n";
                sQuery += " 		AND CI.USE_YN				= '" + PosConst.MST_USE_YN.YES + "'\n";
                sQuery += " WHERE  \n";
                sQuery += " 	CP.CMP_CD		= '" + m_cPosStatus.Base.CmpCd + "'\n";
                sQuery += " AND CP.STOR_CD		= '" + m_cPosStatus.Base.StoreNo + "'\n";
                sQuery += " AND CP.PRODUCT_CD	= '" + sProductID + "'\n";
                sQuery += " AND '" + m_cPosStatus.Base.SaleDate + "' BETWEEN CP.SALE_START_DT AND CP.SALE_FNSH_DT \n";
                sQuery += " AND CP.USE_YN		= '" + PosConst.MST_USE_YN.YES + "'\n";
                sQuery += " ORDER BY CP.MOBILE_CPN_MNG_NO, ISNULL(CI.DC_AMT, 0) desc \n";

                sQuery = sQuery.Replace("\t", " ");

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion

        #region 마스터 기간제휴사 결제할인, 할인상품 마스터 조회
        /// <summary>
        /// 마스터 기간제휴사 결제할인, 할인상품 마스터 조회
        /// </summary>
        /// <param name="sPayDcGrpType"></param>
        /// <param name="sPayDcCd"></param>
        /// <param name="sCmpGradeCd"></param>
        /// <returns></returns>

        //#14231 KT 웰컴기프트 카드 기능 개발, PHJ START
        //기존
        //public DataTable SeletTermCoopCmpPayDc(string sPayDcGrpType, string sPayDcCd, string sCmpGradeCd)
        //변경
        public DataTable SeletTermCoopCmpPayDc(string sPayDcGrpType, string sPayDcCd, string sCmpGradeCd, string sDcApplyTrgt = "")
        //#14231 KT 웰컴기프트 카드 기능 개발, PHJ END
        {
            string sQuery = "";
            try
            {
                sQuery = "";
                sQuery += " SELECT * FROM POSMST..MST_TERM_COOP_CMP_PAY_DC ";
                sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                sQuery += "   AND PAY_DC_GRP_TYPE = '" + sPayDcGrpType + "'";
                sQuery += "   AND PAY_DC_CD = '" + sPayDcCd + "'";
                if (sCmpGradeCd != "")
                    sQuery += "   AND COOP_CMP_GRADE_CD = '" + sCmpGradeCd + "'";

                //#14231 KT 웰컴기프트 카드 기능 개발, PHJ START
                //기존
                //sQuery += "   AND '" + m_cPosStatus.Base.SaleDate + "' BETWEEN START_DT AND FNSH_DT ";
                //변경
                if (sDcApplyTrgt != "")
                {
                    sQuery += "   AND DC_APPLY_TRGT = '" + sDcApplyTrgt + "'";  //할인 대상 (1: 전체, 2:특정상품, 3:웰컴기프트)
                }


                //#14618 KT 더블할인 개발요청 start,phj
                //기존
                //if (sDcApplyTrgt == ItemConst.DC_APPLY_TRGT.DC_WC_GIFT)
                //변경
                if (sDcApplyTrgt == ItemConst.DC_APPLY_TRGT.DC_WC_GIFT || sDcApplyTrgt == ItemConst.DC_APPLY_TRGT.DC_KT_DOUBLE)
                //#14618 KT 더블할인 개발요청 end,phj
                {
                    sQuery += "   AND PAY_DC_METHD = '2'"; // 1: 율, 2: 금액 
                    sQuery += "   AND CONVERT(varchar(30), GETDATE(),112) BETWEEN START_DT AND FNSH_DT ";  //시스템일자
                }
                else
                {
                    sQuery += "   AND '" + m_cPosStatus.Base.SaleDate + "' BETWEEN START_DT AND FNSH_DT ";
                }
                //#14231 KT 웰컴기프트 카드 기능 개발, PHJ END

                //sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }

        /// <summary>
        /// 마스터 기간제휴사 할인상품 마스터 조회
        /// </summary>
        /// <param name="sPayDcGrpType"></param>
        /// <param name="sPayDcCd"></param>
        /// <param name="sCmpGradeCd"></param>
        /// <returns></returns>
        public DataTable SeletTermCoopCmpDcItem(string sPayDcGrpType, string sPayDcCd, string sCmpGradeCd)
        {
            string sQuery = "";
            try
            {
                sQuery = "";
                sQuery += " SELECT * FROM POSMST..MST_TERM_COOP_CMP_DC_ITEM ";
                sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                sQuery += "   AND PAY_DC_GRP_TYPE = '" + sPayDcGrpType + "'";
                sQuery += "   AND PAY_DC_CD = '" + sPayDcCd + "'";
                if (sCmpGradeCd != "")
                    sQuery += "   AND COOP_CMP_GRADE_CD = '" + sCmpGradeCd + "'";
                sQuery += "   AND START_DT <= '" + m_cPosStatus.Base.SaleDate + "'";
                sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion

        //#14231 KT 웰컴기프트 카드 기능 개발, PHJ START
        #region 웰컴 기프트 버튼 활성화 유무
        
        //#14618 KT 더블할인 개발요청 start,phj
        //기존
        //public bool WelcomGiftBtnYN(string sPosMenuKey, double nDestAmt, out string ProductCode)
        //변경
        public bool WelcomGiftBtnYN(string sType, string sPosMenuKey, double nDestAmt, out string ProductCode)
        //#14618 KT 더블할인 개발요청 end,phj
        {
            bool sRet = false;
            ProductCode = "";
            try
            {
                // 웰컴기프트 대상 브랜드는 파리바게트만이기 때문에 이 외 점포는 옵션 미사용으로 해줘야함.
                //if (sPosMenuKey != PosKey.MENU_KEY.KT ||
                if (PosMstManager.GetPosOption(POS_OPTION.OPT332) != "1")
                {
                    return sRet;
                }

                string sPaywayCd = GetMenuKeyToPayWayCd(sPosMenuKey);    // ItemConst.TR_ITEM_ID.MOBILE_COM_POINT;// KTF 결제코드,상세코드
                string sPayDtlCd = GetMenuKeyToPayDtlCd(sPosMenuKey);    // ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KTF;// KTF 결제코드,상세코드

                //#14618 KT 더블할인 개발요청 start,phj
                //기존
                //string sDcApplyTrgt = ItemConst.DC_APPLY_TRGT.DC_WC_GIFT;// 할인 대상 유형 (1: 전체, 2:특정상품, 3:웰컴기프트, 4:KT더블할인)
                //변경
                string sDcApplyTrgt = sType;
                //#14618 KT 더블할인 개발요청 end,phj

                UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                     "KT start !!!  " +
                                     "타입 : " + sType + ", (1:TOT_DC/ 2:ITEM_DC/ 3:WC_DC / 4:DOUBLE_DC)" +
                                     "메뉴키 :" + sPosMenuKey + "," +
                                     "결제코드 :" + sPaywayCd + "," +
                                     "상세코드 :" + sPayDtlCd + "," +
                                     "대상금액 :" + nDestAmt + "," +
                                     "사용유무 :" + PosMstManager.GetPosOption(POS_OPTION.OPT332));



                //제휴사 결제/할인 정보 체크
                DataTable dtPayDcInfo = SeletTermCoopCmpPayDc(sPaywayCd, sPayDtlCd, "", sDcApplyTrgt);

                if (dtPayDcInfo != null && dtPayDcInfo.Rows.Count != 0)
                {
                    DataRow dr = dtPayDcInfo.Rows[0];

                    // 웰컴 기프트 할인 기준 금액
                    //#14231 KT 웰컴기프트 카드 기능 개발, PHJ START, 20180323
                    //금액 상관없이 버튼 활성화 -> 보류
                    
                    if (CmUtil.DoubleParse(CmUtil.GetDataRowStr(dr, PosMst.MST_TERM_COOP_CMP_PAY_DC.DATA.PAY_DC_AMT_STD_PAY_AMT)) > nDestAmt)
                    {
                        UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                             System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                             //"KT 웰컴 기프트 버튼 활성화 여부 end !!! " + sRet.ToString());
                                             "KT end !!!   (" + CmUtil.GetDataRowStr(dr, PosMst.MST_TERM_COOP_CMP_PAY_DC.DATA.PAY_DC_AMT_STD_PAY_AMT) + " > " + nDestAmt.ToString() + ")");
                        return sRet;
                    }
                    
                    //#14231 KT 웰컴기프트 카드 기능 개발, PHJ END, 20180323

                    // 웰컴 기프트의 상품코드(프로덕트코드)는 제휴사 등급 조회 컬럼에 존재한다.
                    string sCOOP_CMP_GRADE_CD = CmUtil.GetDataRowStr(dr, PosMst.MST_TERM_COOP_CMP_PAY_DC.DATA.COOP_CMP_GRADE_CD);
                    // 웰컴 기프트 할인 기준 금액
                    string sPAY_DC_AMT_STD_PAY_AMT = CmUtil.GetDataRowStr(dr, PosMst.MST_TERM_COOP_CMP_PAY_DC.DATA.PAY_DC_AMT_STD_PAY_AMT);
                    // 웰컴 기프트 할인 금액
                    string sPAY_DC_VAL = CmUtil.GetDataRowStr(dr, PosMst.MST_TERM_COOP_CMP_PAY_DC.DATA.PAY_DC_VAL);

                    UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                         System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                         //"KT 웰컴 기프트 ProductID :" + sCOOP_CMP_GRADE_CD + ", 할인 기준 금액 :" + sPAY_DC_AMT_STD_PAY_AMT + ", 할인 금액 :" + sPAY_DC_VAL);
                                         "KT  ProductID :" + sCOOP_CMP_GRADE_CD + ", 할인 기준 금액 :" + sPAY_DC_AMT_STD_PAY_AMT + ", 할인 금액 :" + sPAY_DC_VAL);

                    // 제휴코드에 셋팅한 프로덕트코드 넘김 
                    ProductCode = sCOOP_CMP_GRADE_CD;

                    sRet = true;
                }

                UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                     //"KT 웰컴 기프트 버튼 활성화 여부 end !!! " + sRet.ToString());
                                     "KT end !!! " + sRet.ToString());
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return sRet;
        }
        #endregion
        //#14231 KT 웰컴기프트 카드 기능 개발, PHJ END

        #region 제휴사 결제 할인 금액 계산
        /// <summary>
        /// 제휴사 결제 할인 금액 계산
        /// </summary>
        /// <param name="sPAY_WAY_CD"></param>
        /// <param name="sPAY_DTL_CD_01"></param>
        /// <param name="sCmpGradeCd"></param>
        /// <param name="nSaleAmt"></param>
        /// <returns></returns>
        public double ExecTermCoopCmpPayDc(string sPAY_WAY_CD, string sPAY_DTL_CD_01, string sCmpGradeCd, double nSaleAmt)
        {
            double nDestAmt = 0;

            try
            {
                // 기간 제휴사 결제할인 마스터 조회
                DataTable dtPayDcInfo = SeletTermCoopCmpPayDc(sPAY_WAY_CD, sPAY_DTL_CD_01, sCmpGradeCd);
                if (dtPayDcInfo == null || dtPayDcInfo.Rows.Count == 0)
                {
                    // 기간제휴사 결제할인 마스터가 없으면 결제 할인 마스터 참조 
                    if (PosMstManager.GetMstPayDc(sPAY_WAY_CD, sPAY_DTL_CD_01, PosMst.MST_PAY_DC.DATA.PAY_DC_METHD) == ItemConst.CPI_DC_TYPE.RATE)
                    {
                        nDestAmt = CmUtil.MathAmtPercent(nSaleAmt, CmUtil.DoubleParse(PosMstManager.GetMstPayDc(sPAY_WAY_CD, sPAY_DTL_CD_01, PosMst.MST_PAY_DC.DATA.PAY_DC_VAL)));

                        if (sPAY_WAY_CD == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM) // 적립 포인트 계산(무조건 올림 처리)
                            nDestAmt = CmUtil.MathRounds(nDestAmt, PosConst.MATH_ROUND.CEILING, 0);
                        else
                            nDestAmt = CmUtil.MathRounds(nDestAmt, m_cPosStatus.Mst.DcRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.DcRudDwLoc));
                    }
                    else
                    {
                        nDestAmt = CmUtil.DoubleParse(PosMstManager.GetMstPayDc(sPAY_WAY_CD, sPAY_DTL_CD_01, PosMst.MST_PAY_DC.DATA.PAY_DC_VAL));
                        if (nDestAmt > nSaleAmt) nDestAmt = nSaleAmt;
                    }
                }
                else
                {
                    DataRow dr = dtPayDcInfo.Rows[0];

                    if (CmUtil.GetDataRowStr(dr, PosMst.MST_TERM_COOP_CMP_PAY_DC.DATA.PAY_DC_METHD) == ItemConst.CPI_DC_TYPE.RATE)
                    {
                        nDestAmt = CmUtil.MathAmtPercent(nSaleAmt, CmUtil.GetDataRowDouble(dr, PosMst.MST_TERM_COOP_CMP_PAY_DC.DATA.PAY_DC_VAL));
                        nDestAmt = CmUtil.MathRounds(nDestAmt
                            , CmUtil.GetDataRowStr(dr, PosMst.MST_TERM_COOP_CMP_PAY_DC.DATA.PAY_DC_DEC_PNT_CALC_METHD), CmUtil.GetDataRowInt(dr, PosMst.MST_TERM_COOP_CMP_PAY_DC.DATA.PAY_DC_CALC_DIGT_NO));
                    }
                    else
                    {
                        nDestAmt = CmUtil.GetDataRowDouble(dr, PosMst.MST_TERM_COOP_CMP_PAY_DC.DATA.PAY_DC_VAL);
                        if (nDestAmt > nSaleAmt) nDestAmt = nSaleAmt;
                    }
                }

                //// 해피포인트 적립예정 포인트
                //if (sPAY_WAY_CD == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM && sPAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.ETC_INFO.SAVEPOINT)
                //{
                //    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                //    // 통신사 등록 체크
                //    ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
                //    foreach (Column.TR_PAYMENT.DATA cPayItem in alPayItem)
                //    {
                //        if (cPayItem.CANCEL_DIV != PosConst.CANCEL_DIV.NORMAL) continue;

                //        // 통신사 할인 체크(통신사 가 등록 되어 있으면 기본적립 하지 않음)
                //        if (cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.MOBILE_COM_POINT
                //            && (cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_SKT || cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KTF
                //                || cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_LGT || cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KT_VIP))
                //        {
                //            nDestAmt = 0;
                //            break;
                //        }
                //    }
                //}
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return nDestAmt;
        }
        #endregion

        #region POS IRT 전문 송/수신
        /// <summary>
        /// POS IRT 전문 송/수신(점포서버 송수신: 제이슨 이용)
        /// </summary>
        public string ExecutePosIrt(string sMsgType, string sSvrIP, int nSvrPort, int nTimeout, Hashtable htSendData, ref Hashtable htRecvData)
        {
            return ExecutePosIrt(sMsgType, sSvrIP, nSvrPort, nTimeout, htSendData, ref htRecvData, true);
        }

        public string ExecutePosIrt(string sMsgType, string sSvrIP, int nSvrPort, int nTimeout, Hashtable htSendData, ref Hashtable htRecvData, bool bVisibleMode)
        {
            string sRet = UserCom.RST_ERR;

            try
            {
                // Rhee, 2017.10.23, 포스별 매출 조회기능 추가 Start
                // 기존
                //string sCommHead = ItemColumn.MakeCommHeader(0, sMsgType);        // 통신해더 생성
                // 변경
                string sCommHead = "";
                if ((m_cPosStatus.Base.CmpCd.ToUpper().Equals("PCCN") && htSendData.ContainsKey("POS_NO")) && (m_cPosStatus.Base.PosNo != htSendData[Column.IQ_DATA_SEARCH_REQ.DATA.POS_NO].ToString()) )
                {
                    sCommHead = ItemColumn.MakeCommHeader(0, sMsgType, m_cPosStatus.Base.CmpCd, htSendData[Column.IQ_DATA_SEARCH_REQ.DATA.POS_NO].ToString());        // 통신해더 생성                   
                }
                else
                {
                    sCommHead = ItemColumn.MakeCommHeader(0, sMsgType);             // 통신해더 생성
                }
                // Rhee, 2017.10.23, 포스별 매출 조회기능 추가 End
                

                if (bVisibleMode == false)
                {
                    // 팝업 화면 미표시
                    m_bIRTComplete = true;
                    m_htRecvData = null;

                    Thread thrSecondDisp = new Thread(() => sRet = OnNetworkIRT(sSvrIP, nSvrPort, nTimeout, sCommHead, htSendData));
                    thrSecondDisp.Start();

                    while (m_bIRTComplete == true)
                    {
                        Thread.Sleep(100);
                    }
                    htRecvData = m_htRecvData;
                }
                else
                {
                    string sDispName = string.Format(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0231), "");

                    if (string.IsNullOrEmpty(sDispName) == true) sDispName = "Searching data! Please wait.";

                    m_cfPosIrtMsg.PosMessageStr = sDispName;
                    m_cfPosIrtMsg.ServerIp = sSvrIP;
                    m_cfPosIrtMsg.ServerPort = nSvrPort;
                    m_cfPosIrtMsg.TimeOut = nTimeout;
                    m_cfPosIrtMsg.CommHead = sCommHead;
                    m_cfPosIrtMsg.SendData = htSendData;

                    m_cfPosIrtMsg.ShowDialog();

                    if (m_cfPosIrtMsg.RecvRet != UserCom.OK)
                    {
                        sRet = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0158);
                        // 통신 실패 로그
                        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 + "()",
                            string.Format("SOCKET ERROR,{0},{1}, RET={2}", sSvrIP, nSvrPort, m_cfPosIrtMsg.RecvRet));
                        return sRet;
                    }
                    
                    htRecvData = m_cfPosIrtMsg.RecvData;

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

        #region POS IRT 전문 송/수신 - 외부 VAN
        /// <summary>
        /// POS IRT 전문 송/수신 - 외부 VAN
        /// </summary>
        public string ExecuteExIrt(string sSvrIP, int nSvrPort, int nTimeout, string sSendData, ref string sRecvData, int nRecvDataLen, string sAckData)
        {
            return ExecuteExIrt(sSvrIP, nSvrPort, nTimeout, sSendData, ref sRecvData, nRecvDataLen, sAckData, false);
        }
        public string ExecuteExIrt(string sSvrIP, int nSvrPort, int nTimeout, string sSendData, ref string sRecvData, int nRecvDataLen, string sAckData, bool bErrorSkip)
        {
            string sRet = UserCom.RST_ERR;

            try
            {
                string sDispName = string.Format(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0231), "");

                m_cfExIrtMsg.MessageStr = sDispName;
                m_cfExIrtMsg.ServerIp = sSvrIP;
                m_cfExIrtMsg.ServerPort = nSvrPort;
                m_cfExIrtMsg.TimeOut = nTimeout;
                m_cfExIrtMsg.RecvDataLen = nRecvDataLen;
                m_cfExIrtMsg.AckData = sAckData;
                m_cfExIrtMsg.SendData = sSendData;
                m_cfExIrtMsg.RecvLenFix = true;
                m_cfExIrtMsg.CommByteType = false;
                m_cfExIrtMsg.RecvErrorSkip = bErrorSkip;

                m_cfExIrtMsg.ShowDialog();

                if (m_cfExIrtMsg.RecvRet != UserCom.OK)
                {
                    sRet = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0158);
                    // 통신 실패 로그
                    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 + "()",
                        string.Format("SOCKET ERROR,{0},{1}, RET=", sSvrIP, nSvrPort, m_cfExIrtMsg.RecvRet));
                    return sRet;
                }

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

        #region POS IRT 전문 송/수신 - 외부 VAN
        /// <summary>
        /// POS IRT 전문 송/수신 - 외부 Van (전문 길이 위치 지정)
        /// </summary>
        public string ExecuteLenIrt(string sSvrIP, int nSvrPort, int nTimeout, string sSendData, ref string sRecvData, int nRecvDataLen, int nRecvDataStartPosition)
        {
            return ExecuteLenIrt(sSvrIP, nSvrPort, nTimeout, sSendData, ref sRecvData, true, nRecvDataLen, nRecvDataStartPosition);
        }

        /// <summary>
        /// POS IRT 전문 송/수신 - 외부 Van (헤더 길이 + 전문 길이 위치 지정)
        /// </summary>
        public string ExecuteLenIrt(string sSvrIP, int nSvrPort, int nTimeout, string sSendData, ref string sRecvData, bool bFullSize, int nRecvDataLen, int nRecvDataStartPosition)
        {
            string sRet = UserCom.RST_ERR;

            try
            {
                string sDispName = string.Format(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0231), "");

                //UserLog.WriteLogFile(UserCom.LOG_OP, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                //                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                //                    "@@sDispName=" + sDispName +
                //                    "sSvrIP=" + sSvrIP +
                //                    "nSvrPort=" + nSvrPort +
                //                    "nRecvDataLen=" + nRecvDataLen +
                //                    "nRecvDataStartPosition=" + sDispName +
                //                    "sSendData=" + sSendData
                //                    );                            

                m_cfExIrtMsg.MessageStr = sDispName;
                m_cfExIrtMsg.ServerIp = sSvrIP;
                m_cfExIrtMsg.ServerPort = nSvrPort;
                m_cfExIrtMsg.TimeOut = nTimeout;
                m_cfExIrtMsg.RecvFullSize = bFullSize;
                m_cfExIrtMsg.RecvDataLen = nRecvDataLen;
                m_cfExIrtMsg.RecvDataStartPosition = nRecvDataStartPosition;
                m_cfExIrtMsg.SendData = sSendData;
                m_cfExIrtMsg.CommByteType = false;
                m_cfExIrtMsg.RecvLenFix = false;

                m_cfExIrtMsg.ShowDialog();

                if (m_cfExIrtMsg.RecvRet != UserCom.OK)
                {
                    sRet = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0158);
                    // 통신 실패 로그
                    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 + "()",
                        string.Format("SOCKET ERROR,{0},{1}, RET=", sSvrIP, nSvrPort, m_cfExIrtMsg.RecvRet));
                    return sRet;
                }

                sRecvData = m_cfExIrtMsg.RecvData;
                sRet = UserCom.RST_OK;

                //UserLog.WriteLogFile(UserCom.LOG_OP, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                //                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                //                    "@@sRecvData=" + sRecvData
                //                    );     
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return sRet;
        }
        #endregion

        #region POS IRT 전문 송/수신 - 외부 VAN (Byte 통신)
        /// <summary>
        /// POS IRT 전문 송/수신 -  외부 VAN (Byte 통신)
        /// </summary>
        public string ExecuteByteIrt(string sSvrIP, int nSvrPort, int nTimeout, byte[] bSendData, ref byte[] bRecvData, int nRecvDataLen)
        {
            string sRet = UserCom.RST_ERR;

            try
            {
                string sDispName = string.Format(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0231), "");

                m_cfExIrtMsg.MessageStr = sDispName;
                m_cfExIrtMsg.ServerIp = sSvrIP;
                m_cfExIrtMsg.ServerPort = nSvrPort;
                m_cfExIrtMsg.TimeOut = nTimeout;
                m_cfExIrtMsg.RecvFullSize = false;
                m_cfExIrtMsg.RecvDataLen = nRecvDataLen;
                m_cfExIrtMsg.RecvDataStartPosition = 0;
                m_cfExIrtMsg.SendByteData = bSendData;
                m_cfExIrtMsg.CommByteType = true;
                m_cfExIrtMsg.RecvLenFix = false;

                m_cfExIrtMsg.ShowDialog();

                if (m_cfExIrtMsg.RecvRet != UserCom.OK)
                {
                    sRet = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0158);
                    // 통신 실패 로그
                    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 + "()",
                        string.Format("SOCKET ERROR,{0},{1}, RET=", sSvrIP, nSvrPort, m_cfExIrtMsg.RecvRet));
                    return sRet;
                }

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

        #region POS TCP 전문 송/수신 기타 (Byte 통신)
        /// <summary>
        /// POS TCP 전문 송/수신 기타 (Byte 통신)
        /// </summary>
        public int ExecuteTcpClientIrt(string sFuncName, string sSvrIP, int nSvrPort, int nTimeout, byte[] bytSendData, ref byte[] bytRecvData, int nRecvDataLen)
        {
            try
            {
                m_cTcpClientMsg.MessageStr = string.Format(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0231), "");
                m_cTcpClientMsg.ExecFunction = sFuncName;
                m_cTcpClientMsg.ServerIp = sSvrIP;
                m_cTcpClientMsg.ServerPort = nSvrPort;
                m_cTcpClientMsg.TimeOut = nTimeout;
                m_cTcpClientMsg.SendByteData = bytSendData;
                m_cTcpClientMsg.RecvDataLen = nRecvDataLen;

                // 소캣 송수신 처리
                m_cTcpClientMsg.ShowDialog();

                // 송수신 성공여부 체크
                if (m_cTcpClientMsg.ResultFlag == true)
                {
                    bytRecvData = m_cTcpClientMsg.RecvByteData;

                    return m_cTcpClientMsg.RecvDataLen;
                }
            }
            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 0;
        }
        #endregion

        #region GetMenuKeyToPayCd  결제수단및세부코드 획득
        /// <summary>
        /// 결제수단코드 획득
        /// </summary>
        /// <param name="sPosMenuKey"></param>
        /// <returns></returns>
        public string GetMenuKeyToPayWayCd(string sPosMenuKey)
        {
            string sPayWayCd = "", sPayDtlCd = "";
            try
            {
                GetMenuKeyToPayCd(sPosMenuKey, ref sPayWayCd, ref sPayDtlCd);
            }
            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 sPayWayCd;
        }

        /// <summary>
        /// 결제세부코드 획득
        /// </summary>
        /// <param name="sPosMenuKey"></param>
        /// <returns></returns>
        public string GetMenuKeyToPayDtlCd(string sPosMenuKey)
        {
            string sPayWayCd = "", sPayDtlCd = "";
            try
            {
                GetMenuKeyToPayCd(sPosMenuKey, ref sPayWayCd, ref sPayDtlCd);
            }
            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 sPayDtlCd;
        }

        /// <summary>
        /// 기능키로 결제코드 획득
        /// </summary>
        /// <param name="sPosMenuKey"></param>
        /// <param name="sPayWayCd"></param>
        /// <param name="sPayDtlCd"></param>
        public void GetMenuKeyToPayCd(string sPosMenuKey, ref string sPayWayCd, ref string sPayDtlCd)
        {
            try
            {
                sPayWayCd = ""; sPayDtlCd = "";

                if (sPosMenuKey == PosKey.MENU_KEY.CASH)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.CASH_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.CASH.CASH_PAY;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.CHECK_CASH)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.CHECK_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.CHECK.CHECK_PAY;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.CREDIT_CARD)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.CREDITCARD_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.CREDITCARD.CREDIT_CARD;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.SKT)            // 제휴할인-SKT
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.MOBILE_COM_POINT;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_SKT;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.KT)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.MOBILE_COM_POINT;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KTF;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.LGT)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.MOBILE_COM_POINT;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_LGT;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.OLIBANK)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.MOBILE_COM_POINT;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.MOBILE_COM.OILBANK_POINT;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.BLUE_MEMBERS)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.MOBILE_COM_POINT;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.MOBILE_COM.HBLUE_M_POINT;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.RED_MEMBERS)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.MOBILE_COM_POINT;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.MOBILE_COM.KRED_M_POINT;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.KT_VIP)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.MOBILE_COM_POINT;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KT_VIP;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.KT_DOUBLE)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.MOBILE_COM_POINT;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KT_DOUBLE;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.HAPPY_POINT_USE)        // 포인트사용
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.POINT_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.POINT_USE.HAPPY_POINT;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.OKCASHBACK)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.POINT_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.POINT_USE.OKCASHBACK_POINT;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.SAMSUNG_POINTS)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.POINT_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.POINT_USE.SAMSUNG_POINT;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.HAPPY_POINT_USE_CHINA)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.POINT_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.POINT_USE.HAPPY_POINT_USE_CHINA;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.GIFT_CARD)          // 상품권
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.GIFT_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.GIFT.GIFT_COM;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.ALIPAY)             // 페이-알리페이
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.PAY_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.PAY.ALIPAY_PAY;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.WECHATPAY)          // 페이-위체페이 / 은련페이(Rhee,2017/09/04)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.PAY_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.PAY.WECHAT_PAY;
                }
                //#20170911.001,중국 위쳇 페이, 샤오청쉬 기프트 카드 바이롱과 연동 개발 Start, girak.kim                
                else if (sPosMenuKey == PosKey.MENU_KEY.WECHATPAY_BAIRONG)         
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.PAY_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.PAY.WECHAT_BIORONG_PAY;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.XIAOCHENGXU_GIFTCARD)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.PAY_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.PAY.XIAO_GIFTCARD_PAY;
                }
                //#20170911.001,중국 위쳇 페이, 샤오청쉬 기프트 카드 바이롱과 연동 개발 End, girak.kim

                else if (sPosMenuKey == PosKey.MENU_KEY.SMILE_PAY)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.PAY_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.PAY.SMILE_PAY;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.T_PAY)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.PAY_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.PAY.T_PAY;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.DC_COUPONS)         // 쿠폰
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.COUPON_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.COUPON.NORMAL;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.HAPPY_DC_COUPON)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.COUPON_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.COUPON.INCARD;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.ONLINE_COUPONS)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.COUPON_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.COUPON.ONLINE;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.CAKE_VOUCHERS)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.COUPON_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.COUPON.CAKE_CHANGE;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.T_MONEY)            // 모바일캐시
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.MOBILECASH_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.MOBILECASH.T_MONEY;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.HAPPY_GIFTCARD)     // 선불카드
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.PPCARD_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.PPCARD.HP_GIFT;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.PREPAID_CARDS_HPJOY)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.PPCARD_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.PPCARD.HPPP_CARD;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.MOBILE_COUPON)      // 모바일쿠폰
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.MOBILECON_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.MOBILECON.GIFTCON;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.SPC_EMPLOYEES_PAY)  // 임직원결제
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.EMP_PAY_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.EMP_PAY.SPC;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.SEVERANCE_PAYMENTS)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.EMP_PAY_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.EMP_PAY.SEVERANCE;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.OURHOME)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.EMP_PAY_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.EMP_PAY.OURHOME;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.CREDIT_CUSTOMER)        // 외상
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.CREDIT_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.CREDIT.CREDIT_PAY;
                }
                // Rhee, 2017/09/22 딜리버리 외매(선매) 추가 -- START
                else if (sPosMenuKey == PosKey.MENU_KEY.CREDIT_DELIVERY)        // 외상-딜리버리(외매) 
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.CREDIT_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.CREDIT.CREDIT_PAY_DELIVERY;
                }
                // Rhee, 2017/09/22 딜리버리 외매(선매) 추가 -- END
                else if (sPosMenuKey == PosKey.MENU_KEY.FOREIGN_CURRENCY)       // 외화
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.FOREIGNEX_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.FOREIGNEX.USD;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.RESERVATION)            // 예약
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.RESERVATION_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.RESERVATION.BALANCE_PAY;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.SPC_EMPLOYEE_DC)        // 임직원할인
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.EMP_DC_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.EMP_DC.SPC;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.SAMSUNG_SFC)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.EMP_DC_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.EMP_DC.SAMSUNGCARD;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.SEVERANCE_DC)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.EMP_DC_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.EMP_DC.SEVERANCE;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.SPC_EMPLOYEE_DC_CHINA)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.EMP_DC_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.EMP_DC.SPC_CHINA;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.SPC_EMPLOYEE_DC_PAY)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.EMP_DC_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.EMP_DC.SPC_PAY;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.PAY_INSTOR_DC)      // 임의할인
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.USER_DC_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.USER_DC.IN_EMP_DC;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.PAY_INSTOR_DC_5)    // 입점건물직원할인(5%)(2017.05.25)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.USER_DC_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.USER_DC.IN_EMP_DC_5;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.TOTAL_DC_AMT)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.USER_DC_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.USER_DC.TOTAL_DC_AMT;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.TOTAL_DC_RATE)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.USER_DC_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.USER_DC.TOTAL_DC_RATE;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.TOTAL_ADDDC_AMT)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.USER_DC_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.USER_DC.TOTAL_ADDDC_AMT;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.KAIST_DC)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.USER_DC_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.USER_DC.KAIST_DC;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.ORDER_CALLCENTER)       // 배달(콜센터)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.ORDER_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.ORDER.CALLCENTER_PAY;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.ORDER_BAEMIN)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.ORDER_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.ORDER.BAEMIN_PAY;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.HPORDER_REVDC)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.ORDER_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.ORDER.HPORDER_REVDC;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.HAPPY_POINT)            // 해피포인트
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.ETC_INFO_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.ETC_INFO.SAVEPOINT;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.HAPPY_POINT_SAVE_CHINA)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.ETC_INFO_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.ETC_INFO.POINT_SAVE_CHINA;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.OKCASHBACK_SAVE)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.ETC_INFO_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.ETC_INFO.OCB_SAVE;
                }
                else if (sPosMenuKey == PosKey.MENU_KEY.ONLINE_COUPONS)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.ETC_INFO_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.ETC_INFO.ONLINE_CPN;
                }
                //*** MoonSeokWoo 2017.12.07 Add
                else if (sPosMenuKey == PosKey.MENU_KEY.SHINHANCARD_POINT)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.POINT_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.POINT_USE.SHINHAN_POINT;
                }
                //*** MoonSeokWoo 2017.12.07 Add
                //*** MoonSeokWoo 2017.12.27 Add            
                else if (sPosMenuKey == PosKey.MENU_KEY.HYUNDAI_M_POINTS)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.POINT_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.POINT_USE.HYUNDAI_MPOINTS;
                }
                //*** MoonSeokWoo 2017.12.27 End
                // grayber@20180102 우리모아포인트 추가 start - 기능키 결제코드 분기 추가
                else if (sPosMenuKey == PosKey.MENU_KEY.WOORIMORE_POINTS)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.POINT_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.POINT_USE.WOORIMORE_POINTS;
                }
                // grayber@20180102 우리모아포인트 추가 end

                //grayber@20180208 코레일 마일리지 입력 start - 기능키 결제코드 분기 추가
                else if (sPosMenuKey == PosKey.MENU_KEY.KORAIL_MILEAGE)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.POINT_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.POINT_USE.KORAIL_MILEAGE;
                }
                //grayber@20180208 코레일 마일리지 입력 end

                //#20180413 웰컴카드 신규기능 추가 start,phj
                else if (sPosMenuKey == PosKey.MENU_KEY.WELCOMECARD_DC)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.MOBILE_COM_POINT;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.MOBILE_COM.WELCOMECARD;
                }
                //#20180413 웰컴카드 신규기능 추가 end,phj

                //#20180625 해피기프트(신) 결제/할인 수단 마스터 중복 체크 기능 추가 start
                /*
                else if (sPosMenuKey == PosKey.MENU_KEY.HPGIFTCARD)
                {
                    sPayWayCd = ItemConst.TR_ITEM_ID.PPCARD_ITEM;
                    sPayDtlCd = ItemConst.TR_ITEM_ID.PPCARD.HPGIFT_CARD;
                }
                */
                //#20180625 해피기프트(신) 결제/할인 수단 마스터 중복 체크 기능 추가 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);
            }
        }

        #endregion

        #region 결제수단코드로 POS메뉴키 획득
        /// <summary>
        /// 결제수단코드로 POS메뉴키 획득
        /// </summary>
        /// <param name="sPayWayCd"></param>
        /// <param name="sPayDtlCd"></param>
        /// <returns></returns>
        public string GetPayCdToMenuKey(string sPayWayCd, string sPayDtlCd)
        {
            try
            {
                if (sPayWayCd == ItemConst.TR_ITEM_ID.CASH_ITEM)
                    return PosKey.MENU_KEY.CASH;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.CHECK_ITEM)
                    return PosKey.MENU_KEY.CHECK_CASH;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.CREDITCARD_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.CREDITCARD.CREDIT_CARD)
                    return PosKey.MENU_KEY.CREDIT_CARD;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.MOBILE_COM_POINT && sPayDtlCd == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_SKT)
                    return PosKey.MENU_KEY.SKT;                         // 제휴할인-SKT
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.MOBILE_COM_POINT && sPayDtlCd == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KTF)
                    return PosKey.MENU_KEY.KT;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.MOBILE_COM_POINT && sPayDtlCd == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_LGT)
                    return PosKey.MENU_KEY.LGT;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.MOBILE_COM_POINT && sPayDtlCd == ItemConst.TR_ITEM_ID.MOBILE_COM.OILBANK_POINT)
                    return PosKey.MENU_KEY.OLIBANK;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.MOBILE_COM_POINT && sPayDtlCd == ItemConst.TR_ITEM_ID.MOBILE_COM.HBLUE_M_POINT)
                    return PosKey.MENU_KEY.BLUE_MEMBERS;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.MOBILE_COM_POINT && sPayDtlCd == ItemConst.TR_ITEM_ID.MOBILE_COM.KRED_M_POINT)
                    return PosKey.MENU_KEY.RED_MEMBERS;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.MOBILE_COM_POINT && sPayDtlCd == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KT_VIP)
                    return PosKey.MENU_KEY.KT_VIP;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.MOBILE_COM_POINT && sPayDtlCd == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KT_DOUBLE)
                    return PosKey.MENU_KEY.KT_VIP;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.POINT_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.POINT_USE.HAPPY_POINT)
                    return PosKey.MENU_KEY.HAPPY_POINT_USE;             // 포인트사용
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.POINT_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.POINT_USE.OKCASHBACK_POINT)
                    return PosKey.MENU_KEY.OKCASHBACK;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.POINT_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.POINT_USE.SAMSUNG_POINT)
                    return PosKey.MENU_KEY.SAMSUNG_POINTS;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.POINT_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.POINT_USE.HAPPY_POINT_USE_CHINA)
                    return PosKey.MENU_KEY.HAPPY_POINT_USE_CHINA;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.GIFT_ITEM)
                    return PosKey.MENU_KEY.GIFT_CARD;                   // 상품권
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.PAY_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.PAY.ALIPAY_PAY)    //페이
                {
                    if (m_cPosStatus.Mst.CntryDiv == ItemConst.CNTRY_DIV.KR)
                        return PosKey.MENU_KEY.ALIPAY;                      // 알리페이
                    else
                        return PosKey.MENU_KEY.WECHATPAY;                   // 위쳇페이
                }
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.PAY_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.PAY.WECHAT_PAY)
                    return PosKey.MENU_KEY.WECHATPAY;
                // #Rhee, 20170922 중국 은련페이 추가 start
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.PAY_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.PAY.UNION_PAY)
                    return PosKey.MENU_KEY.WECHATPAY;                                                                       // 위쳇페이와 동일화면 사용
                // #Rhee, 20170922 중국 은련페이 추가 end
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.PAY_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.PAY.SMILE_PAY)
                    return PosKey.MENU_KEY.SMILE_PAY;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.PAY_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.PAY.T_PAY)
                    return PosKey.MENU_KEY.T_PAY;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.COUPON_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.COUPON.NORMAL)
                    return PosKey.MENU_KEY.DC_COUPONS;                  // 쿠폰
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.COUPON_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.COUPON.INCARD)
                    return PosKey.MENU_KEY.HAPPY_DC_COUPON;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.COUPON_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.COUPON.ONLINE)
                    return PosKey.MENU_KEY.ONLINE_COUPONS;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.COUPON_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.COUPON.CAKE_CHANGE)
                    return PosKey.MENU_KEY.CAKE_VOUCHERS;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.MOBILECASH_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.MOBILECASH.T_MONEY)
                    return PosKey.MENU_KEY.T_MONEY;                     // 모바일캐시
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.MOBILECASH_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.MOBILECASH.CASHBEE)
                    return PosKey.MENU_KEY.CASHBEE;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.PPCARD_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.PPCARD.HP_GIFT)
                    return PosKey.MENU_KEY.HAPPY_GIFTCARD;              // 선불카드
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.PPCARD_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.PPCARD.HPPP_CARD)
                    return PosKey.MENU_KEY.PREPAID_CARDS_HPJOY;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.MOBILECON_ITEM)
                    return PosKey.MENU_KEY.MOBILE_COUPON;               // 모바일쿠폰
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.EMP_PAY_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.EMP_PAY.SPC)
                    return PosKey.MENU_KEY.SPC_EMPLOYEES_PAY;           //  임직원결제
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.EMP_PAY_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.EMP_PAY.SEVERANCE)
                    return PosKey.MENU_KEY.SEVERANCE_PAYMENTS;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.EMP_PAY_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.EMP_PAY.OURHOME)
                    return PosKey.MENU_KEY.OURHOME;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.CREDIT_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.CREDIT.CREDIT_PAY)
                    return PosKey.MENU_KEY.CREDIT_CUSTOMER;             // 외상
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.FOREIGNEX_ITEM)
                    return PosKey.MENU_KEY.FOREIGN_CURRENCY;            // 외화
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.RESERVATION_ITEM)
                    return PosKey.MENU_KEY.RESERVATION;                 // 예약
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.EMP_DC_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.EMP_DC.SPC)
                    return PosKey.MENU_KEY.SPC_EMPLOYEE_DC;             //  임직원할인
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.EMP_DC_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.EMP_DC.SAMSUNGCARD)
                    return PosKey.MENU_KEY.SAMSUNG_SFC;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.EMP_DC_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.EMP_DC.SEVERANCE)
                    return PosKey.MENU_KEY.SEVERANCE_DC;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.EMP_DC_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.EMP_DC.SPC_CHINA)
                    return PosKey.MENU_KEY.SPC_EMPLOYEE_DC_CHINA;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.EMP_DC_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.EMP_DC.SPC_PAY)
                    return PosKey.MENU_KEY.SPC_EMPLOYEE_DC_PAY;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.USER_DC_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.USER_DC.IN_EMP_DC)
                    return PosKey.MENU_KEY.PAY_INSTOR_DC;               // 임의할인
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.USER_DC_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.USER_DC.IN_EMP_DC_5)
                    return PosKey.MENU_KEY.PAY_INSTOR_DC_5;             // 입점매장직원할인5(2017.05.25)
                //#20180110 전체금액할인 & 전체%할인 통합 Start
                // 기존
                //else if (sPayWayCd == ItemConst.TR_ITEM_ID.USER_DC_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.USER_DC.TOTAL_DC_AMT)
                //    return PosKey.MENU_KEY.TOTAL_DC_AMT;
                //else if (sPayWayCd == ItemConst.TR_ITEM_ID.USER_DC_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.USER_DC.TOTAL_DC_RATE)
                //    return PosKey.MENU_KEY.TOTAL_DC_RATE;
               
                //#20180227 전체금액할인 & 전체%할인 통합 국내만 적용되도록 수정 Start
                // 변경
                //else if ((sPayWayCd == ItemConst.TR_ITEM_ID.USER_DC_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.USER_DC.TOTAL_DC_AMT) ||
                //         (sPayWayCd == ItemConst.TR_ITEM_ID.USER_DC_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.USER_DC.TOTAL_DC_RATE))
                //    return PosKey.MENU_KEY.TOTAL_DC_RATE;

                else if ((sPayWayCd == ItemConst.TR_ITEM_ID.USER_DC_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.USER_DC.TOTAL_DC_RATE) ||
                         (sPayWayCd == ItemConst.TR_ITEM_ID.USER_DC_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.USER_DC.TOTAL_DC_AMT && m_cPosStatus.Mst.CntryDiv == ItemConst.CNTRY_DIV.KR))
                    return PosKey.MENU_KEY.TOTAL_DC_RATE;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.USER_DC_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.USER_DC.TOTAL_DC_AMT && m_cPosStatus.Mst.CntryDiv != ItemConst.CNTRY_DIV.KR)
                    return PosKey.MENU_KEY.TOTAL_DC_AMT;
                //#20180227 전체금액할인 & 전체%할인 통합 국내만 적용되도록 수정 End
                //#20180110 전체금액할인 & 전체%할인 통합 End
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.USER_DC_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.USER_DC.TOTAL_ADDDC_AMT)
                    return PosKey.MENU_KEY.TOTAL_ADDDC_AMT;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.ORDER_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.ORDER.CALLCENTER_PAY)
                    return PosKey.MENU_KEY.ORDER_CALLCENTER;            //배달(콜센터)
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.ORDER_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.ORDER.BAEMIN_PAY)
                    return PosKey.MENU_KEY.ORDER_BAEMIN;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.ETC_INFO.SAVEPOINT)
                    return PosKey.MENU_KEY.HAPPY_POINT;                 // 해피포인트
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.ETC_INFO.POINT_SAVE_CHINA)
                    return PosKey.MENU_KEY.HAPPY_POINT_SAVE_CHINA;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.ETC_INFO.OCB_SAVE)
                    return PosKey.MENU_KEY.OKCASHBACK_SAVE;
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.ETC_INFO.ONLINE_CPN)
                    return PosKey.MENU_KEY.ONLINE_COUPONS;
                //*** MoonSeokWoo 2017.12.07 Add 
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.POINT_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.POINT_USE.SHINHAN_POINT)
                    return PosKey.MENU_KEY.SHINHANCARD_POINT;
                //*** MoonSeokWoo 2017.12.07 Add 
                //*** MoonSeokWoo 2017.12.27 Add 
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.POINT_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.POINT_USE.HYUNDAI_MPOINTS)
                    return PosKey.MENU_KEY.HYUNDAI_M_POINTS;
                //*** MoonSeokWoo 2017.12.27 Add 
                // grayber@20180102 우리모아포인트 추가 start - POS메뉴키 획득 분기 추가
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.POINT_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.POINT_USE.WOORIMORE_POINTS)
                    return PosKey.MENU_KEY.WOORIMORE_POINTS;
                // grayber@20180102 우리모아포인트 추가 end
                //grayber@20180208 코레일 마일리지 입력 start - POS 메뉴ㅣ 획득 분기 추가
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.POINT_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.POINT_USE.KORAIL_MILEAGE)
                    return PosKey.MENU_KEY.KORAIL_MILEAGE;
                //grayber@20180208 코레일 마일리지 입력 end

                //#20180413 웰컴카드 신규기능 추가 start,phj
                else if (sPayWayCd == ItemConst.TR_ITEM_ID.MOBILE_COM_POINT && sPayDtlCd == ItemConst.TR_ITEM_ID.MOBILE_COM.WELCOMECARD)
                    return PosKey.MENU_KEY.WELCOMECARD_DC;
                //#20180413 웰컴카드 신규기능 추가 end,phj
            }
            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  PayDcDuplicationCheck 결제할인 마스터에서 결제할인 중복 가능여부 체크
        /// <summary>
        /// 결제할인 마스터에서 결제할인 중복 가능여부 체크
        /// </summary>
        /// <param name="sPosMenuKey"></param>
        /// <returns></returns>
        public bool PayDcDuplicationCheck(string sPosMenuKey)
        {
            bool bRet = true;
            try
            {
                string sPayWayCd = GetMenuKeyToPayWayCd(sPosMenuKey);
                string sPayDtlCd = GetMenuKeyToPayDtlCd(sPosMenuKey);
                if (sPayWayCd == "" || sPayDtlCd == "")
                {
                    //#20180309 제휴할인(통합) 사용시 에러 로그 생성 되는 부분 수정 start
                    //제휴할인(통합)은 결제할인코드가 없기 때문에 예외조건에 추가
                    //기존
                    /*
                    if (sPosMenuKey != PosKey.MENU_KEY.PAY_OTHER_DC && sPosMenuKey != PosKey.MENU_KEY.OTHER_PAYMENTS)
                    {
                        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 + "()", "Not Find MenuKey = " + sPosMenuKey);
                    }
                    */
                    //변경

                    //#20180626 해피포인트 기본 적립제외 사용시 에러 로그 생성되는 부분 수정 start
                    //해피포인트 기본 적립제외는 결제할인코드가 없기 때문에 예외조건에 추가
                    //기존
                    /*
                    if (sPosMenuKey != PosKey.MENU_KEY.PAY_OTHER_DC && sPosMenuKey != PosKey.MENU_KEY.OTHER_PAYMENTS && sPosMenuKey != PosKey.MENU_KEY.MOBILE_UNITY)
                    {
                        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 + "()", "Not Find MenuKey = " + sPosMenuKey);
                    }
                    */
                    //변경
                    if (sPosMenuKey != PosKey.MENU_KEY.PAY_OTHER_DC && 
                        sPosMenuKey != PosKey.MENU_KEY.OTHER_PAYMENTS && 
                        sPosMenuKey != PosKey.MENU_KEY.MOBILE_UNITY &&
                        sPosMenuKey != PosKey.MENU_KEY.HAPPY_SAVE_EXCLUDE)
                    {
                        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 + "()", "Not Find MenuKey = " + sPosMenuKey);
                    }
                    //#20180626 해피포인트 기본 적립제외 사용시 에러 로그 생성되는 부분 수정 end

                    //#20180309 제휴할인(통합) 사용시 에러 로그 생성 되는 부분 수정 end

                    return true;
                }
                return PayDcDuplicationCheck(sPayWayCd, sPayDtlCd, 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 bRet;
        }
        /// <summary>
        /// 결제할인 마스터에서 결제할인 중복 가능여부 체크
        /// </summary>
        /// <returns></returns>
        public bool PayDcDuplicationCheck(string sPayWayCd, string sPayDtlCd, bool bShowMsg)
        {
            bool bRet = true;

            try
            {
                ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///// 결제할인 마스터 중복 가능여부 체크
                ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                string sCpiDupYn = PosMstManager.GetMstPayDc(sPayWayCd, sPayDtlCd, PosMst.MST_PAY_DC.DATA.CPI_DUP_YN);                  // 캠페인 중복여부(0:불가, 1:가능)
                string sDcTelecomDupYn = PosMstManager.GetMstPayDc(sPayWayCd, sPayDtlCd, PosMst.MST_PAY_DC.DATA.DC_TELECOM_DUP_YN);     // 할인통신사 중복여부(0:불가, 1:가능)
                string sDcPointDupYn = PosMstManager.GetMstPayDc(sPayWayCd, sPayDtlCd, PosMst.MST_PAY_DC.DATA.DC_POINT_DUP_YN);         // 할인포인트 중복여부(0:불가, 1:가능)
                string sDcCpnDupYn = PosMstManager.GetMstPayDc(sPayWayCd, sPayDtlCd, PosMst.MST_PAY_DC.DATA.DC_CPN_DUP_YN);             // 할인쿠폰 중복여부(0:불가, 1:가능)
                string sDcEmpDcDupYn = PosMstManager.GetMstPayDc(sPayWayCd, sPayDtlCd, PosMst.MST_PAY_DC.DATA.DC_EMP_DC_DUP_YN);        // 할인직원할인 중복여부(0:불가, 1:가능)
                string sDcGnrlDupYn = PosMstManager.GetMstPayDc(sPayWayCd, sPayDtlCd, PosMst.MST_PAY_DC.DATA.DC_GNRL_DUP_YN);           // 할인일반 중복여부(0:불가, 1:가능)
                string sPayGnrlDupYn = PosMstManager.GetMstPayDc(sPayWayCd, sPayDtlCd, PosMst.MST_PAY_DC.DATA.PAY_GNRL_DUP_YN);         // 결제일반 중복여부(0:불가, 1:가능)
                string sPayMovileDupYn = PosMstManager.GetMstPayDc(sPayWayCd, sPayDtlCd, PosMst.MST_PAY_DC.DATA.PAY_MOBILE_DUP_YN);     // 결제모바일 중복여부(0:불가, 1:가능)
                string sPayPointDupYn = PosMstManager.GetMstPayDc(sPayWayCd, sPayDtlCd, PosMst.MST_PAY_DC.DATA.PAY_POINT_DUP_YN);       // 결제포인트 중복여부(0:불가, 1:가능)

                ArrayList alTrPluItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM);                   // 상품 아이템
                foreach (Column.TR_PLU.DATA cSaleItem in alTrPluItem)
                {
                    if (cSaleItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cSaleItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue;    // 지정취소
                    if (cSaleItem.BILLSPR_NO != m_cTrnStatus.Sale.BillSplitNo) continue;                                                            // 빌분리번호

                    // 캠페인 할인 체크
                    if (sCpiDupYn == "0" && cSaleItem.CPI_DC_AMT > 0)
                    {
                        if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0192);    // 캠페인 할인이 등록되어 있습니다. 중복 불가 합니다
                        return false;
                    }
                    // 할인 통신사 체크
                    if (sDcTelecomDupYn == "0" && cSaleItem.COOP_CARD_DC_AMT > 0)
                    {
                        if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0193);    // 통신사 할인이 등록되어 있습니다. 중복 불가 합니다
                        return false;
                    }
                    // 할인 포인트 체크
                    if (sDcPointDupYn == "0" && cSaleItem.POINT_DC_AMT > 0)
                    {
                        if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0194);    // 포인트 할인이 등록되어 있습니다. 중복 불가 합니다
                        return false;
                    }
                    // 할인 쿠폰 체크
                    if (sDcCpnDupYn == "0" && cSaleItem.CPN_DC_AMT > 0)
                    {
                        if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0195);    // 쿠폰 할인이 등록되어 있습니다. 중복 불가 합니다
                        return false;
                    }
                    // 할인 직원할인 체크
                    if (sDcEmpDcDupYn == "0" && cSaleItem.EMP_DC_AMT > 0)
                    {
                        if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0196);    // 직원 할인이 등록되어 있습니다. 중복 불가 합니다
                        return false;
                    }
                    // 할인 일반 체크
                    if (sDcGnrlDupYn == "0" && (cSaleItem.ITEM_DC_AMT > 0 || cSaleItem.SUM_DC_AMT > 0 || cSaleItem.SET_DC_AMT > 0))
                    {
                        if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0197);    // 일반 할인이 등록되어 있습니다. 중복 불가 합니다
                        return false;
                    }
                }

                ArrayList alTrPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);       // 결제아이템
                foreach (Column.TR_PAYMENT.DATA cPayItem in alTrPayItem)
                {
                    if (cPayItem.CANCEL_DIV == ItemConst.PAY_CANCEL_DIV.CANCEL) continue;

                    if (cPayItem.PAY_DTL_CD_05 == PosConst.PAY_DC_TYPE.PAY)            // 할인결제구분 (1:결제, 2:할인)
                    {
                        // 결제일반 체크
                        if (sPayGnrlDupYn == "0" && cPayItem.PAY_WAY_CD != ItemConst.TR_ITEM_ID.MOBILECON_ITEM && cPayItem.PAY_WAY_CD != ItemConst.TR_ITEM_ID.POINT_ITEM)
                        {
                            if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0198);    // 이미 결제가 등록되어 있습니다. 중복 불가 합니다
                            return false;
                        }
                        // 결제모바일 체크
                        if (sPayMovileDupYn == "0" && cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.MOBILECON_ITEM)
                        {
                            if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0199);    // 모바일 결제가 등록되어 있습니다. 중복 불가 합니다
                            return false;
                        }
                        // 결제포인트 체크
                        if (sPayPointDupYn == "0" && cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.POINT_ITEM)
                        {
                            if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0200);    // 포인트 결제가 등록되어 있습니다. 중복 불가 합니다
                            return false;
                        }
                    }

                    // 할인 통신사 체크
                    if (sDcTelecomDupYn == "0" && cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.MOBILE_COM_POINT
                        && (cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_SKT || cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KTF
                            //#20180413 웰컴카드 신규기능 추가 start,phj
                            || cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.WELCOMECARD
                            //#20180413 웰컴카드 신규기능 추가 end,phj
                            || cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_LGT
                            || cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KT_VIP || cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KT_DOUBLE))
                    {
                        if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0193);    // 통신사 할인이 등록되어 있습니다. 중복 불가 합니다
                        return false;
                    }
                    // 할인 포인트 체크
                    if (sDcPointDupYn == "0" && cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.MOBILE_COM_POINT
                        && (cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.OILBANK_POINT || cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.HBLUE_M_POINT
                            || cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.KRED_M_POINT))
                    {
                        if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0194);    // 포인트 할인이 등록되어 있습니다. 중복 불가 합니다
                        return false;
                    }
                    // 할인 쿠폰 체크
                    if (sDcCpnDupYn == "0" && cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.COUPON_ITEM)
                    {
                        if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0195);    // 쿠폰 할인이 등록되어 있습니다. 중복 불가 합니다
                        return false;
                    }
                    // 할인 직원할인 체크
                    if (sDcEmpDcDupYn == "0" && cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.EMP_DC_ITEM)
                    {
                        if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0196);    // 직원 할인이 등록되어 있습니다. 중복 불가 합니다
                        return false;
                    }

                    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    ///// 결제할인 중복 가능여부 체크 - 마스터 참고 불가 항목
                    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    // 제휴 할인은 중복 등록 안됨
                    if (sPayWayCd == ItemConst.TR_ITEM_ID.MOBILE_COM_POINT && cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.MOBILE_COM_POINT)
                    {
                        // 할인 통신사 체크
                        if (cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_SKT || cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KTF
                            || cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_LGT
                            //#20180413 웰컴카드 신규기능 추가 start,phj
                            || cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.WELCOMECARD 
                            //#20180413 웰컴카드 신규기능 추가 end,phj
                            || cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KT_VIP || cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KT_DOUBLE)
                        {
                            if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0193);    // 통신사 할인이 등록되어 있습니다. 중복 불가 합니다
                            return false;
                        }
                        // 할인 포인트 체크
                        if (cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.OILBANK_POINT ||
                            cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.HBLUE_M_POINT || 
                            cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.KRED_M_POINT)
                        {
                            if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0194);    // 포인트 할인이 등록되어 있습니다. 중복 불가 합니다
                            return false;
                        }
                    }

                    // 임직원 할인은 중복 등록 안됨
                    if (sPayWayCd == ItemConst.TR_ITEM_ID.EMP_DC_ITEM && cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.EMP_DC_ITEM)
                    {
                        if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0196);      // 직원 할인이 등록되어 있습니다. 중복 불가 합니다
                        return false;
                    }

                    //// 해피포인트 적립은 통신사 할인이 있으면 등록 안됨(SKT 제외)
                    //if (sPayWayCd == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.ETC_INFO.SAVEPOINT)
                    //{
                    //    if (cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.MOBILE_COM_POINT && ( cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KTF
                    //                                                                       || cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_LGT || cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KT_VIP))
                    //    {
                    //        if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0193);    // 통신사 할인이 등록되어 있습니다. 중복 불가 합니다
                    //        return false;
                    //    }
                    //}
                }

                ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                ///// 결제할인 중복 가능여부 체크 - 마스터 참고 불가 항목
                ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // 해피포인트 카드 등록 여부 체크
                bool bHappyPointExist = false;
                ArrayList alEtcItem = (ArrayList)StateObject.GetItemObject(Column.TR_ETC.ITEM);     // 기타 내역 받아 오기
                foreach (Column.TR_ETC.DATA cEtcItem in alEtcItem)
                {
                    if (cEtcItem.CANCEL_DIV == ItemConst.PAY_CANCEL_DIV.CANCEL) continue;

                    if (cEtcItem.ETC_WAY_CD == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM && cEtcItem.ETC_DTL_CD_01 == ItemConst.TR_ITEM_ID.ETC_INFO.SAVEPOINT)
                    {
                        bHappyPointExist = true;
                        break;
                    }
                }

                //// 통신사 할인은 해피포인트 적립 있으면 등록 안됨(SKT 제외)
                //if (bHappyPointExist == true && sPayWayCd == ItemConst.TR_ITEM_ID.MOBILE_COM_POINT && (sPayDtlCd == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KTF
                //                                                        || sPayDtlCd == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_LGT || sPayDtlCd == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KT_VIP))
                //{
                //    if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0201);      // 해피포인트가 등록되어 있습니다. 중복 불가 합니다
                //    return false;
                //}
                // 해피포인트 적립은 중복 등록 안됨
                if (bHappyPointExist == true && sPayWayCd == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM && sPayDtlCd == ItemConst.TR_ITEM_ID.ETC_INFO.SAVEPOINT)
                {
                    if (bShowMsg == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0201);      // 해피포인트가 등록되어 있습니다. 중복 불가 합니다
                }

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

        #region 제휴사(통신사) VIP증정 대상 상품 체크
        /// <summary>
        /// 제휴사(통신사) VIP증정 대상 상품 체크
        /// </summary>
        /// <param name="sPAY_WAY_CD"></param>
        /// <param name="sPAY_DTL_CD_01"></param>
        /// <param name="sCmpGradeCd"></param>
        /// <returns></returns>
        public double SrarchTermCoopCmpDcItem(string sPAY_WAY_CD, string sPAY_DTL_CD_01, string sCmpGradeCd)
        {
            int nSelRow = -1;
            return SrarchTermCoopCmpDcItem(sPAY_WAY_CD, sPAY_DTL_CD_01, sCmpGradeCd, ref nSelRow);
        }
        public double SrarchTermCoopCmpDcItem(string sPAY_WAY_CD, string sPAY_DTL_CD_01, string sCmpGradeCd, ref int nSelRow)
        {
            double nSalePrice = 0;    // 대상 상품단가

            try
            {
                nSelRow = -1;

                // 제휴사 할인상품 마스터 조회
                DataTable dtDcItem = SeletTermCoopCmpDcItem(sPAY_WAY_CD, sPAY_DTL_CD_01, sCmpGradeCd);
                if (dtDcItem == null || dtDcItem.Rows.Count == 0)
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()"
                        , "No Rows PayCd=" + sPAY_WAY_CD + ", PayDtlCd =" + sPAY_DTL_CD_01);
                    //WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0151);
                    return 0;
                }

                // KT VIP 상품은 최고가 기준으로 체크
                ArrayList alSaleItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM);
                for (int i = 0; i < alSaleItem.Count; i++)
                {
                    Column.TR_PLU.DATA cPluItem = (Column.TR_PLU.DATA)alSaleItem[i];

                    if (cPluItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cPluItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue;      // 지정취소
                    if (cPluItem.ITEM_DIV != ItemConst.PLU_ITEM_DIV.NORMAL && cPluItem.ITEM_DIV != ItemConst.PLU_ITEM_DIV.SET_MAIN) continue;       // 일반상품

                    foreach (DataRow dr in dtDcItem.Rows)
                    {
                        if (CmUtil.GetDataRowStr(dr, PosMst.MST_TERM_COOP_CMP_DC_ITEM.DATA.ITEM_CD) == cPluItem.ITEM_PLU_CD)
                        {
                            double nSalePrc = cPluItem.SALE_PRC;    // 상품단가
                            if (nSalePrc > cPluItem.BILL_AMT) nSalePrc = cPluItem.BILL_AMT;

                            if (nSalePrc > nSalePrice)
                            {
                                nSalePrice = nSalePrc;
                                nSelRow = i;  
                            }
                        }
                    }
                }

                //if (nSalePrice == 0)
                //{
                //    WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0154);
                //    return nSalePrice;
                //}
            }
            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 nSalePrice;
        }
        #endregion

        #region POS IRT 전문 송수신 - 화면 미표시용
        private string OnNetworkIRT(string sServerIp, int nServerPort, int nTimeOut, string sCommHead, Hashtable htSendData)
        {
            string sRet = UserCom.RST_ERR;
            int nRecvRet = -1;
            try
            {
                m_bIRTComplete = true;

                if (m_cNetService == null) m_cNetJSONService = (INetworkJSON)sManager.InitServiceInstance(ServiceLists.AGENT_NETWORK.DLL, ServiceLists.AGENT_NETWORK.NETWORK_IRT);
                nRecvRet = m_cNetJSONService.IRTSendReceive(sServerIp, nServerPort, nTimeOut, sCommHead, htSendData, ref m_htRecvData);

                if (nRecvRet == BaseCom.OK) sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                    "Process Exception !!! " + ex.Message);
            }
            finally
            {
                m_bIRTComplete = false;
            }
            return sRet;
        }
        #endregion

        #region 공통승인로그
        /// <summary>
        /// 공통 승인 로그 DB 저장
        /// </summary>
        /// <param name="결제정보"></param>
        /// <param name="([0]결제수단, [1]결제상세코드, [2]전문구분, [3]요청구분, [4]카드번호, [5]결제금액, [6]승인번호, [7]승인일자, [8]승인시간, [9]응답상태값, [10]응답메시지, [11]전문, [12]입력구분, [13]추후적립여부, [14]적립구분, [15] skt할인상품코드, [16]고객번호)"></param>
        public string SetSaleApprLog(string sTradeDiv, string[] aParm)
        {
            string sRet = UserCom.RST_ERR;
            string sQuery = "";

            double[] nAMT_ENTRY = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            string[] sOCCUR_ENTRY = new string[] { "", "", "", "", "", "", "", "", "" };

            int nNowPos = 0;
            string sHP_ADD_INFO = "";
            string[] aIrtRsp = null;

            string sSaleDate = "";
            string sSaleTime = "";

            try
            {
                #region 승인일자 및 승인시간 체크
                sSaleDate = aParm[7].Trim();
                sSaleTime = aParm[8].Trim();

                if (aParm[7].Trim() == "")
                    sSaleDate = DateTime.Now.ToString("yyyyMMdd");
                if (aParm[7].Trim().Length == 6)
                    sSaleDate = CmUtil.MidH(DateTime.Now.ToString("yyyyMMdd"), 0, 2) + aParm[7].Trim();
                if (aParm[8].Trim() == "")
                    sSaleTime = DateTime.Now.ToString("HHmmss");
                #endregion

                #region 해피포인트 별도 처리
                if (aParm[3].Trim() == "R")
                {
                    // 응답인 경우만 체크
                    if (
                        (aParm[0].Trim() == "04" && aParm[1].Trim() == "00")            // 해피포인트 사용
                        //||
                        //(aParm[0].Trim() == "04" && aParm[1].Trim() == "04")            // 해피포인트 사용 (중국)
                        ||
                        (aParm[0].Trim() == "80" && aParm[1].Trim() == "01")            // 해피포인트 적립
                        //||
                        //(aParm[0].Trim() == "80" && aParm[1].Trim() == "05")            // 해피포인트 적립 (중국)
                        )
                    {
                        // 포인트 분해
                        byte[] bytes = Encoding.Default.GetBytes(aParm[11].Trim());
                        aIrtRsp = new string[Column.POS_RES_POINT.LEN.Length];
                        nNowPos = 0;
                        ItemColumn.ParseMessage(Column.POS_RES_POINT.LEN, Column.POS_RES_POINT.TYPE, bytes, ref nNowPos, ref aIrtRsp);

                        if (sTradeDiv == PosConst.CANCEL_DIV.NORMAL)
                        {
                            // 정상
                            nAMT_ENTRY[0] = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_POINT.SEQ.ResTrPoint]);                   // 적립포인트     
                            nAMT_ENTRY[1] = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_POINT.SEQ.ResSavePoint]);                 // 총포인트(누적포인트)
                            if (aParm[2].Trim() == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_QRY_A)
                            {
                                nAMT_ENTRY[2] = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_POINT.SEQ.ResUsesPoint]);             // 가용포인트
                                sHP_ADD_INFO = aIrtRsp[Column.POS_RES_POINT.SEQ.ResAddRespon].Trim();                           // 추가응답정보

                                nNowPos = 0;
                                aIrtRsp = new string[Column.POINT_ADD_INFO_SEARCH.LEN.Length];
                                ItemColumn.ParseMessage(Column.POINT_ADD_INFO_SEARCH.LEN, Column.POINT_ADD_INFO_SEARCH.TYPE, Encoding.Default.GetBytes(sHP_ADD_INFO), ref nNowPos, ref aIrtRsp);

                                nAMT_ENTRY[3] = CmUtil.LongParse(aIrtRsp[Column.POINT_ADD_INFO_SEARCH.SEQ.pointDELHPPOINT]);    // 소명예정포인트
                            }
                            else
                            {
                                sHP_ADD_INFO = aIrtRsp[Column.POS_RES_POINT.SEQ.ResAddRespon].Trim();                           // 추가응답정보

                                nNowPos = 0;
                                aIrtRsp = new string[Column.POINT_ADD_INFO_SAVE.LEN.Length];
                                ItemColumn.ParseMessage(Column.POINT_ADD_INFO_SAVE.LEN, Column.POINT_ADD_INFO_SAVE.TYPE, Encoding.Default.GetBytes(sHP_ADD_INFO), ref nNowPos, ref aIrtRsp);

                                nAMT_ENTRY[4] = CmUtil.DoubleParse(aIrtRsp[Column.POINT_ADD_INFO_SAVE.SEQ.AddSavePnt]);         // 추가적립포인트
                            }
                        }
                        else
                        {
                            // 반품
                            nAMT_ENTRY[1] = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_POINT.SEQ.ResSavePoint]);                 // 총포인트(누적포인트)

                            sHP_ADD_INFO = aIrtRsp[Column.POS_RES_POINT.SEQ.ResAddRespon].Trim();                               // 추가응답정보

                            nNowPos = 0;
                            aIrtRsp = new string[Column.POINT_ADD_INFO_SAVE.LEN.Length];
                            ItemColumn.ParseMessage(Column.POINT_ADD_INFO_SAVE.LEN, Column.POINT_ADD_INFO_SAVE.TYPE, Encoding.Default.GetBytes(sHP_ADD_INFO), ref nNowPos, ref aIrtRsp);
                        }
                    }
                }

                nAMT_ENTRY[5] = CmUtil.DoubleParse(aParm[5]);                                           // 승인금액
                if ((aParm[0].Trim() == "04" && aParm[1].Trim() == "00")                                // 해피포인트 사용
                    //||
                    //(aParm[0].Trim() == "04" && aParm[1].Trim() == "04")                                // 해피포인트 사용 (중국)
                    )                               
                {
                    nAMT_ENTRY[6] = CmUtil.DoubleParse(aParm[5]);                                       // 사용point
                }

                if (aParm.Length > 12)
                {
                    sOCCUR_ENTRY[0] = aParm[12];                                                        // 입력구분
                    sOCCUR_ENTRY[1] = aParm[16];                                                        // 고객번호
                    sOCCUR_ENTRY[2] = aParm[13];                                                        // 추후승인여부
                    sOCCUR_ENTRY[3] = "";                                                               // 
                    sOCCUR_ENTRY[4] = aParm[14];                                                        // 적립구분
                    sOCCUR_ENTRY[5] = "";                                                               // 할인구분
                    sOCCUR_ENTRY[6] = aParm[15];                                                        // skt할인상품코드
                    sOCCUR_ENTRY[7] = "";                                                               // 
                    sOCCUR_ENTRY[8] = "";                                                               //
                }

                if (aParm[0].Trim() == "03")                                                            // 제휴서비스 할인
                {
                    byte[] bytes = Encoding.Default.GetBytes(aParm[11].Trim());
                    aIrtRsp = new string[Column.POS_RES_POINT.LEN.Length];
                    nNowPos = 0;
                    ItemColumn.ParseMessage(Column.POS_RES_POINT.LEN, Column.POS_RES_POINT.TYPE, bytes, ref nNowPos, ref aIrtRsp);

                    nAMT_ENTRY[7] = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_POINT.SEQ.ResTrPoint]);   // 사용포인트(할인금액)
                    sOCCUR_ENTRY[5] = CmUtil.MidH(aIrtRsp[Column.POS_RES_POINT.SEQ.ResReserved], 0, 3) + CmUtil.MidH(aIrtRsp[Column.POS_RES_POINT.SEQ.ResReserved], 12, 1);        // 할인구분
                }

                // 포인트 조회
                if (aParm[2] == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_QRY_A)
                {
                    if ((aParm[0].Trim() == "04" && aParm[1].Trim() == "00")                            // 해피포인트 사용
                        ||
                        (aParm[0].Trim() == "80" && aParm[1].Trim() == "01")                            // 해피포인트 적립
                        )                           
                    {
                        byte[] bytes = Encoding.Default.GetBytes(aParm[11].Trim());
                        aIrtRsp = new string[Column.POS_RES_POINT.LEN.Length];
                        nNowPos = 0;
                        ItemColumn.ParseMessage(Column.POS_RES_POINT.LEN, Column.POS_RES_POINT.TYPE, bytes, ref nNowPos, ref aIrtRsp);

                        if (aIrtRsp[Column.POS_RES_POINT.SEQ.ResStatus] == "O")
                        {
                            string sAddInfo = aIrtRsp[Column.POS_RES_POINT.SEQ.ResAddRespon];           // 고정정보

                            if (sAddInfo.Trim() != "")
                            {
                                nNowPos = 0;
                                aIrtRsp = new string[Column.POINT_ADD_INFO_SEARCH.LEN.Length];
                                ItemColumn.ParseMessage(Column.POINT_ADD_INFO_SEARCH.LEN, Column.POINT_ADD_INFO_SEARCH.TYPE, Encoding.Default.GetBytes(sAddInfo), ref nNowPos, ref aIrtRsp);

                                string sCustInfo = aIrtRsp[Column.POINT_ADD_INFO_SEARCH.SEQ.pointMEMINFO];

                                sOCCUR_ENTRY[1] = CmUtil.MidH(sCustInfo, 45, 35).Trim();                // 고객번호
                            }
                        }
                    }
                }

                #endregion

                sQuery = " DECLARE @SEQ INT \n";
                sQuery += " SELECT @SEQ = ISNULL(MAX(SEQ),0) + 1 \n";
                sQuery += " FROM POSLOG..TR_SALE_APPR_LOG \n";
                sQuery += " WHERE 1 = 1 AND CMP_CD   = '{0}' AND STOR_CD  = '{1}' AND SALE_DT  = '{2}' AND POS_NO   = '{3}' AND TRADE_NO = '{4}' \n";
                sQuery += " \n";
                sQuery += " INSERT INTO POSLOG..TR_SALE_APPR_LOG( \n";
                sQuery += "    CMP_CD, STOR_CD, SALE_DT, POS_NO, TRADE_NO, SEQ, TRADE_DIV \n";
                sQuery += "  , PAY_WAY_CD, PAY_DTL_CD, INQ_TYPE, TRAN_TYPE, CARD_NO, PAY_AMT \n";
                sQuery += "  , APPR_NO, APPR_DT, APPR_TIME \n";
                sQuery += "  , RES_CD, RES_MSG, APPR_LOG, SEND_YN, REG_DATE, REG_ID \n";
                sQuery += "  , AMT_ENTRY_01, AMT_ENTRY_02, AMT_ENTRY_03, AMT_ENTRY_04, AMT_ENTRY_05 \n";
                sQuery += "  , AMT_ENTRY_06, AMT_ENTRY_07, AMT_ENTRY_08, AMT_ENTRY_09 \n";
                sQuery += "  , OCCUR_ENTRY_01, OCCUR_ENTRY_02, OCCUR_ENTRY_03, OCCUR_ENTRY_04, OCCUR_ENTRY_05 \n";
                sQuery += "  , OCCUR_ENTRY_06, OCCUR_ENTRY_07, OCCUR_ENTRY_08, OCCUR_ENTRY_09 \n";
                sQuery += "  , USE_YN \n";
                sQuery += "   ) \n";
                sQuery += "   VALUES ( '{0}', '{1}', '{2}', '{3}', '{4}', @SEQ, '{5}' \n";
                sQuery += "           , '{6}', '{7}', '{8}' , '{9}', '{10}', {11} \n";
                sQuery += "           , '{12}', '{13}', '{14}', '{15}', N'{16}', N'{17}', '{18}', '{19}', '{20}' \n";
                sQuery += "           , {21}, {22}, {23}, {24}, {25} \n";
                sQuery += "           , {26}, {27}, {28}, {29} \n";
                sQuery += "           , N'{30}', N'{31}', N'{32}', N'{33}', N'{34}' \n";
                sQuery += "           , N'{35}', N'{36}', N'{37}', N'{38}' \n";
                sQuery += "           , '{39}' \n";
                sQuery += "           )\n";
                sQuery = sQuery.Replace("\t", " ");

                string sRegDateTime = DateTime.Now.ToString("yyyyMMddHHmmss");

                sQuery = string.Format(sQuery
                    , m_cPosStatus.Base.CmpCd                                           // 0 CMP_CD
                    , m_cPosStatus.Base.StoreNo                                         // 1 STOR_CD
                    , m_cPosStatus.Base.SaleDate                                        // 2 SALE_DT
                    , m_cPosStatus.Base.PosNo                                           // 3 POS_NO
                    , m_cPosStatus.Base.TradeNo                                         // 4 TRADE_NO
                    , sTradeDiv                                                         // 5 판매구분

                    , EnterNullRemoval(aParm[0].Trim())                                 // 6 결제수단
                    , EnterNullRemoval(aParm[1].Trim())                                 // 7 결제상세코드

                    , EnterNullRemoval(aParm[2].Trim())                                 // 8 INQ_TYPE
                    , EnterNullRemoval(aParm[3].Trim())                                 // 9 TRAN_TYPE

                    , EnterNullRemoval(CmUtil.LeftH(aParm[4], 6).Trim())                // 10 CARD_NO

                    , EnterNullRemoval(CmUtil.DoubleParse(aParm[5]).ToString().Trim())  // 11 PAY_AMT
                    , EnterNullRemoval(CmUtil.MidH(aParm[6].Trim(), 0, 16).Trim())      // 12 APPR_NO
                    , EnterNullRemoval(CmUtil.MidH(sSaleDate, 0, 8).Trim())             // 13 APPR_DT
                    , EnterNullRemoval(CmUtil.MidH(sSaleTime, 0, 6).Trim())             // 14 APPR_TIME

                    , EnterNullRemoval(CmUtil.MidH(aParm[9].Trim(), 0, 20).Trim())      // 15 RES_CD
                    , CmUtil.MidH(EnterNullRemoval(aParm[10].Trim()), 0, 199).Trim()    // 16 RES_MSG
                    //, EnterNullRemoval(aParm[11].Trim())                                // 17 APPR_LOG                    

                    , CmUtil.MidH(EnterNullRemoval(aParm[11].Trim()), 0, 3500)          // 17 APPR_LOG   2017.04.17 선불고객 조회가 5000 넘아가 수정함                 

                    , "0"                                                               // 18 SEND_YN
                    , sRegDateTime                                                      // 19 REG_DATE
                    , m_cPosStatus.Base.CashierNo                                       // 20 REG_ID

                    , nAMT_ENTRY[0]                                                     // 21 적립포인트
                    , nAMT_ENTRY[1]                                                     // 22 총포인트
                    , nAMT_ENTRY[2]                                                     // 23 가용포인트
                    , nAMT_ENTRY[3]                                                     // 24 소멸예정포인트
                    , nAMT_ENTRY[4]                                                     // 25 추가적립포인트

                    , nAMT_ENTRY[5]                                                     // 26 승인금액
                    , nAMT_ENTRY[6]                                                     // 27 사용포인트
                    , nAMT_ENTRY[7]                                                     // 28 할인금액
                    , nAMT_ENTRY[8]                                                     // 29 금액9

                    , EnterNullRemoval(sOCCUR_ENTRY[0])                                 // 30 입력구분
                    , EnterNullRemoval(sOCCUR_ENTRY[1])                                 // 31 고객번호
                    , EnterNullRemoval(sOCCUR_ENTRY[2])                                 // 32 추후승인여부
                    , EnterNullRemoval(sOCCUR_ENTRY[3])                                 // 33 입력3
                    , EnterNullRemoval(sOCCUR_ENTRY[4])                                 // 34 적립구분
                    , EnterNullRemoval(sOCCUR_ENTRY[5])                                 // 35 할인구분
                    , EnterNullRemoval(sOCCUR_ENTRY[6])                                 // 36 skt할인상품코드
                    , EnterNullRemoval(sOCCUR_ENTRY[7])                                 // 37 입력8
                    , EnterNullRemoval(sOCCUR_ENTRY[8])                                 // 38 입력9

                    , "1"                                                               // 39 사용유무 
                    );

                //UserLog.WriteLogFile(UserCom.LOG_OP, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                //                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "@@SaleApprLog=" + sQuery);                            

                m_cSqlDbService.DBExecuteNonQuery(new string[] { sQuery });

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return sRet;
        }
        /// <summary>
        /// 특수문자 제거
        /// </summary>
        /// <param name="sStr"></param>
        /// <returns></returns>
        private string EnterNullRemoval(string sStr)
        {

            string sRet = sStr;
            try
            {
                sRet = sStr.Replace("\r", "").Replace("\n", "").Replace(null, "");

            }
            catch (Exception) { }

            return sRet;

        }


        #endregion 공통승인로그

        #region 중간입금/마감입금 거래 조회
        /// <summary>
        /// 중간입금/마감입금 거래 조회
        /// </summary>
        /// <param name="sKind"></param>
        /// <returns></returns>
        public DataTable SelectADMTList(string sKind)
        {
            try
            {
                // 조회

                string sQuery = "";

                sQuery += "SELECT  \n";
                //if (sKind == ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT) 
                sQuery += "     TOP 1 \n";
                sQuery += "		TSH.TRADE_NO  \n";
                sQuery += "	,	TSH.TRADE_DIV  \n";
                sQuery += "	,	TSH.PAY_TIME  \n";
                sQuery += "FROM POSLOG..TR_SALE_HEADER		TSH  \n";
                sQuery += "WHERE  \n";
                sQuery += "	   TSH.CMP_CD   = '" + m_cPosStatus.Base.CmpCd + "' \n";
                sQuery += "AND TSH.SALE_DT	= '" + m_cPosStatus.Base.SaleDate + "' \n";
                sQuery += "AND TSH.STOR_CD	= '" + m_cPosStatus.Base.StoreNo + "' \n";
                sQuery += "AND TSH.POS_NO	= '" + m_cPosStatus.Base.PosNo + "' \n";
                sQuery += "AND TSH.TRADE_DIV     = '0'      \n";
                sQuery += "AND TSH.TRAIN_MODE_YN = '0'  \n";
                sQuery += "AND TSH.TRADE_KINDPER = '" + sKind + "'  \n";
                sQuery += "ORDER BY 1 DESC, 3 DESC  \n";

                sQuery = sQuery.Replace("\t", " ");

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion

        #region 중간입금/마감입금 내역 조회
        /// <summary>
        /// 중간입금/마감입금 내역 조회
        /// </summary>
        /// <param name="sTradeNo"></param>
        /// <returns></returns>
        public DataTable SelectDPSTList(string sTradeNo)
        {
            try
            {
                // 조회

                string sQuery = "";

                sQuery += "SELECT \n";
                sQuery += "		SDW.DPST_WTHDR_CD \n";
                sQuery += "	,	ISNULL(SDW.DPST_WTHDR_QTY, 0)	DPST_WTHDR_QTY \n";
                sQuery += "	,	ISNUll(SDW.DPST_WTHDR_AMT, 0)	DPST_WTHDR_AMT \n";
                sQuery += "	,	ISNULL(SDW.DPST_WTHDR_NM, '')	DPST_WTHDR_NM \n";
                sQuery += "FROM POSLOG..TR_SALE_DPST_WTHDR		SDW \n";
                sQuery += "WHERE  \n";
                sQuery += "	   SDW.CMP_CD   = '" + m_cPosStatus.Base.CmpCd + "' \n";
                sQuery += "AND SDW.SALE_DT	= '" + m_cPosStatus.Base.SaleDate + "' \n";
                sQuery += "AND SDW.STOR_CD	= '" + m_cPosStatus.Base.StoreNo + "' \n";
                sQuery += "AND SDW.POS_NO	= '" + m_cPosStatus.Base.PosNo + "' \n";
                sQuery += "AND SDW.TRADE_NO = '" + sTradeNo + "' \n";
                sQuery += "ORDER BY SDW.SEQ \n";

                sQuery = sQuery.Replace("\t", " ");

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion

        #region 중간입금/마감입금 원거래 취소 조회
        /// <summary>
        /// 중간입금/마감입금 원거래 취소 조회
        /// </summary>
        /// <param name="sTradeNo"></param>
        /// <returns></returns>
        public DataTable SelectDPSTRefund(string sTradeNo)
        {
            try
            {
                // 조회

                string sQuery = "";

                sQuery += "SELECT \n";
                sQuery += "		COUNT(*) QTY  \n";
                sQuery += "FROM POSLOG..TR_SALE_HEADER		TSH \n";
                sQuery += "WHERE  \n";
                sQuery += "	   TSH.CMP_CD           = '" + m_cPosStatus.Base.CmpCd + "' \n";
                sQuery += "AND TSH.STOR_CD	        = '" + m_cPosStatus.Base.StoreNo + "' \n";
                sQuery += "AND TSH.ORG_BILLDT	    = '" + m_cPosStatus.Base.SaleDate + "' \n";
                sQuery += "AND TSH.ORG_BILL_POSNO	= '" + m_cPosStatus.Base.PosNo + "' \n";
                sQuery += "AND TSH.ORG_BILL_NO      = '" + sTradeNo + "' \n";

                sQuery = sQuery.Replace("\t", " ");

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion

        #region 서버전송 데이터 저장
        /// <summary>
        /// 서버전송 데이터 저장
        /// </summary>
        /// <param name="sFuncCode"></param>
        /// <param name="aParam"></param>
        public void SaveServerRequestTransactionData(string sFuncCode, string[] aParam)
        {
            string sSQL = string.Empty;
            string sRegDt = DateTime.Now.ToString("yyyyMMddHHmmss");

            try
            {
                if (sFuncCode == PosConst.RE_TRANSACTIONDATA.OWNER_MODE)   //점주 알바
                {

                    sSQL = "  DECLARE @CMP_CD    VARCHAR(4) ";
                    sSQL += " DECLARE @STOR_CD   VARCHAR(10)";
                    sSQL += " DECLARE @WORK_DT   VARCHAR(8)";
                    sSQL += " DECLARE @WORK_HOUR VARCHAR(6)";
                    sSQL += " DECLARE @EMP_DIV   VARCHAR(1)";

                    sSQL += " SET @CMP_CD    ='" + m_cPosStatus.Base.CmpCd + "'";
                    sSQL += " SET @STOR_CD   ='" + m_cPosStatus.Base.StoreNo + "'";
                    sSQL += " SET @WORK_DT   ='" + DateTime.Now.ToString("yyyyMMdd") + "'";
                    sSQL += " SET @WORK_HOUR ='" + DateTime.Now.ToString("HHmmss") + "'";
                    sSQL += " SET @EMP_DIV   ='" + aParam[0] + "'";

                    sSQL += " IF NOT EXISTS (SELECT * ";
                    sSQL += "   FROM POSLOG.dbo.TR_STOR_EMP_WORK";
                    sSQL += "  WHERE CMP_CD    = @CMP_CD";
                    sSQL += "    AND STOR_CD   = @STOR_CD";
                    sSQL += "    AND WORK_DT   = @WORK_DT";
                    sSQL += "    AND WORK_HOUR = @WORK_HOUR";
                    sSQL += "    AND EMP_DIV   = @EMP_DIV)";
                    sSQL += "    BEGIN";
                    sSQL += " INSERT INTO POSLOG.dbo.TR_STOR_EMP_WORK (";
                    sSQL += "   CMP_CD,STOR_CD,WORK_DT,WORK_HOUR,EMP_DIV,POS_NO,SEND_YN,REG_DATE,UPD_DATE ";
                    sSQL += " ) VALUES ( ";
                    sSQL += " @CMP_CD,@STOR_CD,@WORK_DT,@WORK_HOUR,@EMP_DIV,'{0}','{1}','{2}','{2}' ) ";
                    sSQL += "    END";

                    sSQL = string.Format(sSQL
                        , m_cPosStatus.Base.PosNo
                        , ""
                        , sRegDt
                        );
                }

                if (sSQL != "")
                {
                    m_cSqlDbService.DBExecuteNonQuery(new string[] { sSQL });
                }


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

        #region 기타 공지 처리 프로세스
        /// <summary>
        /// 기타 공지 처리 프로세스
        /// </summary>
        /// <param name="sMsgType"></param>
        /// <param name="aInParam"></param>
        /// <param name="aOutParam"></param>
        /// <returns></returns>
        public bool GetEtcNoticeProcess(string sMsgType, ref string[] aOutParam)
        {
            string sSQL = string.Empty;
            bool bRet = false;

            try
            {
                if (sMsgType == "01")
                {
                    //01 - 점주알바모드
                    sSQL = " SELECT MAX(MSG_DIV) AS 'MSG_DIV' ";
                    sSQL += "      ,ISNULL(MAX(VAL_ENTRY_01),0) AS 'OWNER' ";
                    sSQL += "      ,ISNULL(MAX(VAL_ENTRY_02),0) AS 'PART' ";
                    sSQL += "  FROM POSLOG.dbo.ETC_NOTICE_MNG ";
                    sSQL += " WHERE CMP_CD  = '{0}' ";
                    sSQL += "   AND STOR_CD = '{1}' ";
                    sSQL += "   AND POS_NO  = '{2}' ";
                    sSQL += "   AND MSG_DIV IN ('01') ";
                    sSQL += "   AND SUBSTRING(REG_DATE,1,8) = (SELECT MAX(SUBSTRING(REG_DATE,1,8)) FROM POSLOG.dbo.ETC_NOTICE_MNG WHERE CMP_CD = '{0}' AND STOR_CD = '{1}' AND POS_NO  = '{2}' AND MSG_DIV IN ('01')) ";
                    sSQL += "   AND SUBSTRING(REG_DATE,1,8) BETWEEN CONVERT(VARCHAR,GETDATE() - 31,112) AND CONVERT(VARCHAR,GETDATE(),112) ";
                    //sSQL += "   AND SEND_FLAG = '1' ";
                }
                else if (sMsgType == "05")
                {
                    //05 - 기념일 배송 => 건수 필드 수정(2017.07.20)
                    sSQL = " SELECT ISNULL(VAL_ENTRY_01, 0) AS CNT ";
                    sSQL += "  FROM POSLOG.dbo.ETC_NOTICE_MNG";
                    sSQL += " WHERE CMP_CD  = '{0}'";
                    sSQL += "   AND STOR_CD = '{1}'";
                    sSQL += "   AND POS_NO  = '{2}'";
                    sSQL += "   AND MSG_DIV IN ('05') ";
                    //sSQL += "   AND SUBSTRING(REG_DATE,1,8) BETWEEN CONVERT(VARCHAR,GETDATE() - 31,112) AND CONVERT(VARCHAR,GETDATE(),112) ";
                    sSQL += "   AND SEND_FLAG = '0' ";

                    //sSQL = " SELECT ISNULL(COUNT(CMP_CD),0) AS CNT ";
                    //sSQL += "  FROM POSLOG.dbo.ETC_NOTICE_MNG";
                    //sSQL += " WHERE CMP_CD  = '{0}'";
                    //sSQL += "   AND STOR_CD = '{1}'";
                    //sSQL += "   AND POS_NO  = '{2}'";
                    //sSQL += "   AND MSG_DIV IN ('05') ";
                    //sSQL += "   AND SUBSTRING(REG_DATE,1,8) BETWEEN CONVERT(VARCHAR,GETDATE() - 31,112) AND CONVERT(VARCHAR,GETDATE(),112) ";
                    //sSQL += "   AND SEND_FLAG = '0' ";
                    //sSQL += " ORDER BY SEND_FLAG ";
                }
                else
                {
                    //02 - 유해상품
                    //03 - 입고등록 확인
                    //04 - 배송정보
                    //05 - 기념일 배송

                    sSQL = " SELECT TOP 1 CMP_CD,STOR_CD,POS_NO,MSG_DIV,SEQ,VAL_ENTRY_01,VAL_ENTRY_02,VAL_ENTRY_03,VAL_ENTRY_04 ";
                    sSQL += "      ,VAL_ENTRY_05,VAL_ENTRY_06,VAL_ENTRY_07,VAL_ENTRY_08,VAL_ENTRY_09,VAL_ENTRY_10 ";
                    sSQL += "  FROM POSLOG.dbo.ETC_NOTICE_MNG";
                    sSQL += " WHERE CMP_CD  = '{0}'";
                    sSQL += "   AND STOR_CD = '{1}'";
                    sSQL += "   AND POS_NO  = '{2}'";
                    sSQL += "   AND MSG_DIV IN ('02','03','04') ";
                    //sSQL += "   AND MSG_DIV IN ('02','03','04','05') ";
                    sSQL += "   AND SUBSTRING(REG_DATE,1,8) BETWEEN CONVERT(VARCHAR,GETDATE() - 31,112) AND CONVERT(VARCHAR,GETDATE(),112) ";
                    sSQL += "   AND SEND_FLAG = '0' ";
                    //sSQL += " ORDER BY SEND_FLAG ";
                }

                if (sSQL != "")
                {
                    sSQL = string.Format(sSQL, m_cPosStatus.Base.CmpCd, m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.PosNo);

                    DataTable dt = m_cMstService.Select(new string[] { sSQL });

                    //디비조회
                    if (!(dt == null || dt.Rows.Count == 0))
                    {
                        DataRow dr = dt.Rows[0];

                        if (sMsgType == "01")
                        {
                            aOutParam = new string[] { dr["OWNER"].ToString(), dr["PART"].ToString() };
                        }
                        else if (sMsgType == "05")
                        {
                            aOutParam = new string[] { dr["CNT"].ToString() };
                        }
                        else
                        {
                            //팝업처리

                            string sMsg = string.Empty;

                            //CASE별 분리!
                            if (dr["MSG_DIV"].ToString() == "02") //위해상품이면
                            {
                                sMsg = string.Format("[{0}]{1}-{2}-{3}\n{4}:{5}\n{6}:{7}", MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0741), dr["VAL_ENTRY_01"], dr["VAL_ENTRY_02"], dr["VAL_ENTRY_03"]
                                    , MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0015), dr["VAL_ENTRY_04"], MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0173), dr["VAL_ENTRY_05"]);
                            }

                            if (sMsg != "")
                            {
                                WinManager.ConfirmMessage(sMsg);
                            }


                            UpdateEtcNoticeProcess(dr["MSG_DIV"].ToString(), dr);
                        }

                    }

                    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);
            }

            return bRet;
        }

        /// <summary>
        /// 기타 공지 업데이트
        /// </summary>
        /// <param name="sMsgDiv"></param>
        /// <param name="sSeq"></param>
        public void UpdateEtcNoticeProcess(string sMsgDiv, DataRow dr)
        {
            string sSQL = string.Empty;

            try
            {

                //#20171227 거래데이터 저장 오류 관련 로그추가 start
                UserLog.WriteLogFile(UserCom.LOG_DEBUG,
                                 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 (함수명))
                                 "UpdateEtcNoticeProcess STEP 1 -> " + "sMsgDiv : " + sMsgDiv);
                //#20171227 거래데이터 저장 오류 관련 로그추가 end

                //#20180212 기타공지 업데이트 오류 수정 start
                if (sMsgDiv == "")
                {
                    return;
                }
                //#20180212 기타공지 업데이트 오류 수정 end

                sSQL = " UPDATE POSLOG.dbo.ETC_NOTICE_MNG SET SEND_FLAG = '1' ";
                sSQL += " WHERE CMP_CD  = '{0}'";
                sSQL += "   AND STOR_CD = '{1}'";
                sSQL += "   AND POS_NO  = '{2}'";
                sSQL += "   AND MSG_DIV = '{3}'";

                if (sMsgDiv == "01" || sMsgDiv == "05")    //점주알바, 기념일 배송
                {
                    sSQL = string.Format(sSQL, m_cPosStatus.Base.CmpCd, m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.PosNo, sMsgDiv);
                }
                else if (sMsgDiv == "02")    //위해상품
                {

                    sSQL += "   AND VAL_ENTRY_01 = '{4}'";
                    sSQL += "   AND VAL_ENTRY_02 = '{5}'";
                    sSQL += "   AND VAL_ENTRY_03 = '{6}'";

                    sSQL = string.Format(sSQL, m_cPosStatus.Base.CmpCd, m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.PosNo, sMsgDiv, dr["VAL_ENTRY_01"], dr["VAL_ENTRY_02"], dr["VAL_ENTRY_03"]);
                }
                else
                {
                    sSQL += "   AND SEQ     = '{4}'";

                    //#20171227 거래데이터 저장 오류 관련 로그추가 start
                    UserLog.WriteLogFile(UserCom.LOG_DEBUG,
                                     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 (함수명))
                                     "UpdateEtcNoticeProcess STEP 2 -> " + "sMsgDiv : " + sMsgDiv + ", SEQ : " + dr["SEQ"].ToString());
                    //#20171227 거래데이터 저장 오류 관련 로그추가 end

                    sSQL = string.Format(sSQL, m_cPosStatus.Base.CmpCd, m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.PosNo, sMsgDiv, dr["SEQ"]);
                }

                int iRet = m_cMstService.Update(new string[] { sSQL });

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

        #region 주변장치 상태 관리

        /// <summary>
        /// 주변장치 상태 관리
        /// </summary>
        public Color GS_DeviceStatus()
        {
            string sStatus = "";
            string sDeviceName = "";
            Color cColor = Color.Green;
            try
            {
                // 주변장치 목록 체크
                CmMessage m_cDeviceList = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosDevice);

                m_cPosStatus = (PosStatus)StateObject.POS;

                for (int i = 0; i < m_cDeviceList.Count; i++)
                {
                    sDeviceName = m_cDeviceList.MessageKeyList[i].ToString();

                    if (m_cDeviceList.GetMessage(sDeviceName).GetMessageValue("UseFlag") != PosConst.DEVICE_USE_FLAG.YES_USE)
                    {
                    }
                    else
                    {
                        switch (sDeviceName)
                        {
                            case "POSPRINTER":
                                sStatus = m_cPosStatus.Base.OlePosPrinterStatus;
                                if (sStatus.Trim().Length > 0 && sStatus != UserCom.RST_OK)
                                {
                                    cColor = Color.Crimson;
                                    goto Skip_Next;
                                }

                                break;
                            case "SCANNER":
                                sStatus = m_cPosStatus.Base.OlePosScannerStatus;
                                if (sStatus.Trim().Length > 0 && sStatus != UserCom.RST_OK)
                                {
                                    cColor = Color.Crimson;
                                    goto Skip_Next;
                                }
                                break;
                            case "ICREADER":
                                sStatus = m_cPosStatus.Base.OlePosICReaderStatus;
                                if (sStatus.Trim().Length > 0 && sStatus != UserCom.RST_OK)
                                {
                                    cColor = Color.Crimson;
                                    goto Skip_Next;
                                }
                                break;
                            case "CATTERMINAL":
                                sStatus = m_cPosStatus.Base.OlePosCATStatus;
                                if (sStatus.Trim().Length > 0 && sStatus != UserCom.RST_OK)
                                {
                                    cColor = Color.Crimson;
                                    goto Skip_Next;
                                }
                                break;
                            case "CASHDRAWER":
                                //sStatus = m_cPosStatus.Base.OlePosCashDrawerStatus;
                                //if (sStatus != UserCom.RST_OK)
                                //{
                                //    cColor = Color.Crimson;
                                //    goto Skip_Next;
                                //}
                                break;
                            case "SCALE":
                                sStatus = m_cPosStatus.Base.OlePosScaleStatus;
                                if (sStatus.Trim().Length > 0 && sStatus != UserCom.RST_OK)
                                {
                                    cColor = Color.Crimson;
                                    goto Skip_Next;
                                }
                                break;
                            case "SIGNPAD":
                                sStatus = m_cPosStatus.Base.OlePosSignPadStatus;
                                if (sStatus.Trim().Length > 0 && sStatus != UserCom.RST_OK)
                                {
                                    cColor = Color.Crimson;
                                    goto Skip_Next;
                                }
                                break;
                            case "LABELPRINTER":
                                sStatus = m_cPosStatus.Base.OlePosLabelPrinterStatus;
                                if (sStatus.Trim().Length > 0 && sStatus != UserCom.RST_OK)
                                {
                                    cColor = Color.Crimson;
                                    goto Skip_Next;
                                }
                                break;
                            case "MSR":
                                sStatus = m_cPosStatus.Base.OlePosMsrStatus;
                                if (sStatus.Trim().Length > 0 && sStatus != UserCom.RST_OK)
                                {
                                    cColor = Color.Crimson;
                                    goto Skip_Next;
                                }
                                break;
                            case "SCALEPOLEDISP":
                                sStatus = m_cPosStatus.Base.OlePosScalePoleDispStatus;
                                if (sStatus.Trim().Length > 0 && sStatus != UserCom.RST_OK)
                                {
                                    cColor = Color.Crimson;
                                    goto Skip_Next;
                                }
                                break;
                            case "":
                                break;
                        }
                    }

                    // Network
                    sStatus = m_cPosStatus.Base.OlePosNetworkStatus;
                    if (sStatus.Trim().Length > 0 && sStatus != UserCom.RST_OK)
                    {
                        cColor = Color.Crimson;
                    }

                }

            Skip_Next:
                return cColor;
            }
            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 cColor;
        }
        #endregion

        #region 대기번호 번호 자동 채번

        /// <summary>
        /// 대기번호 자동 채번
        /// </summary>
        /// <returns></returns>
        public string GetWaitNoForDb()
        {
            string sSQL = string.Empty;
            string sRet = "";
            int iRet = 0;
            DataTable dt = null;

            try
            {
                sSQL = " SELECT ISNULL(MAX(CONVERT(int,case when len(order_no) > 2 then  substring(order_no, len('87') + 1, len(order_no)) else order_no end)),0) + 1 AS ORDER_NO ";
                sSQL += "  FROM POSLOG.dbo.TR_SALE_HEADER ";
                sSQL += " WHERE CMP_CD  ='" + m_cPosStatus.Base.CmpCd + "'";
                sSQL += "   AND SALE_DT ='" + m_cPosStatus.Base.SaleDate + "'";
                sSQL += "   AND STOR_CD ='" + m_cPosStatus.Base.StoreNo + "'";
                //sSQL += "   AND POS_NO  ='" + m_cPosStatus.Base.PosNo + "'";                                          // del, 2017.02.02, 후불판매모드 대응 
                sSQL += "   AND ISNUMERIC(ORDER_NO) = 1 ";

                iRet = m_cSqlDbService.DBSelect(sSQL, out dt);

                if (iRet == 1)
                {
                    sRet = m_cPosStatus.Base.PosNo + dt.Rows[0]["ORDER_NO"].ToString();
                    //sRet = dt.Rows[0]["ORDER_NO"].ToString();
                }
                else
                {
                    //실패시 거래번호라도 주자!
                    sRet = CmUtil.IntParse(m_cTrnStatus.Head.TradeNo).ToString();
                }
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }

        #endregion 대기번호 번호 자동 채번

        #region BR 팝업 업무 처리

        /// <summary>
        /// BR 팝업 업무 조회 셋팅
        /// </summary>
        /// <returns></returns>
        public void SetBrPopUpBizMst()
        {
            DataTable dt = null;
            string sComCd = "";
            string sQuery = "";
            string sSQL = "";

            try
            {

                //BRK만 처리!
                if (m_cPosStatus.Mst.CorpDiv == ItemConst.CORP_DIV.BR)
                {

                    string sSaleDt = DateTime.Now.ToString("yyyyMMdd");

                    sQuery = " SELECT CMP_CD ";
                    sQuery += "      ,CMM_GRP_CD ";
                    sQuery += "      ,CMM_CD ";
                    sQuery += "      ,CHAR_VAL_TITLE_VAL_01 ";
                    sQuery += "      ,CHAR_VAL_TITLE_VAL_02 ";
                    sQuery += "  FROM POSMST.dbo.MST_CMM A ";
                    sQuery += "  WHERE CMP_CD     = '{0}' ";
                    sQuery += "    AND CMM_GRP_CD IN ({1}) ";
                    sQuery += "    AND USE_YN     = '1' ";

                    if (m_cPosStatus.Base.BrandCd == PosConst.MST_BRAND_CODE.BR_BR)    //베스킨
                    {
                        sComCd = string.Format("'{0}','{1}'", PosConst.COMMON_CODE_GROUP.Z0015, PosConst.COMMON_CODE_GROUP.Z0016);
                    }
                    else if (m_cPosStatus.Base.BrandCd == PosConst.MST_BRAND_CODE.BR_DD)   //던킨
                    {
                        //토, 일 체크
                        DateTime dtTime = DateTime.Now;

                        if (dtTime.DayOfWeek == DayOfWeek.Saturday || dtTime.DayOfWeek == DayOfWeek.Sunday) //토,일만 처리
                        {
                            sComCd = string.Format("'{0}','{1}'", PosConst.COMMON_CODE_GROUP.Z0018, PosConst.COMMON_CODE_GROUP.Z0019);
                        }
                        else
                        {
                            sComCd = string.Format("'{0}'", PosConst.COMMON_CODE_GROUP.Z0018);
                        }
                    }

                    sQuery = string.Format(sQuery, m_cPosStatus.Base.CmpCd, sComCd);

                    int iRet = m_cSqlDbService.DBSelect(sQuery, out dt);

                    if (iRet == 1)
                    {
                        if (dt == null || dt.Rows.Count == 0)
                        {
                            //처리 없음!
                        }
                        else
                        {
                            sSQL = " IF NOT EXISTS (SELECT * ";
                            sSQL += "   FROM POSLOG.dbo.ETC_BR_POPUP";
                            sSQL += "  WHERE CMP_CD     = '{0}'";
                            sSQL += "    AND BRAND_CD   = '{1}'";
                            sSQL += "    AND SALE_DT    = '{2}'";
                            sSQL += "    AND STOR_CD    = '{3}'";
                            sSQL += "    AND POS_NO     = '{4}'";
                            sSQL += "    AND CMM_GRP_CD = '{5}'";
                            sSQL += "    AND CMM_CD     = '{6}')";
                            sSQL += " BEGIN";
                            sSQL += "  INSERT INTO POSLOG.dbo.ETC_BR_POPUP (";
                            sSQL += "   CMP_CD, BRAND_CD, SALE_DT, STOR_CD, POS_NO, CMM_GRP_CD, CMM_CD, START_TM, END_TM, SHOW_MSG1 ";
                            sSQL += "   ,SHOW_MSG2, SHOW_MSG3, READ_FLAG, REG_DATE, UPD_DATE ";
                            sSQL += " ) VALUES ( ";
                            sSQL += "    '{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '' ";
                            sSQL += "   ,'', '','0','{9}','{9}' )";
                            sSQL += " END ";

                            foreach (DataRow dr in dt.Rows)
                            {
                                sQuery = string.Format(sSQL
                                    , m_cPosStatus.Base.CmpCd
                                    , m_cPosStatus.Base.BrandCd
                                    , sSaleDt
                                    , m_cPosStatus.Base.StoreNo
                                    , m_cPosStatus.Base.PosNo
                                    , dr["CMM_GRP_CD"]
                                    , dr["CMM_CD"]
                                    , dr["CHAR_VAL_TITLE_VAL_01"]
                                    , dr["CHAR_VAL_TITLE_VAL_02"]
                                    , DateTime.Now.ToString("yyyyMMddHHmmss"));

                                iRet = m_cSqlDbService.DBExecuteNonQuery(sQuery);
                            }
                        }
                    }
                }
            }
            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>
        /// BR 팝업 업무 조회
        /// </summary>
        public DataTable GetBrPopUpBizMst()
        {
            DataTable dt = null;
            string sSQL = "";

            try
            {

                //BRK만 처리!
                if (m_cPosStatus.Mst.CorpDiv == ItemConst.CORP_DIV.BR)
                {

                    string sSaleDt = DateTime.Now.ToString("yyyyMMdd");
                    string sSaleTm = DateTime.Now.ToString("HHmmss");

                    sSQL = " SELECT * ";
                    sSQL += "   FROM POSLOG.dbo.ETC_BR_POPUP";
                    sSQL += "  WHERE CMP_CD     = '{0}'";
                    sSQL += "    AND BRAND_CD   = '{1}'";
                    sSQL += "    AND SALE_DT    = '{2}'";
                    sSQL += "    AND STOR_CD    = '{3}'";
                    sSQL += "    AND POS_NO     = '{4}'";
                    sSQL += "    AND READ_FLAG  = '1'";
                    sSQL += "    AND '{5}' BETWEEN START_TM AND END_TM ";

                    sSQL = string.Format(sSQL
                        , m_cPosStatus.Base.CmpCd
                        , m_cPosStatus.Base.BrandCd
                        , sSaleDt
                        , m_cPosStatus.Base.StoreNo
                        , m_cPosStatus.Base.PosNo
                        , sSaleTm
                        );

                    int iRet = m_cSqlDbService.DBSelect(sSQL, out dt);

                    if (iRet == 1) return dt;

                }
            }
            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 null;


        }

        /// <summary>
        /// 디비 업데이트
        /// </summary>
        /// <param name="dr"></param>
        /// <returns></returns>
        public bool BrPopupUpdate(DataRow dr)
        {

            bool bRet = false;
            string sSQL = "";

            try
            {
                sSQL = " UPDATE POSLOG.dbo.ETC_BR_POPUP ";
                sSQL += "   SET READ_FLAG  = '2'";
                sSQL += " WHERE CMP_CD     = '" + dr["CMP_CD"] + "'";
                sSQL += "   AND BRAND_CD   = '" + dr["BRAND_CD"] + "'";
                sSQL += "   AND SALE_DT    = '" + dr["SALE_DT"] + "'";
                sSQL += "   AND STOR_CD    = '" + dr["STOR_CD"] + "'";
                sSQL += "   AND POS_NO     = '" + dr["POS_NO"] + "'";
                sSQL += "   AND CMM_GRP_CD = '" + dr["CMM_GRP_CD"] + "'";
                sSQL += "   AND CMM_CD     = '" + dr["CMM_CD"] + "'";

                m_cSqlDbService.DBExecuteNonQuery(new string[] { sSQL });

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

            return bRet;
        }
        #endregion

        #region MSR 카드번호 첫자리와 끝자리 체크하여 문자인 경우 스페이스로 치환
        /// <summary>
        /// MSR  카드번호 첫자리와 끝자리 체크하여 문자인 경우 스페이스로 치환
        /// </summary>
        /// <param name="sCardNo"></param>
        /// <param name="sValidDate"></param>
        /// <param name="sInputType"></param>
        /// <returns></returns>
        //#20171024 START, PHJ
        //기존
        //public string MSR_CardNoCheck(string sCardNo, string sValidDate, ref string sInputType)

        //변경
        public string MSR_CardNoCheck(string sCardNo, string sValidDate, ref string sInputType, string sPayWayCd = "", string sPayDtlCd = "")
        //#20171024 END, PHJ
        {
            string sRet = "";
            string sFirst = CmUtil.MidH(sCardNo, 0, 1);
            string sLast = CmUtil.MidH(sCardNo, CmUtil.LenH(sCardNo.Trim()) - 1, 1);


            try
            {
                if (sFirst.Contains("^") == true)
                    return "";
                else if (sFirst.Contains("%") == true)
                    return "";

                sCardNo = sCardNo.Trim();

                if (sFirst.Contains(m_cDevStatus.Msr.STX) == true && m_cDevStatus.Msr.STX.Trim() != "")
                {
                    // 첫자리가 ;, ? 경우 치환
                    sCardNo = CmUtil.MidH(sCardNo, 1, CmUtil.LenH(sCardNo.Trim()));
                }
                else if (CmUtil.IsNumber(sFirst) != true)
                {
                    // 첫자리가 숫자가 아닌 경우 치환
                    sCardNo = CmUtil.MidH(sCardNo, 1, CmUtil.LenH(sCardNo.Trim()));
                }

                if (sLast.Contains(m_cDevStatus.Msr.ETX) == true && m_cDevStatus.Msr.ETX.Trim() != "")
                {
                    // 끝자리가 ? 경우 치환
                    sCardNo = CmUtil.MidH(sCardNo, 0, CmUtil.LenH(sCardNo.Trim()) - 1);
                }

                if (sCardNo.IndexOf("=") > 0)
                {
                    if (sCardNo.Trim().Length >= 37)
                        sCardNo = CmUtil.MidH(sCardNo, 0, 37);

                    if (sInputType != PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF)
                        sInputType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP;
                }
                else if (sValidDate != null && sValidDate.Trim() != "")
                {
                    sCardNo = sCardNo + "=" + sValidDate;
                    if (sInputType != PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF)
                        sInputType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN;
                }
                else
                {
                    //#20171024 START, PHJ
                    //기존
                    //if (sInputType != PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF)
                    //    sInputType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN;

                    //변경
                    //해피포인트 번호로 현금영수증 시도 할 때
                    //키인 S로 변경하고, 카드번호의 특수문자 짤라서 리턴해줌.
                    if (sInputType != PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF)
                    {
                        if ((sPayWayCd == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM) &&
                            (sPayDtlCd == ItemConst.TR_ITEM_ID.ETC_INFO.CASHBILL) &&
                            (sCardNo.StartsWith(PosConst.HP_CARD_PRIFIX)) &&
                            //(CmUtil.IsNumber(sCardNo.Substring(16, 1))) == false) &&  
                            (sCardNo.Length >= 16))
                        {
                            sInputType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP;
                            sCardNo = CmUtil.MidH(sCardNo, 0, 16);
                        }
                        else
                        {
                            sInputType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN;
                        }
                    }
                    //#20171024 END, PHJ
                }

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

        #region 거래번호 증가 체크
        /// <summary>
        /// 거래번호 증가 체크
        /// </summary>
        /// <returns></returns>
        public bool TradeNoAddCheck(string sTranKind)
        {

            bool bRet = true;

            if (sTranKind == "") sTranKind = m_cTrnStatus.Head.TradeKind;

            try
            {
                if (m_cPosStatus.Base.TrainingFlag == "0" && 
                    (sTranKind == ItemConst.TRAN_KIND.NORMAL.SALE || sTranKind == ItemConst.TRAN_KIND.UNDECIDED.RESERVATION_COMPLETE ||
                     sTranKind == ItemConst.TRAN_KIND.UNDECIDED.RESERVATION_REG || sTranKind == ItemConst.TRAN_KIND.FORIGN.O2O ||
                     sTranKind == ItemConst.TRAN_KIND.FORIGN.SHOPPINGMALL || sTranKind == ItemConst.TRAN_KIND.CHARGESALE.GIFT ||
                     sTranKind == ItemConst.TRAN_KIND.CHARGESALE.PREPAID || sTranKind == ItemConst.TRAN_KIND.CHARGESALE.REFUND ||
                     sTranKind == ItemConst.TRAN_KIND.ETC.LOSS || sTranKind == ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT ||
                     //#Rhee, 20180117 미주 픽업 추가 Start
                     // 기존
                     //sTranKind == ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT))
                     // 변경
                     sTranKind == ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT || sTranKind == ItemConst.TRAN_KIND.UNDECIDED.RESERVATION_PICKUP))
                {
                    //증가!
                    //17.05.18 dkshin 쇼킹박스 추가
                    if (m_cTrnStatus.Head.ShockingBoxStat == "0")
                    {
                        //미증가!
                        bRet = false;
                    }
                    else
                    {
                        //증가!
                    }
                }
                else
                {
                    //17.05.18 dkshin 쇼킹박스 추가
                    //미증가!
                    //bRet = false;
                    if (m_cTrnStatus.Head.ShockingBoxStat == "1")
                    {
                        //증가!
                    }
                    else
                    {//쇼킹박스 전체취소, 쇼킹박스 영수증저장(ETC_SALE_HEADER)
                        //미증가!
                        bRet = false;
                    }
                    
                }
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return bRet;
        }
        #endregion

        #region 상품 마스터 조회(선불카드 금액으로 상품 검색)
        /// <summary>
        /// 상품 마스터 조회(선불카드 금액으로 상품 검색)
        /// </summary>
        /// <param name="sSubStoreNo"></param>
        /// <param name="nSaleAmt"></param>
        /// <returns></returns>
        public DataTable SeletItemMst_PrePaidCard_Sale(string sSubStoreNo, double nSaleAmt)
        {
            string sQuery = "";
            try
            {
                // 상품코드로 상품 마스터 조회
                sQuery = "";
                sQuery += "SELECT TOP 1 * FROM POSMST..MST_ITEM \n";
                sQuery += "WHERE \n";
                sQuery += "    CMP_CD       = '" + m_cPosStatus.Base.CmpCd + "' \n";
                sQuery += "AND STOR_CD      = '" + m_cPosStatus.Base.StoreNo + "' \n";
                sQuery += "AND SUB_STOR_CD  = '" + sSubStoreNo + "' \n";
                sQuery += "AND '" + m_cPosStatus.Base.SaleDate + "' BETWEEN SALE_START_DT AND SALE_FNSH_DT \n";
                sQuery += "AND SALE_PRMT_YN = '" + PosConst.MST_USE_YN.YES + "' \n";
                if (PosMstManager.GetPosOption(POS_OPTION.OPT041) == "1")
                {
                    sQuery += "AND TAKE_OUT_SALE_AMT = " + nSaleAmt + " \n";
                }
                else
                {
                    sQuery += "AND TAKE_IN_SALE_AMT = " + nSaleAmt + " \n";
                }
                sQuery += "AND ITEM_TYPE    = '" + PosConst.ITEM_TYPE.PREPAID + "' \n";
                sQuery += "AND USE_YN       = '" + PosConst.MST_USE_YN.YES + "'\n";
                sQuery = sQuery.Replace("\t", " ");

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion

        #region 카드사 코드 조회
        /// <summary>
        /// 카드사 코드 조회
        /// </summary>
        /// <param name="sCardDiv"></param>
        /// <returns></returns>
        public DataTable SeletCardCmp(string sCardDiv)
        {
            string sQuery = "";
            try
            {
                // 카드사코드 조회
                sQuery += " SELECT \n";
                sQuery += "         ROW_NUMBER() OVER( ORDER BY CARD_CMP_CD)                SEQ  \n";
                sQuery += " 	,	CMP_CD                                                  CMP_CD  \n";
                sQuery += " 	,	'" + m_cPosStatus.Base.StoreNo + "'                     STOR_CD  \n";
                sQuery += " 	,	SALES_ORG_CD                                            BRAND_CD  \n";
                sQuery += " 	,	ISNULL(CARD_CMP_CD, '')                                 CARD_CMP_CD  \n";
                sQuery += " 	,	ISNULL(CARD_CMP_NM, '')                                 CARD_CMP_NM  \n";
                sQuery += " 	,	ISNULL(TERM_DIV, '')							        TERM_DIV \n";
                sQuery += " 	,	ISNULL(GRP_CD, '')					                    GRP_CD \n";
                sQuery += " 	,	'WHITE'                                                 BACKGR_COLOR  \n";
                sQuery += " 	,	'10'                                                    FONT_SIZE  \n";
                sQuery += " 	,	'0'                                                     BTN_SIZE  \n";
                sQuery += " 	,	''                                                      BTN_ITEM_IMG  \n";
                sQuery += "FROM POSMST..MST_CARD_CMP  \n";
                sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'  \n";
                sQuery += "   AND TERM_DIV = '" + sCardDiv + "' \n";           // 카드사구분 (N:일반, S:샨더, U:은련)
                sQuery += "   AND RTRIM(TERM_RTN_NO) = '' \n";
                sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "' \n";
                sQuery += " ORDER BY CMP_CD, CARD_CMP_CD \n";

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion

        //#20170704 중국 단말기 승인 카드사 조회 start
        #region 카드 매입사 조회
        /// <summary>
        /// 카드사 매입사 조회
        /// </summary>
        /// <param name="sCardDiv"></param>
        /// <param name="sBankNo"></param>
        /// <returns></returns>
        public DataTable SeletCardCmpNm(string sCardDiv, string sBankNo)
        {
            string sQuery = "";
            try
            {
                // 카드사 매입사 조회
                sQuery += " SELECT \n";
                sQuery += "         ROW_NUMBER() OVER( ORDER BY CARD_CMP_CD)                SEQ  \n";
                sQuery += " 	,	CMP_CD                                                  CMP_CD  \n";
                sQuery += " 	,	'" + m_cPosStatus.Base.StoreNo + "'                     STOR_CD  \n";
                sQuery += " 	,	SALES_ORG_CD                                            BRAND_CD  \n";
                sQuery += " 	,	ISNULL(CARD_CMP_CD, '')                                 CARD_CMP_CD  \n";
                sQuery += " 	,	ISNULL(CARD_CMP_NM, '')                                 CARD_CMP_NM  \n";
                sQuery += " 	,	ISNULL(TERM_DIV, '')							        TERM_DIV \n";
                sQuery += " 	,	ISNULL(GRP_CD, '')					                    GRP_CD \n";
                sQuery += " 	,	'WHITE'                                                 BACKGR_COLOR  \n";
                sQuery += " 	,	'10'                                                    FONT_SIZE  \n";
                sQuery += " 	,	'0'                                                     BTN_SIZE  \n";
                sQuery += " 	,	''                                                      BTN_ITEM_IMG  \n";
                sQuery += "FROM POSMST..MST_CARD_CMP  \n";
                sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'  \n";
                sQuery += "   AND TERM_DIV = '" + sCardDiv + "' \n";           // 카드사구분 (N:일반, S:샨더, U:은련)
                sQuery += "   AND TERM_RTN_NO = '" + sBankNo + "' \n";
                sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "' \n";
                sQuery += " ORDER BY CMP_CD, CARD_CMP_CD \n";

                // 쿼리 로그, Rhee
                //if (m_cPosStatus.Base.CmpCd.ToUpper().Equals("PCCN"))
                //{
                //    UserLog.WriteLogFile(UserCom.LOG_OP, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                //                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "@@SeletCardCmpNm1=" + sQuery);

                //}

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion
        //#20170704 중국 단말기 승인 카드사 조회 end

        //#Rhee,20170830 중국 단말기 승인 카드사 조회2 start
        #region 카드 매입사 조회2
        /// <summary>
        /// 카드사 매입사 조회
        /// </summary>
        /// <param name="sCardDiv"></param>
        /// <param name="sBankNo"></param>
        /// <param name="sCardType"></param>
        /// <returns></returns>
        public DataTable SeletCardCmpNm(string sCardDiv, string sBankNo, string sCardType)
        {
            string sQuery = "";
            try
            {
                // 카드사 매입사 조회
                sQuery += " SELECT TOP 1 \n";
                sQuery += " SEQ, CMP_CD, STOR_CD, BRAND_CD, CARD_CMP_CD, CARD_CMP_NM, TERM_DIV, GRP_CD, BACKGR_COLOR, FONT_SIZE, BTN_SIZE, BTN_ITEM_IMG \n";
                sQuery += " FROM ( \n";

                sQuery += " SELECT TOP 1 \n";
                sQuery += "         ROW_NUMBER() OVER( ORDER BY CARD_CMP_CD)                SEQ  \n";
                sQuery += " 	,	CMP_CD                                                  CMP_CD  \n";
                sQuery += " 	,	'" + m_cPosStatus.Base.StoreNo + "'                     STOR_CD  \n";
                sQuery += " 	,	SALES_ORG_CD                                            BRAND_CD  \n";
                sQuery += " 	,	ISNULL(CARD_CMP_CD, '')                                 CARD_CMP_CD  \n";
                sQuery += " 	,	ISNULL(CARD_CMP_NM, '')                                 CARD_CMP_NM  \n";
                sQuery += " 	,	ISNULL(TERM_DIV, '')							        TERM_DIV \n";
                sQuery += " 	,	ISNULL(GRP_CD, '')					                    GRP_CD \n";
                sQuery += " 	,	'WHITE'                                                 BACKGR_COLOR  \n";
                sQuery += " 	,	'10'                                                    FONT_SIZE  \n";
                sQuery += " 	,	'0'                                                     BTN_SIZE  \n";
                sQuery += " 	,	''                                                      BTN_ITEM_IMG  \n";
                sQuery += " 	,	'A'                                                     TMPSORT \n";
                sQuery += "FROM POSMST..MST_CARD_CMP WITH(NOLOCK)  \n";
                sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'  \n";
                sQuery += "   AND TERM_DIV = '" + sCardDiv + "' \n";           // 카드사구분 (N:일반, S:샨더, U:은련)
                sQuery += "   AND TERM_RTN_NO = '" + sBankNo + "' \n";               
                sQuery += "   AND TERM_RTN_NO <> '' \n";
                sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "' \n";

                sQuery += " UNION \n";

                sQuery += " SELECT TOP 1 \n";
                sQuery += "         ROW_NUMBER() OVER( ORDER BY CARD_CMP_CD)                SEQ  \n";
                sQuery += " 	,	CMP_CD                                                  CMP_CD  \n";
                sQuery += " 	,	'" + m_cPosStatus.Base.StoreNo + "'                     STOR_CD  \n";
                sQuery += " 	,	SALES_ORG_CD                                            BRAND_CD  \n";
                sQuery += " 	,	ISNULL(CARD_CMP_CD, '')                                 CARD_CMP_CD  \n";
                sQuery += " 	,	ISNULL(CARD_CMP_NM, '')                                 CARD_CMP_NM  \n";
                sQuery += " 	,	ISNULL(TERM_DIV, '')							        TERM_DIV \n";
                sQuery += " 	,	ISNULL(GRP_CD, '')					                    GRP_CD \n";
                sQuery += " 	,	'WHITE'                                                 BACKGR_COLOR  \n";
                sQuery += " 	,	'10'                                                    FONT_SIZE  \n";
                sQuery += " 	,	'0'                                                     BTN_SIZE  \n";
                sQuery += " 	,	''                                                      BTN_ITEM_IMG  \n";
                sQuery += " 	,	'B'                                                     TMPSORT \n";
                sQuery += "FROM POSMST..MST_CARD_CMP WITH(NOLOCK)  \n";
                sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'  \n";
                sQuery += "   AND TERM_DIV = '" + sCardDiv + "' \n";           // 카드사구분 (N:일반, S:샨더, U:은련)
                sQuery += "   AND GRP_CD = '" + sCardType + "' \n";
                sQuery += "   AND GRP_CD <> '' \n";
                sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "' \n";
                
                sQuery += " ) AA ORDER BY TMPSORT, SEQ \n";

                // 쿼리 로그, Rhee
                if (m_cPosStatus.Base.CmpCd.ToUpper().Equals("PCCN"))
                {
                    UserLog.WriteLogFile(UserCom.LOG_OP, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "@@SeletCardCmpNm2=" + sQuery);
                }

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        #endregion
        //#Rhee,20170830 중국 단말기 승인 카드사 조회2 start


        //2017-06-02 dkshin 해피앱 추후적립
        public string ExecutePosHPAPPIrt(string sMsgType, string sSvrIP, int nSvrPort, int nTimeout, Hashtable htSendData, ref Hashtable htRecvData)
        {
            string sRet = UserCom.RST_ERR;

            try
            {
                string sCommHead = ItemColumn.MakeCommHeader(0, sMsgType);        // 통신해더 생성


                string sSysYmd = DateTime.Now.ToString("yyyyMMdd");
                string sSysHms = DateTime.Now.ToString("HHmmss");
                //string sCommHeader = this.MakeCommHeader(htSendData.Count, sMsgType, PosConst.ENCRYPT_MODE.ENC_ON, m_cPosStatus.Base.CmpCd, m_cPosStatus.Base.BrandCd, m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.SaleDate, m_cPosStatus.Base.PosNo, m_cPosStatus.Base.TradeNo, sSysYmd, sSysHms);

                //if (bVisibleMode == false)
                {
                    // 팝업 화면 미표시
                    m_bIRTComplete = true;
                    m_htRecvData = null;

                    Thread thrSecondDisp = new Thread(() => sRet = OnNetworkIRT(sSvrIP, nSvrPort, nTimeout, sCommHead, htSendData));
                    thrSecondDisp.Start();

                    while (m_bIRTComplete == true)
                    {
                        Thread.Sleep(100);
                    }

                }

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

        //#2017/08/10 중국 선불카드 MST_ITEM 생성 start
        #region 선불카드 MST_ITEM 생성
        /// <summary>
        /// 선불카드 MST_ITEM 생성
        /// </summary>
        /// Rhee, 2017/08/10
        public void PrecardSaveToMstItem()
        {
            string sSQL = string.Empty;

            try
            {                
                sSQL = " DELETE FROM POSMST.dbo.MST_ITEM WHERE 1=1 ";
                sSQL += " AND CMP_CD        ='" + m_cPosStatus.Base.CmpCd + "'";
                sSQL += " AND STOR_CD       ='" + m_cPosStatus.Base.StoreNo + "'";
                sSQL += " AND ITEM_TYPE     ='13'";
                sSQL += " AND LEN(item_cd)  = 2 ;";

                sSQL += " UPDATE POSMST.dbo.MST_ITEM SET use_yn = '0' WHERE 1=1";
                sSQL += " AND CMP_CD        ='" + m_cPosStatus.Base.CmpCd + "'";
                sSQL += " AND STOR_CD       ='" + m_cPosStatus.Base.StoreNo + "'";
                sSQL += " AND ITEM_TYPE     ='13'";
                sSQL += " AND USE_YN        = '1' ;";

                sSQL += " INSERT INTO POSMST.dbo.MST_ITEM ( ";
                sSQL += " CMP_CD";
                sSQL += " , STOR_CD";
                sSQL += " , SUB_STOR_CD";
                sSQL += " , ITEM_CD";
                sSQL += " , L_CLSS";
                sSQL += " , M_CLSS";
                sSQL += " , S_CLSS";
                sSQL += " , FLAVOUR_DIV";
                sSQL += " , FLAVOUR_QTY";
                sSQL += " , FLAVOUR_STOCK";
                sSQL += " , SHTCUT_ITEMNM";
                sSQL += " , ITEM_NM";
                sSQL += " , TAKE_IN_SALE_AMT";
                sSQL += " , TAKE_OUT_SALE_AMT";
                sSQL += " , IF_MENU1";
                sSQL += " , IF_MENU2";
                sSQL += " , OPEN_ITEM_DIV";
                sSQL += " , DISPO_ITEM_DIV";
                sSQL += " , SUB_SET_MNG_TYPE";
                sSQL += " , ITEM_TAX_AMT_DIV";
                sSQL += " , TAKE_IN_VAT_CD";
                sSQL += " , TAKE_OUT_VAT_CD";
                sSQL += " , ITEM_COST";
                sSQL += " , SALE_PRMT_YN";
                sSQL += " , SALE_NOQ";
                sSQL += " , FREE_GIFT_YN";
                sSQL += " , DC_PRMT_YN";
                sSQL += " , ACCUM_PRMT_YN";
                sSQL += " , SVC_FEE_TRGT_YN";
                sSQL += " , BTN_ITEM_IMG";
                sSQL += " , NEW_ITEM_START_DT";
                sSQL += " , NEW_ITEM_FNSH_DT";
                sSQL += " , ITEM_TYPE";
                sSQL += " , TIME_BAR_CD_YN";
                sSQL += " , DISTBT_EXPIRE_NOD";
                sSQL += " , ALCOHOL_ITEM_TYPE";
                sSQL += " , SALE_START_DT";
                sSQL += " , SALE_FNSH_DT";
                sSQL += " , COOP_CARD_DC_NOADM_YN";
                sSQL += " , CAKE_EXCHNG_CPN_USE_POSS_YN";
                sSQL += " , ITEM_INFO";
                sSQL += " , CALORY_INFO";
                sSQL += " , SALE_IMG_FILE_NM";
                sSQL += " , FILLER1";
                sSQL += " , FILLER2";
                sSQL += " , FILLER3";
                sSQL += " , FILLER4";
                sSQL += " , FILLER5";
                sSQL += " , USE_YN";
                sSQL += " , UPD_DT";
                sSQL += " , REG_DT )";

                sSQL += " SELECT ";
                sSQL += " CMP_CD";
                sSQL += " , STOR_CD";
                sSQL += " , STOR_CD AS SUB_STOR_CD";
                sSQL += " , PRECARD_ID AS ITEM_CD";
                sSQL += " , '410000' AS L_CLSS";
                sSQL += " , '411800' AS M_CLSS";
                sSQL += " , '411801' AS S_CLSS";
                sSQL += " , '0' AS FLAVOUR_DIV";
                sSQL += " , 0 AS FLAVOUR_QTY";
                sSQL += " , 0 AS FLAVOUR_STOCK";
                sSQL += " , PRECARD_SHORT_NM AS SHTCUT_ITEMNM";
                sSQL += " , PRECARD_SHORT_NM AS ITEM_NM";
                sSQL += " , PRECARD_AMT AS TAKE_IN_SALE_AMT";
                sSQL += " , PRECARD_AMT AS TAKE_OUT_SALE_AMT";
                sSQL += " , '' AS IF_MENU1";
                sSQL += " , '' AS IF_MENU2";
                sSQL += " , '0' AS OPEN_ITEM_DIV";
                sSQL += " , '0' AS DISPO_ITEM_DIV";
                sSQL += " , '0' AS SUB_SET_MNG_TYPE";
                sSQL += " , '1' AS ITEM_TAX_AMT_DIV";
                sSQL += " , 'E' AS TAKE_IN_VAT_CD";
                sSQL += " , 'E' AS TAKE_OUT_VAT_CD";
                sSQL += " , '0' AS ITEM_COST";
                sSQL += " , '1' AS SALE_PRMT_YN";
                sSQL += " , '1' AS SALE_NOQ";
                sSQL += " , '0' AS FREE_GIFT_YN";
                sSQL += " , '0' AS DC_PRMT_YN";
                sSQL += " , '1' AS ACCUM_PRMT_YN";
                sSQL += " , '0' AS SVC_FEE_TRGT_YN";
                sSQL += " , '' AS BTN_ITEM_IMG";
                sSQL += " , '' AS NEW_ITEM_START_DT";
                sSQL += " , '' AS NEW_ITEM_FNSH_DT";
                sSQL += " , '13' AS ITEM_TYPE";
                sSQL += " , '0' AS TIME_BAR_CD_YN";
                sSQL += " , '0' AS DISTBT_EXPIRE_NOD";
                sSQL += " , '0' AS ALCOHOL_ITEM_TYPE";
                sSQL += " , '20000101' AS SALE_START_DT";
                sSQL += " , '99991231' AS SALE_FNSH_DT";
                sSQL += " , '0' AS COOP_CARD_DC_NOADM_YN";
                sSQL += " , '0' AS CAKE_EXCHNG_CPN_USE_POSS_YN";
                sSQL += " , '' AS ITEM_INFO";
                sSQL += " , '' AS CALORY_INFO";
                sSQL += " , '' AS SALE_IMG_FILE_NM";
                sSQL += " , '' AS FILLER1";
                sSQL += " , '' AS FILLER2";
                sSQL += " , '' AS FILLER3";
                sSQL += " , '' AS FILLER4";
                sSQL += " , '' AS FILLER5";
                sSQL += " , '1' AS USE_YN";
                sSQL += " , CONVERT(CHAR(8), getdate(), 112)+'000000' AS UPD_DT";
                sSQL += " , CONVERT(CHAR(8), getdate(), 112)+'000000' REG_DT";
                sSQL += " FROM POSMST.dbo.MST_PRECARD WHERE 1=1";
                sSQL += " AND CMP_CD        ='" + m_cPosStatus.Base.CmpCd + "'";
                sSQL += " AND STOR_CD       ='" + m_cPosStatus.Base.StoreNo + "'";
 	            sSQL += " AND USE_YN        = '1' ;";
                

                if (sSQL != "")
                {
                    m_cSqlDbService.DBExecuteNonQuery(new string[] { sSQL });
                }


            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
        }
        #endregion
        //#2017/08/10 중국 선불카드 MST_ITEM 생성 end

        //#20170906 T페이 고도화 작업 phj, start
        #region T페이 프리픽스 체크
        /*
        public DataTable TpayPrefixCheck(string sCardNo)
        {
            string sQuery = "";
            try
            {
                sQuery += "SELECT  * ";
                sQuery += "  FROM MST_CARD_PREFIX ";
                sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "   AND SUBSTRING(PRFX_CD,1,3) = '" + sCardNo.Substring(0, 3) + "'";
                sQuery += "   AND USE_YN = '" + PosConst.MST_USE_YN.YES + "'";

                return m_cMstService.Select(new string[] { sQuery });
            }
            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 null;
        }
        */
        #endregion
        //#20170906 T페이 고도화 작업 phj, end

        //#20171120 유통기한 바코드 인식률 start, phj
        #region 유통기한 바코드 인식률
        
        public void BarCodeSuccessRate(string sBarcodeNo, string sSuccessYN)
        {
            DataTable dtSeqCnt = null;
            DataRow drSeqCnt = null;
            string sQuery = "";
            string sQry = "";
            int iSeq = 0;

            try
            {
                //grayber@20171207 BR N코드에 대하여 유통기한 바코드 인식률 대한 무시 처리 
                //grayber@20171208 BR N코드에 대하여 조건 추가 start : BR, sBarcodeNo 길이 6
                if (sBarcodeNo.Length == 6 && sBarcodeNo.StartsWith("N") == true && m_cPosStatus.Mst.CorpDiv.Equals(ItemConst.CORP_DIV.BR) == true)
                {
                    return;
                }
                //grayber@20171208 BR N코드에 대하여 조건 추가 end
                //grayber@20171207 BR N코드에 대하여 유통기한 바코드 인식률 대한 무시 처리 

                // seq 구하기. 
                sQuery = "";
                sQuery += " SELECT ISNULL(MAX(SEQ) + 1,0) AS SEQ  ";
                sQuery += "   FROM POSLOG..TR_BAR_SUCESS_RATE";
                sQuery += "  WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "    AND SALE_DT = '" + m_cPosStatus.Base.SaleDate + "'";
                sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.SubShopNo + "'";
                sQuery += "    AND POS_NO = '" + m_cPosStatus.Base.PosNo + "'";
                sQuery += "    AND REG_NO = '" + m_cPosStatus.Base.TradeNo + "'";

                //dtSeqCnt = m_cSqlDbService.DBSelect(new string[] { sQuery });
                m_cSqlDbService.DBSelect(sQuery, out dtSeqCnt);

                if (dtSeqCnt != null && dtSeqCnt.Rows.Count > 0)
                {
                    drSeqCnt = dtSeqCnt.Rows[0];
                    iSeq = Convert.ToInt32(CmUtil.GetDataRowStr(drSeqCnt, "SEQ"));
                }


                // update 하기.
                sQuery = "";
                sQuery += " INSERT INTO POSLOG..TR_BAR_SUCESS_RATE(CMP_CD,SALE_DT,STOR_CD,POS_NO,REG_NO,SEQ,BAR_CD,SUCESS_YN, SEND_YN, UPD_DATE, REG_DATE)  ";
                sQuery += " VALUES('{0}'";
                sQuery += " ,'{1}'";
                sQuery += " ,'{2}'";
                sQuery += " ,'{3}'";
                sQuery += " ,'{4}'";
                sQuery += " , {5}";
                sQuery += " ,'{6}'";
                sQuery += " ,'{7}'";
                sQuery += " ,'{8}'";
                sQuery += " ,'{9}'";
                sQuery += " ,'{10}')";

                sQry = string.Format(sQuery
                                     , m_cPosStatus.Base.CmpCd
                                     , m_cPosStatus.Base.SaleDate
                                     , m_cPosStatus.Base.SubShopNo
                                     , m_cPosStatus.Base.PosNo
                                     , m_cPosStatus.Base.TradeNo
                                     , iSeq.ToString()
                                     , sBarcodeNo
                                     , sSuccessYN
                                     , "0"
                                     , ""
                                     , DateTime.Now.ToString("yyyyMMddHHmmss"));

                m_cSqlDbService.DBExecuteNonQuery(new string[] { sQry });

            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                            System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +
                                            System.Reflection.MethodBase.GetCurrentMethod().Name +
                                            "BarCodeSuccessRate Insert Error (" + sBarcodeNo + " / " + sSuccessYN + ")",
                                            ex.Message);
            }
        }
        
        #endregion 유통기한 바코드 인식률
        //#20171120 유통기한 바코드 인식률 end, phj

        //#20171116 온라인 쿠폰 제품군코드,상품코드 존재 시 할인 대상이 변경되도록 추가 start, phj
        #region 온라인 쿠폰 조회 응답 전문의 제품군 기준 - 제품 리스트 검색
        /// <summary>
        /// 온라인 쿠폰 조회 응답 전문의 제품군의 상품 정보를 한다.
        /// </summary>
        public DataTable CpnItemDCTargetList(string CpnItemDcCode)
        {
            try
            {
                string sQry = string.Empty;

                //#20180502 온라인쿠폰 제품군, 상품코드 할인 적용 기능 적용 start
                //기존
                //sQry = " SELECT A.CMP_CD, A.ITEM_GRP_CD, B.ITEM_CD ";
                //변경
                sQry = " SELECT A.CMP_CD, A.ITEM_GRP_CD, B.ITEM_CD, A.GUBUN ";
                //#20180502 온라인쿠폰 제품군, 상품코드 할인 적용 기능 적용 end

                
                sQry += "   FROM POSMST..MST_CPN_ITEM_GRP_MNG A INNER JOIN POSMST..MST_CPN_ITEM_GRP_MNG_DTL B ";
                sQry += "   ON (A.CMP_CD = B.CMP_CD AND A.ITEM_GRP_CD = B.ITEM_GRP_CD AND A.USE_YN = B.USE_YN) ";
                sQry += "  WHERE A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQry += "    AND A.ITEM_GRP_CD = '" + CpnItemDcCode + "'";
                sQry += "    AND A.USE_YN = '" + PosConst.MST_USE_YN.YES + "'";

                sQry = sQry.Replace("\t", " ");

                return m_cMstService.Select(new string[] { sQry });
            }
            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 null;
        }
        #endregion
        //#20171116 온라인 쿠폰 제품군코드,상품코드 존재 시 할인 대상이 변경되도록 추가 end, phj 

        //#20180502 온라인쿠폰 제품군, 상품코드 할인 적용 기능 적용 start
        #region 불필요
        ////#20171116 온라인 쿠폰 제품군코드,상품코드 존재 시 할인 대상이 변경되도록 추가 start, phj
        //#region 온라인 쿠폰 조회 응답 전문의 코드가 제품군인지 상품코드인지 체크.
        ///// <summary>
        ///// 온라인 쿠폰 조회 응답 전문의 코드가 제품군인지 상품코드인지 체크.
        ///// MST_CPN_ITEM_GRP_MNG에 존재 시 제품군 코드이고 아니면 상품코드로 판단한다.
        ///// MST_ITEM에서 상품코드인지 조회하지 않는 이유는 등록 상품에 존재한다면 당연히 MST_ITEM에도 데이터가 존재하기 때문이다.
        ///// </summary>
        ////public int CpnItemDCTargetCheck(string CpnItemDcCode, ref DataTable CpnItemDt)
        //public int CpnItemDCTargetCheck(string CpnItemDcCode)
        //{
        //    int iRst = 0;
        //    string sQry = string.Empty;
        //    //string sSubQry = string.Empty;
        //
        //    DataTable dtItemGroup = null;
        //    //DataTable dtItemCd = null;
        //
        //    try
        //    {
        //        /*
        //        sQry = " SELECT * ";
        //        sQry += "   FROM POSMST..MST_CPN_ITEM_GRP_MNG A INNER JOIN POSMST..MST_CPN_ITEM_GRP_MNG_DTL B ";
        //        sQry += "   ON (A.CMP_CD = B.CMP_CD AND A.ITEM_GRP_CD = B.ITEM_GRP_CD AND A.USE_YN = B.USE_YN) ";
        //        sQry += "  WHERE A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
        //        sQry += "    AND A.ITEM_GRP_CD = '" + CpnItemDcCode + "'";
        //        sQry += "    AND A.USE_YN = '" + PosConst.MST_USE_YN.YES + "'";
        //        */
        //
        //        sQry = " SELECT * ";
        //        sQry += "   FROM POSMST..MST_CPN_ITEM_GRP_MNG";
        //        sQry += "  WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
        //        sQry += "    AND ITEM_GRP_CD = '" + CpnItemDcCode + "'";
        //        sQry += "    AND USE_YN = '" + PosConst.MST_USE_YN.YES + "'";
        //
        //        m_cSqlDbService.DBSelect(sQry, out dtItemGroup);
        //
        //        if (dtItemGroup != null && dtItemGroup.Rows.Count > 0)
        //        {
        //            //CpnItemDcCode는 제품군이다.
        //            //CpnItemDt = dtItemGroup;
        //            iRst = 1;
        //
        //        }
        //        else
        //        {
        //            /*
        //            sSubQry = " SELECT TOP 1 ITEM_CD ";
        //            sSubQry += "   FROM MST_ITEM ";
        //            sSubQry += "  WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
        //            sSubQry += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
        //            sSubQry += "    AND SUB_STOR_CD = '" + m_cPosStatus.Base.SubShopNo + "'";
        //            sSubQry += "    AND ITEM_CD = '" + CpnItemDcCode + "'";
        //            sSubQry += "    AND USE_YN = '" + PosConst.MST_USE_YN.YES + "'";
        //
        //            m_cSqlDbService.DBSelect(sSubQry, out dtItemCd);
        //
        //            if (dtItemCd != null && dtItemCd.Rows.Count > 0)
        //            {
        //                //CpnItemDcCode는 상품코드다.
        //                CpnItemDt = dtItemCd;
        //                iRst = 2; 
        //            }
        //            */
        //
        //            //CpnItemDt = null;
        //            iRst = 2;
        //        }
        //
        //        UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
        //                             System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +
        //                             System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
        //                             "CpnItemDCTargetCheck : " + iRst.ToString());
        //
        //        return iRst;
        //    }
        //    catch (Exception ex)
        //    {
        //        WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
        //            System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +
        //            System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
        //            "CpnItemDCTargetCheck Error : " + ex.Message);
        //
        //        //CpnItemDt = null;
        //        return -99;
        //    }
        //}
        //#endregion
        ////#20171116 온라인 쿠폰 제품군코드,상품코드 존재 시 할인 대상이 변경되도록 추가 end, phj  
        #endregion
        //#20180502 온라인쿠폰 제품군, 상품코드 할인 적용 기능 적용 end

        //#13341 신용카드 할부 개월 수 제한 기능 적용 start, phj
        #region 공통코드 조회하기
        public string MstCmmSearch(string pGrpCode, string pCode)
        {
            string sQry = string.Empty;
            string sResult = string.Empty;
            DataTable dtMstCmm = null;
            try
            {
                sQry = " SELECT ENTRY_NM ";
                sQry += "   FROM POSMST..MST_CMM";
                sQry += "  WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";

                if (pGrpCode != "")
                {
                    sQry += "    AND cmm_grp_cd = '" + pGrpCode + "'";
                }
                if (pCode != "")
                {
                    sQry += "    AND cmm_cd = '" + pCode + "'";
                }

                sQry += "    AND use_yn = '" + PosConst.MST_USE_YN.YES + "'";

                m_cSqlDbService.DBSelect(sQry, out dtMstCmm);

                if (dtMstCmm != null && dtMstCmm.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtMstCmm.Rows)
                    {
                        sResult = CmUtil.GetDataRowStr(dr, "ENTRY_NM");
                    }
                }
                return sResult;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +
                    System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                    "MstCmmSearch Error : " + ex.Message);

                return sResult;
            }
        }
        #endregion
        //#13341 신용카드 할부 개월 수 제한 기능 적용 end, phj


        //#20180322 휴게소pos매출연동 start,phj
        #region 도로공사 매출 연동
        //public string SaveRoadJson(string sType, string sFilePath, string sData)
        //{
        //    string sRet = UserCom.RST_ERR;
        //    //string sPath = string.Empty;
        //
        //    try
        //    {
        //        // 해당 경로에 해당 하는 폴더가 없으면 만들어 줌 
        //        if (Directory.Exists(sFilePath) == false)
        //        {
        //            //DirectoryInfo di = new DirectoryInfo(sFilePath);
        //            //if (!di.Exists)
        //            //{
        //            //    di.Create();
        //            //}
        //            Directory.CreateDirectory(sFilePath);
        //        }
        //
        //        /*
        //        switch (sType)
        //        {
        //            case ItemConst.ROAD_SAVE_TYPE.SALE:
        //                sPath = m_cPosStatus.RestAreaPos.RestAreaPosDir; //m_cPosStatus.Mst.ETC_IF_FTP_PATH;
        //                break;
        //            case ItemConst.ROAD_SAVE_TYPE.CLOSING:
        //                sPath = m_cPosStatus.RestAreaPos.RestAreaPosDir; //m_cPosStatus.Mst.ETC_IF_FTP_PATH;
        //                break;
        //            default:
        //                sPath = m_cPosStatus.RestAreaPos.RestAreaPosDir; //m_cPosStatus.Mst.ETC_IF_FTP_PATH; 
        //                break;
        //        }
        //        */
        //
        //        if (ItemConst.ROAD_SAVE_TYPE.SALE.Equals(sType) || ItemConst.ROAD_SAVE_TYPE.CLOSING.Equals(sType))
        //        {
        //            sRet = m_cNetJSONService.SaveJsonFile(sType, sFilePath, sData);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        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 + "()",
        //                    string.Format("{0}", ex.ToString()));
        //    }
        //
        //    return sRet;
        //}
        public string HashToJsonString(Hashtable htData, ref string sJsonData)
        {
            return m_cNetJSONService.HashToJsonString(htData, ref sJsonData);
        }
        #endregion
        //#20180322 휴게소pos매출연동 end,phj

        //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 start, 20180528
        //쿠폰 발송 횟수 제한 기능
        
        #region 쿠폰 발송 횟수 조회
        public string CpnSendCntSearch()
        {
            string sQry = string.Empty;
            string sResult = "0";
            DataTable dtCpnSendCnt = null;
            try
            {
                sQry = " SELECT SUM(A.CPN_SEND_CNT) AS CPN_SEND_CNT ";
                sQry += "  FROM ( ";
                sQry += "       SELECT COUNT(*) CPN_SEND_CNT ";
                sQry += "         FROM POSLOG..TR_SALE_ETC ";
                sQry += "        WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQry += "          AND SALE_DT = '" + m_cPosStatus.Base.SaleDate + "'";
                sQry += "          AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                sQry += "          AND POS_NO = '" + m_cPosStatus.Base.PosNo + "'";
                sQry += "          AND ETC_WAY_CD = '80' ";
                sQry += "          AND ETC_DTL_CD_01 = '09' ";
                sQry += "          AND CANCEL_DIV = '0' ";
                sQry += "        UNION ALL ";
                sQry += "       SELECT COUNT(*) CPN_SEND_CNT ";
                sQry += "         FROM POSLOG..ETC_SALE_ETC ";
                sQry += "        WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQry += "          AND SALE_DT = '" + m_cPosStatus.Base.SaleDate + "'";
                sQry += "          AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                sQry += "          AND POS_NO = '" + m_cPosStatus.Base.PosNo + "'";
                sQry += "          AND ETC_WAY_CD = '80' ";
                sQry += "          AND ETC_DTL_CD_01 = '09' ";
                sQry += "          AND CANCEL_DIV = '0' ";
                sQry += "       ) AS A ";

                m_cSqlDbService.DBSelect(sQry, out dtCpnSendCnt);

                if (dtCpnSendCnt != null && dtCpnSendCnt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtCpnSendCnt.Rows)
                    {
                        sResult = CmUtil.GetDataRowStr(dr, "CPN_SEND_CNT");
                    }
                }
                return sResult;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +
                    System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                    "CpnSendCntSearch Error : " + ex.Message);

                return sResult;
            }
        }
        #endregion
        
        //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 end, 20180528

        //#15897 요청)점포생산제품 바코드 출력기능 수정요청 start
        #region 바코드 라벨 프린터 관련 수정
        
        private string LabelBarCodeCheck(string bdate)
        {
            string sRet = string.Empty;
            string sumEndstr = string.Empty;
            int sum, i, sumLen = 0;
            int[] num = { 1, 3, 9 };
            int[] dnum = new int[9];

            try
            {
                if (bdate == "") return sRet;

                dnum[0] = int.Parse(CmUtil.MidH(bdate, 0, 1)) * num[0];
                dnum[1] = int.Parse(CmUtil.MidH(bdate, 1, 1)) * num[1];
                dnum[2] = int.Parse(CmUtil.MidH(bdate, 2, 1)) * num[2];
                dnum[3] = int.Parse(CmUtil.MidH(bdate, 3, 1)) * num[0];
                dnum[4] = int.Parse(CmUtil.MidH(bdate, 4, 1)) * num[1];
                dnum[5] = int.Parse(CmUtil.MidH(bdate, 5, 1)) * num[2];
                dnum[6] = int.Parse(CmUtil.MidH(bdate, 6, 1)) * num[0];
                dnum[7] = int.Parse(CmUtil.MidH(bdate, 7, 1)) * num[1];
                dnum[8] = int.Parse(CmUtil.MidH(bdate, 8, 1)) * num[2];

                sum = 0;
                for (i = 0; i <= 8; i++)
                {
                    sum = sum + dnum[i];
                }

                sumEndstr = sum.ToString();
                sumLen = sumEndstr.Length;
                sumEndstr = sumEndstr.Substring(sumLen - 1, 1);

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

            }
            return sRet;
        }
        
        #endregion 바코드 라벨 프린터 관련 수정
        //#15897 요청)점포생산제품 바코드 출력기능 수정요청 end

        //#20180821 해피포인트 고객이름 마스킹 start
        public string NameMasking(string sName)
        {
            string sRet = "";
            try
            {
                if (sName.IndexOf("*") <= 0)
                {
                    sRet = sName.Substring(0, 1) + "*" + sName.Substring(2, sName.Length - 2);
                }
                else
                {
                    sRet = sName;
                }                    
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                            System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +
                                            System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                            "NameMasking Error [" + sName + "] : " + ex.Message);
            }
            return sRet;
        }
        //#20180821 해피포인트 고객이름 마스킹 end

        //#16577 결제창 내부 봉투 추가 기능 도입 start, 20180920
        #region 공통코드 봉투상품 조회(T0042)
        /// <summary>
        /// 공통코드 봉투상품 조회(T0042)
        /// </summary>
        /// <returns></returns>
        public DataTable ChkAddBagMstCmm()
        {
            string sSql = "";

            try
            {
                sSql = "";
                sSql += " SELECT * ";
                sSql += "   FROM POSMST..MST_CMM ";
                sSql += "  WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sSql += "    AND CMM_GRP_CD = 'T0042'";
                sSql += "    AND SALES_ORG_CD = '" + m_cPosStatus.Base.BrandCd + "'";
                sSql += "    AND USE_YN = '" + PosConst.MST_USE_YN.YES + "'";

                DataTable dtDataInfo = m_cMstService.Select(new string[] { sSql });

                return dtDataInfo;
            }
            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 null;
        }

        #endregion 공통코드 봉투상품 조회(T0042)
        //#16577 결제창 내부 봉투 추가 기능 도입 end, 20180920

        //#20181016 메모리 사용량 로그남기기 start
        #region PC 메모리 로그
        /// <summary>
        /// PC 메모리 로그 
        /// </summary>
        /// <returns></returns>
        public void MemoryCheckLog()
        {
            try
            {
                // 프로세스 이름
                string sProcessName = System.Diagnostics.Process.GetCurrentProcess().ProcessName;

                // 총 메모리 양 
                //#20181016 메모리 사용량 로그남기기 start, 20181029
                //가상메모리 제거
                //long tot_Virtualmem64 = 0;// 연결된 프로세스에 할당된 가상 메모리의 양 
                //int tot_Virtualmem32 = 0;// 연결된 프로세스에 할당된 가상 메모리의 양 
                //#20181016 메모리 사용량 로그남기기 end, 20181029
                float tot_real_mem64 = 0;// 연결된 프로세스의 실제 메모리 사용량
                float tot_real_mem32 = 0;// 연결된 프로세스의 실제 메모리 사용량

                // 판매포스 총 메모리 양 
                //#20181016 메모리 사용량 로그남기기 start, 20181029
                //가상메모리 제거
                //long pos_Virtualmem64 = 0;// 연결된 프로세스에 할당된 가상 메모리의 양 
                //int pos_Virtualmem32 = 0;// 연결된 프로세스에 할당된 가상 메모리의 양 
                //#20181016 메모리 사용량 로그남기기 end, 20181029
                float pos_real_mem64 = 0;// 연결된 프로세스의 실제 메모리 사용량
                float pos_real_mem32 = 0;// 연결된 프로세스의 실제 메모리 사용량

                System.Diagnostics.Process[] allPro = System.Diagnostics.Process.GetProcesses();
                foreach (System.Diagnostics.Process pro in allPro)
                {
                    // 연결된 프로세스에 할당된 가상 메모리 양 
                    //#20181016 메모리 사용량 로그남기기 start, 20181029
                    //가상메모리 제거
                    //tot_Virtualmem64 += pro.VirtualMemorySize64;
                    //tot_Virtualmem32 += pro.VirtualMemorySize;
                    //#20181016 메모리 사용량 로그남기기 end, 20181029
                    // 연결된 프로세스의 실제 가상 메모리 사용량
                    tot_real_mem64 += pro.WorkingSet64;
                    tot_real_mem32 += pro.WorkingSet;

                    // 포스에서 사용중인 메모리
                    if (sProcessName == pro.ProcessName)
                    {
                        // 연결된 프로세스에 할당된 메모리 양 
                        //#20181016 메모리 사용량 로그남기기 start, 20181029
                        //가상메모리 제거
                        //pos_Virtualmem64 += pro.VirtualMemorySize64;
                        //pos_Virtualmem32 += pro.VirtualMemorySize;
                        //#20181016 메모리 사용량 로그남기기 end, 20181029
                        // 연결된 프로세스의 실제 메모리 사용량
                        pos_real_mem64 += pro.WorkingSet64;
                        pos_real_mem32 += pro.WorkingSet;
                    }
                }

                //#20181016 메모리 사용량 로그남기기 start, 20181029
                //가상메모리 제거
                tot_real_mem64 = ((float)(tot_real_mem64) / (float)(1024)) / (float)(1024);
                tot_real_mem32 = ((float)(tot_real_mem32) / (float)(1024)) / (float)(1024);
                pos_real_mem64 = ((float)(pos_real_mem64) / (float)(1024)) / (float)(1024);
                pos_real_mem32 = ((float)(pos_real_mem32) / (float)(1024)) / (float)(1024);
                //#20181016 메모리 사용량 로그남기기 end, 20181029

                // 사용 가능한 메모리 (MB)
                // Available MBytes는 컴퓨터에서 실행되는 프로세스에 할당하거나 시스템에서 사용할 수 있는 실제 메모리의 양(메가바이트)입니다. 
                // 이것은 대기 중이거나 비어 있거나 0으로 채워진 페이지 목록에 할당된 메모리의 총계입니다.
                float Available_mem = 0;
                System.Diagnostics.PerformanceCounter Memory_Available_MBytes = new System.Diagnostics.PerformanceCounter("Memory", "Available MBytes", null);
                Available_mem = (float)Memory_Available_MBytes.NextValue(); /// 1024;                
                Memory_Available_MBytes.Close();
                Memory_Available_MBytes.Dispose();

                // PosMain.vshost 사용 중 메모리 (MB)
                // Working Set - Private는 다른 프로세서가 공유하거나 공유할 수 있는 작업 집합이 아니라 이 프로세서만 사용하고 있는 작업 집합의 크기(바이트)입니다.
                float pos_use_mem = 0; // byte
                System.Diagnostics.Process proc = System.Diagnostics.Process.GetCurrentProcess();
                System.Diagnostics.PerformanceCounter PC = new System.Diagnostics.PerformanceCounter();
                PC.CategoryName = "Process";
                PC.CounterName = "Working Set - Private";
                PC.InstanceName = proc.ProcessName;
                pos_use_mem = ((float)(PC.NextValue()) / (float)(1024)) / (float)(1024);
                PC.Close();
                PC.Dispose();


                UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                    //#20181016 메모리 사용량 로그남기기 start, 20181029
                                    //가상메모리 제거
                                     //"▷ 연결된 프로세스에 할당된 가상 메모리의 양 (64) :" + tot_Virtualmem64 + " Mbytes" +
                                     //"▷ 연결된 프로세스에 할당된 가상 메모리의 양 (32) :" + tot_Virtualmem32 + " Mbytes" +
                                    //#20181016 메모리 사용량 로그남기기 end, 20181029
                                     "▷ 연결된 프로세스의 실제 메모리 사용량 (64) :" + tot_real_mem64 + " Mbytes" +
                                     "▷ 연결된 프로세스의 실제 메모리 사용량 (32) :" + tot_real_mem32 + " Mbytes");

                UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                    //#20181016 메모리 사용량 로그남기기 start, 20181029
                                    //가상메모리 제거
                                     //"▷ 판매POS 연결된 프로세스에 할당된 가상 메모리의 양 (64) :" + pos_Virtualmem64 + " Mbytes" +
                                     //"▷ 판매POS 연결된 프로세스에 할당된 가상 메모리의 양 (32) :" + pos_Virtualmem32 + " Mbytes" +
                                    //#20181016 메모리 사용량 로그남기기 end, 20181029
                                     "▷ 판매POS 연결된 프로세스의 실제 메모리 사용량 (64) :" + pos_real_mem64 + " Mbytes" +
                                     "▷ 판매POS 연결된 프로세스의 실제 메모리 사용량 (32) :" + pos_real_mem32 + " Mbytes");

                UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                     "▷ 실제 사용 가능한 메모리 : " + Available_mem + " Mbytes" +
                                     "▷ PosMain.vshost 사용 중 메모리 : " + pos_use_mem + " Mbytes");

                #region 참고!!!
                /*                 
                PerformanceCounter Memory_Available_MBytes = new PerformanceCounter("Memory", "Available MBytes", null);
                float iMemory_Available_MBytes = (float)Memory_Available_MBytes.NextValue();
                PerformanceCounter Memory_Commit_Limit = new PerformanceCounter("Memory", "Commit Limit", null);
                float iMemory_Commit_Limit = (float)Memory_Commit_Limit.NextValue();
                PerformanceCounter Memory_Committed_Bytes = new PerformanceCounter("Memory", "Committed Bytes", null);
                float iMemory_Committed_Bytes = (float)Memory_Committed_Bytes.NextValue();
                PerformanceCounter Committed_Bytes_In_Use = new PerformanceCounter("Memory", "% Committed Bytes In Use", null);
                float iCommitted_Bytes_In_Use = (float)Committed_Bytes_In_Use.NextValue();
                PerformanceCounter Memory_Pool_Paged_Bytes = new PerformanceCounter("Memory", "Pool Paged Bytes", null);
                float iMemory_Pool_Paged_Bytes = (float)Memory_Pool_Paged_Bytes.NextValue();
                PerformanceCounter Memory_Pool_Nonpaged_Bytes = new PerformanceCounter("Memory", "Pool Nonpaged Bytes", null);
                float iMemory_Pool_Nonpaged_Bytes = (float)Memory_Pool_Nonpaged_Bytes.NextValue();
                PerformanceCounter Memory_Cache_Bytes = new PerformanceCounter("Memory", "Cache Bytes", null);
                float iMemory_Cache_Bytes = (float)Memory_Cache_Bytes.NextValue();

                PerformanceCounter Process_HandleCnt = new PerformanceCounter("Process", "Handle Count", "_Total");
                float iProcess_HandleCnt = (float)Process_HandleCnt.NextValue();
                PerformanceCounter Process_ThreadCnt = new PerformanceCounter("Process", "Thread Count", "_Total");
                float iProcess_ThreadCnt = (float)Process_ThreadCnt.NextValue();
                PerformanceCounter Working_Set = new PerformanceCounter("Process", "Working Set", sProcessName);
                float iWorking_Set = (float)Working_Set.NextValue();
                PerformanceCounter Process_ProcessorTime = new PerformanceCounter("Process", "% Processor Time", sProcessName, true);
                float iProcess_ProcessorTime = (float)Process_ProcessorTime.NextValue();

                PerformanceCounter Processor_Processor_Time = new PerformanceCounter("Processor", "% Processor Time", "_Total");
                float iProcessor_Processor_Time = (float)Processor_Processor_Time.NextValue();
                PerformanceCounter Processor_Privileged_Time = new PerformanceCounter("Processor", "% Privileged Time", "_Total");
                float iProcessor_Privileged_Time = (float)Processor_Privileged_Time.NextValue();
                PerformanceCounter Processor_Interrupt_Time = new PerformanceCounter("Processor", "% Interrupt Time", "_Total");
                float iProcessor_Interrupt_Time = (float)Processor_Interrupt_Time.NextValue();
                PerformanceCounter Processor_DPC_Time = new PerformanceCounter("Processor", "% DPC Time", "_Total");
                float iProcessor_DPC_Time = (float)Processor_DPC_Time.NextValue();

                PerformanceCounter PhysicalDisk_AvgQueueLength = new PerformanceCounter("PhysicalDisk", "Avg. Disk Queue Length", "_Total");
                float iPhysicalDisk_AvgQueueLength = (float)PhysicalDisk_AvgQueueLength.NextValue();
                PerformanceCounter PhysicalDisk_Disk_Read = new PerformanceCounter("PhysicalDisk", "Disk Read Bytes/sec", "_Total");
                float iPhysicalDisk_Disk_Read = (float)PhysicalDisk_Disk_Read.NextValue();
                PerformanceCounter PhysicalDisk_Disk_Write = new PerformanceCounter("PhysicalDisk", "Disk Write Bytes/sec", "_Total");
                float iPhysicalDisk_Disk_Write = (float)PhysicalDisk_Disk_Write.NextValue();
                PerformanceCounter PhysicalDisk_AvgRead_sec = new PerformanceCounter("PhysicalDisk", "Avg. Disk sec/Read", "_Total");
                float iPhysicalDisk_AvgRead_sec = (float)PhysicalDisk_AvgRead_sec.NextValue();
                PerformanceCounter PhysicalDisk_AvgWrite_sec = new PerformanceCounter("PhysicalDisk", "Avg. Disk sec/Write", "_Total");
                float iPhysicalDisk_AvgWrite_sec = (float)PhysicalDisk_AvgWrite_sec.NextValue();
                PerformanceCounter PhysicalDisk_DiskTime = new PerformanceCounter("PhysicalDisk", "% Disk Time", "_Total");
                float iPhysicalDisk_DiskTime = (float)PhysicalDisk_DiskTime.NextValue();

                PerformanceCounter System_Context_Switches = new PerformanceCounter("System", "Context Switches/sec", null);
                float iSystem_Context_Switches = (float)System_Context_Switches.NextValue();
                PerformanceCounter System_System_Call = new PerformanceCounter("System", "System Calls/sec", null);
                float iSystem_System_Call = (float)System_System_Call.NextValue();
                PerformanceCounter System_Processor_Queue_Length = new PerformanceCounter("System", "Processor Queue Length", null);
                float iSystem_Processor_Queue_Length = (float)System_Processor_Queue_Length.NextValue();

                PerformanceCounter Paging_Usage = new PerformanceCounter("Paging File", "% Usage", "_Total");
                float iPaging_Usage = (float)Paging_Usage.NextValue();
                */
                #endregion
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                            System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +
                                            System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                            ex.Message);
            }
        }

        #endregion 공통코드 봉투상품 조회(T0042)
        //#20181016 메모리 사용량 로그남기기 end



        #region Kiosk 조회 =========================================================================================
        /// <summary>
        /// 2019-03-04 - 1997fx11 : 01.NHS_SCREEN
        /// </summary>
        /// <param name="sScreenCD"></param>
        /// <returns></returns>
        public DataTable Select_NHS_SCREEN(string sScreenCD = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[STOR_CD],[A].[SCREEN_CD]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[STOR_CD] ");
                sbQuery.Append(",[A].[SCREEN_CD] ");
                sbQuery.Append(",[A].[LAYOUT_CD] ");
                sbQuery.Append(",[A].[SCREEN_NM] ");
                sbQuery.Append(",[A].[SCREEN_DESC] ");
                sbQuery.Append(",[A].[DISPLAY_YN] ");
                sbQuery.Append(",[A].[DISPLAY_START_DT] ");
                sbQuery.Append(",[A].[DISPLAY_END_DT] ");
                sbQuery.Append(",[A].[REG_USER_ID] ");
                sbQuery.Append(",[A].[REG_DATE] ");
                sbQuery.Append(",[A].[UPD_USER_ID] ");
                sbQuery.Append(",[A].[UPD_DATE] ");
                sbQuery.Append("FROM POSMST..NHS_SCREEN AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                sbQuery.AppendFormat("AND [A].[STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);
                         sbQuery.Append("AND [A].[DISPLAY_YN] = 1 ");
                if (!string.IsNullOrEmpty(sScreenCD)) { sbQuery.AppendFormat("AND [A].[SCREEN_CD] = '{0}' ", sScreenCD); }
                sbQuery.Append("ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[STOR_CD],[A].[SCREEN_CD] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }


        /// <summary>
        /// 2019-03-04 - 1997fx11 : 02.NHS_SCREEN_CONTENTS
        /// </summary>
        /// <param name="sScreenCD"></param>
        /// <param name="sFrameCD"></param>
        /// <param name="sLayerCD"></param>
        /// <param name="sContentsID"></param>
        /// <returns></returns>
        public DataTable Select_NHS_SCREEN_CONTENTS(string sScreenCD, string sFrameCD = null, string sLayerCD = null, string sContentsID = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[STOR_CD],[A].[LAYER_CD],[A].[CONTENTS_ID]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[STOR_CD] ");
                sbQuery.Append(",[A].[LAYER_CD] ");
                sbQuery.Append(",[A].[CONTENTS_ID] ");
                sbQuery.Append(",[A].[SCREEN_CD] ");
                sbQuery.Append(",[A].[FRAME_CD] ");
                sbQuery.Append(",[A].[DISPLAY_ORDER] ");
                sbQuery.Append(",[A].[DISPLAY_START_TIME] ");
                sbQuery.Append(",[A].[DISPLAY_END_TIME] ");
                sbQuery.Append(",[A].[FILE_FULLPATH] ");
                sbQuery.Append(",[A].[FILE_NAME] ");
                sbQuery.Append(",[A].[FILE_MIME_TYPE] ");
                sbQuery.Append(",[A].[PLAY_TIME] ");
                sbQuery.Append(",[A].[LINK_YN] ");
                sbQuery.Append(",[A].[PRD_CATE_L] ");
                sbQuery.Append(",[A].[PRD_CATE_M] ");
                sbQuery.Append(",[A].[REG_USER_ID] ");
                sbQuery.Append(",[A].[REG_DATE] ");
                sbQuery.Append(",[A].[UPD_USER_ID] ");
                sbQuery.Append(",[A].[UPD_DATE] ");
                sbQuery.Append("FROM POSMST..NHS_SCREEN_CONTENTS AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                sbQuery.AppendFormat("AND [A].[STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);
                sbQuery.AppendFormat("AND [A].[SCREEN_CD] = '{0}' ", sScreenCD);
                if (!string.IsNullOrEmpty(sFrameCD)) { sbQuery.AppendFormat("AND [A].[FRAME_CD] = '{0}' ", sFrameCD); }
                if (!string.IsNullOrEmpty(sLayerCD)) { sbQuery.AppendFormat("AND [A].[LAYER_CD] = '{0}' ", sLayerCD); }
                if (!string.IsNullOrEmpty(sContentsID)) { sbQuery.AppendFormat("AND [A].[CONTENTS_ID] = '{0}' ", sContentsID); }
                sbQuery.Append("ORDER BY [A].[DISPLAY_ORDER] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }


        /// <summary>
        /// 2019-03-04 - 1997fx11 : 03.NHS_SCREEN_LAYER
        /// </summary>
        /// <param name="sScreenCD"></param>
        /// <param name="sFrameCD"></param>
        /// <param name="sLayerCD"></param>
        /// <returns></returns>
        public DataTable Select_NHS_SCREEN_LAYER(string sScreenCD, string sFrameCD = null, string sLayerCD = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[STOR_CD],[A].[FRAME_CD],[A].[LAYER_CD]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[STOR_CD] ");
                sbQuery.Append(",[A].[FRAME_CD] ");
                sbQuery.Append(",[A].[LAYER_CD] ");
                sbQuery.Append(",[A].[SCREEN_CD] ");
                sbQuery.Append(",[A].[FRAME_VERTICAL_SIZE] ");
                sbQuery.Append(",[A].[LAYER_DISPLAY_ORDER] ");
                sbQuery.Append(",[A].[FIX_YN] ");
                sbQuery.Append(",[A].[REG_USER_ID] ");
                sbQuery.Append(",[A].[REG_DATE] ");
                sbQuery.Append(",[A].[UPD_USER_ID] ");
                sbQuery.Append(",[A].[UPD_DATE] ");
                sbQuery.Append("FROM POSMST..NHS_SCREEN_LAYER AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                sbQuery.AppendFormat("AND [A].[STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);
                sbQuery.AppendFormat("AND [A].[SCREEN_CD] = '{0}' ", sScreenCD);
                if (!string.IsNullOrEmpty(sFrameCD)) { sbQuery.AppendFormat("AND [A].[FRAME_CD] = '{0}' ", sFrameCD); }
                if (!string.IsNullOrEmpty(sLayerCD)) { sbQuery.AppendFormat("AND [A].[LAYER_CD] = '{0}' ", sLayerCD); }
                sbQuery.Append("ORDER BY [A].[LAYER_DISPLAY_ORDER] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }


        /// <summary>
        /// 2019-03-04 - 1997fx11 : 03.Select_NHS_SCREEN_LAYER_GROUPBY_FRAMECD
        /// </summary>
        /// <param name="sScreenCD"></param>
        /// <param name="sFrameCD"></param>
        /// <returns></returns>
        public DataTable Select_NHS_SCREEN_LAYER_GROUPBY_FRAMECD(string sScreenCD, string sFrameCD = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[FRAME_CD]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[FRAME_CD] ");
                sbQuery.Append("FROM POSMST..NHS_SCREEN_LAYER AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                sbQuery.AppendFormat("AND [A].[STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);
                sbQuery.AppendFormat("AND [A].[SCREEN_CD] = '{0}' ", sScreenCD);
                if (!string.IsNullOrEmpty(sFrameCD)) { sbQuery.AppendFormat("AND [A].[FRAME_CD] = '{0}' ", sFrameCD); }
                sbQuery.Append("GROUP BY [A].[FRAME_CD] ");
                sbQuery.Append("ORDER BY [A].[FRAME_CD] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            catch
            {
                return null;
            }
        }


        /*
        /// <summary>
        /// 2019-03-04 - 1997fx11 : 04.NHS_STOR_PRD_CATE
        /// </summary>
        /// <param name="sPrdCateUpCD"></param>
        /// <param name="sPrdCateCD"></param>
        /// 2019-03-11 - 1997fx11 : 'Select_NHS_STOR_PRD_CATE' 삭제
        /// <returns></returns>
        public DataTable Select_NHS_STOR_PRD_CATE(string sPrdCateUpCD = null, string sPrdCateCD = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[STOR_CD],[A].[PRD_CATE_UP_CD],[A].[PRD_CATE_CD]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[STOR_CD] ");
                sbQuery.Append(",[A].[PRD_CATE_UP_CD] ");
                sbQuery.Append(",[A].[PRD_CATE_CD] ");
                sbQuery.Append(",[A].[FILE_FULLPATH] ");
                sbQuery.Append(",[A].[FILE_NAME] ");
                sbQuery.Append(",[A].[DISPLAY_ORDER] ");
                sbQuery.Append(",[A].[USE_YN] ");
                sbQuery.Append(",[A].[HIDE_YN] ");
                sbQuery.Append(",[A].[REG_USER_ID] ");
                sbQuery.Append(",[A].[REG_DATE] ");
                sbQuery.Append(",[A].[UPD_USER_ID] ");
                sbQuery.Append(",[A].[UPD_DATE] ");
                sbQuery.Append("FROM POSMST..NHS_STOR_PRD_CATE AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                sbQuery.AppendFormat("AND [A].[STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);
                if (!string.IsNullOrEmpty(sPrdCateUpCD)) { sbQuery.AppendFormat("AND [A].[PRD_CATE_UP_CD] = '{0}' ", sPrdCateUpCD); }
                if (!string.IsNullOrEmpty(sPrdCateCD)) { sbQuery.AppendFormat("AND [A].[PRD_CATE_CD] = '{0}' ", sPrdCateCD); }
                sbQuery.Append("AND [A].[USE_YN] = '1' ");
                sbQuery.Append("AND [A].[HIDE_YN] = '0' ");
                sbQuery.Append("ORDER BY [A].[DISPLAY_ORDER] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }
        */


        /// <summary>
        /// 2019-03-04 - 1997fx11 : 05.NHS_STOR_PRD_KEY
        /// 2019-03-08 - 1997fx11 : 'NHS_PRD_CATE' Table 과 Inner Join
        /// 2019-03-08 - 1997fx11 : 'FILE_NAME' Column 표시
        /// </summary>
        /// <param name="sPrdCateCD"></param>
        /// <param name="sTouchKeyCD"></param>
        /// <param name="sItemCD"></param>
        /// <param name="sBarcode"></param>
        /// <returns></returns>
        public DataTable Select_NHS_STOR_PRD_KEY(string sItemCD,string sBarcode=null, string sPrdCateCD = null, string sTouchKeyCD = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT [A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[STOR_CD] ");
                sbQuery.Append(",[A].[PRD_CATE_CD] ");
                sbQuery.Append(",[B].[PRD_CATE_UP_CD] ");
                sbQuery.Append(",[A].[TOUCH_KEY_CD] ");
                sbQuery.Append(",[A].[ITEM_CD] ");
                sbQuery.Append(",[A].[DISPLAY_ORDER] ");
                sbQuery.Append(",[A].[USE_YN] ");
                sbQuery.Append(",[A].[SOLDOUT_YN] ");
                sbQuery.Append(",[A].[RECOMMAND_YN] ");
                sbQuery.Append(",[A].[NEW_YN] ");
                sbQuery.Append(",[A].[PRESENT_YN] ");
                sbQuery.Append(",[A].[SALES_PRC] ");
                sbQuery.Append(",[A].[OPTN_YN] ");
                sbQuery.Append(",[A].[TOUCH_KEY_NM] ");
                sbQuery.Append(",[A].[LAST_UPD_TIME] ");
                sbQuery.Append(",[A].[FILE_NAME] ");
                sbQuery.Append(",[A].[BAR_CD] ");
                sbQuery.Append(",[A].[ORDER_TYPE] ");
                sbQuery.Append(",[A].[REG_USER_ID] ");
                sbQuery.Append(",[A].[REG_DATE] ");
                sbQuery.Append(",[A].[UPD_USER_ID] ");
                sbQuery.Append(",[A].[UPD_DATE] ");
                sbQuery.Append("FROM POSMST..NHS_STOR_PRD_KEY AS [A] WITH (NOLOCK) ");
                sbQuery.Append("INNER JOIN POSMST..NHS_PRD_CATE AS [B] WITH (NOLOCK) ON ([A].[CMP_CD] = [B].[CMP_CD] AND [A].[SALES_ORG_CD] = [B].[SALES_ORG_CD] AND [A].[PRD_CATE_CD] = [B].[PRD_CATE_CD]) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.Append("AND [A].[USE_YN] = '1' ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                sbQuery.AppendFormat("AND [A].[STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);
                if (!string.IsNullOrEmpty(sItemCD)) { sbQuery.AppendFormat("AND [A].[ITEM_CD] IN ({0}) ", sItemCD); }
                if (!string.IsNullOrEmpty(sBarcode)) { sbQuery.AppendFormat("AND [A].[BAR_CD] = '{0}' ", sBarcode); }
                if (!string.IsNullOrEmpty(sPrdCateCD)) { sbQuery.AppendFormat("AND [A].[PRD_CATE_CD] = '{0}' ", sPrdCateCD); }
                if (!string.IsNullOrEmpty(sTouchKeyCD)) { sbQuery.AppendFormat("AND [A].[TOUCH_KEY_CD] = '{0}' ", sTouchKeyCD); }
                sbQuery.Append("ORDER BY [A].[DISPLAY_ORDER]  ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }


        /// <summary>
        /// 2019-03-04 - 1997fx11 : 06.NHS_UI_TEMPLATE
        /// </summary>
        /// <param name="sTemplCD"></param>
        /// <returns></returns>
        public DataTable Select_NHS_UI_TEMPLATE(string sTemplCD = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[STOR_CD],[A].[TEMPL_CD]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[STOR_CD] ");
                sbQuery.Append(",[A].[TEMPL_CD] ");
                sbQuery.Append(",[A].[TEMPL_NM] ");
                sbQuery.Append(",[A].[LOGO_FILE_NAME] ");
                sbQuery.Append(",[A].[LOGO_FILE_FULLPATH] ");
                sbQuery.Append(",[A].[GNB_BACK_COLOR] ");
                sbQuery.Append(",[A].[MAIN_BACK_COLOR] ");
                sbQuery.Append(",[A].[MAIN_FONT_COLOR] ");
                sbQuery.Append(",[A].[HPC_GNB_BACK_COLOR] ");
                sbQuery.Append(",[A].[HPC_MAIN_BACK_COLOR] ");
                sbQuery.Append(",[A].[HPC_MAIN_FONT_COLOR] ");
                sbQuery.Append(",[A].[USE_YN] ");
                sbQuery.Append(",[A].[REG_USER_ID] ");
                sbQuery.Append(",[A].[REG_DATE] ");
                sbQuery.Append(",[A].[UPD_USER_ID] ");
                sbQuery.Append(",[A].[UPD_DATE] ");
                sbQuery.Append("FROM POSMST..NHS_UI_TEMPLATE AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                sbQuery.AppendFormat("AND [A].[STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);
                if (!string.IsNullOrEmpty(sTemplCD)) { sbQuery.AppendFormat("AND [A].[PRD_CATE_UP_CD] = '{0}' ", sTemplCD); }
                sbQuery.Append("ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[STOR_CD],[A].[TEMPL_CD] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }


        /// <summary>
        /// 2019-03-04 - 1997fx11 : 07.NHS_CPI_CONTENTS
        /// </summary>
        /// <param name="sCpiCD"></param>
        /// <returns></returns>
        public DataTable Select_NHS_CPI_CONTENTS(string sCpiCD = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[CPI_CD]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[CPI_CD] ");
                sbQuery.Append(",[A].[FILE_FULLPATH] ");
                sbQuery.Append(",[A].[FILE_NAME] ");
                sbQuery.Append(",[A].[REG_USER_ID] ");
                sbQuery.Append(",[A].[REG_DATE] ");
                sbQuery.Append(",[A].[UPD_USER_ID] ");
                sbQuery.Append(",[A].[UPD_DATE] ");
                sbQuery.Append("FROM POSMST..NHS_CPI_CONTENTS AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                if (!string.IsNullOrEmpty(sCpiCD)) { sbQuery.AppendFormat("AND [A].[CPI_CD] = '{0}' ", sCpiCD); }
                sbQuery.Append("ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[CPI_CD] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }


        /*
        /// <summary>
        /// 2019-03-04 - 1997fx11 : 08.NHS_CUST_BUY_HIST
        /// 2019-03-07 - 1997fx11 : 삭제
        /// </summary>
        /// <param name="sHPCCustCD"></param>
        /// <param name="sItemCD"></param>
        /// <returns></returns>
        public DataTable Select_NHS_CUST_BUY_HIST(string sHPCCustCD = null, string sItemCD = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[HPC_CUST_CD],[A].[ITEM_CD]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[HPC_CUST_CD] ");
                sbQuery.Append(",[A].[ITEM_CD] ");
                sbQuery.Append(",[A].[ITEM_NM] ");
                sbQuery.Append(",[A].[BUY_DT] ");
                sbQuery.Append(",[A].[REG_USER_ID] ");
                sbQuery.Append(",[A].[REG_DATE] ");
                sbQuery.Append(",[A].[UPD_USER_ID] ");
                sbQuery.Append(",[A].[UPD_DATE] ");
                sbQuery.Append("FROM POSMST..NHS_CUST_BUY_HIST AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                if (!string.IsNullOrEmpty(sHPCCustCD)) { sbQuery.AppendFormat("AND [A].[HPC_CUST_CD] = '{0}' ", sHPCCustCD); }
                if (!string.IsNullOrEmpty(sItemCD)) { sbQuery.AppendFormat("AND [A].[ITEM_CD] = '{0}' ", sItemCD); }
                sbQuery.Append("ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[HPC_CUST_CD],[A].[ITEM_CD] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }
        */


        /// <summary>
        /// 2019-03-04 - 1997fx11 : 09.NHS_LANG_MSG
        /// 2019-03-07 - 1997fx11 : 'PRD_CATE_CD', 'ITEM_CD' Column 삭제
        /// </summary>
        /// <param name="sLanguageGubunCD"></param>
        /// <param name="sLanguageCD"></param>
        /// <param name="sLanguageMessageCD"></param>
        /// <returns></returns>
        public DataTable Select_NHS_LANG_MSG(string sLanguageGubunCD = null, string sLanguageMessageCD = null, string sLanguageCD = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[LANG_GBN_CD],[A].[LANG_CD],[A].[LANG_MESSAGE_CD]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[LANG_GBN_CD] ");
                sbQuery.Append(",[A].[LANG_CD] ");
                sbQuery.Append(",[A].[LANG_MESSAGE_CD] ");
                sbQuery.Append(",[A].[LANG_MESSAGE] ");
                //sbQuery.Append(",[A].[PRD_CATE_CD] ");
                //sbQuery.Append(",[A].[ITEM_CD] ");
                sbQuery.Append(",[A].[REG_USER_ID] ");
                sbQuery.Append(",[A].[REG_DATE] ");
                sbQuery.Append(",[A].[UPD_USER_ID] ");
                sbQuery.Append(",[A].[UPD_DATE] ");
                sbQuery.Append("FROM POSMST..NHS_LANG_MSG AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                if (!string.IsNullOrEmpty(sLanguageGubunCD)) { sbQuery.AppendFormat("AND [A].[LANG_GBN_CD] = '{0}' ", sLanguageGubunCD); }
                if (!string.IsNullOrEmpty(sLanguageCD)) { sbQuery.AppendFormat("AND [A].[LANG_CD] = '{0}' ", sLanguageCD); }
                if (!string.IsNullOrEmpty(sLanguageMessageCD)) { sbQuery.AppendFormat("AND [A].[LANG_MESSAGE_CD] = '{0}' ", sLanguageMessageCD); }
                sbQuery.Append("ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[LANG_GBN_CD],[A].[LANG_CD],[A].[LANG_MESSAGE_CD] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }


        /// <summary>
        /// 2019-03-04 - 1997fx11 : 10.NHS_LAYOUT
        /// </summary>
        /// <param name="sLayoutCD"></param>
        /// <returns></returns>
        public DataTable Select_NHS_LAYOUT(string sLayoutCD = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[LAYOUT_CD]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[LAYOUT_CD] ");
                sbQuery.Append(",[A].[LAYOUT_NM] ");
                sbQuery.Append(",[A].[LAYOUT_RESOLUTION] ");
                sbQuery.Append(",[A].[FRAME_COUNT] ");
                sbQuery.Append(",[A].[RESOLUTION_HORIZEN] ");
                sbQuery.Append(",[A].[RESOLUTION_VERTICAL] ");
                sbQuery.Append(",[A].[REG_USER_ID] ");
                sbQuery.Append(",[A].[REG_DATE] ");
                sbQuery.Append(",[A].[UPD_USER_ID] ");
                sbQuery.Append(",[A].[UPD_DATE] ");
                sbQuery.Append("FROM POSMST..NHS_LAYOUT AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                if (!string.IsNullOrEmpty(sLayoutCD)) { sbQuery.AppendFormat("AND [A].[LAYOUT_CD] = '{0}' ", sLayoutCD); }
                sbQuery.Append("ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[LAYOUT_CD] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }


        /*
        /// <summary>
        /// 2019-03-04 - 1997fx11 : 11.NHS_PRD_CATE_L
        /// </summary>
        /// <param name="sProductCategoryCD"></param>
        /// <param name="sProductCategoryUpCD"></param>
        /// 2019-03-11 - 1997fx11 : 'Select_NHS_PRD_CATE_L' 삭제
        /// <returns></returns>
        public DataTable Select_NHS_PRD_CATE_L(string sProductCategoryCD = null, string sProductCategoryUpCD = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[PRD_CATE_CD],[A].[PRD_CATE_UP_CD]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[PRD_CATE_CD] ");
                sbQuery.Append(",[A].[PRD_CATE_UP_CD] ");
                sbQuery.Append(",[A].[FILE_FULLPATH] ");
                sbQuery.Append(",[A].[FILE_NAME] ");
                sbQuery.Append(",[A].[DISPLAY_ORDER] ");
                sbQuery.Append(",[A].[USE_YN] ");
                sbQuery.Append(",[A].[HIDE_YN] ");
                sbQuery.Append(",[A].[REG_USER_ID] ");
                sbQuery.Append(",[A].[REG_DATE] ");
                sbQuery.Append(",[A].[UPD_USER_ID] ");
                sbQuery.Append(",[A].[UPD_DATE] ");
                sbQuery.Append("FROM POSMST..NHS_PRD_CATE_L AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                if (!string.IsNullOrEmpty(sProductCategoryCD)) { sbQuery.AppendFormat("AND [A].[PRD_CATE_CD] = '{0}' ", sProductCategoryCD); }
                if (!string.IsNullOrEmpty(sProductCategoryUpCD)) { sbQuery.AppendFormat("AND [A].[PRD_CATE_UP_CD] = '{0}' ", sProductCategoryUpCD); }
                sbQuery.Append("AND [A].[USE_YN] = '1' ");
                sbQuery.Append("AND [A].[HIDE_YN] = '0' ");
                sbQuery.Append("ORDER BY [A].[DISPLAY_ORDER] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }
        */


        /*
        /// <summary>
        /// 2019-03-04 - 1997fx11 : 12.NHS_PRD_CATE_M
        /// </summary>
        /// <param name="sProductCategoryCD"></param>
        /// <param name="sProductCategoryUpCD"></param>
        /// 2019-03-11 - 1997fx11 : 'Select_NHS_PRD_CATE_M' 삭제
        /// <returns></returns>
        public DataTable Select_NHS_PRD_CATE_M(string sProductCategoryCD = null, string sProductCategoryUpCD = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[PRD_CATE_CD],[A].[PRD_CATE_UP_CD]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[PRD_CATE_CD] ");
                sbQuery.Append(",[A].[PRD_CATE_UP_CD] ");
                sbQuery.Append(",[A].[FILE_FULLPATH] ");
                sbQuery.Append(",[A].[FILE_NAME] ");
                sbQuery.Append(",[A].[DISPLAY_ORDER] ");
                sbQuery.Append(",[A].[USE_YN] ");
                sbQuery.Append(",[A].[HIDE_YN] ");
                sbQuery.Append(",[A].[REG_USER_ID] ");
                sbQuery.Append(",[A].[REG_DATE] ");
                sbQuery.Append(",[A].[UPD_USER_ID] ");
                sbQuery.Append(",[A].[UPD_DATE] ");
                sbQuery.Append("FROM POSMST..NHS_PRD_CATE_M AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                if (!string.IsNullOrEmpty(sProductCategoryCD)) { sbQuery.AppendFormat("AND [A].[PRD_CATE_CD] = '{0}' ", sProductCategoryCD); }
                if (!string.IsNullOrEmpty(sProductCategoryUpCD)) { sbQuery.AppendFormat("AND [A].[PRD_CATE_UP_CD] = '{0}' ", sProductCategoryUpCD); }
                sbQuery.Append("AND [A].[USE_YN] = '1' ");
                sbQuery.Append("AND [A].[HIDE_YN] = '0' ");
                sbQuery.Append("ORDER BY [A].[DISPLAY_ORDER] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }
        */


        /// <summary>
        /// 2019-03-04 - 1997fx11 : 13.NHS_PRD_MST
        /// </summary>
        /// <param name="sBarCD"></param>
        /// <param name="sItemCD"></param>
        /// <returns></returns>
        public DataTable Select_NHS_PRD_MST(string sBarCD = null, string sItemCD = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT [A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[PRD_CATE_CD] ");
                sbQuery.Append(",[A].[ITEM_CD] ");
                sbQuery.Append(",[A].[ITEM_NM] ");
                sbQuery.Append(",[A].[FILE_FULLPATH] ");
                sbQuery.Append(",[A].[FILE_NAME] ");
                sbQuery.Append(",[A].[ORDER_TYPE] ");
                sbQuery.Append(",[A].[RECOMMAND_YN] ");
                sbQuery.Append(",[A].[NEW_YN] ");
                sbQuery.Append(",[A].[DISPLAY_ORDER] ");
                sbQuery.Append(",[A].[USE_YN] ");
                sbQuery.Append(",[A].[PRESENT_YN] ");
                sbQuery.Append(",[A].[BAR_CD] ");
                sbQuery.Append(",[A].[REG_USER_ID] ");
                sbQuery.Append(",[A].[REG_DATE] ");
                sbQuery.Append(",[A].[UPD_USER_ID] ");
                sbQuery.Append(",[A].[UPD_DATE] ");
                sbQuery.Append(",[B].[TAKE_OUT_SALE_AMT] ");
                sbQuery.Append("FROM POSMST..NHS_PRD_MST AS [A] WITH (NOLOCK) ");
                sbQuery.Append("INNER JOIN [dbo].[MST_ITEM] AS [B] WITH (NOLOCK) ON ([A].[CMP_CD] = [B].[CMP_CD]  AND [A].[ITEM_CD] = [B].[ITEM_CD]) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.Append("AND [A].[USE_YN] = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                if (!string.IsNullOrEmpty(sBarCD)) { sbQuery.AppendFormat("AND [A].[BAR_CD] = '{0}' ", sBarCD); }
                if (!string.IsNullOrEmpty(sItemCD)) { sbQuery.AppendFormat("AND [A].[ITEM_CD] = '{0}' ", sItemCD); }
                sbQuery.Append("ORDER BY [A].[DISPLAY_ORDER] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }


        /// <summary>
        /// 2019-03-04 - 1997fx11 : 14.NHS_OPTN_MST
        /// </summary>
        /// <param name="sItemOptionGroupCD"></param>
        /// <param name="sItemOptionCD"></param>
        /// <returns></returns>
        public DataTable Select_NHS_OPTN_MST(string sItemOptionGroupCD = null, string sItemOptionCD = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[ITEM_OPTN_GRP_CD],[A].[ITEM_OPTN_CD]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[ITEM_OPTN_GRP_CD] ");
                sbQuery.Append(",[A].[ITEM_OPTN_CD] ");
                sbQuery.Append(",[A].[ITEM_OPTN_NM] ");
                sbQuery.Append(",[A].[KIND] ");
                sbQuery.Append(",[A].[OPTN_MTD] ");
                sbQuery.Append(",[A].[KIND_CODE] ");
                sbQuery.Append(",[A].[AMT] ");
                sbQuery.Append(",[A].[MIN_AMT] ");
                sbQuery.Append(",[A].[MAX_AMT] ");
                sbQuery.Append(",[A].[REG_USER_ID] ");
                sbQuery.Append(",[A].[REG_DATE] ");
                sbQuery.Append(",[A].[UPD_USER_ID] ");
                sbQuery.Append(",[A].[UPD_DATE] ");
                sbQuery.Append("FROM POSMST..NHS_OPTN_MST AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                if (!string.IsNullOrEmpty(sItemOptionGroupCD)) { sbQuery.AppendFormat("AND [A].[ITEM_OPTN_GRP_CD] = '{0}' ", sItemOptionGroupCD); }
                if (!string.IsNullOrEmpty(sItemOptionCD)) { sbQuery.AppendFormat("AND [A].[ITEM_OPTN_CD] = '{0}' ", sItemOptionCD); }
                sbQuery.Append("ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[ITEM_OPTN_GRP_CD],[A].[ITEM_OPTN_CD] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }


        /// <summary>
        /// 2019-03-04 - 1997fx11 : 15.NHS_PRD_OPTN_GRP
        /// </summary>
        /// <param name="sItemOptionGroupCD"></param>
        /// <returns></returns>
        public DataTable Select_NHS_PRD_OPTN_GRP(string sItemOptionGroupCD = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[ITEM_OPTN_GRP_CD]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[ITEM_OPTN_GRP_CD] ");
                sbQuery.Append(",[A].[OPTN_GRP_NM] ");
                sbQuery.Append(",[A].[FILE_FULLPATH] ");
                sbQuery.Append(",[A].[FILE_NAME] ");
                sbQuery.Append(",[A].[SEL_MTD] ");
                sbQuery.Append(",[A].[RQRD_YN] ");
                sbQuery.Append(",[A].[USE_YN] ");
                sbQuery.Append(",[A].[REG_USER_ID] ");
                sbQuery.Append(",[A].[REG_DATE] ");
                sbQuery.Append(",[A].[UPD_USER_ID] ");
                sbQuery.Append(",[A].[UPD_DATE] ");
                sbQuery.Append("FROM POSMST..NHS_PRD_OPTN_GRP AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                if (!string.IsNullOrEmpty(sItemOptionGroupCD)) { sbQuery.AppendFormat("AND [A].[ITEM_OPTN_GRP_CD] = '{0}' ", sItemOptionGroupCD); }
                sbQuery.Append("ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[ITEM_OPTN_GRP_CD] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }


        /// <summary>
        /// 2019-03-04 - 1997fx11 : 16.NHS_PRD_OPTN
        /// 2019-03-08 'PRD_CATE_CD' Column 삭제
        /// </summary>
        /// <param name="sItemCD"></param>
        /// <param name="sItemOptionGroupCD"></param>
        /// <returns></returns>
        public DataTable Select_NHS_PRD_OPTN(string sItemCD = null, string sItemOptionGroupCD = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[STOR_CD],[A].[ITEM_CD],[A].[ITEM_OPTN_GRP_CD]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[STOR_CD] ");
                sbQuery.Append(",[A].[ITEM_CD] ");
                sbQuery.Append(",[A].[ITEM_OPTN_GRP_CD] ");
                sbQuery.Append(",[A].[DISPLAY_ORDER] ");
                sbQuery.Append(",[A].[REG_USER_ID] ");
                sbQuery.Append(",[A].[REG_DATE] ");
                sbQuery.Append(",[A].[UPD_USER_ID] ");
                sbQuery.Append(",[A].[UPD_DATE] ");
                sbQuery.Append("FROM POSMST..NHS_PRD_OPTN AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                sbQuery.AppendFormat("AND [A].[STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);
                if (!string.IsNullOrEmpty(sItemCD)) { sbQuery.AppendFormat("AND [A].[ITEM_CD] = '{0}' ", sItemCD); }
                if (!string.IsNullOrEmpty(sItemOptionGroupCD)) { sbQuery.AppendFormat("AND [A].[ITEM_OPTN_GRP_CD] = '{0}' ", sItemOptionGroupCD); }
                sbQuery.Append("ORDER BY [A].[DISPLAY_ORDER] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }


        /// <summary>
        /// 2019-03-04 - 1997fx11 : 17.NHS_PRD_CATE
        /// </summary>
        /// <param name="sProductCategoryCD"></param>
        /// <param name="sProductCategoryUpCD"></param>
        /// <returns></returns>
        public DataTable Select_NHS_PRD_CATE(string sProductCategoryUpCD = null, string sProductCategoryCD = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[PRD_CATE_CD],[A].[PRD_CATE_UP_CD]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[PRD_CATE_CD] ");
                sbQuery.Append(",[A].[PRD_CATE_UP_CD] ");
                sbQuery.Append(",[A].[FILE_FULLPATH] ");
                sbQuery.Append(",[A].[FILE_NAME] ");
                sbQuery.Append(",[A].[DISPLAY_ORDER] ");
                sbQuery.Append(",[A].[USE_YN] ");
                sbQuery.Append(",[A].[HIDE_YN] ");
                sbQuery.Append(",[A].[REG_USER_ID] ");
                sbQuery.Append(",[A].[REG_DATE] ");
                sbQuery.Append(",[A].[UPD_USER_ID] ");
                sbQuery.Append(",[A].[UPD_DATE] ");
                sbQuery.Append("FROM POSMST..NHS_PRD_CATE AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                if (!string.IsNullOrEmpty(sProductCategoryCD)) { sbQuery.AppendFormat("AND [A].[PRD_CATE_CD] = '{0}' ", sProductCategoryCD); }
                if (!string.IsNullOrEmpty(sProductCategoryUpCD)) { sbQuery.AppendFormat("AND [A].[PRD_CATE_UP_CD] = '{0}' ", sProductCategoryUpCD); }
                sbQuery.Append("AND [A].[USE_YN] = '1' ");
                sbQuery.Append("AND [A].[HIDE_YN] = '0' ");
                //sbQuery.Append("ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[PRD_CATE_CD],[A].[PRD_CATE_UP_CD] ");
                sbQuery.Append("ORDER BY [A].[DISPLAY_ORDER] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }


        /// <summary>
        /// 2019-03-04 - 1997fx11 : 18.NHS_STOR_PRD_TAG
        /// </summary>
        /// <param name="sItemCD"></param>
        /// <param name="sTagKind"></param>
        /// <returns></returns>
        public DataTable Select_NHS_STOR_PRD_TAG(string sItemCD = null, string sTagKind = null)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[STOR_CD],[A].[ITEM_CD],[A].[TAG_KIND]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[STOR_CD] ");
                sbQuery.Append(",[A].[ITEM_CD] ");

                sbQuery.Append(",[A].[TAG_KIND] ");
                sbQuery.Append(",[A].[FILE_NAME] ");
                sbQuery.Append(",[A].[NEW_START_DT] ");
                sbQuery.Append(",[A].[NEW_END_DT] ");

                sbQuery.Append(",[A].[REG_USER_ID] ");
                sbQuery.Append(",[A].[REG_DATE] ");
                sbQuery.Append(",[A].[UPD_USER_ID] ");
                sbQuery.Append(",[A].[UPD_DATE] ");
                sbQuery.Append("FROM POSMST..NHS_STOR_PRD_TAG AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                sbQuery.AppendFormat("AND [A].[STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);
                if (!string.IsNullOrEmpty(sItemCD)) { sbQuery.AppendFormat("AND [A].[ITEM_CD] = '{0}' ", sItemCD); }
                if (!string.IsNullOrEmpty(sTagKind)) { sbQuery.AppendFormat("AND [A].[TAG_KIND] = '{0}' ", sTagKind); }
                sbQuery.Append("ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[STOR_CD],[A].[ITEM_CD],[A].[TAG_KIND] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }


        /// <summary>
        /// Kiosk 에서 사용가능한 결재수단 목록을 조회 : 2019-05-17 - 1997fx11
        /// </summary>
        /// <param name="bUseYN"></param>
        /// <returns></returns>
        public DataTable Select_NHS_PAY_DC(bool bUseYN = true)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[CMP_CD],[A].[STOR_CD],[A].[PAY_DC_GRP_TYPE],[A].[PAY_DC_CD]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[CMP_CD] ");
                sbQuery.Append(",[A].[STOR_CD] ");
                sbQuery.Append(",[A].[PAY_DC_GRP_TYPE] ");
                sbQuery.Append(",[A].[PAY_DC_CD] ");

                sbQuery.Append(",[A].[PAY_DC_NM] ");
                sbQuery.Append(",[A].[PAY_DC_TYPE] ");
                sbQuery.Append(",[A].[APPR_VEND_CD] ");
                sbQuery.Append(",[A].[CASH_BILL_ISSUE_YN] ");
                sbQuery.Append(",[A].[BLNC_AMT_EXCHNG_CPN_PRT_YN] ");
                sbQuery.Append(",[A].[CNNT_ITEM_CHECK_YN] ");
                sbQuery.Append(",[A].[COOP_CMP_CNNT_YN] ");
                sbQuery.Append(",[A].[PRFX_TRGT_YN] ");
                sbQuery.Append(",[A].[PAY_DC_METHD] ");
                sbQuery.Append(",[A].[PAY_DC_VAL] ");
                sbQuery.Append(",[A].[DC_APPLY_TRGT] ");
                sbQuery.Append(",[A].[HP_BASIC_ACCUM_YN] ");
                sbQuery.Append(",[A].[DC_TRGT_AMT_TYPE] ");
                sbQuery.Append(",[A].[CPI_DUP_YN] ");
                sbQuery.Append(",[A].[DC_TELECOM_DUP_YN] ");
                sbQuery.Append(",[A].[DC_POINT_DUP_YN] ");
                sbQuery.Append(",[A].[DC_CPN_DUP_YN] ");
                sbQuery.Append(",[A].[DC_EMP_DC_DUP_YN] ");
                sbQuery.Append(",[A].[DC_GNRL_DUP_YN] ");
                sbQuery.Append(",[A].[PAY_GNRL_DUP_YN] ");
                sbQuery.Append(",[A].[PAY_MOBILE_DUP_YN] ");
                sbQuery.Append(",[A].[PAY_POINT_DUP_YN] ");
                sbQuery.Append(",[A].[SALE_POS_PRT_QUE] ");
                sbQuery.Append(",[A].[USE_YN] ");
                sbQuery.Append(",[A].[UPD_DT] ");
                sbQuery.Append(",[A].[REG_DT] ");
                sbQuery.Append(",[A].[HP_ADD_ACCUM_DIV] ");
                sbQuery.Append(",[A].[MOBILE_DC_DIV] ");
                sbQuery.Append("FROM POSMST..MST_PAY_DC AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);

                if (bUseYN) { sbQuery.Append("AND [A].[USE_YN] = '1' "); }

                sbQuery.Append("ORDER BY [A].[CMP_CD],[A].[STOR_CD],[A].[PAY_DC_GRP_TYPE],[A].[PAY_DC_CD] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }

        /// <summary>
        /// Kiosk 에서 사용가능한 결재수단 사용여부를 조회 : 2019-06-10 - 1997fx11
        /// </summary>
        /// <param name="bUseYN"></param>
        /// <returns></returns>
        public DataTable Select_NHS_FUNC_INFO(bool bUseYN  = false)
        {
            StringBuilder sbQuery = new StringBuilder();

            try
            {
                sbQuery.Append("SELECT ROW_NUMBER() OVER(ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[STOR_CD],[A].[STEP_GRP_CD],[A].[FUNC_GRP_CD],[A].[FUNC_CD]) AS [NOW_NUMBER] ");
                sbQuery.Append(",[A].[CMP_CD] ");
                sbQuery.Append(",[A].[SALES_ORG_CD] ");
                sbQuery.Append(",[A].[STOR_CD] ");

                sbQuery.Append(",[A].[STEP_GRP_CD] ");
                sbQuery.Append(",[A].[FUNC_GRP_CD] ");
                sbQuery.Append(",[A].[FUNC_CD] ");
                sbQuery.Append(",[A].[STEP_GRP_NM] ");
                sbQuery.Append(",[A].[FUNC_GRP_NM] ");
                sbQuery.Append(",[A].[FUNC_NM] ");
                sbQuery.Append(",[A].[DISPLAY_ORDER] ");
                sbQuery.Append(",[A].[USE_YN] ");
                sbQuery.Append("FROM POSMST..NHS_FUNC_INFO AS [A] WITH (NOLOCK) ");
                sbQuery.Append("WHERE 1 = 1 ");
                sbQuery.AppendFormat("AND [A].[CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd);
                sbQuery.AppendFormat("AND [A].[SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);
                sbQuery.AppendFormat("AND [A].[STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);
                sbQuery.Append("AND FUNC_CD <> '00000' ");
                if (bUseYN) { sbQuery.Append("AND [A].[USE_YN] = '1' "); }

                sbQuery.Append("ORDER BY [A].[CMP_CD],[A].[SALES_ORG_CD],[A].[STOR_CD],[A].[STEP_GRP_CD],[A].[FUNC_GRP_CD],[A].[FUNC_CD] ");

                return m_cMstService.Select(new string[] { sbQuery.ToString() });
            }
            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 null;
            }

            //return null;
        }


        private Cosmos.Common.INetworkJSON m_cNetworkJson = null;             // 2019-03-19 - 1997fx11 : JSON 통신 관련 서비스
        private Cosmos.Common.IDatabaseSQL m_cDatabaseSql = null;             // 2019-03-20 - 1997fx11 : 데이터베이스 관련
        /// <summary>
        /// 2019-03-04 - 1997fx11 : 08.NHS_CUST_BUY_HIST - GetCustBuyHistory
        /// 2019-03-07 - 1997fx11 : 삭제
        /// 2019-03-19 - 1997fx11 : 호출시 실행하는 방법으로 변경
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sHpcCustCd"></param>
        /// <param name="sItemCD"></param>
        /// <returns></returns>
        public string[] Select_NHS_CUST_BUY_HIST(string sUpdateDT, string sHpcCustCd, string sItemCD = null)
        {
            string[] aRowDatas = null;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            //string sUpDate = string.Empty;
            int iReturn = BaseCom.NG;

            try
            {
                m_cNetworkJson = (Cosmos.Common.INetworkJSON)sManager.InitServiceInstance(Cosmos.Common.ServiceLists.AGENT_NETWORK.DLL, Cosmos.Common.ServiceLists.AGENT_NETWORK.NETWORK_JSON);

                htReqData = new Hashtable();

                // 응답코드 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.ResCd, string.Empty);
                // 요청코드 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.ProcCd, "0");
                // 변경 일시 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.UpdDt, sUpdateDT);
                // 고객코드 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.HpcCustCd, sHpcCustCd);
                // INQ Type 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.InqType, "01");

                iReturn = m_cNetworkJson.CmsIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.KioskPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.HPC_CUST_BUY_HIST, m_cPosStatus.Base.BrandCd)
                                                          , htReqData
                                                          , ref sbRecvData
                                                          , ref sUpdateDT);

                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                }
                else
                {
                    return null;
                }

                return aRowDatas;
            }
            catch
            {
                return null;
            }

            //return null;
        }


        /// <summary>
        /// 2019-03-04 - 1997fx11 : 신규 ITEM 수신
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sItemCD"></param>
        /// <returns></returns>
        public int Get_NEW_PRODUCT_BY_IRT(string sUpdateDT = null, string sItemCD = null)
        {
            bool bReturn = false;
            string sQuery = string.Empty;
            string[] aRowDatas = null;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            //string sUpDate = string.Empty;
            int iReturn = BaseCom.NG;

            try
            {
                m_cNetworkJson = (Cosmos.Common.INetworkJSON)sManager.InitServiceInstance(Cosmos.Common.ServiceLists.AGENT_NETWORK.DLL, Cosmos.Common.ServiceLists.AGENT_NETWORK.NETWORK_JSON);

                //  Config 파일에서 Last Update Date 를 들고옴.
                CmMessage m_PosSaleInfo = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosSaleInfo);
                sUpdateDT = CmUtil.StringNullEmpty(GetConfigInfo(m_PosSaleInfo, "CHECKOVER", "NewProductUpdDate"));

                htReqData = new Hashtable();

                // 응답코드 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.ResCd, string.Empty);
                // 요청코드 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.ProcCd, "0");
                // 변경 일시 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.UpdDt, sUpdateDT);
                // INQ Type 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.InqType, "02");

                iReturn = m_cNetworkJson.CmsIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.KioskPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.NEW_PRODUCT_BY_IRT, m_cPosStatus.Base.BrandCd)
                                                          , htReqData
                                                          , ref sbRecvData
                                                          , ref sUpdateDT);

                if (iReturn == BaseCom.OK)
                {
                    //  행구분자(#~)로 구분한 Row Data를 string array에 저장
                    aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    //  DB에 저장
                    bReturn = InsertNHS_STOR_PRD_KEY(aRowDatas);
                    //  Config 파일에 Last Update Date 저장
                    m_PosSaleInfo.GetMessage("CHECKOVER").MakeMessageOverWrite("NewProductUpdDate      ".Trim(), sUpdateDT);
                    m_PosSaleInfo.MakeFileFromMessage(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosSaleInfo);
                }
                else
                {
                    return -1;
                }

                return iReturn;
            }
            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 -1;
            }

            //return null;
        }


        /// <summary>
        /// 2019-03-04 - 1997fx11 : 신규 ITEM 수신
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool InsertNHS_STOR_PRD_KEY(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string[] aParams = null;

            m_cDatabaseSql = (Cosmos.Common.IDatabaseSQL)sManager.InitServiceInstance(Cosmos.Common.ServiceLists.AGENT_DATABASE.DLL, Cosmos.Common.ServiceLists.AGENT_DATABASE.DATABASE_MSSQL);

            try
            {
                sInsQuery = "UPDATE POSMST..NHS_STOR_PRD_KEY \n"
                + "     SET [ITEM_CD] = '{5}' \n"
                + "         ,[DISPLAY_ORDER] = '{6}' \n"
                + "         ,[USE_YN] = '{7}' \n"
                + "         ,[SOLDOUT_YN] = '{8}' \n"
                + "         ,[RECOMMAND_YN] = '{9}' \n"

                + "         ,[NEW_YN] = '{10}' \n"
                + "         ,[PRESENT_YN] = '{11}' \n"
                + "         ,[SALES_PRC] = '{12}' \n"
                + "         ,[OPTN_YN] = '{13}' \n"
                + "         ,[TOUCH_KEY_NM] = '{14}' \n"

                + "         ,[LAST_UPD_TIME] = Convert(datetime,'{15}') \n"
                + "         ,[FILE_NAME] = '{16}' \n"
                + "         ,[UPD_USER_ID] = '{19}' \n"
                + "         ,[UPD_DATE] = Convert(datetime,'{20}') \n"
                + "     WHERE [CMP_CD] = '{0}' \n"
                + "         AND [SALES_ORG_CD] = '{1}' \n"
                + "         AND [STOR_CD] = '{2}' \n"
                + "         AND [PRD_CATE_CD] = '{3}' \n"
                + "         AND [TOUCH_KEY_CD] = '{4}' \n"
                + "IF @@ROWCOUNT = 0 \n"
                + "INSERT INTO POSMST..NHS_STOR_PRD_KEY \n"
                + "    ([CMP_CD] \n"
                + "    ,[SALES_ORG_CD] \n"
                + "    ,[STOR_CD] \n"
                + "    ,[PRD_CATE_CD] \n"
                + "    ,[TOUCH_KEY_CD] \n"

                + "    ,[ITEM_CD] \n"
                + "    ,[DISPLAY_ORDER] \n"
                + "    ,[USE_YN] \n"
                + "    ,[SOLDOUT_YN] \n"
                + "    ,[RECOMMAND_YN] \n"

                + "    ,[NEW_YN] \n"
                + "    ,[PRESENT_YN] \n"
                + "    ,[SALES_PRC] \n"
                + "    ,[OPTN_YN] \n"
                + "    ,[TOUCH_KEY_NM] \n"

                + "    ,[LAST_UPD_TIME] \n"
                + "    ,[ORDER_TYPE] \n"
                + "    ,[REG_USER_ID] \n"
                + "    ,[REG_DATE]) \n"
                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}',Convert(datetime,'{15}'),'{16}','{17}',Convert(datetime,'{18}')) \n";

                foreach (string sRowData in aRowDatas)
                {
                    aParams = sRowData.Split('|');

                    sQuery = string.Format(sInsQuery
                                                    , aParams[0]
                                                    , aParams[1]
                                                    , 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]);

                    if (m_cDatabaseSql.DBExecuteNonQuery(sQuery) != UserCom.OK)
                    {
                        UserLog.WriteLogFile(UserCom.LOG_ERROR,
                                             UserCom.WARNING_LEVEL,
                                             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 (함수명))
                                             sQuery);
                    }
                }

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


        /// <summary>
        /// 2019-03-21 - 1997fx11 : 설정 파일 읽기
        /// </summary>
        /// <param name="cCfgInfo"></param>
        /// <param name="sGroup"></param>
        /// <param name="sValueName"></param>
        /// <param name="sDefault"></param>
        /// <returns></returns>
        private string GetConfigInfo(CmMessage cCfgInfo, string sGroup, string sValueName, string sDefault = "")
        {
            try
            {
                string sValue = cCfgInfo.GetMessage(sGroup).GetMessageValue(sValueName);
                //if (sValue == null)
                if (string.IsNullOrWhiteSpace(sValue))
                    return sDefault;
                else
                    return sValue;
            }
            catch { }

            return sDefault;
        }


        /// <summary>
        /// 2019-03-21 - 1997fx11 : 상품(아이템) 변경 처리
        /// </summary>
        /// <returns></returns>
        public int Send_SYSTEM_INFO()
        {
            double AvailableFreeSpaceDisk = 0;
            double TotalSizeDisk = 0;
            double UseSizeDisk = 0;
            long TotalPhysicalMemeory = 0;
            long FreePhysicalMemeory = 0;
            bool bReturn = false;
            string sQuery = string.Empty;
            string[] aRowDatas = null;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            string sUpdateDT = string.Empty;
            string sLstBootDT = string.Empty;
            string sLstShotdownDT = string.Empty;
            int iReturn = BaseCom.NG;

            try
            {
                sUpdateDT = string.Format("{0:yyyyMMddHHmmss}", DateTime.Now);

                //  "DISK"
                DriveInfo drv = new DriveInfo(CmUtil.MidH(BaseCom.NxDownPath, 0, 1));
                AvailableFreeSpaceDisk = ((drv.AvailableFreeSpace) / 1024 / 1024);
                TotalSizeDisk = ((drv.TotalSize) / 1024 / 1024);
                UseSizeDisk = TotalSizeDisk - AvailableFreeSpaceDisk;

                //  "MEMORY";
                System.Management.ManagementClass cls = new System.Management.ManagementClass("Win32_OperatingSystem");
                System.Management.ManagementObjectCollection instances = cls.GetInstances();

                foreach (System.Management.ManagementObject info in instances)
                {
                    long total_physical_memeory = long.Parse(info["TotalVisibleMemorySize"].ToString()) / 1024;
                    long free_physical_memeory = long.Parse(info["FreePhysicalMemory"].ToString()) / 1024;
                    long remmain_physical_memory = total_physical_memeory - free_physical_memeory;

                    TotalPhysicalMemeory = TotalPhysicalMemeory + total_physical_memeory;
                    FreePhysicalMemeory = FreePhysicalMemeory + free_physical_memeory;
                }

                //  "CPU"
                PerformanceCounter cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
                //PerformanceCounter ramCounter = new PerformanceCounter("Memory", "Available MBytes");
                //float _cpuage = cpuCounter.NextValue();
                float firstValue = cpuCounter.NextValue();
                System.Threading.Thread.Sleep(1000);
                float secondValue = cpuCounter.NextValue();
                int cpuPercent = Convert.ToInt32(secondValue);

                //  "LAST_BOOT_TIME"
                DateTime _dt = new DateTime();
                SelectQuery query = new SelectQuery("SELECT LastBootUpTime FROM Win32_OperatingSystem WHERE Primary = 'true'");
                ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
                foreach (ManagementObject mo in searcher.Get())
                {
                    _dt = ManagementDateTimeConverter.ToDateTime(mo.Properties["LastBootUpTime"].Value.ToString());
                }
                sLstBootDT = string.Format("{0:yyyyMMddHHmmss}", _dt);


                //  "LAST_SHUTDOWN_TIME"
                string sKey = @"System\CurrentControlSet\Control\Windows";
                Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sKey);

                string sValueName = "ShutdownTime";
                byte[] val = (byte[])key.GetValue(sValueName);
                long valueAsLong = BitConverter.ToInt64(val, 0);
                _dt = DateTime.FromFileTime(valueAsLong);
                sLstShotdownDT = string.Format("{0:yyyyMMddHHmmss}", _dt);




                m_cNetworkJson = (Cosmos.Common.INetworkJSON)sManager.InitServiceInstance(Cosmos.Common.ServiceLists.AGENT_NETWORK.DLL, Cosmos.Common.ServiceLists.AGENT_NETWORK.NETWORK_JSON);

                htReqData = new Hashtable();

                // 응답코드 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.ResCd, string.Empty);
                // 요청코드 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.ProcCd, "0");
                // HDD 총용량 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.HddTotal, TotalSizeDisk.ToString());
                // HDD 사용량 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.HddUse, UseSizeDisk.ToString());
                // Memory 총용량 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.MemoryTotal, TotalPhysicalMemeory.ToString());
                // Memory 사용량 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.MemoryUse, FreePhysicalMemeory.ToString());
                // CPU 사용 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.CpuUse, cpuPercent.ToString()); //counters.Count.ToString());
                // LastBootTime 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.LastBootTime, sLstBootDT);
                // LastShutdownTime 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.LastShutdownTime, sLstShotdownDT);
                // 변경 일시 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.UpdDt, sUpdateDT);
                // INQ Type 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.InqType, "04");

                iReturn = m_cNetworkJson.CmsIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.KioskPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.SEND_SYSTEM_INFO_BY_IRT, m_cPosStatus.Base.BrandCd)
                                                          , htReqData
                                                          , ref sbRecvData
                                                          , ref sUpdateDT);

                if (iReturn == BaseCom.OK)
                {
                    //  행구분자(#~)로 구분한 Row Data를 string array에 저장
                    aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                }
                else
                {
                    return -1;
                }

                return iReturn;
            }
            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 -1;
            }

            //return null;
        }

        /// <summary>
        /// 2019-05-29 - 1997fx11 : 알림톡 전송
        /// </summary>
        /// <param name="sPhoneNo"></param>
        /// <param name="korItemName"></param>
        /// <param name="itemCount"></param>
        /// <returns></returns>
        public int Send_NoticeTalk(string sPhoneNo, string korItemName, string itemCount)
        {
            int iReturn = BaseCom.NG;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            string[] aRowDatas = null;
            string sUpdateDT = string.Empty;
            string sHeaderInfo = string.Empty;
            string sPrd_Nm = string.Empty;
            string sPrd_Count = string.Empty;
            string sDateFormat = "yyyyMMddHHmmss";

            try
            {
                m_cNetworkJson = (Cosmos.Common.INetworkJSON)sManager.InitServiceInstance(Cosmos.Common.ServiceLists.AGENT_NETWORK.DLL, Cosmos.Common.ServiceLists.AGENT_NETWORK.NETWORK_JSON);

                sUpdateDT = string.Format("{0:yyyyMMddHHmmss}", DateTime.Now);
                string dateTime = ($"{m_cTrnStatus.Head.SaleDate}{m_cTrnStatus.Head.PayHms}");
                DateTime dt = DateTime.ParseExact(dateTime, sDateFormat, null);                
                var lastBarcode = m_cPosStatus.Base.LastRcptBarcodeData;
                var storeName =  CmUtil.GetDataRowStr(PosMstManager.GetMstStore(), PosMst.MST_STORE.DATA.STORNM);
                htReqData = new Hashtable();

                // 응답코드 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.ResCd, string.Empty);
                // 요청코드 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.ProcCd, "0");
                // Page Id 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.Page_Id, "01");
                // Phone No 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.Phone_No, sPhoneNo);
                // INQ Type 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.InqType, "05");
                // 점포명 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.Stor_Nm, storeName);
                // 거래일시 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.Trade_Date, dt.ToString("yyyy-MM-dd HH:mm:ss"));
                // 배열 0번째 아이템명 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.Prd_Nm, korItemName);
                // 배열 길이 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.Prd_Count, itemCount);
                // 적립대상금액 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.After_Save_Point, m_cTrnStatus.Head.AftSavePoint.ToString());
                // 바코드 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.Barcode, lastBarcode);
                // 변경 일시 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.UpdDt, sUpdateDT);

                iReturn = m_cNetworkJson.CmsIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.KioskPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.SEND_SYSTEM_INFO_BY_IRT, m_cPosStatus.Base.BrandCd)
                                                          , htReqData                                                          
                                                          , ref sbRecvData
                                                          , ref sUpdateDT);

                sHeaderInfo = ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.SEND_SYSTEM_INFO_BY_IRT, m_cPosStatus.Base.BrandCd);
                
                if (iReturn == BaseCom.OK)
                {
                    //  행구분자(#~)로 구분한 Row Data를 string array에 저장
                    aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                }
                else
                {
                    UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, "DataCommon.Send_NoticeTalk()", sHeaderInfo);
                    return -1;
                }

                return iReturn;
            }
            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 -1;
            }

            //return null;
        }
        #endregion =============================================================================================


        private IDataServiceUs m_cSOD = null;
        private IAccADMT m_cAccADMT = null;
        private IServiceUs m_cPosConfig = null;                                     // 환경설정 정보 송/수신
        /// <summary>
        /// 2019-04-26 - 1997fx11 : 자동 마감/개업
        /// </summary>
        public void SetSaleEndOpen()
        {
            string sSaleDate = System.DateTime.Now.ToString("yyyyMMdd");
            string sOrgDate = m_cPosStatus.Base.SaleDate;

            if (m_cPosStatus.Base.OpenClose == "1") //  개점처리 되어있음.
            {
                if (CmUtil.LongParse(sOrgDate) >= CmUtil.LongParse(sSaleDate))
                {
                    //  MSG : 이미 개점 처리 되었습니다.
                    return;
                }
                else
                {
                    //  Main POS 확인
                    if (IsMainPOS())
                    {
                    }
                    else
                    {
                        string sTempDate = GetMainPosSaleOpenDate();

                        if (sTempDate.Trim().Length == 8)
                        {
                            sSaleDate = m_cPosStatus.Global.DateToCulture(sTempDate);
                        }
                        else
                        {
                            // 메인포스가 아닌데 return값이 없으면 메인포스가 아직 개점하지 않았으므로 Pass!!
                            return;
                        }
                    }

                    //  MSG : 전일자 마감처리 되지 않았습니다.전일 마감 후 개점처리 하십시요.
                    //  마감처리 후 개점처리 필요.
                    SetSaleEnd();

                    //  개점
                    SetSaleOpen(sSaleDate);
                }
            }
        }


        /// <summary>
        /// 메인포스일 경우 개점일자 조회
        /// </summary>
        /// <returns></returns>
        private string GetMainPosSaleOpenDate()
        {
            string MainPosOpenDate = string.Empty;

            try
            {
                var ret = (string)m_cSOD.GetData(new string[] { "CHECK_SUBPOS_OPEN" });

                if (ret.StartsWith(UserCom.RST_ERR))
                {
                    return string.Empty;
                }

                if (ret.StartsWith(UserCom.RST_OK))
                {
                    var tmp = ret.Split('|');
                    if (tmp.Length > 1) { MainPosOpenDate = tmp[1].Trim(); }
                }

                //if (MainPosOpenDate.Trim().Length == 8)
                //{
                //    sSaleDate = m_cPosStatus.Global.DateToCulture(MainPosOpenDate);
                //}
            }
            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 string.Empty;
            }

            return MainPosOpenDate;
        }


        /// <summary>
        /// 메인포스어부
        /// </summary>
        /// <returns></returns>
        private bool IsMainPOS()
        {
            bool bResult = true;

            if (m_cPosStatus.Base.PosType == PosConst.POS_TYPE.DEFERRED_PAYMENT && m_cPosStatus.Base.PosCommunicationType == PosConst.MAIN_POS_DIV.SUB_POS)
            {
                bResult = false;
            }

            return bResult;
        }


        /// <summary>
        /// 자동 마감
        /// </summary>
        private void SetSaleEnd()
        {
            string sRet = UserCom.RST_ERR;
            //string sSysDate = m_cPosStatus.Global.DateToCulture(System.DateTime.Now.ToString("yyyyMMdd"));
            string sSysDate = DateTime.Now.ToString("yyyyMMdd");
            string m_sTranKind = ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT;
            string m_sTradeDiv = ItemConst.TRAN_DIV.NORMAL;

            try
            {
                //  영업일자와 현재일자가 같으면 마감되었다고 판단 후 Pass
                if (m_cPosStatus.Base.SaleDate == sSysDate) { return; }
                ////  마감처리 되었음 확인 후 Pass
                //if (m_sTradeDiv == ItemConst.TRAN_DIV.NORMAL && m_cPosStatus.Base.OpenClose == "1") { return; }
                //  마감취소 되었음 확인 후 Pass
                if (m_sTradeDiv == ItemConst.TRAN_DIV.REFUND && m_cPosStatus.Base.OpenClose == "1") { return; }

                m_cAccADMT = (IAccADMT)sManager.InitServiceInstance(ServiceLists.BSV_OPEN_CLOSE.DLL, ServiceLists.BSV_OPEN_CLOSE.ACC_ADMT);

                // 입금저장
                DataTable dtData = new DataTable();
                dtData.Columns.Add(new DataColumn("DPST_WTHDR_CD", typeof(string)));
                dtData.Columns.Add(new DataColumn("DPST_WTHDR_QTY", typeof(string)));
                dtData.Columns.Add(new DataColumn("DPST_WTHDR_AMT", typeof(string)));
                dtData.Columns.Add(new DataColumn("DPST_WTHDR_NM", typeof(string)));

                // 영업마감인 경우 차수 99로 설정
                m_cPosStatus.Base.MidCloseSeq = "99";

                // 마감시재
                sRet = m_cAccADMT.SetData(new string[] { ItemConst.TRAN_KIND.STATEMENT.CLOSING_MONEY, m_sTradeDiv }, dtData, "1");

                // 정산
                sRet = m_cAccADMT.SetData(new string[] { m_sTranKind, m_sTradeDiv }, dtData, "1");
                if (sRet == UserCom.RST_OK)
                {
                    // 마감시간 저장
                    m_cPosStatus.Base.CloseDateTime = DateTime.Now.ToString("yyyyMMddHHmmss");

                    m_cPosStatus.Base.OpenClose = "0";

                    CmMessage m_PosSal = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosSaleInfo);
                    m_PosSal.GetMessage("POSOPEN").MakeMessageOverWrite("OpenClose", m_cPosStatus.Base.OpenClose);
                    m_PosSal.GetMessage("POSOPEN").MakeMessageOverWrite("CloseDateTime", m_cPosStatus.Base.CloseDateTime);
                    m_PosSal.MakeFileFromMessage(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosSaleInfo);
                    sRet = UserCom.RST_OK;
                }

                //  개점처리
                //  DB백업 ??
                string sSaleDate = m_cPosStatus.Global.DateToCulture(System.DateTime.Now.ToString("yyyyMMdd"));

                SetBackupDatabase();    //디비백업!
                SetConfigToServer();    //환경설정파일백업!
            }
            catch (Exception) { }
        }


        /// <summary>
        /// 디비백업
        /// </summary>
        /// <returns></returns>
        private bool SetBackupDatabase()
        {
            bool bRet = false;

            try
            {
                //메인포스만 백업함!
                if (m_cPosStatus.Base.PosCommunicationType == PosConst.MAIN_POS_DIV.MAIN_POS)
                {
                    IDatabaseSQL m_cSqlDbService = (IDatabaseSQL)sManager.InitServiceInstance(ServiceLists.AGENT_DATABASE.DLL, ServiceLists.AGENT_DATABASE.DATABASE_MSSQL);

                    if (m_cSqlDbService != null)
                    {
                        //쿼리 생성
                        string sSQL = string.Empty;
                        string sPath = BaseCom.NxBackPath + PosConst.BACKUP_PATH.DB;
                        string sFullPath = "";

                        CmUtil.CreateDirectory(sPath);

                        sFullPath = string.Format("{0}{1}{2}", sPath, DateTime.Now.ToString("yyyyMMdd"), "_POSMST.BAK");

                        sSQL += " USE[master] ";
                        sSQL += " BACKUP DATABASE [POSMST] TO DISK = '{0}' WITH INIT; ";

                        sSQL = string.Format(sSQL, sFullPath);

                        m_cSqlDbService.SetDBConnectionString(m_cPosStatus.Base.LocalDbSource, m_cPosStatus.Base.LocalDbCatalog, m_cPosStatus.Base.LocalDbUserID, m_cPosStatus.Base.LocalDbPassword);

                        int nRows = m_cSqlDbService.DBExecuteNonQuery(new string[] { sSQL }, false);
                        if (nRows > 0)
                        {
                            UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "DataBase(POSMST) Backup Success!");
                        }
                        else
                        {
                            UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "DataBase(POSMST) Backup Fail!");
                        }

                        sFullPath = string.Format("{0}{1}{2}", sPath, DateTime.Now.ToString("yyyyMMdd"), "_POSLOG.BAK");

                        sSQL = string.Empty;
                        sSQL += " USE[master] ";
                        sSQL += " BACKUP DATABASE [POSLOG] TO DISK = '{0}' WITH INIT; ";

                        sSQL = string.Format(sSQL, sFullPath);

                        m_cSqlDbService.SetDBConnectionString(m_cPosStatus.Base.LocalDbSource, m_cPosStatus.Base.LocalDbCatalog, m_cPosStatus.Base.LocalDbUserID, m_cPosStatus.Base.LocalDbPassword);

                        nRows = m_cSqlDbService.DBExecuteNonQuery(new string[] { sSQL }, false);
                        if (nRows > 0)
                        {
                            UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "DataBase(POSLOG) Backup Success!");
                        }
                        else
                        {
                            UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "DataBase(POSLOG) Backup Fail!");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.ToString());
            }

            return bRet;
        }


        /// <summary>
        /// 환경설정파일백업
        /// </summary>
        private void SetConfigToServer()
        {
            try
            {
                m_cPosConfig = (IServiceUs)sManager.InitServiceInstance(ServiceLists.BSV_ADMIN.DLL, ServiceLists.BSV_ADMIN.POS_CONFIG);

                //회사코드, 점포코드, 포스번호, 서버아이피, 서버 포트 유무 체크
                if (m_cPosStatus.Base.CmpCd != "" && m_cPosStatus.Base.StoreNo != "" && m_cPosStatus.Base.PosNo != "" && m_cPosStatus.Base.CommSvrIp.Trim() != "" && (int)m_cPosStatus.Base.BizInqPort != 0)
                {
                    m_cPosConfig.Execute(new string[] { ItemConst.POS_CONFIG_TYPE.SAVE, "" });
                }
            }
            catch (Exception) { }
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="sSaleDate"></param>
        private void SetSaleOpen(string sSaleDate)
        {
            string sRet = UserCom.RST_ERR;

            try
            {
                m_cSOD = (IDataServiceUs)sManager.InitServiceInstance(ServiceLists.BSV_OPEN_CLOSE.DLL, ServiceLists.BSV_OPEN_CLOSE.SALE_OPEN);

                // 개점 완료 처리 => 영업일자 변경, 거래번호 설정
                sRet = m_cSOD.SetData(sSaleDate);

                // 개점정보 생성
                IAccADMT m_cAccADMT = (IAccADMT)sManager.InitServiceInstance(ServiceLists.BSV_OPEN_CLOSE.DLL, ServiceLists.BSV_OPEN_CLOSE.ACC_ADMT);
                sRet = m_cAccADMT.SetData(new string[] { ItemConst.TRAN_KIND.LOG.POS_OPEN, ItemConst.TRAN_DIV.NORMAL }, null, "0");
            }
            catch (Exception) { }
        }
    }
}
