using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Reflection;
using System.Data;

using Cosmos.Common;
using Cosmos.CommonManager;
using Cosmos.BaseFrame;
using Cosmos.UserFrame;
using Cosmos.ServiceProvider;
using System.Data.SqlClient;
//#20171102 MST_ITEM_BAR_CD 마스터 수신 로그 생성 start
/*
using System.IO;
using Newtonsoft.Json;
*/
//#20171102 MST_ITEM_BAR_CD 마스터 수신 로그 생성 end

//************************************************************************************************
// 변경  이력 : 2017.11.23,마스터 수신 시 "MST_*** 테이블" 행 오류 처리 수정 ; girak.kim; Start
//------------------------------------------------------------------------------------------------
// - 수정 이유 : 각 마스터 테이블 정보 Update, Insert 시에 여러개 행 중 하나라도 오류가 발생하면 그 이후에 행은 Update, Insert 가 되지 않는 문제 발생하여
//                 문제가 발생하는 행만 오류 나고 그 이 후 행은 Update , Insert 되게 수정 진행중.
// - 수정 내용 :isQueryError 추가,  foreach 에 오류 발생 시 false 에서 continue 처리, 리턴시에 isQueryError 값 체크하여 리턴, 상세 부분은 각 메소드 소스 참고
//              여러개 행 중 하나라도 오류 발생하면 기존과 같이 처리 결과는 false 로 처리하기에 그 이후 마스터 수신 여부 정보에는 update 되지 않음 (그 이후 프로세스 동일)
// - 수정 적용된 내용 :   UpdateMST_CMM, UpdateMST_MSG, UpdateMST_SALESORG_INSPCT_DTL, UpdateMST_ITEM    
// - 기 타 : 해당되는 모든 "마스터 테이블" 을 수정, 확인 하여야 하기에 조금씩 변경 진행중에 있음.
//************************************************************************************************

namespace Cosmos.Service
{
    class MasterDown : IMasterDownUs
    {
        private SManager sManager = new SManager();                                 // 이 객체를 통해 업무 Service 호출
        private StateServer StateObject = (StateServer)StateServer.GetInstance();   // StateObject : StateServer Object (객체)
        private PosStatus m_cPosStatus = new PosStatus();                           // 기본정보 참조

        private INetworkJSON m_cNetworkJson = null;             // JSON 통신 관련 서비스
        private IDatabaseSQL m_cDatabaseSql = null;             // 데이터베이스 관련
        private IFormSaleOpenUs m_cFormSaleOpen = null;         // 프로그램 초기 화면 관련

        private int nTotalMstCnt = 0;
        private int nCurMstCnt = 0;

        private bool m_bIsComplexStore = false;
        private string m_sSubStorNo = "";

        private bool m_bIsAborted = false;
        public bool IsAborted { get { return m_bIsAborted; } set { m_bIsAborted = value; } }

        private const int nRefreshCnt = 100;
                

        /// <summary>
        /// 생성자
        /// </summary>
        public MasterDown()
        {
            m_cPosStatus = (PosStatus)StateObject.POS;

            m_cNetworkJson = (INetworkJSON)sManager.InitServiceInstance(ServiceLists.AGENT_NETWORK.DLL, ServiceLists.AGENT_NETWORK.NETWORK_JSON);
            m_cDatabaseSql = (IDatabaseSQL)sManager.InitServiceInstance(ServiceLists.AGENT_DATABASE.DLL, ServiceLists.AGENT_DATABASE.DATABASE_MSSQL);
            m_cFormSaleOpen = (IFormSaleOpenUs)FormManager.GetForm(FormManager.FORM_PROGRAM_START);
            
            //// DB Connect
            //m_cDatabaseSql.SetDBConnectionString( m_cPosStatus.Base.LocalDbSource
            //                                    , m_cPosStatus.Base.LocalDbCatalog
            //                                    , m_cPosStatus.Base.LocalDbUserID
            //                                    , m_cPosStatus.Base.LocalDbPassword );
        }


        public string Execute(object[] aParam)
        {
            int nFailedCnt = 0;
            string sRet = UserCom.RST_ERR;
            bool bResult = false;
            try
            {
                IsAborted = false;
                // DB Connect
                m_cDatabaseSql.SetDBConnectionString( m_cPosStatus.Base.LocalDbSource
                                                    , m_cPosStatus.Base.LocalDbCatalog
                                                    , m_cPosStatus.Base.LocalDbUserID
                                                    , m_cPosStatus.Base.LocalDbPassword);

                Hashtable htMasters = (Hashtable)aParam[0];
                nTotalMstCnt = htMasters.Count;

                if( aParam[1].ToString().Equals(PosConst.BEGINNING_MST_DOWN_DATE) == true ||
                    aParam[2].ToString().Equals(PosConst.BEGINNING_MST_DOWN_DATE) == true) //m_cPosStatus.Mst.ComplexShopType == 0 이고, 포스메인에서 마스터 전체 수신, 캠페인 전체 수신 버튼 클릭으로 다운 받을 때 사용
                {
                    ExecuteSqlScript(new SqlDB(m_cPosStatus.Base.LocalDbSource, "POSMST", m_cPosStatus.Base.LocalDbUserID, m_cPosStatus.Base.LocalDbPassword)
                                    , BaseCom.NxBinPath + @"\CreateTempMST.sql");
                }

                for (int nLoop = 0; nLoop < nTotalMstCnt; nLoop++)
                {
                    // 다운로드 취소 플래그 SET 되면 다운로드 중지
                    if (IsAborted == true)
                    {
                        // 다운로드 취소 시에도 권한 재부여 되도록 수정(20170621)
                        //return UserCom.RST_ERR;
                        nFailedCnt++;
                        break;                        
                    }
                    nCurMstCnt = nLoop + 1;
                    // Dynamically call method.
                    Type type = typeof(MasterDown);
                    MethodInfo method = type.GetMethod(htMasters[nLoop].ToString());
                    // 단독 점포일 경우
                    if (aParam.Length == 3 || aParam.Length == 4)
                    {
                        if (aParam.Length == 4) 
                            m_cFormSaleOpen = (IFormSaleOpenUs)aParam[3];
                        else
                            m_cFormSaleOpen = (IFormSaleOpenUs)FormManager.GetForm(FormManager.FORM_PROGRAM_START);

                        m_bIsComplexStore = false;
                        m_sSubStorNo = m_cPosStatus.Base.StoreNo;
                        bResult = (bool)method.Invoke(this, new object[] { aParam[1], aParam[2], m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.BrandCd, m_cPosStatus.Base.StoreNo });
                    }
                    // 복합매장일 경우
                    else
                    {
                        if (aParam.Length == 6) 
                            m_cFormSaleOpen = (IFormSaleOpenUs)aParam[5];
                        else
                            m_cFormSaleOpen = (IFormSaleOpenUs)FormManager.GetForm(FormManager.FORM_PROGRAM_START);

                        m_bIsComplexStore = true;
                        m_sSubStorNo = aParam[4].ToString();
                        bResult = (bool)method.Invoke(this, new object[] { aParam[1], aParam[2], m_cPosStatus.Base.StoreNo, aParam[3], aParam[4] });
                    }
                    if (bResult == false)
                    {
                        nFailedCnt++;
                        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 (함수명))
                                             htMasters[nLoop].ToString() + " Master download and insert failure,"+
                                             "Refer to the upper line log ([SendData], [RecvData], [RecvLen])"//bResult 가 false 인 것은 NetworkJson.cs 파일에 SendReceiveMstData() 에서 로그가 남음으로 AppError yyyyMMdd.log 파일에서는 상위 라인 데이터를 참고 하여 원인 분석 할 수 있다.
                                             );
                        //return UserCom.RST_ERR;
                    }
                }

                if (aParam[1].ToString().Equals(PosConst.BEGINNING_MST_DOWN_DATE) == true ||
                    aParam[2].ToString().Equals(PosConst.BEGINNING_MST_DOWN_DATE) == true)//m_cPosStatus.Mst.ComplexShopType == 0 이고, 포스메인에서 마스터 전체 수신, 캠페인 전체 수신 버튼 클릭으로 다운 받을 때 사용
                {
                    ExecuteSqlScript(new SqlDB(m_cPosStatus.Base.LocalDbSource, "POSLOG", m_cPosStatus.Base.LocalDbUserID, m_cPosStatus.Base.LocalDbPassword)
                                    , BaseCom.NxBackPath + @"\AlterLOG.sql");
                }

                if (nFailedCnt == 0)
                {
                    sRet = UserCom.RST_OK;
                }
                else
                {
                    sRet = UserCom.RST_ERR;
                }
            }
            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);
            }
            finally
            {
                // DB Close
                m_cDatabaseSql.Close();
            }

            return sRet;
        }


        public object GetData(string[] aParam)
        {
            string sQuery = string.Empty;
            DataTable dtData = null;
            try
            {
                sQuery  = " SELECT COMPLEX_SHOP_BRAND_CD AS SUB_BRAND_CD ";
                sQuery += "      , COMPLEX_SHOP_STOR_CD AS SUB_STOR_CD ";
                sQuery += "   FROM MST_COMPLEX_SHOP_STOR ";
                sQuery += "  WHERE CMP_CD = '" + aParam[0] + "' ";
                sQuery += "    AND STOR_CD = '" + aParam[1] + "' ";
                sQuery += "    AND USE_YN = '1' ";

                m_cDatabaseSql.DBSelect(sQuery, out dtData);
            }
            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 dtData;
        }


        /// <summary>
        /// POS마스터 요청 Data를 Hashtable 형태로 반환
        /// </summary>
        /// <param name="sMasterDiv"></param>
        /// <param name="sUpdDt"></param>
        /// <param name="ProcCd"></param>
        /// <returns></returns>
        private Hashtable GetPosMasterReqData(string sMasterDiv, string sUpdDt, string sStoreCd, string sSubStoreCd, string ProcCd)
        {
            Hashtable htReqData = null;
            try
            {
                htReqData = new Hashtable();

                // INQ Type 설정
                htReqData.Add(Column.IQ_POSMASTER_REQ.DATA.InqType, ItemConst.IRT_INQ_TYPE.POSMASTER_REQ);
                // 마스터 요청 구분 설정
                htReqData.Add(Column.IQ_POSMASTER_REQ.DATA.MasterDiv, sMasterDiv);
                // 점포코드 설정
                htReqData.Add(Column.IQ_POSMASTER_REQ.DATA.StorCd, sStoreCd);
                // SUB 점포코드 설정
                htReqData.Add(Column.IQ_POSMASTER_REQ.DATA.SubStorCd, sSubStoreCd);
                // 변경 일시 설정
                htReqData.Add(Column.IQ_POSMASTER_REQ.DATA.UpdDt, sUpdDt);
                // 전송데이터 Count 설정
                htReqData.Add(Column.IQ_POSMASTER_REQ.DATA.DataCount, string.Empty);
                // 요청코드 설정
                htReqData.Add(Column.IQ_POSMASTER_REQ.DATA.ProcCd, ProcCd);
                // 응답코드 설정
                htReqData.Add(Column.IQ_POSMASTER_REQ.DATA.ResCd, string.Empty);
            }
            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 htReqData;
        }


        /// <summary>
        /// 2019-02-26 - 1997fx11 : Kiosk 요청 Data를 Hashtable 형태로 반환
        /// </summary>
        /// <param name="ProcCd"></param>
        /// <param name="sUpdDt"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sInqType"></param>
        /// <returns></returns>
        private Hashtable GetKioskReqData(string ProcCd, string sUpdDt, string sStoreCd, string sInqType)  //  string sKioskDiv, string sSubStoreCd, 
        {
            Hashtable htReqData = null;
            try
            {
                htReqData = new Hashtable();

                // 응답코드 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.ResCd, string.Empty);
                // 요청코드 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.ProcCd, ProcCd);
                // 변경 일시 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.UpdDt, sUpdDt);
                // 점포코드 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.StorCd, sStoreCd);
                // INQ Type 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.InqType, sInqType);

                /*
                // 마스터 요청 구분 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.KioskDiv, sKioskDiv);
                // SUB 점포코드 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.SubStorCd, sSubStoreCd);
                // 전송데이터 Count 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.DataCount, string.Empty);
                // INQ Type 설정
                htReqData.Add(Column.IQ_KIOSK_REQ.DATA.InqType, ItemConst.IRT_INQ_TYPE.KIOSK_REQ);
                */
            }
            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 htReqData;
        }


        public DataTable SelectEmergencyMasterList()
        {
            string sQuery = string.Empty;
            DataTable dtData = null;
            try
            {
                sQuery  = "SELECT MST_TBL_CD, MST_TBL_ID ";
                sQuery += "  FROM POSMST..MST_POSMST_TABLE_LST ";
                sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' ";
                sQuery += "   AND EMG_DIV = '1' ";

                m_cDatabaseSql.DBSelect(sQuery, out dtData);
            }
            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 dtData;
        }


        public int UpdateEmergencyMasterList()
        {
            int iRet = UserCom.NG;
            string sQuery = string.Empty;

            try
            {
                sQuery  = "UPDATE POSMST..MST_POSMST_TABLE_LST ";
                sQuery += "   SET EMG_DIV = '0' ";

                int iRows = m_cDatabaseSql.DBExecuteNonQuery(sQuery);

                if(iRows > 0)
                {
                    iRet = UserCom.OK;
                }
            }
            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 iRet;
        }


        /// <summary>
        /// SQL 스크립트 파일 실행
        /// </summary>
        private bool ExecuteSqlScript(SqlDB cSqlDB, string sFileName)
        {
            try
            {
                string sScript = CmUtil.ReadTextFile(sFileName);
                if (sScript == "") return true;

                UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                            System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                            "SQL SERVER EXEC SCRIPT => " + sFileName);

                string[] saQuery = sScript.Split(new string[] { "\n\r", "\r\n" }, StringSplitOptions.None);
                string sQuery = "";
                foreach (string sData in saQuery)
                {
                    if (sData.Trim().ToUpper() == "GO")
                    {
                        int nRet = cSqlDB.DBExecuteNonQuery(new string[] { sQuery }, CommandType.Text, (SqlParameter[])null, false);
                        if (nRet != UserCom.OK && nRet != UserCom.NG4)
                        {
                            UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                    "SQL SERVER EXEC SCRIPT FAIL");
                        }
                        sQuery = "";
                    }
                    else
                    {
                        sQuery += sData + PosConst.CRLF;
                    }
                }

                if (sQuery != "")
                {
                    int nRet = cSqlDB.DBExecuteNonQuery(new string[] { sQuery }, CommandType.Text, (SqlParameter[])null, false);
                    if (nRet != UserCom.OK && nRet != UserCom.NG4)
                    {
                        UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                "SQL SERVER EXEC SCRIPT FAIL");
                    }
                }

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


        //#20171102 MST_ITEM_BAR_CD 마스터 수신 로그 생성 start
        #region 로그파일 저장
        /*
        /// <summary>
        /// 로그파일 저장
        /// </summary>
        /// <param name="sFileData"></param>
        /// <returns></returns>
        public bool WriteLogFile(string sFileData)
        {
            bool bRet = false;
            try
            {
                // 현재 디렉토리
                DirectoryInfo directories = Directory.GetParent(Directory.GetCurrentDirectory());

                string sFilePath = directories.FullName + @"\LOG\MST_BAR\";

                if (Directory.Exists(sFilePath) == false) Directory.CreateDirectory(sFilePath);     // 대상폴더 생성

                //
                string sFileName = sFilePath + @"MST_ITEM_BAR_CD" + DateTime.Now.ToString("yyMMdd") + ".log";

                FileStream fs = new FileStream(sFileName, FileMode.Append, FileAccess.Write);
                StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.Default);

                try
                {
                    sw.BaseStream.Seek(0, SeekOrigin.End);

                    sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + sFileData);
                    sw.Flush();

                    bRet = true;
                }
                catch
                {

                }
                finally
                {
                    sw.Close();
                    fs.Close();
                }
            }
            catch
            {
                return false;
            }
            return bRet;
        }
        */
        #endregion
        //#20171102 MST_ITEM_BAR_CD 마스터 수신 로그 생성 end


        //*----------------------------------------------------------------------------------------------------------*/
        // Master Download / Insert 처리
        //*----------------------------------------------------------------------------------------------------------*/
        #region 01 - MOT 메시지 마스터 Download / Insert
        /// <summary>
        /// MOT 메시지 마스터
        /// </summary>
        /// <param name="aIrtReq"></param>
        /// <returns></returns>
        public bool MST_MOT_MSG(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_MOT_MSG.DIV,
                                                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 start
                                                //항상 마스터 전체 받도록 수정
                                                //기존
                                                //(MasterListManager.IsBackgroundMaster(MasterLists.MST_MOT_MSG_DTL.ID) ? sBGUpdateDT : sUpdateDT),
                                                //변경
                                                "20000101000000",
                                                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 end
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_MOT_MSG.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_MOT_MSG(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateMST_MOT_MSG(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 start
            //서버에서 삭제시킨건 데이터 내려오지 않음.
            string sUpdQuery = string.Empty;
            //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 end
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 start
                sUpdQuery += "UPDATE POSMST..MST_MOT_MSG ";
                sUpdQuery += "   SET UPD_DT = 'DELETE' ";                
                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 end

                //#20180214 마스터 수신 시 포스에서 설정한 MOT 값 변경안되도록 수정  start,phj
                if (m_cPosStatus.Mst.CntryDiv == ItemConst.CNTRY_DIV.KR && m_cPosStatus.Mst.CorpDiv == ItemConst.CORP_DIV.PC
                    //#13753 POS MOT음성 기능 추가 개발요청 - 20180222 음성MOT 옵션처리 start,phj
                    && PosMstManager.GetPosOption(POS_OPTION.OPT331) == "1")
                    //#13753 POS MOT음성 기능 추가 개발요청 - 20180222 음성MOT 옵션처리 end,phj
                
                {
                    sUpdQuery += " WHERE FILLER5 <> 'POSSAVE' ";
                }
                //#20180214 마스터 수신 시 포스에서 설정한 MOT 값 변경안되도록 수정  end,phj

                sInsQuery = "UPDATE POSMST..MST_MOT_MSG \n"
                          + "   SET MOT_NM = N'{5}', IMG_NM = '{6}', SOUND_FILE_DIV = '{7}', SOUND_FILE_NM = '{8}', TTS_DSCRP = N'{9}' \n";
                          
                          //#20180214 마스터 수신 시 포스에서 설정한 MOT 값 변경안되도록 수정  start,phj
                          //기존
                          //+ "     , FILLER1 = '{10}', FILLER2 = '{11}', FILLER3 = '{12}', FILLER4 = '{13}', FILLER5 = '{14}' \n"
                          //+ "     , UPD_DT = '{15}', USE_YN = '{16}' \n"
                          //+ " WHERE CMP_CD = '{0}' \n"
                          
                          //변경
                          if (m_cPosStatus.Mst.CntryDiv == ItemConst.CNTRY_DIV.KR && m_cPosStatus.Mst.CorpDiv == ItemConst.CORP_DIV.PC
                              //#13753 POS MOT음성 기능 추가 개발요청 - 20180222 음성MOT 옵션처리 start,phj
                              && PosMstManager.GetPosOption(POS_OPTION.OPT331) == "1")
                              //#13753 POS MOT음성 기능 추가 개발요청 - 20180222 음성MOT 옵션처리 end,phj
                          {
                              sInsQuery = sInsQuery + "       , FILLER5 = CASE WHEN FILLER5 = 'POSSAVE' THEN FILLER5 ELSE '{14}' END  \n"
                                                    + "       , UPD_DT = '{15}'\n"
                                                    + "       , USE_YN = CASE WHEN FILLER5 = 'POSSAVE' THEN USE_YN ELSE '{16}' END  \n";
                          }
                          else
                          {
                              sInsQuery = sInsQuery + "       , FILLER1 = '{10}', FILLER2 = '{11}', FILLER3 = '{12}', FILLER4 = '{13}', FILLER5 = '{14}' \n"
                                                    + "       , UPD_DT = '{15}', USE_YN = '{16}' \n";
                          }
                          sInsQuery = sInsQuery + " WHERE CMP_CD = '{0}' \n"
                          //#20180214 마스터 수신 시 포스에서 설정한 MOT 값 변경안되도록 수정  end,phj              
            
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND MSG_TYPE = '{2}' \n"
                          + "   AND CNNT_ID = '{3}' \n"
                          + "   AND SEQ_NO = {4} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_MOT_MSG \n"
                          + "       ( CMP_CD, STOR_CD, MSG_TYPE, CNNT_ID, SEQ_NO \n"
                          + "       , MOT_NM, IMG_NM, SOUND_FILE_DIV, SOUND_FILE_NM, TTS_DSCRP \n"
                          + "       , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n"
                          + "       , REG_DT, USE_YN ) \n"
                          + "       VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', {4} \n"
                          + "       , N'{5}', '{6}', '{7}', '{8}', N'{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}', '{16}' ) \n";

                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 start
                sDelQuery += "DELETE FROM POSMST..MST_MOT_MSG ";
                sDelQuery += " WHERE UPD_DT = 'DELETE' ";
                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 end

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 start
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);
                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 end

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]
                                          , DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[17]);
                    
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_MOT_MSG.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 start
                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);
                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 end

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

                return false;
            }
        }
        #endregion

        #region 02 - MOT 메시지 마스터 상세 Download / Insert
        /// <summary>
        /// MOT 메시지 마스터 상세 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <returns></returns>
        public bool MST_MOT_MSG_DTL(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_MOT_MSG_DTL.DIV,
                                                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 start
                                                //항상 마스터 전체 받도록 수정
                                                //기존
                                                //(MasterListManager.IsBackgroundMaster(MasterLists.MST_MOT_MSG_DTL.ID) ? sBGUpdateDT : sUpdateDT),
                                                //변경
                                                "20000101000000",
                                                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 end
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_MOT_MSG_DTL.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_MOT_MSG_DTL(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// MOT 메시지 마스터 상세 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_MOT_MSG_DTL(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 start
            //서버에서 삭제시킨건 데이터 내려오지 않음.
            string sUpdQuery = string.Empty;
            //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 end
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 start
                sUpdQuery += "UPDATE POSMST..MST_MOT_MSG_DTL ";
                sUpdQuery += "   SET UPD_DT = 'DELETE' ";
                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 end

                sInsQuery = "UPDATE POSMST..MST_MOT_MSG_DTL \n"
                          + "   SET MSG = N'{6}', FONT_SIZE = {7}, FONT_COLOR = '{8}', NEW_LINE_YN = '{9}', FILLER1 = '{10}' \n"
                          + "     , FILLER2 = '{11}', FILLER3 = '{12}', FILLER4 = '{13}', FILLER5 = '{14}', UPD_DT = '{15}' \n"
                          + "     , USE_YN = '{16}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND MSG_TYPE = '{2}' \n"
                          + "   AND CNNT_ID = '{3}' \n"
                          + "   AND SEQ_NO = {4} \n"
                          + "   AND SEQ = {5} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_MOT_MSG_DTL \n"
                          + "       ( CMP_CD, STOR_CD, MSG_TYPE, CNNT_ID, SEQ_NO \n"
                          + "       , SEQ, MSG, FONT_SIZE, FONT_COLOR, NEW_LINE_YN \n"
                          + "       , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n"
                          + "       , REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', {4} \n"
                          + "       , {5}, N'{6}', {7}, '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}', '{16}' ) \n";

                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 start
                sDelQuery += "DELETE FROM POSMST..MST_MOT_MSG_DTL ";
                sDelQuery += " WHERE UPD_DT = 'DELETE' ";
                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 end

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 start
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);
                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 end

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]
                                          , DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[17]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_MOT_MSG_DTL.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 start
                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);
                //#20170825 MST_MOT_MSG, MST_MOT_MSG_DTL 내려온 데이터 이외는 삭제 처리 end

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

                return false;
            }
        }
        #endregion

        #region 03 - POS 마스터 Download / Insert
        /// <summary>
        /// POS 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <returns></returns>
        public bool MST_POS(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_POS.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_POS.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_POS.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_POS(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// POS 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_POS(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_POS \n"
                          + "   SET POS_IP = '{3}', POS_TYPE = '{4}', MAIN_YN = '{5}', BILL_TYPEGRP = '{6}', KTCHPRINTER_TYPE_GRP = '{7}' \n"
                          + "     , ADMT_TYPE_GRP = '{8}', CERTF_VER = '{9}', FILLER1 = '{10}', FILLER2 = '{11}', FILLER3 = '{12}' \n"
                          + "     , FILLER4 = '{13}', FILLER5 = '{14}', UPD_DT = '{15}', USE_YN = '{16}', SUB_STOR_CD = '{17}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND POS_NO = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_POS \n"
                          + "       ( CMP_CD, STOR_CD, POS_NO, POS_IP, POS_TYPE \n"
                          + "       , MAIN_YN, BILL_TYPEGRP, KTCHPRINTER_TYPE_GRP, ADMT_TYPE_GRP, CERTF_VER \n"
                          + "       , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n"
                          + "       , REG_DT, USE_YN, SUB_STOR_CD ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}', '{16}', '{17}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]
                                            , DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[17], aParams[18]);
                    
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_POS.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 04 - POS 설정 마스터 Download / Insert
        ///// <summary>
        ///// POS 설정 마스터 다운로드 처리
        ///// </summary>
        ///// <param name="sUpdateDT"></param>
        ///// <returns></returns>
        //public bool MST_POS_SETTNG(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        //{
        //    bool bReturn = false;
        //    string sIrtData = string.Empty;
        //    string sRecvData = string.Empty;
        //    Hashtable htReqData = null;
        //    StringBuilder sbRecvData = null;
        //    int iReturn = BaseCom.NG;

        //    try
        //    {
        //        htReqData = new Hashtable();

        //        // 마스터 요청 Hashtable Data 생성
        //        htReqData = GetPosMasterReqData(MasterLists.MST_POS_SETTNG.DIV,
        //                                        (MasterListManager.IsBackgroundMaster(MasterLists.MST_POS_SETTNG.ID) ? sBGUpdateDT : sUpdateDT), 
        //                                        sStoreCd, 
        //                                        sSubStoreCd, 
        //                                        "0");

        //        m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_POS_SETTNG.ID + " Downloading ... ");
        //        m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

        //        iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
        //                                                  , (int)m_cPosStatus.Base.MstPort
        //                                                  , 60000
        //                                                  , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
        //                                                  , htReqData
        //                                                  , ref sbRecvData);
        //        if (iReturn == BaseCom.OK)
        //        {
        //            // 행구분자(#~)로 구분한 Row Data를 string array에 저장
        //            string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
        //            // DB Insert
        //            bReturn = UpdateMST_POS_SETTNG(aRowDatas);
        //        }
        //        else
        //        {
        //            return false;
        //        }

        //        return bReturn;
        //    }
        //    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>
        ///// POS 설정 마스터 Update
        ///// </summary>
        ///// <param name="aRowDatas"></param>
        ///// <returns></returns>
        //private bool UpdateMST_POS_SETTNG(string[] aRowDatas)
        //{
        //    string sQuery = string.Empty;
        //    string sInsQuery = string.Empty;
        //    string sDelQuery = string.Empty;
        //    string[] aParams = null;
        //    try
        //    {
        //        sDelQuery  = " DELETE FROM POSMST..MST_POS_SETTNG ";
        //        sDelQuery += "  WHERE CMP_CD = '{0}' ";
        //        sDelQuery += "    AND STOR_CD = '{1}' ";
        //        sDelQuery += "    AND POS_NO = '{2}' ";
        //        sDelQuery += "    AND SETTNG_ENTRY_CLSS_DIV = '{3}' ";
        //        sDelQuery += "    AND SETTNG_ENTRY_CD = '{4}' ";

        //        sInsQuery  = " INSERT INTO POSMST..MST_POS_SETTNG ";
        //        sInsQuery += "        ( CMP_CD, STOR_CD, POS_NO, SETTNG_ENTRY_CLSS_DIV, SETTNG_ENTRY_CD ";
        //        sInsQuery += "        , SETTNG_ENTRY_VAL, SETTNG_ENTRY_NM, SETTNG_INPUT_DIV, FILLER1, FILLER2 ";
        //        sInsQuery += "        , FILLER3, FILLER4, FILLER5, UPD_DT, REG_DT ";
        //        sInsQuery += "        , USE_YN ) ";
        //        sInsQuery += "        VALUES ";
        //        sInsQuery += "        ( '{0}', '{1}', '{2}', '{3}', '{4}' ";
        //        sInsQuery += "        , '{5}', '{6}', '{7}', '{8}', '{9}' ";
        //        sInsQuery += "        , '{10}', '{11}', '{12}', '{13}', '{14}' ";
        //        sInsQuery += "        , '{15}' ) ";

        //        // 현재 Row Counting
        //        int nCnt = 0;
        //        // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
        //        int nCntToStepUp = aRowDatas.Length / 100;
        //        // nCntToStepUp 값을 체크하기 위한 Counting
        //        int nCheckToStepUp = 0;

        //        // ProgressBar Style 변경
        //        m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

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

        //            if (nCheckToStepUp == nCntToStepUp)
        //            {
        //                m_cFormSaleOpen.ProgressProgressBar(1);
        //                nCheckToStepUp = 0;
        //            }
        //            else
        //            {
        //                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_POS_SETTNG.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
        //                nCheckToStepUp++;
        //            }

        //            sQuery = string.Format(sDelQuery
        //                                  , aParams[0]
        //                                  , aParams[1]
        //                                  , aParams[2]
        //                                  , aParams[3]
        //                                  , aParams[4]);

        //            m_cDatabaseSql.DBExecuteNonQuery(sQuery);

        //            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], DateTime.Now.ToString("yyyyMMddHHmmsss"), DateTime.Now.ToString("yyyyMMddHHmmsss")
        //                                    , aParams[15]);

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

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

        //        return false;
        //    }
        //}
        #endregion

        #region 05 - POS 옵션 마스터 Download / Insert  -- POS 데이터 사용 안함(CMS 로 변경)..2019.06.05 syshim
        /// <summary>
        /// POS 옵션 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <returns></returns>
        public bool MST_POS_OPTN(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {

            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;


            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_POS_OPTN.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_POS_OPTN.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_POS_OPTN.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateMST_POS_OPTN(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// POS 옵션 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_POS_OPTN(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_POS_OPTN \n"
                          + "   SET OPTN_VAL = '{4}', OPTN_NM = N'{5}', OPTN_EXPLN = N'{6}', FILLER1 = '{7}', FILLER2 = '{8}' \n"
                          + "     , FILLER3 = '{9}', FILLER4 = '{10}', FILLER5 = '{11}', UPD_DT = '{12}', USE_YN = '{13}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND POS_NO = '{2}' \n"
                          + "   AND OPTN_CD = '{3}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_POS_OPTN \n"
                          + "       ( CMP_CD, STOR_CD, POS_NO, OPTN_CD, OPTN_VAL \n"
                          + "       , OPTN_NM, OPTN_EXPLN, FILLER1, FILLER2, FILLER3 \n"
                          + "       , FILLER4, FILLER5, REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , N'{5}', N'{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[14]);
                    
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_POS_OPTN.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 06 - VAN 마스터 Download / Insert
        /// <summary>
        /// VAN 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <returns></returns>
        public bool MST_VAN(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                if (CmUtil.IsNull(PosMstManager.GetPosOption(POS_OPTION.OPT317), "0") == "1")
                {
                    return true;
                }

                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_VAN.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_VAN.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_VAN.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp 
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd) 
                                                          , htReqData 
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_VAN(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// VAN 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_VAN(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_VAN \n"
                          + "   SET APPR_VEND_NM = N'{3}', IP = '{4}', PORT = '{5}', CMP_APPR_ID = '{6}', CMP_APPR_PWD = '{7}' \n"
                          + "     , HOME_PAGE = '{8}', APPR_ID = '{9}', APPR_PWD = '{10}', USE_YN = '{11}', FILLER1 = '{12}' \n"
                          + "     , FILLER2 = '{13}', FILLER3 = '{14}', FILLER4 = '{15}', FILLER5 = '{16}', UPD_DT = '{17}' \n"
                          + "     , MSR_PORT = '{18}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND APPR_VEND_CD = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_VAN \n"
                          + "       ( CMP_CD, STOR_CD, APPR_VEND_CD, APPR_VEND_NM, IP \n"
                          + "       , PORT, CMP_APPR_ID, CMP_APPR_PWD, HOME_PAGE, APPR_ID \n"
                          + "       , APPR_PWD, USE_YN, FILLER1, FILLER2, FILLER3 \n"
                          + "       , FILLER4, FILLER5, REG_DT, MSR_PORT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', N'{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}', '{16}', '{17}', '{18}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach(string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[19]);
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_VAN.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 07 - WEB연동 버튼 마스터 Download / Insert
        /// <summary>
        /// WEB연동 버튼 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <returns></returns>
        public bool MST_WEB_LNKAGE(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_WEB_LNKAGE.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_WEB_LNKAGE.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_WEB_LNKAGE.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_WEB_LNKAGE(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// WEB연동 버튼 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_WEB_LNKAGE(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sUpdQuery = "UPDATE POSMST..MST_WEB_LNKAGE \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";

                sInsQuery = "UPDATE POSMST..MST_WEB_LNKAGE \n"
                          + "   SET DIV = '{3}', DISP_SEQ = '{4}', DISP_YN = '{5}', MENU_NM = '{6}', WEB_MENU_ID = '{7}' \n"
                          + "     , FUNC_ID = '{8}', PARAM = '{9}', FILLER1 = '{10}', FILLER2 = '{11}', FILLER3 = '{12}' \n"
                          + "     , FILLER4 = '{13}', FILLER5 = '{14}', UPD_DT = '{15}', USE_YN = '{16}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND SEQ_NO = {2} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_WEB_LNKAGE \n"
                          + "       ( CMP_CD, STOR_CD, SEQ_NO, DIV, DISP_SEQ \n"
                          + "       , DISP_YN, MENU_NM, WEB_MENU_ID, FUNC_ID, PARAM \n"
                          + "       , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n"
                          + "       , REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', {2}, '{3}', {4} \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}', '{16}' ) \n";

                sDelQuery = "DELETE FROM POSMST..MST_WEB_LNKAGE \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_WEB_LNKAGE 테이블은 INSERT 전 모든 데이터 삭제
                // 안호성C 요청 - 2016/12/05
                //m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);
                // 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]
                                          , DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[17]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_WEB_LNKAGE.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region 08 - 공통 마스터 Download / Insert
        /// <summary>
        /// 공통 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <returns></returns>
        public bool MST_CMM(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_CMM.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_CMM.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CMM.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    if (sbRecvData == null || sbRecvData.ToString().Length == 0)
                    {
                        bReturn = true;
                    }
                    else
                    {
                        // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                        string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                        // DB Insert
                        bReturn = UpdateMST_CMM(aRowDatas);
                    }
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 공통 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_CMM(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_CMM \n"
                          + "   SET ENTRY_NM = N'{4}', DISP_SEQ = {5} \n"
                          + "     , H_RANK_CMM_GRP_CD = '{6}', H_RANK_CMM_CD = '{7}', SALES_ORG_CD = '{8}', EXPLN = N'{9}', USE_YN = '{10}' \n"
                          + "     , CHAR_VAL_TITLE_VAL_01 = N'{11}', CHAR_VAL_TITLE_VAL_02 = N'{12}', CHAR_VAL_TITLE_VAL_03 = N'{13}', CHAR_VAL_TITLE_VAL_04 = N'{14}', CHAR_VAL_TITLE_VAL_05 = N'{15}' \n"
                          + "     , CHAR_VAL_TITLE_VAL_06 = N'{16}', CHAR_VAL_TITLE_VAL_07 = N'{17}', CHAR_VAL_TITLE_VAL_08 = N'{18}', CHAR_VAL_TITLE_VAL_09 = N'{19}', CHAR_VAL_TITLE_VAL_10 = N'{20}' \n"
                          + "     , CHAR_VAL_TITLE_VAL_11 = N'{21}', CHAR_VAL_TITLE_VAL_12 = N'{22}', CHAR_VAL_TITLE_VAL_13 = N'{23}', CHAR_VAL_TITLE_VAL_14 = N'{24}', CHAR_VAL_TITLE_VAL_15 = N'{25}' \n"
                          + "     , NUM_VAL_TITLE_VAL_01 = '{26}', NUM_VAL_TITLE_VAL_02 = '{27}', NUM_VAL_TITLE_VAL_03 = '{28}', NUM_VAL_TITLE_VAL_04 = '{29}', NUM_VAL_TITLE_VAL_05 = '{30}' \n"
                          + "     , UPD_DT = '{31}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND CMM_GRP_CD = '{1}' \n"
                          + "   AND CMM_CD = '{2}' \n"
                          + "   AND LANG_TYPE = '{3}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_CMM \n"
                          + "       ( CMP_CD, CMM_GRP_CD, CMM_CD, LANG_TYPE, ENTRY_NM \n"
                          + "       , DISP_SEQ, H_RANK_CMM_GRP_CD, H_RANK_CMM_CD, SALES_ORG_CD, EXPLN \n"
                          + "       , USE_YN, CHAR_VAL_TITLE_VAL_01, CHAR_VAL_TITLE_VAL_02, CHAR_VAL_TITLE_VAL_03, CHAR_VAL_TITLE_VAL_04 \n"
                          + "       , CHAR_VAL_TITLE_VAL_05, CHAR_VAL_TITLE_VAL_06, CHAR_VAL_TITLE_VAL_07, CHAR_VAL_TITLE_VAL_08, CHAR_VAL_TITLE_VAL_09 \n"
                          + "       , CHAR_VAL_TITLE_VAL_10, CHAR_VAL_TITLE_VAL_11, CHAR_VAL_TITLE_VAL_12, CHAR_VAL_TITLE_VAL_13, CHAR_VAL_TITLE_VAL_14 \n"
                          + "       , CHAR_VAL_TITLE_VAL_15, NUM_VAL_TITLE_VAL_01, NUM_VAL_TITLE_VAL_02, NUM_VAL_TITLE_VAL_03, NUM_VAL_TITLE_VAL_04 \n"
                          + "       , NUM_VAL_TITLE_VAL_05, REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', N'{4}' \n"
                          + "       ,    {5},    '{6}',   '{7}',   '{8}', N'{9}' \n"
                          + "       ,  '{10}', N'{11}', N'{12}', N'{13}', N'{14}' \n"
                          + "       , N'{15}', N'{16}', N'{17}', N'{18}', N'{19}' \n"
                          + "       , N'{20}', N'{21}', N'{22}', N'{23}', N'{24}' \n"
                          + "       , N'{25}',  '{26}',  '{27}',  '{28}',  '{29}' \n"
                          + "       ,  '{30}',  '{31}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_CMM 테이블은 INSERT 전 모든 데이터 삭제
                // 안호성C 요청 - 2016/12/02
                //m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);
                // 모든 DATA의 DELETE 플래그 SET
                //m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);
               
                bool isQueryError = false;//2017.11.23;여러개 행 중에 중간에 오류 발생 했는지 여부;girak.kim

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], aParams[21], aParams[22], aParams[23], aParams[24]
                                            , aParams[25], aParams[26], aParams[27], aParams[28], aParams[29]
                                            , aParams[30], DateTime.Now.ToString("yyyyMMddHHmmsss"));
                    
                    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 false; 기존 소스      
                        //Strat;2017.11.23;한 행 만 실패하더라도 해당 테이블에 그 다음 내용은 추가,수정이 안 되므로 그 이 후 내용 수정, 추가 되도록 변경;girak.kim;
                        isQueryError = true;//중간 오류 발생함.
                        //nCheckToStepUp++;// nCheckToStepUp 는 일단 증가 시키지 않았음
                        continue;
                        //End

                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CMM.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }
                
                //기존 소스
                //return true;
                //Start;2017.11.23;여러개 행 중에 중간 오류 발생 했는지 체크 하여 결과 리턴;girak.kim
                if (isQueryError) return false;
                else return true;
                //End;
            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.LOG_ERROR,
                                     System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                     System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                     ex.Message);

                return false;
            }
        }
        #endregion

        #region 09 - 기능키 거래유형별 마스터 Download / Insert
        /// <summary>
        /// 기능키 거래유형별 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <returns></returns>
        public bool MST_FUNC_KEY_TRADE_TYPEPER(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_FUNC_KEY_TRADE_TYPEPER.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_FUNC_KEY_TRADE_TYPEPER.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_FUNC_KEY_TRADE_TYPEPER.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_FUNC_KEY_TRADE_TYPEPER(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 기능키 거래유형별 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_FUNC_KEY_TRADE_TYPEPER(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_FUNC_KEY_TRADE_TYPEPER \n"
                          + "   SET NORMAL = '{3}', REFUND = '{4}', TRN_MODE_0 = '{5}', TRN_MODE_1 = '{6}', TRN_MODE_2 = '{7}' \n"
                          + "     , TRN_MODE_3 = '{8}', TRN_MODE_4 = '{9}', TRN_MODE_5 = '{10}', TRN_MODE_6 = '{11}', TRN_MODE_7 = '{12}' \n"
                          + "     , TRN_MODE_8 = '{13}', TRN_MODE_9 = '{14}', FILLER1 = '{15}', FILLER2 = '{16}', FILLER3 = '{17}' \n"
                          + "     , FILLER4 = '{18}', FILLER5 = '{19}', UPD_DT = '{20}', USE_YN = '{21}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND FUNC_ID = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_FUNC_KEY_TRADE_TYPEPER \n"
                          + "       ( CMP_CD, STOR_CD, FUNC_ID, NORMAL, REFUND \n"
                          + "       , TRN_MODE_0, TRN_MODE_1, TRN_MODE_2, TRN_MODE_3, TRN_MODE_4 \n"
                          + "       , TRN_MODE_5, TRN_MODE_6, TRN_MODE_7, TRN_MODE_8, TRN_MODE_9 \n"
                          + "       , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n"
                          + "       , REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}', '{16}', '{17}', '{18}', '{19}' \n"
                          + "       , '{20}', '{21}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]
                                            , DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[22]);
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_FUNC_KEY_TRADE_TYPEPER.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 10 - 기능키 그룹 마스터 Download / Insert
        /// <summary>
        /// 기능키 그룹 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <returns></returns>
        public bool MST_FUNC_KEY_GRP(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_FUNC_KEY_GRP.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_FUNC_KEY_GRP.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_FUNC_KEY_GRP.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_FUNC_KEY_GRP(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 기능키 그룹 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_FUNC_KEY_GRP(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string[] aParams = null;
            try
            {
                // MST_FUNC_KEY_GRP 테이블은 INSERT 전 모든 데이터 삭제
                // 박동철B 요청 - 2016/10/26
                //sDelQuery  = " DELETE FROM POSMST..MST_FUNC_KEY_GRP ";
                //sDelQuery += "  WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd +"' ";
                //sDelQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' ";
                ////sDelQuery += "    AND FUNC_GRP_ID = '{2}' ";
                ////sDelQuery += "    AND FUNC_ID = '{3}' ";

                //sInsQuery  = " INSERT INTO POSMST..MST_FUNC_KEY_GRP ";
                //sInsQuery += "        ( CMP_CD, STOR_CD, FUNC_GRP_ID, FUNC_ID, DISP_SEQ ";
                //sInsQuery += "        , FUNC_BTN_SIZE, FONT_SIZE, FUNC_BTN_COLOR, FUNC_NM, USE_YN ";
                //sInsQuery += "        , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 ";
                //sInsQuery += "        , UPD_DT, REG_DT ) ";
                //sInsQuery += "        VALUES ";
                //sInsQuery += "        ( '{0}', '{1}', '{2}', '{3}', {4} ";
                //sInsQuery += "        , {5}, {6}, '{7}', N'{8}', '{9}' ";
                //sInsQuery += "        , '{10}', '{11}', '{12}', '{13}', '{14}' ";
                //sInsQuery += "        , '{15}', '{16}' ) ";

                sUpdQuery = "UPDATE POSMST..MST_FUNC_KEY_GRP \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";

                sInsQuery = "UPDATE POSMST..MST_FUNC_KEY_GRP \n"
                          + "   SET DISP_SEQ = {4}, FUNC_BTN_SIZE = {5}, FONT_SIZE = {6} \n"
                          + "     , FUNC_BTN_COLOR = '{7}', FUNC_NM = N'{8}', USE_YN = '{9}', FILLER1 = '{10}', FILLER2 = '{11}' \n"
                          + "     , FILLER3 = '{12}', FILLER4 = '{13}', FILLER5 = '{14}', UPD_DT = '{15}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND FUNC_GRP_ID = '{2}' \n"
                          + "   AND FUNC_ID = '{3}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_FUNC_KEY_GRP \n"
                          + "       ( CMP_CD, STOR_CD, FUNC_GRP_ID, FUNC_ID, DISP_SEQ \n"
                          + "       , FUNC_BTN_SIZE, FONT_SIZE, FUNC_BTN_COLOR, FUNC_NM, USE_YN \n"
                          + "       , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n"
                          + "       , REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', {4} \n"
                          + "       , {5}, {6}, '{7}', N'{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}' ) \n";

                sDelQuery = "DELETE FROM POSMST..MST_FUNC_KEY_GRP \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_FUNC_KEY_GRP 테이블은 INSERT 전 모든 데이터 삭제
                // 박동철B 요청 - 2016/10/26
                //m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);
                // 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);

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

                    sQuery = string.Format(sInsQuery
                                            , aParams[0], m_cPosStatus.Base.StoreNo, 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]
                                            , DateTime.Now.ToString("yyyyMMddHHmmsss"));
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_FUNC_KEY_GRP.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region 11 - 기능키 마스터 Download / Insert
        /// <summary>
        /// 기능키 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <returns></returns>
        public bool MST_FUNC_KEY(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_FUNC_KEY.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_FUNC_KEY.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_FUNC_KEY.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_FUNC_KEY(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 기능키 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_FUNC_KEY(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_FUNC_KEY \n"
                          + "   SET FUNC_NM = N'{3}', ASCII_CODE = '{4}', TBL = '{5}', ITEM_REG_BF = '{6}', ITEM_REG_AF = '{7}' \n"
                          + "     , PAY_POINT = '{8}', PAY_DC = '{9}', PAY_WAY = '{10}', MENU_GRP = '{11}', EXPLN = N'{12}' \n"
                          + "     , NORMAL = '{13}', REFUND = '{14}', TRN_MODE_0 = '{15}', TRN_MODE_1 = '{16}', TRN_MODE_2 = '{17}' \n"
                          + "     , TRN_MODE_3 = '{18}', TRN_MODE_4 = '{19}', TRN_MODE_5 = '{20}', TRN_MODE_6 = '{21}', TRN_MODE_7 = '{22}' \n"
                          + "     , TRN_MODE_8 = '{23}', TRN_MODE_9 = '{24}', FILLER1 = '{25}', FILLER2 = '{26}', FILLER3 = '{27}' \n"
                          + "     , FILLER4 = '{28}', FILLER5 = '{29}', UPD_DT = '{30}', USE_YN = '{31}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND FUNC_ID = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_FUNC_KEY \n"
                          + "       ( CMP_CD, STOR_CD, FUNC_ID, FUNC_NM, ASCII_CODE \n"
                          + "       , TBL, ITEM_REG_BF, ITEM_REG_AF, PAY_POINT, PAY_DC \n"
                          + "       , PAY_WAY, MENU_GRP, EXPLN, NORMAL, REFUND \n"
                          + "       , TRN_MODE_0, TRN_MODE_1, TRN_MODE_2, TRN_MODE_3, TRN_MODE_4 \n"
                          + "       , TRN_MODE_5, TRN_MODE_6, TRN_MODE_7, TRN_MODE_8, TRN_MODE_9 \n"
                          + "       , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n"
                          + "       , REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', N'{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', N'{12}', '{13}', '{14}' \n"
                          + "       , '{15}', '{16}', '{17}', '{18}', '{19}' \n"
                          + "       , '{20}', '{21}', '{22}', '{23}', '{24}' \n"
                          + "       , '{25}', '{26}', '{27}', '{28}', '{29}' \n"
                          + "       , '{30}', '{31}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], aParams[21], aParams[22], aParams[23], aParams[24]
                                           , aParams[25], aParams[26], aParams[27], aParams[28], aParams[29]
                                           , DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[32]);
                    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 false;
                    }
                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_FUNC_KEY.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 12 - 담당자권한 마스터 Download / Insert
        /// <summary>
        /// 담당자권한 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <returns></returns>
        public bool MST_PIC_AUTH(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_PIC_AUTH.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_PIC_AUTH.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_PIC_AUTH.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_PIC_AUTH(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 담당자 권한 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_PIC_AUTH(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                // MST_PIC_AUTH 테이블은 INSERT 전 모든 데이터 삭제
                // 박동철B 요청 - 2016/10/26
                //sDelQuery = " DELETE FROM POSMST..MST_PIC_AUTH ";
                //sDelQuery += "  WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' ";
                //sDelQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' ";
                ////sDelQuery += "    AND CASHIER_ID = '{2}' ";
                ////sDelQuery += "    AND FUNC_ID = '{3}' ";

                //sInsQuery  = " INSERT INTO POSMST..MST_PIC_AUTH ";
                //sInsQuery += "        ( CMP_CD, STOR_CD, CASHIER_ID, FUNC_ID, MNG_AUTH ";
                //sInsQuery += "        , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 ";
                //sInsQuery += "        , UPD_DT, REG_DT, USE_YN ) ";
                //sInsQuery += "        VALUES ";
                //sInsQuery += "        ( '{0}', '{1}', '{2}', '{3}', '{4}' ";
                //sInsQuery += "        , '{5}', '{6}', '{7}', '{8}', '{9}' ";
                //sInsQuery += "        , '{10}', '{11}', '{12}' ) ";

                sUpdQuery = "UPDATE POSMST..MST_PIC_AUTH \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";

                sInsQuery = "UPDATE POSMST..MST_PIC_AUTH \n"
                          + "   SET MNG_AUTH = '{4}', FILLER1 = '{5}', FILLER2 = '{6}', FILLER3 = '{7}', FILLER4 = '{8}' \n"
                          + "     , FILLER5 = '{9}', UPD_DT = '{10}', USE_YN = '{11}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND CASHIER_ID = '{2}' \n"
                          + "   AND FUNC_ID = '{3}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_PIC_AUTH \n"
                          + "       ( CMP_CD, STOR_CD, CASHIER_ID, FUNC_ID, MNG_AUTH \n"
                          + "       , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n"
                          + "       , REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}' ) \n";

                sDelQuery = "DELETE FROM POSMST..MST_PIC_AUTH \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_PIC_AUTH 테이블은 INSERT 전 모든 데이터 삭제
                // 박동철B 요청 - 2016/10/26
                //m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);
                // 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]
                                            , DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[12]);
                    
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_PIC_AUTH.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region 13 - 상품 분류 마스터 Download / Insert
        /// <summary>
        /// 상품분류 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <returns></returns>
        public bool MST_ITEM_CLSS(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_ITEM_CLSS.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_ITEM_CLSS.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM_CLSS.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_ITEM_CLSS(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 상품분류 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_ITEM_CLSS(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_ITEM_CLSS \n"
                          + "   SET ITEM_CLSS_NM = N'{3}', L_CLSS_CD = '{4}', M_CLSS_CD = '{5}', S_CLSS_CD = '{6}', H_RANK_ITEM_CLSS_CD = '{7}' \n"
                          + "     , ITEM_CLSS_LVL_TYPE = '{8}', DISP_SEQ = {9}, USE_YN = '{10}', FILLER1 = '{11}', FILLER2 = '{12}' \n"
                          + "     , FILLER3 = '{13}', FILLER4 = '{14}', FILLER5 = '{15}', UPD_DT = '{16}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND ITEM_CLSS_TYPE_CD = '{1}' \n"
                          + "   AND ITEM_CLSS_CD = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_ITEM_CLSS \n"
                          + "       ( CMP_CD, ITEM_CLSS_TYPE_CD, ITEM_CLSS_CD, ITEM_CLSS_NM, L_CLSS_CD \n"
                          + "       , M_CLSS_CD, S_CLSS_CD, H_RANK_ITEM_CLSS_CD, ITEM_CLSS_LVL_TYPE, DISP_SEQ \n"
                          + "       , USE_YN, FILLER1, FILLER2, FILLER3, FILLER4 \n"
                          + "       , FILLER5, REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', N'{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', {9} \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}', '{16}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM_CLSS.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 14 - 메시지 마스터 Download / Insert
        /// <summary>
        /// 메시지 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <returns></returns>
        public bool MST_MSG(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_MSG.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_MSG.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_MSG.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_MSG(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 메시지 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_MSG(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_MSG \n"
                          + "   SET MSG1 = N'{4}', MSG2 = N'{5}', MSG3 = N'{6}', MSG4 = N'{7}', MSG5 = N'{8}' \n"
                          + "     , FILLER1 = '{9}', FILLER2 = '{10}', FILLER3 = '{11}', FILLER4 = '{12}', FILLER5 = '{13}' \n"
                          + "     , UPD_DT = '{14}', USE_YN = '{15}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND LANG_CD = '{1}' \n"
                          + "   AND MSG_TYPE = '{2}' \n"
                          + "   AND MSG_NO = '{3}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_MSG \n"
                          + "       ( CMP_CD, LANG_CD, MSG_TYPE, MSG_NO, MSG1 \n"
                          + "       , MSG2, MSG3, MSG4, MSG5, FILLER1 \n"
                          + "       , FILLER2, FILLER3, FILLER4, FILLER5, REG_DT \n"
                          + "       , USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', N'{4}' \n"
                          + "       , N'{5}', N'{6}', N'{7}', N'{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                bool isQueryError = false;//2017.11.23;여러개 행 중에 중간에 오류 발생 했는지 여부;girak.kim
                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss")
                                            , aParams[16]);

                    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 false; 기존 소스      
                        //Strat;2017.11.23;한 행 만 실패하더라도 해당 테이블에 그 다음 내용은 추가,수정이 안 되므로 그 이 후 내용 수정, 추가 되도록 변경;girak.kim;
                        isQueryError = true;//중간 오류 발생함.
                        //nCheckToStepUp++;// nCheckToStepUp 는 일단 증가 시키지 않았음
                        continue;
                        //End
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_MSG.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //기존 소스
                //return true;
                //Start;2017.11.23;여러개 행 중에 중간 오류 발생 했는지 체크 하여 결과 리턴;girak.kim
                if (isQueryError) return false;
                else return true;
                //End;
            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.LOG_ERROR,
                                     System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                     System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                     ex.Message);

                return false;
            }
        }
        #endregion

        #region 15 - 문화 마스터 Download / Insert
        /// <summary>
        /// 문화 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <returns></returns>
        public bool MST_CULTURE(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_CULTURE.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_CULTURE.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CULTURE.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_CULTURE(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 문화 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_CULTURE(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_CULTURE \n"
                          + "   SET CULTURE_NM = N'{2}', MLT_CULT_ENG_NM = N'{3}', LANG_TYPE = N'{4}', NATN_TYPE = N'{5}', DT_PATTERN = '{6}' \n"
                          + "     , CURR_SYMBL = N'{7}', CURR_NM = N'{8}', DEC_PNT_DIGITS = {9}, DEC_PNT_SYMBL = N'{10}', GRP_DIGITS = {11} \n"
                          + "     , GRP_SYMBL = N'{12}', FILLER1 = '{13}', FILLER2 = '{14}', FILLER3 = '{15}', FILLER4 = '{16}' \n"
                          + "     , FILLER5 = '{17}', UPD_DT = '{18}', USE_YN = '{19}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND CULTURE_CD = '{1}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_CULTURE \n"
                          + "       ( CMP_CD, CULTURE_CD, CULTURE_NM, MLT_CULT_ENG_NM, LANG_TYPE \n"
                          + "       , NATN_TYPE, DT_PATTERN, CURR_SYMBL, CURR_NM, DEC_PNT_DIGITS \n"
                          + "       , DEC_PNT_SYMBL, GRP_DIGITS, GRP_SYMBL, FILLER1, FILLER2 \n"
                          + "       , FILLER3, FILLER4, FILLER5, REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', N'{2}', N'{3}', N'{4}' \n"
                          + "       , N'{5}', '{6}', N'{7}', N'{8}', {9} \n"
                          + "       , N'{10}', {11}, N'{12}', '{13}', '{14}' \n"
                          + "       , '{15}', '{16}', '{17}', '{18}', '{19}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"), 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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CULTURE.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 16 - 부가메뉴 마스터 Download / Insert
        /// <summary>
        /// 부가메뉴 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <returns></returns>
        public bool MST_SUBPRC_MENU(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_SUBPRC_MENU.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_SUBPRC_MENU.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_SUBPRC_MENU.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_SUBPRC_MENU(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 부가메뉴 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_SUBPRC_MENU(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sUpdQuery = "UPDATE POSMST..MST_SUBPRC_MENU \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND SUB_STOR_CD = '" + m_sSubStorNo + "' \n";

                sInsQuery = "UPDATE POSMST..MST_SUBPRC_MENU \n"
                          + "   SET SUBPRC_MENU_GRP_CD = '{5}', SUBPRC_MENU_GRP_NM = N'{6}', SEL_TYPE = '{7}', USE_YN = '{8}', FILLER1 = '{9}' \n"
                          + "     , FILLER2 = '{10}', FILLER3 = '{11}', FILLER4 = '{12}', FILLER5 = '{13}', UPD_DT = '{14}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND SUB_STOR_CD = '{2}' \n"
                          + "   AND M_CLSS = '{3}' \n"
                          + "   AND SEQ_NO = {4} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_SUBPRC_MENU \n"
                          + "       ( CMP_CD, STOR_CD, SUB_STOR_CD, M_CLSS, SEQ_NO \n"
                          + "       , SUBPRC_MENU_GRP_CD, SUBPRC_MENU_GRP_NM, SEL_TYPE, USE_YN, FILLER1 \n"
                          + "       , FILLER2, FILLER3, FILLER4, FILLER5, REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', {4} \n"
                          + "       , '{5}', N'{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' ) \n";

                sDelQuery = "DELETE FROM POSMST..MST_SUBPRC_MENU \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_SUBPRC_MENU 테이블은 INSERT 전 모든 데이터 삭제
                // 파스쿠찌 서초우성점 요청(점별 부가상품 관리) - 2017/04/12
                // 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);

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

                    sQuery = string.Format(sInsQuery
                                            , aParams[0], m_cPosStatus.Base.StoreNo, aParams[2], aParams[3], aParams[4]
                                            , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9]
                                            , aParams[10], aParams[11], aParams[12], aParams[13], DateTime.Now.ToString("yyyyMMddHHmmsss"));
                    
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_SUBPRC_MENU.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region 17 - 부가메뉴 그룹 마스터 Download / Insert
        /// <summary>
        /// 부가메뉴 그룹 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_SUBPRC_MENU_GRP(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_SUBPRC_MENU_GRP.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_SUBPRC_MENU_GRP.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_SUBPRC_MENU_GRP.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_SUBPRC_MENU_GRP(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 부가메뉴 그룹 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_SUBPRC_MENU_GRP(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sUpdQuery = "UPDATE POSMST..MST_SUBPRC_MENU_GRP \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND SUB_STOR_CD = '" + m_sSubStorNo + "' \n";

                sInsQuery = "UPDATE POSMST..MST_SUBPRC_MENU_GRP \n"
                          + "   SET SUBPRC_MENU_KEY_DIV = '{5}', SUBPRC_MENU_KEY_CD = '{6}', LABEL_NM = N'{7}', SUBPRC_MENU_KEY_VAL = '{8}', FONT_SIZE = {9} \n"
                          + "     , FONT_COLOR = '{10}', FILLER1 = '{11}', FILLER2 = '{12}', FILLER3 = '{13}', FILLER4 = '{14}' \n"
                          + "     , FILLER5 = '{15}', UPD_DT = '{16}', USE_YN = '{17}', UP_CHARGE_AMT = {18} \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND SUB_STOR_CD = '{2}' \n"
                          + "   AND SUBPRC_MENU_GRP_CD = '{3}' \n"
                          + "   AND SEQ_NO = {4} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_SUBPRC_MENU_GRP \n"
                          + "       ( CMP_CD, STOR_CD, SUB_STOR_CD, SUBPRC_MENU_GRP_CD, SEQ_NO \n"
                          + "       , SUBPRC_MENU_KEY_DIV, SUBPRC_MENU_KEY_CD, LABEL_NM, SUBPRC_MENU_KEY_VAL, FONT_SIZE \n"
                          + "       , FONT_COLOR, FILLER1, FILLER2, FILLER3, FILLER4 \n"
                          + "       , FILLER5, REG_DT, USE_YN, UP_CHARGE_AMT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', {4} \n"
                          + "       , '{5}', '{6}', N'{7}', '{8}', {9} \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}', '{16}', '{17}', {18} ) \n";

                sDelQuery = "DELETE FROM POSMST..MST_SUBPRC_MENU_GRP \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_SUBPRC_MENU_GRP 테이블은 INSERT 전 모든 데이터 삭제
                // 파스쿠찌 서초우성점 요청(점별 부가상품 관리) - 2017/04/12
                // 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);

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

                    sQuery = string.Format(sInsQuery
                                            , aParams[0], m_cPosStatus.Base.StoreNo, 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], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[18], aParams[19]);
                    
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_SUBPRC_MENU_GRP.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제 
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region 18 - 사용자 마스터 Download / Insert
        /// <summary>
        /// 사용자 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_USER(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_USER.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_USER.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_USER.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_USER(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 사용자 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_USER(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_USER \n"
                          + "   SET CASHIER_DIV = '{3}', CASHIER_NM = N'{4}', CASHIER_PWD = '{5}', CASHIER_CARD_NO = '{6}', RTN_PWD = '{7}' \n"
                          + "     , WEB_POS_PWD = '{8}', FILLER1 = '{9}', FILLER2 = '{10}', FILLER3 = '{11}', FILLER4 = '{12}' \n"
                          + "     , FILLER5 = '{13}', UPD_DT = '{14}', USE_YN = '{15}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND CASHIER_ID = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_USER \n"
                          + "       ( CMP_CD, STOR_CD, CASHIER_ID, CASHIER_DIV, CASHIER_NM \n"
                          + "       , CASHIER_PWD, CASHIER_CARD_NO, RTN_PWD, WEB_POS_PWD, FILLER1 \n"
                          + "       , FILLER2, FILLER3, FILLER4, FILLER5, REG_DT \n"
                          + "       , USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', N'{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss")
                                            , aParams[16]);
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_USER.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 19 - 상품 마스터 Download / Insert
        /// <summary>
        /// 상품 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_ITEM(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
         {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_ITEM.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_ITEM.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                //DateTime dtStart = DateTime.Now;

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //#20180410 상품마스터 마스터 수신 건수 로그 추가 start
                    
                    string sMstDwnCnt = aRowDatas.Length.ToString();
                                        
                    UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                        "MST_ITEM MasterDown - Count: " + sMstDwnCnt + ", UpdateDT: " + (MasterListManager.IsBackgroundMaster(MasterLists.MST_ITEM.ID) ? sBGUpdateDT : sUpdateDT));
                    
                    //#20180410 상품마스터 마스터 수신 건수 로그 추가 end

                    // DB Insert
                    //#20170912 스퀘어 점포 마스터 수신 마지막 점포만 받는 현상 수정 start
                    //기존
                    //if ((MasterListManager.IsBackgroundMaster(MasterLists.MST_ITEM.ID) ? sBGUpdateDT : sUpdateDT) == PosConst.BEGINNING_MST_DOWN_DATE)
                    //변경
                    if (((MasterListManager.IsBackgroundMaster(MasterLists.MST_ITEM.ID) ? sBGUpdateDT : sUpdateDT) == PosConst.BEGINNING_MST_DOWN_DATE) &&
                        (m_cPosStatus.Mst.ComplexShopType == "0"))
                    //#20170912 스퀘어 점포 마스터 수신 마지막 점포만 받는 현상 수정 end
                    {
                        //#20180410 상품마스터 마스터 수신 건수 로그 추가 start
                        UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                            System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                            "MST_ITEM MasterDown - all");
                        //#20180410 상품마스터 마스터 수신 건수 로그 추가 end

                        // 마스터 전체 수신
                        bReturn = UpdateEntireMST_ITEM(aRowDatas);
                    }
                    else
                    {
                        //#20180410 상품마스터 마스터 수신 건수 로그 추가 start
                        UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                            System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                            "MST_ITEM MasterDown - change");
                        //#20180410 상품마스터 마스터 수신 건수 로그 추가 end

                        // 마스터 변경 분 수신
                        bReturn = UpdateMST_ITEM(aRowDatas);
                    }
                }
                else
                {
                    return false;
                }

                //DateTime dtEnd = DateTime.Now;
                //TimeSpan duration = dtEnd.Subtract(dtStart);

                //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 (함수명))
                //                     MasterLists.MST_ITEM.ID + " duration : " + duration);

                return bReturn;
            }
            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>
        /// 상품 마스터 전체 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateEntireMST_ITEM(string[] aRowDatas)
        {
            //@@미주에서 51 번째로 TAX_AMT_INCLUDE_YN (부가세 정보) 가 내려오는거 관련하여 수정;girak.kim
            string[] aParams = null;

            try
            {
                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                string sTheName = System.Reflection.MethodBase.GetCurrentMethod().Name.Substring(12);
                string tmpTableDboNm = "[POSMST].[dbo].[temp_" + sTheName + "]";
                string orgTableDboNm = "[POSMST].[dbo].[" + sTheName + "]";
                string orgTableNm = sTheName;

                string tmpPKDboNm = "[POSMST].[dbo].[PK_temp_" + sTheName + "]";
                string orgPKNm = "PK_" + sTheName;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                #region ## POSMST..MST_ITEM 과 반드시 동기화 되어야 되는 DataTable ##
                DataTable tempTable = new DataTable();

                //2018.01.22;tempMST_ITEM PK 칼럼 지정(가끔 상품 코드에 대.소문자 구분없이 추가하여 오류 발생 시 원인 분석용;girak.kim;start
                /*기존 소스
                tempTable.Columns.Add("CMP_CD", typeof(string));
                tempTable.Columns.Add("STOR_CD", typeof(string));
                tempTable.Columns.Add("SUB_STOR_CD", typeof(string));
                tempTable.Columns.Add("ITEM_CD", typeof(string));
               */
                DataColumn colCMP_CD = new DataColumn(); colCMP_CD.ColumnName = "CMP_CD"; colCMP_CD.DataType = typeof(string);
                tempTable.Columns.Add(colCMP_CD);

                DataColumn colSTOR_CD = new DataColumn(); colSTOR_CD.ColumnName = "STOR_CD"; colSTOR_CD.DataType = typeof(string);
                tempTable.Columns.Add(colSTOR_CD);

                DataColumn colSUB_STOR_CD = new DataColumn(); colSUB_STOR_CD.ColumnName = "SUB_STOR_CD"; colSUB_STOR_CD.DataType = typeof(string);
                tempTable.Columns.Add(colSUB_STOR_CD);

                DataColumn colITEM_CD = new DataColumn(); colITEM_CD.ColumnName = "ITEM_CD"; colITEM_CD.DataType = typeof(string);
                tempTable.Columns.Add(colITEM_CD);
                
                //2018.01.22;tempMST_ITEM PK 칼럼 지정(가끔 상품 코드에 대.소문자 구분없이 추가하여 오류 발생 시 원인 분석용;girak.kim;End

                tempTable.Columns.Add("L_CLSS", typeof(string));
                tempTable.Columns.Add("M_CLSS", typeof(string));
                tempTable.Columns.Add("S_CLSS", typeof(string));
                tempTable.Columns.Add("FLAVOUR_DIV", typeof(string));
                tempTable.Columns.Add("FLAVOUR_QTY", typeof(double));
                tempTable.Columns.Add("FLAVOUR_STOCK", typeof(double));
                tempTable.Columns.Add("SHTCUT_ITEMNM", typeof(string));
                tempTable.Columns.Add("ITEN_NM", typeof(string));
                tempTable.Columns.Add("TAKE_IN_SALE_AMT", typeof(double));
                tempTable.Columns.Add("TAKE_OUT_SALE_AMT", typeof(double));
                tempTable.Columns.Add("IF_MENU1", typeof(string));
                tempTable.Columns.Add("IF_MENU2", typeof(string));
                tempTable.Columns.Add("OPEN_ITEM_DIV", typeof(string));
                tempTable.Columns.Add("DISPO_ITEM_DIV", typeof(string));
                tempTable.Columns.Add("SUB_SET_MNG_TYPE", typeof(string));
                tempTable.Columns.Add("ITEM_TAX_AMT_DIV", typeof(string));
                tempTable.Columns.Add("TAKE_IN_VAT_CD", typeof(string));
                tempTable.Columns.Add("TAKE_OUT_VAT_CD", typeof(string));
                tempTable.Columns.Add("ITEM_COST", typeof(double));
                tempTable.Columns.Add("SALE_PRMT_YN", typeof(string));
                tempTable.Columns.Add("SALE_NOQ", typeof(int));
                tempTable.Columns.Add("FREE_GIFT_YN", typeof(string));
                tempTable.Columns.Add("DC_PRMT_YN", typeof(string));
                tempTable.Columns.Add("ACCUM_PRMT_YN", typeof(string));
                tempTable.Columns.Add("SVC_FEE_TRGT_YN", typeof(string));
                tempTable.Columns.Add("BTN_ITEM_IMG", typeof(string));
                tempTable.Columns.Add("NEW_ITEM_START_DT", typeof(string));
                tempTable.Columns.Add("NEW_ITEM_FNSH_DT", typeof(string));
                tempTable.Columns.Add("ITEM_TYPE", typeof(string));
                tempTable.Columns.Add("TIME_BAR_CD_YN", typeof(string));
                tempTable.Columns.Add("DISTBT_EXPIRE_NOD", typeof(string));
                tempTable.Columns.Add("ALCOHOL_ITEM_TYPE", typeof(string));
                tempTable.Columns.Add("SALE_START_DT", typeof(string));
                tempTable.Columns.Add("SALE_FNSH_DT", typeof(string));
                tempTable.Columns.Add("COOP_CARD_DC_NOADM_YN", typeof(string));
                tempTable.Columns.Add("CAKE_EXCHNG_CPN_USE_POSS_YN", typeof(string));
                tempTable.Columns.Add("ITEM_INFO", typeof(string));
                tempTable.Columns.Add("CALORY_INFO", typeof(string));
                tempTable.Columns.Add("SALE_IMG_FILE_NM", typeof(string));
                tempTable.Columns.Add("FILLER1", typeof(string));
                tempTable.Columns.Add("FILLER2", typeof(string));
                tempTable.Columns.Add("FILLER3", typeof(string));
                tempTable.Columns.Add("FILLER4", typeof(string));
                tempTable.Columns.Add("FILLER5", typeof(string));
                tempTable.Columns.Add("USE_YN", typeof(string));
                tempTable.Columns.Add("UPD_DT", typeof(string));
                tempTable.Columns.Add("REG_DT", typeof(string));
                //MoonSeokWoo 2017.11.15 Add 
                tempTable.Columns.Add("RPST_ITEM_CD", typeof(string));
                //MoonSeokWoo 2017.11.15 End
                

                //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 start
                tempTable.Columns.Add("PLACE_ORIGIN", typeof(string)); // 원산지
                tempTable.Columns.Add("ITEM_EXPLN", typeof(string)); // 상품설명 
                tempTable.Columns.Add("ALLERGY", typeof(string)); // 알레르기성분
                //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 end


                //#15945 해피오더 자동주문 상세기능 start
                tempTable.Columns.Add("HP_ORD_DIV", typeof(string)); // 1: 해피오더 자동주문 대상 상품, 2: 그외 대상 아님

                tempTable.Columns.Add("ITEM_PROD_TYPE_YN", typeof(string)); //add 20180817 (Y: 제조혹시생산, N: 완제품, 공백: 그외)
                //#15945 해피오더 자동주문 상세기능 end

                tempTable.Columns.Add("TAX_AMT_INCLUDE_YN", typeof(string));//2018.01.04;TAX_AMT_INCLUDE_YN 칼럼 추가(상품에 부가세 포함 여부) ; girak.kim; 

                //#17143 [해피오더]자동 주문 처리 개선 start
                tempTable.Columns.Add("EXE_HPORD", typeof(string)); //(Y: 해피오더 자동주문 2차대상 제한상품, N: 해피오더 자동주문 2차대상 제한상품아님)
                //#17143 [해피오더]자동 주문 처리 개선 end

                tempTable.PrimaryKey = new DataColumn[] { colCMP_CD, colSTOR_CD, colSUB_STOR_CD, colITEM_CD };//2018.01.22;tempMST_ITEM PK 칼럼 지정(가끔 상품 코드에 대.소문자 구분없이 추가하여 오류 발생 시 원인 분석용;girak.kim

                #endregion ## POSMST..MST_ITEM 과 반드시 동기화 되어야 되는 DataTable ##

                string aParams_51 = string.Empty;//2018.01.02;미주에서 51 번째로 TAX_AMT_INCLUDE_YN 가 내려옴;girak.kim

                try
                {
                   foreach (string sRowData in aRowDatas)
                    {
                        #region
                        nCnt++;
                        aParams = sRowData.Split('|');

                        //2018.01.02;미주에서 51 번째로 TAX_AMT_INCLUDE_YN (부가세 정보) 가 내려옴;girak.kim
                        if (m_cPosStatus.Base.CmpCd.ToUpper().Equals(PosConst.POS_COMPANY_CODE.PCUS))
                        {                      
                                aParams_51 = aParams[51];//상품에 부가세 포함 여부
                        }
                        //                       

                        tempTable.Rows.Add( aParams[0], m_cPosStatus.Base.StoreNo, aParams[2], aParams[3], aParams[4]
                                          , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9]
                                          , aParams[10], aParams[11], aParams[12], aParams[13], aParams[14]
                                          , aParams[15], aParams[16], aParams[17], aParams[18], aParams[19]
                                          , aParams[20], aParams[21], aParams[22], aParams[23], aParams[24]
                                          , aParams[25], aParams[26], aParams[27], aParams[28], aParams[29]
                                          , aParams[30], aParams[31], aParams[32], aParams[33], aParams[34]
                                          , aParams[35], aParams[36], aParams[37], aParams[38], aParams[39]
                                          , aParams[40], aParams[41], aParams[42], aParams[43], aParams[44]
                                          , aParams[45], aParams[46], aParams[47], aParams[48], DateTime.Now.ToString("yyyyMMddHHmmsss")
                                          , DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[50] //MoonSeokWoo 2017.11.15 Add aParams[49]
                            //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 start
                            //기존
                            /*
                            , aParams_51); //2018.01.02;미주에서 51 번째로 TAX_AMT_INCLUDE_YN (부가세 정보) 가 내려옴(aParams_51);girak.kim
                            */
                            //변경
                                          , aParams_51
                                          , aParams[52]
                                          , aParams[53]
                                          , aParams[54]
                            //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 end

                        //#17143 [해피오더]자동 주문 처리 개선 start
                        //기존
                        /*
                            //#15945 해피오더 자동주문 상세기능 start
                                          , aParams[55]
                                          , aParams[56]); //add 20180817 (Y: 제조혹시생산, N: 완제품, 공백: 그외)
                            //#15945 해피오더 자동주문 상세기능 end  
                        */
                        //변경
                        
                                          , aParams[55]   
                                          , aParams[56]   // (Y: 제조혹시생산, N: 완제품, 공백: 그외)
                                          , aParams[57]); // (Y: 해피오더 자동주문 2차대상 제한상품, N: 해피오더 자동주문 2차대상 제한상품아님)
                        
                        //#17143 [해피오더]자동 주문 처리 개선 end

                             

                        if (nCheckToStepUp >= nCntToStepUp)
                        {
                            m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                            nCheckToStepUp = 0;
                        }
                        else
                        {
                            if (nCnt % 100 == 0 || nCnt == aRowDatas.Length)
                            {
                                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + sTheName + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                            }
                            nCheckToStepUp++;
                        }
                        #endregion
                    }

                    string strSqlConnectionString = "Data Source=" + m_cPosStatus.Base.LocalDbSource + "; Initial Catalog = " + m_cPosStatus.Base.LocalDbCatalog +
                                                    " ; uid = " + m_cPosStatus.Base.LocalDbUserID + "; Password = " + m_cPosStatus.Base.LocalDbPassword;
                 
                //2018.01.23;try{} 문을 foreach 상단으로 이동 시킴, foreach 데이터 insert 시에 pk 오류, 값 형식 등 발생시에 catch 할 수 있음,girak.kim
                //try
                //{
                    using (SqlBulkCopy bulkCopy = new SqlBulkCopy(strSqlConnectionString))
                    {
                        // 입력할 테이블 지정
                        bulkCopy.DestinationTableName = tmpTableDboNm;
                        //bulkCopy.BatchSize = 1000;
                        // 데이터 입력
                        bulkCopy.WriteToServer(tempTable);
                    }                    
                }
                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 (함수명))
                                         "1.Exception :" + ex.Message + ":" + nCnt.ToString());

                    // 임시테이블 DROP
                    m_cDatabaseSql.DBExecuteNonQuery("DROP TABLE " + tmpTableDboNm);

                    return false;
                }

                // 기존 테이블 DROP
                m_cDatabaseSql.DBExecuteNonQuery("DROP TABLE " + orgTableDboNm);

                // 임시 테이블을 본 테이블로 Rename
                m_cDatabaseSql.DBExecuteNonQuery("EXEC sp_rename '" + tmpTableDboNm + "', '" + orgTableNm + "'");
                m_cDatabaseSql.DBExecuteNonQuery("EXEC sp_rename '" + tmpPKDboNm + "', '" + orgPKNm + "'");
                
                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 (함수명))
                                     "2.Exception :" + ex.Message);

                return false;
            }
        }
        /// <summary>
        /// 상품 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_ITEM(string[] aRowDatas)
        {
            //@@미주에서 51 번째로 TAX_AMT_INCLUDE_YN (부가세 정보) 가 내려오는거 관련하여 수정;girak.kim

            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                
                sInsQuery = "UPDATE POSMST..MST_ITEM \n"
                          + "   SET L_CLSS = '{4}', M_CLSS = '{5}', S_CLSS = '{6}', FLAVOUR_DIV = '{7}', FLAVOUR_QTY = {8} \n"
                          + "     , FLAVOUR_STOCK = {9}, SHTCUT_ITEMNM = N'{10}', ITEM_NM = N'{11}', TAKE_IN_SALE_AMT = {12}, TAKE_OUT_SALE_AMT = {13} \n"
                          + "     , IF_MENU1 = '{14}', IF_MENU2 = '{15}', OPEN_ITEM_DIV = '{16}', DISPO_ITEM_DIV = '{17}', SUB_SET_MNG_TYPE = '{18}' \n"
                          + "     , ITEM_TAX_AMT_DIV = '{19}', TAKE_IN_VAT_CD = '{20}', TAKE_OUT_VAT_CD = '{21}', ITEM_COST = {22} \n"
                          + "     , SALE_PRMT_YN = '{23}', SALE_NOQ = {24}, FREE_GIFT_YN = '{25}', DC_PRMT_YN = '{26}', ACCUM_PRMT_YN = '{27}' \n"
                          + "     , SVC_FEE_TRGT_YN = '{28}', BTN_ITEM_IMG = '{29}', NEW_ITEM_START_DT = '{30}', NEW_ITEM_FNSH_DT = '{31}', ITEM_TYPE = '{32}' \n"
                          + "     , TIME_BAR_CD_YN = '{33}', DISTBT_EXPIRE_NOD = '{34}', ALCOHOL_ITEM_TYPE = '{35}', SALE_START_DT = '{36}', SALE_FNSH_DT = '{37}' \n"
                          + "     , COOP_CARD_DC_NOADM_YN = '{38}', CAKE_EXCHNG_CPN_USE_POSS_YN = '{39}', ITEM_INFO = N'{40}', CALORY_INFO = N'{41}', SALE_IMG_FILE_NM = '{42}' \n"
                          + "     , FILLER1 = '{43}', FILLER2 = '{44}', FILLER3 = '{45}', FILLER4 = '{46}', FILLER5 = '{47}' \n"
                          + "     , USE_YN = '{48}', UPD_DT = '{49}' , RPST_ITEM_CD = '{50}' \n"
                          + "     , TAX_AMT_INCLUDE_YN = '{51}' \n" //2018.01.04;TAX_AMT_INCLUDE_YN 칼럼 추가(상품에 부가세 포함 여부) ; girak.kim;
                          
                          //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 start

                          + "     , PLACE_ORIGIN = '{52}' \n" // 원산지정보
                          + "     , ALLERGY = '{53}' \n" // 알레리기성분
                          + "     , ITEM_EXPLN = '{54}' \n" // 상품설명

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

                          //#15945 해피오더 자동주문 상세기능 start
                          + "     , HP_ORD_DIV = '{55}' \n"
                          + "     , ITEM_PROD_TYPE_YN = '{56}' \n" //add 20180817 (Y: 제조혹시생산, N: 완제품, 공백: 그외)
                          //#15945 해피오더 자동주문 상세기능 end

                          //#17143 [해피오더]자동 주문 처리 개선 start
                          + "     , EXE_HPORD = '{57}' \n" // (Y: 해피오더 자동주문 2차대상 제한상품, N: 해피오더 자동주문 2차대상 제한상품아님)
                          //#17143 [해피오더]자동 주문 처리 개선 end

                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND SUB_STOR_CD = '{2}' \n"
                          + "   AND ITEM_CD = '{3}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_ITEM \n"
                          + "       ( CMP_CD, STOR_CD, SUB_STOR_CD, ITEM_CD, L_CLSS \n"
                          + "       , M_CLSS, S_CLSS, FLAVOUR_DIV, FLAVOUR_QTY, FLAVOUR_STOCK \n"
                          + "       , SHTCUT_ITEMNM, ITEM_NM, TAKE_IN_SALE_AMT, TAKE_OUT_SALE_AMT, IF_MENU1 \n"
                          + "       , IF_MENU2, OPEN_ITEM_DIV, DISPO_ITEM_DIV, SUB_SET_MNG_TYPE, ITEM_TAX_AMT_DIV \n"
                          + "       , TAKE_IN_VAT_CD, TAKE_OUT_VAT_CD, ITEM_COST, SALE_PRMT_YN, SALE_NOQ \n"
                          + "       , FREE_GIFT_YN, DC_PRMT_YN, ACCUM_PRMT_YN, SVC_FEE_TRGT_YN, BTN_ITEM_IMG \n"
                          + "       , NEW_ITEM_START_DT, NEW_ITEM_FNSH_DT, ITEM_TYPE, TIME_BAR_CD_YN, DISTBT_EXPIRE_NOD \n"
                          + "       , ALCOHOL_ITEM_TYPE, SALE_START_DT, SALE_FNSH_DT, COOP_CARD_DC_NOADM_YN, CAKE_EXCHNG_CPN_USE_POSS_YN \n"
                          + "       , ITEM_INFO, CALORY_INFO, SALE_IMG_FILE_NM, FILLER1, FILLER2 \n"
                          + "       , FILLER3, FILLER4, FILLER5, USE_YN, REG_DT, RPST_ITEM_CD \n" //MoonSEokWoo  2017.11.15  RPST_ITEM_CD 추가
                          //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 start
                          //기존
                          //+ "       , TAX_AMT_INCLUDE_YN) \n" //2018.01.04;TAX_AMT_INCLUDE_YN 칼럼 추가(상품에 부가세 포함 여부) ; girak.kim;
                          //변경
                          + "       , TAX_AMT_INCLUDE_YN, PLACE_ORIGIN, ALLERGY,ITEM_EXPLN  \n"
                          //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 end

                          //#15945 해피오더 자동주문 상세기능 start
                          + "       , HP_ORD_DIV \n"
                          + "       , ITEM_PROD_TYPE_YN \n" //add 20180817 (Y: 제조혹시생산, N: 완제품, 공백: 그외)
                          //#15945 해피오더 자동주문 상세기능 end

                          //#17143 [해피오더]자동 주문 처리 개선 start
                          + "       , EXE_HPORD \n" // (Y: 해피오더 자동주문 2차대상 제한상품, N: 해피오더 자동주문 2차대상 제한상품아님)
                          //#17143 [해피오더]자동 주문 처리 개선 end

                          + "       ) \n"
                          
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', {8}, {9} \n"
                          + "       , N'{10}', N'{11}', {12}, {13}, '{14}' \n"
                          + "       , '{15}', '{16}', '{17}', '{18}', '{19}' \n"
                          + "       , '{20}', '{21}', {22}, '{23}', {24} \n"
                          + "       , '{25}', '{26}', '{27}', '{28}', '{29}' \n"
                          + "       , '{30}', '{31}', '{32}', '{33}', '{34}' \n"
                          + "       , '{35}', '{36}', '{37}', '{38}', '{39}' \n"
                          + "       , N'{40}', N'{41}', '{42}', '{43}', '{44}' \n"
                          + "       , '{45}', '{46}', '{47}', '{48}', '{49}' ,'{50}' \n"  //MoonSEokWoo  2017.11.15  RPST_ITEM_CD 추가
                         //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 start
                         //기존
                         //+ "        , '{51}') \n";  ///2018.01.04;TAX_AMT_INCLUDE_YN 칼럼 추가(상품에 부가세 포함 여부) ; girak.kim;
                         //변경
                         + "        , '{51}', '{52}', '{53}', '{54}' \n"
                         //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 end

                         //#15945 해피오더 자동주문 상세기능 start
                         + "        , '{55}' \n"
                         + "        , '{56}' \n" //add 20180817 (Y: 제조혹시생산, N: 완제품, 공백: 그외)
                         //#15945 해피오더 자동주문 상세기능 end

                         //#17143 [해피오더]자동 주문 처리 개선 start
                         + "        , '{57}' \n" // (Y: 해피오더 자동주문 2차대상 제한상품, N: 해피오더 자동주문 2차대상 제한상품아님)
                         //#17143 [해피오더]자동 주문 처리 개선 end

                         +"        ) \n";
                         

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);
                bool isQueryError = false;//2017.11.23;여러개 행 중에 중간에 오류 발생 했는지 여부;girak.kim

                string aParams_51 = string.Empty;//미주에서 51 번째로 TAX_AMT_INCLUDE_YN 가 내려옴...

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

                    //@@미주에서 51 번째로 TAX_AMT_INCLUDE_YN (부가세 정보) 가 내려옴;girak.kim
                    if (m_cPosStatus.Base.CmpCd.ToUpper().Equals(PosConst.POS_COMPANY_CODE.PCUS))
                    {                     
                            aParams_51 = aParams[51];//@@부가세 포함
                    }                    
                    //

                    sQuery = string.Format( sInsQuery
                                          , aParams[0], m_cPosStatus.Base.StoreNo, aParams[2], aParams[3], aParams[4]
                                          , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9]
                                          , aParams[10], aParams[11], aParams[12], aParams[13], aParams[14]
                                          , aParams[15], aParams[16], aParams[17], aParams[18], aParams[19]
                                          , aParams[20], aParams[21], aParams[22], aParams[23], aParams[24]
                                          , aParams[25], aParams[26], aParams[27], aParams[28], aParams[29]
                                          , aParams[30], aParams[31], aParams[32], aParams[33], aParams[34]
                                          , aParams[35], aParams[36], aParams[37], aParams[38], aParams[39]
                                          , aParams[40], aParams[41], aParams[42], aParams[43], aParams[44]
                                          , aParams[45], aParams[46], aParams[47], aParams[48], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[50]//MoonSEokWoo  2017.11.15  RPST_ITEM_CD 추가
                                          //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 start
                                          //기존
                                          //, aParams_51); //@@미주에서 51 번째로 TAX_AMT_INCLUDE_YN (부가세 정보) 가 내려옴(aParams_51);girak.kim
                                          //변경
                                          , aParams_51, aParams[52], aParams[53], aParams[54]
                                          //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 end

                                          //#15945 해피오더 자동주문 상세기능 start
                                          , aParams[55]
                                          , aParams[56] //add 20180817 (Y: 제조혹시생산, N: 완제품, 공백: 그외)
                                          //#15945 해피오더 자동주문 상세기능 end

                                          //#17143 [해피오더]자동 주문 처리 개선 start
                                          , aParams[57] // (Y: 해피오더 자동주문 2차대상 제한상품, N: 해피오더 자동주문 2차대상 제한상품아님)
                                          //#17143 [해피오더]자동 주문 처리 개선 end
                                          );

                    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 false; 기존 소스      
                        //Strat;2017.11.23;한 행 만 실패하더라도 해당 테이블에 그 다음 내용은 추가,수정이 안 되므로 그 이 후 내용 수정, 추가 되도록 변경;girak.kim;
                        isQueryError = true;//중간 오류 발생함.
                        //nCheckToStepUp++;// nCheckToStepUp 는 일단 증가 시키지 않았음
                        continue;
                        //End
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //기존 소스
                //return true;
                //Start;2017.11.23;여러개 행 중에 중간 오류 발생 했는지 체크 하여 결과 리턴;girak.kim
                if (isQueryError) return false;
                else return true;
                //End;
            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.LOG_ERROR,
                                     System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                     System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                     ex.Message);

                return false;
            }
        }
        #endregion

        #region 20 - 상품 바코드 마스터 Download / Insert
        /// <summary>
        /// 상품 바코드 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_ITEM_BAR_CD(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_ITEM_BAR_CD.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_ITEM_BAR_CD.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                //#20171102 MST_ITEM_BAR_CD 마스터 수신 로그 생성 start
                /*
                string sJsonSendData = string.Empty;
                sJsonSendData = JsonConvert.SerializeObject(htReqData);

                Byte[] sBytTempBuff = Encoding.UTF8.GetBytes(sJsonSendData);
                string sDataLen = string.Format("{0:000000}", sBytTempBuff.Length);

                string sCommData = ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd);
                sCommData = sDataLen + sCommData.Substring(TcpSocket.COMM_MSGLEN);

                WriteLogFile(CmUtil.RPadH("[SEND" + ":" + m_cPosStatus.Base.CommSvrIp + ":" + (int)m_cPosStatus.Base.MstPort, 27) + "] " + sCommData + sJsonSendData);
                */
                //#20171102 MST_ITEM_BAR_CD 마스터 수신 로그 생성 end


                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM_BAR_CD.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    //#20171102 MST_ITEM_BAR_CD 마스터 수신 로그 생성 start
                    //WriteLogFile(CmUtil.RPadH("[RECV" + ":" + m_cPosStatus.Base.CommSvrIp + ":" + (int)m_cPosStatus.Base.MstPort, 27) + "] " + sbRecvData.ToString());
                    //#20171102 MST_ITEM_BAR_CD 마스터 수신 로그 생성 end
                    
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    //#20170912 스퀘어 점포 마스터 수신 마지막 점포만 받는 현상 수정 start
                    //기존
                    //if ((MasterListManager.IsBackgroundMaster(MasterLists.MST_ITEM.ID) ? sBGUpdateDT : sUpdateDT) == PosConst.BEGINNING_MST_DOWN_DATE)
                    //변경
                    if (((MasterListManager.IsBackgroundMaster(MasterLists.MST_ITEM.ID) ? sBGUpdateDT : sUpdateDT) == PosConst.BEGINNING_MST_DOWN_DATE) &&
                        (m_cPosStatus.Mst.ComplexShopType == "0"))
                    //#20170912 스퀘어 점포 마스터 수신 마지막 점포만 받는 현상 수정 end
                    {
                        // 마스터 전체 수신
                        bReturn = UpdateEntireMST_ITEM_BAR_CD(aRowDatas);
                    }
                    else
                    {
                        // 마스터 변경 분 수신
                        bReturn = UpdateMST_ITEM_BAR_CD(aRowDatas);
                    }
                }
                else
                {
                    return false;
                }

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

        private bool UpdateEntireMST_ITEM_BAR_CD(string[] aRowDatas)
        {
            string[] aParams = null;

            try
            {
                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                string sTheName = System.Reflection.MethodBase.GetCurrentMethod().Name.Substring(12);
                string tmpTableDboNm = "[POSMST].[dbo].[temp_" + sTheName + "]";
                string orgTableDboNm = "[POSMST].[dbo].[" + sTheName + "]";
                string orgTableNm = sTheName;

                string tmpPKDboNm = "[POSMST].[dbo].[PK_temp_" + sTheName + "]";
                string orgPKNm = "PK_" + sTheName;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                #region ## POSMST..MST_ITEM_BAR_CD 과 반드시 동기화 되어야 되는 DataTable ##
                DataTable tempTable = new DataTable();
                tempTable.Columns.Add("CMP_CD", typeof(string));
                tempTable.Columns.Add("STOR_CD", typeof(string));
                tempTable.Columns.Add("SUB_STOR_CD", typeof(string));
                tempTable.Columns.Add("BAR_CD_NO", typeof(string));
                tempTable.Columns.Add("ITEM_CD", typeof(string));
                tempTable.Columns.Add("FILLER1", typeof(string));
                tempTable.Columns.Add("FILLER2", typeof(string));
                tempTable.Columns.Add("FILLER3", typeof(string));
                tempTable.Columns.Add("FILLER4", typeof(string));
                tempTable.Columns.Add("FILLER5", typeof(string));
                tempTable.Columns.Add("UPD_DT", typeof(string));
                tempTable.Columns.Add("REG_DT", typeof(string));
                tempTable.Columns.Add("USE_YN", typeof(string));
                #endregion ## POSMST..MST_ITEM_BAR_CD 과 반드시 동기화 되어야 되는 DataTable ##

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

                    tempTable.Rows.Add( aParams[0], m_cPosStatus.Base.StoreNo, aParams[2], aParams[3], aParams[4]
                                      , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9]
                                      , DateTime.Now.ToString("yyyyMMddHHmmsss"), DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[12]);

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % 100 == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + sTheName + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                string strSqlConnectionString = "Data Source=" + m_cPosStatus.Base.LocalDbSource + "; Initial Catalog = " + m_cPosStatus.Base.LocalDbCatalog +
                                                    " ; uid = " + m_cPosStatus.Base.LocalDbUserID + "; Password = " + m_cPosStatus.Base.LocalDbPassword;

                try
                {
                    using (SqlBulkCopy bulkCopy = new SqlBulkCopy(strSqlConnectionString))
                    {
                        // 입력할 테이블 지정
                        bulkCopy.DestinationTableName = tmpTableDboNm;
                        //bulkCopy.BatchSize = 1000;
                        // 데이터 입력
                        bulkCopy.WriteToServer(tempTable);
                    }
                }
                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);

                    // 임시테이블 DROP
                    m_cDatabaseSql.DBExecuteNonQuery("DROP TABLE " + tmpTableDboNm);

                    return false;
                }

                // 기존 테이블 DROP
                m_cDatabaseSql.DBExecuteNonQuery("DROP TABLE " + orgTableDboNm);

                // 임시 테이블을 본 테이블로 Rename
                m_cDatabaseSql.DBExecuteNonQuery("EXEC sp_rename '" + tmpTableDboNm + "', '" + orgTableNm + "'");
                m_cDatabaseSql.DBExecuteNonQuery("EXEC sp_rename '" + tmpPKDboNm + "', '" + orgPKNm + "'");

                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>
        /// 상품 바코드 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_ITEM_BAR_CD(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_ITEM_BAR_CD \n"
                          + "   SET ITEM_CD = '{4}', FILLER1 = '{5}', FILLER2 = '{6}', FILLER3 = '{7}', FILLER4 = '{8}' \n"
                          + "     , FILLER5 = '{9}', UPD_DT = '{10}', USE_YN = '{11}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD= '{1}' \n"
                          + "   AND SUB_STOR_CD = '{2}' \n"
                          + "   AND BAR_CD_NO = '{3}' \n"
                          //#20180222 중복바코드 존재시 해당 바코드 마스터 수신되는 경우 에러 발생 start
                          + "   AND ITEM_CD = '{4}' \n"
                          //#20180222 중복바코드 존재시 해당 바코드 마스터 수신되는 경우 에러 발생 end
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_ITEM_BAR_CD \n"
                          + "       ( CMP_CD, STOR_CD, SUB_STOR_CD, BAR_CD_NO, ITEM_CD \n"
                          + "       , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n"
                          + "       , REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

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

                    sQuery = string.Format(sInsQuery
                                            , aParams[0], m_cPosStatus.Base.StoreNo, aParams[2], aParams[3], aParams[4]
                                            , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9]
                                            , DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[12]);
                    
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM_BAR_CD.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 21 - 상품권 마스터 Download / Insert
        /// <summary>
        /// 상품권 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_GIF(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_GIF.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_GIF.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_GIF.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_GIF(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 상품권 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_GIF(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sUpdQuery += "UPDATE POSMST..MST_GIF ";
                sUpdQuery += "   SET UPD_DT = 'DELETE' ";

                sInsQuery += "UPDATE POSMST..MST_GIF ";
                sInsQuery += "   SET GIF_SHORT_NM = N'{1}', GIF_NM = N'{2}', BRAND_CD = '{3}', GIF_FIX_BRAND_CD = '{4}', GIF_AMT = {5} ";
                sInsQuery += "     , APPR_YN = '{6}', MNDTRY_INPUT_YN = '{7}', BTN_BACKGRCOLOR = '{8}', FONT_COLOR = '{9}', IMG_USE_YN = '{10}' ";
                sInsQuery += "     , IMG_PATH = N'{11}', HP_ACCUM_YN = '{12}', APPR_SVR_DIV = '{13}', SORT_QUE = '{14}', CHANGE_PAYMNT_YN = '{15}' ";
                sInsQuery += "     , HPY_GIF_DIV = '{16}', USE_YN = '{17}', FILLER1 = '{18}', FILLER2 = '{19}', FILLER3 = '{20}' ";
                sInsQuery += "     , FILLER4 = '{21}', FILLER5 = '{22}', UPD_DT = '{23}' ";
                sInsQuery += " WHERE GIF_CD = '{0}' ";
                sInsQuery += "IF @@ROWCOUNT = 0 ";
                sInsQuery += "INSERT INTO POSMST..MST_GIF ";
                sInsQuery += "       ( GIF_CD, GIF_SHORT_NM, GIF_NM, BRAND_CD, GIF_FIX_BRAND_CD ";
                sInsQuery += "       , GIF_AMT, APPR_YN, MNDTRY_INPUT_YN, BTN_BACKGRCOLOR, FONT_COLOR ";
                sInsQuery += "       , IMG_USE_YN, IMG_PATH, HP_ACCUM_YN, APPR_SVR_DIV, SORT_QUE ";
                sInsQuery += "       , CHANGE_PAYMNT_YN, HPY_GIF_DIV, USE_YN, FILLER1, FILLER2 ";
                sInsQuery += "       , FILLER3, FILLER4, FILLER5, REG_DT ) ";
                sInsQuery += "VALUES ";
                sInsQuery += "       ( '{0}', N'{1}', N'{2}', '{3}', '{4}' ";
                sInsQuery += "       , {5}, '{6}', '{7}', '{8}', '{9}' ";
                sInsQuery += "       , '{10}', N'{11}', '{12}', '{13}', {14} ";
                sInsQuery += "       , '{15}', '{16}', '{17}', '{18}', '{19}' ";
                sInsQuery += "       , '{20}', '{21}', '{22}', '{23}' ) ";

                sDelQuery += "DELETE FROM POSMST..MST_GIF ";
                sDelQuery += " WHERE UPD_DT = 'DELETE' ";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_GIF 테이블은 INSERT 전 모든 데이터 삭제
                // 안호성C 요청 - 2016/11/25
                //m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);
                // 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], aParams[21], aParams[22], DateTime.Now.ToString("yyyyMMddHHmmsss"));
                    
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_GIF.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region 22 - 세트 마스터 Download / Insert
        /// <summary>
        /// 세트 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_ITEM_SET(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_ITEM_SET.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_ITEM_SET.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM_SET.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_ITEM_SET(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 세트 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_ITEM_SET(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sUpdQuery = "UPDATE POSMST..MST_ITEM_SET \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND SUB_STOR_CD = '" + m_sSubStorNo + "' \n";

                sInsQuery = "UPDATE POSMST..MST_ITEM_SET \n"
                          + "   SET SET_ITEM_DIV = '{6}', SET_ITEM_CD = '{7}', SET_ITEM_QTY = {8}, SET_GRPNM = N'{9}', SET_ITEM_GRP_CD = '{10}' \n"
                          + "     , FILLER1 = '{11}', FILLER2 = '{12}', FILLER3 = '{13}', FILLER4 = '{14}', FILLER5 = '{15}' \n"
                          + "     , UPD_DT = '{16}', USE_YN = '{17}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND SUB_STOR_CD = '{2}' \n"
                          + "   AND ITEM_CD = '{3}' \n"
                          + "   AND SET_AUTO_DIV = '{4}' \n"
                          + "   AND SEQ_NO = {5} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_ITEM_SET \n"
                          + "       ( CMP_CD, STOR_CD, SUB_STOR_CD, ITEM_CD, SET_AUTO_DIV \n"
                          + "       , SEQ_NO, SET_ITEM_DIV, SET_ITEM_CD, SET_ITEM_QTY, SET_GRPNM \n"
                          + "       , SET_ITEM_GRP_CD , FILLER1, FILLER2, FILLER3, FILLER4 \n"
                          + "       , FILLER5, REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , {5}, '{6}', '{7}', {8}, N'{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}', '{16}', '{17}' ) \n";

                sDelQuery = "DELETE FROM POSMST..MST_ITEM_SET \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND SUB_STOR_CD = '" + m_sSubStorNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";


                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_ITEM_SET 테이블은 INSERT 전 모든 데이터 삭제
                // 손현봉B 요청 - 2017/03/14
                // 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);

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

                    sQuery = string.Format( sInsQuery
                                          , aParams[0], m_cPosStatus.Base.StoreNo, 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], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[18] );
                    
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM_SET.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region 23 - 세트그룹 마스터 Download / Insert
        /// <summary>
        /// 세트그룹 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_ITEM_SET_GRP(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_ITEM_SET_GRP.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_ITEM_SET_GRP.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM_SET_GRP.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_ITEM_SET_GRP(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 세트그룹 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_ITEM_SET_GRP(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_ITEM_SET_GRP \n"
                          + "   SET SET_ITEM_CD = '{5}', LABEL_NM = N'{6}', SET_ITEM_UP_PRC = {7}, FONT_SIZE = {8}, FONT_COLOR = '{9}' \n"
                          + "     , FILLER1 = '{10}', FILLER2 = '{11}', FILLER3 = '{12}', FILLER4 = '{13}', FILLER5 = '{14}' \n"
                          + "     , REG_DT = '{15}', USE_YN = '{16}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND SUB_STOR_CD = '{2}' \n"
                          + "   AND SET_ITEM_GRP_CD = '{3}' \n"
                          + "   AND SEQ_NO = {4} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_ITEM_SET_GRP \n"
                          + "       ( CMP_CD, STOR_CD, SUB_STOR_CD, SET_ITEM_GRP_CD, SEQ_NO \n"
                          + "       , SET_ITEM_CD, LABEL_NM, SET_ITEM_UP_PRC, FONT_SIZE, FONT_COLOR \n"
                          + "       , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n"
                          + "       , REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', {4} \n"
                          + "       , '{5}', N'{6}', {7}, {8}, '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}', '{16}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

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

                    sQuery = string.Format(sInsQuery
                                            , aParams[0], m_cPosStatus.Base.StoreNo, 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]
                                            , DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[17]);
                    
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM_SET_GRP.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 24 - 식권 마스터 Download / Insert
        /// <summary>
        /// 식권 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_MEAL_TCKT(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_MEAL_TCKT.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_MEAL_TCKT.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_MEAL_TCKT.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_MEAL_TCKT(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 식권 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_MEAL_TCKT(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_MEAL_TCKT \n"
                          + "   SET MEAL_TCKT_NM = N'{3}', MEAL_TCKT_FACE_AMT = {4}, BLNC_AMT_EXCHNG_CPN_ISSUE_YN = '{5}', CHANGE_PAYMNT_YN = '{6}', FILLER1 = '{7}' \n"
                          + "     , FILLER2 = '{8}', FILLER3 = '{9}', FILLER4 = '{10}', FILLER5 = '{11}', UPD_DT = '{12}', USE_YN = '{13}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND MEAL_TCKT_ID = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_MEAL_TCKT \n"
                          + "       ( CMP_CD, STOR_CD, MEAL_TCKT_ID, MEAL_TCKT_NM, MEAL_TCKT_FACE_AMT \n"
                          + "       , BLNC_AMT_EXCHNG_CPN_ISSUE_YN, CHANGE_PAYMNT_YN, FILLER1, FILLER2, FILLER3 \n"
                          + "       , FILLER4, FILLER5, REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', N'{3}', {4} \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[14]);
                    
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_MEAL_TCKT.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 25 - 영수증 마스터 Download / Insert
        /// <summary>
        /// 영수증 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_BILL_MSG(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_BILL_MSG.DIV,
                                                //#20171211 MST_BILL_MSG 내려온 데이터 이외는 삭제 처리 start
                                                //항상 마스터 전체 받도록 수정
                                                //기존
                                                //(MasterListManager.IsBackgroundMaster(MasterLists.MST_BILL_MSG.ID) ? sBGUpdateDT : sUpdateDT),
                                                //변경
                                                "20000101000000",
                                                //#20171211 MST_BILL_MSG 내려온 데이터 이외는 삭제 처리 end
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_BILL_MSG.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_BILL_MSG(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 영수증 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_BILL_MSG(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            //#20171211 MST_BILL_MSG 내려온 데이터 이외는 삭제 처리 start
            //서버에서 삭제시킨건 데이터 내려오지 않음.
            string sUpdQuery = string.Empty;
            //#20171211 MST_BILL_MSG 내려온 데이터 이외는 삭제 처리 end
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                //#20171211 MST_BILL_MSG 내려온 데이터 이외는 삭제 처리 start
                sUpdQuery = "UPDATE POSMST..MST_BILL_MSG \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
                //#20171211 MST_BILL_MSG 내려온 데이터 이외는 삭제 처리 end

                sInsQuery = "UPDATE POSMST..MST_BILL_MSG \n"
                          + "   SET PRT_SEQ = '{5}', PRT_DIV = '{6}', PRT_START_DT = '{7}', PRT_FNSH_DT = '{8}', PRT_START_HOUR = '{9}' \n"
                          + "     , PRT_FNSH_HOUR = '{10}', EXPAND_CHAR = '{11}', BOLD_YN = '{12}', ALIGN_TYPE = '{13}', CHAR_ROW = N'{14}' \n"
                          + "     , FILLER1 = '{15}', FILLER2 = '{16}', FILLER3 = '{17}', FILLER4 = '{18}', FILLER5 = '{19}' \n"
                          + "     , UPD_DT = '{20}', USE_YN = '{21}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND PRT_LOC = '{2}' \n"
                          + "   AND WRITE_DIV = '{3}' \n"
                          + "   AND SEQ = {4} \n"
                          // Rhee, 20171120, 프린트메시지 마스터 수신 키(START_DT) 추가 Start
                          + "   AND PRT_START_DT = '{7}' \n"       // 키(START_DT) 추가 
                          // Rhee, 20171120, 프린트메시지 마스터 수신 키(START_DT) 추가 End
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_BILL_MSG \n"
                          + "       ( CMP_CD, STOR_CD, PRT_LOC, WRITE_DIV, SEQ \n"
                          + "       , PRT_SEQ, PRT_DIV, PRT_START_DT, PRT_FNSH_DT, PRT_START_HOUR \n"
                          + "       , PRT_FNSH_HOUR, EXPAND_CHAR, BOLD_YN, ALIGN_TYPE, CHAR_ROW \n"
                          + "       , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n"
                          + "       , REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', {4} \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', N'{14}' \n"
                          + "       , '{15}', '{16}', '{17}', '{18}', '{19}' \n"
                          + "       , '{20}', '{21}' ) \n";

                //#20171211 MST_BILL_MSG 내려온 데이터 이외는 삭제 처리 start
                sDelQuery = "DELETE FROM POSMST..MST_BILL_MSG \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";
                //#20171211 MST_BILL_MSG 내려온 데이터 이외는 삭제 처리 end

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //#20171211 MST_BILL_MSG 내려온 데이터 이외는 삭제 처리 start
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);
                //#20171211 MST_BILL_MSG 내려온 데이터 이외는 삭제 처리 end

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]
                                            , DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[22]);                    

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_BILL_MSG.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //#20171211 MST_BILL_MSG 내려온 데이터 이외는 삭제 처리 start
                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);
                //#20171211 MST_BILL_MSG 내려온 데이터 이외는 삭제 처리 end

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

                return false;
            }
        }
        #endregion

        #region 26 - 영수증유형 마스터 Download / Insert
        /// <summary>
        /// 영수증유형 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_BILL_TYPE(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_BILL_TYPE.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_BILL_TYPE.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_BILL_TYPE.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    if (sbRecvData == null || sbRecvData.ToString().Length == 0)
                    {
                        bReturn = true;
                    }
                    else
                    {
                        // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                        string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                        // DB Insert
                        bReturn = UpdateMST_BILL_TYPE(aRowDatas);
                    }
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 영수증유형 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_BILL_TYPE(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sUpdQuery = "UPDATE POSMST..MST_BILL_TYPE \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";

                sInsQuery = "UPDATE POSMST..MST_BILL_TYPE \n"
                          + "   SET SORT_DIV = '{5}', SIZE_DIV = '{6}', BOLD_YN = '{7}', BILL_TYPE_TAG = N'{8}', FILLER1 = '{9}' \n"
                          + "     , FILLER2 = '{10}', FILLER3 = '{11}', FILLER4 = '{12}', FILLER5 = '{13}', UPD_DT = '{14}' \n"
                          + "     , USE_YN = '{15}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND BILL_TYPE_GRP_CD = '{2}' \n"
                          + "   AND BILL_TYPE_DIV = '{3}' \n"
                          + "   AND SEQ_NO = {4} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_BILL_TYPE \n"
                          + "       ( CMP_CD, STOR_CD, BILL_TYPE_GRP_CD, BILL_TYPE_DIV, SEQ_NO \n"
                          + "       , SORT_DIV, SIZE_DIV, BOLD_YN, BILL_TYPE_TAG, FILLER1 \n"
                          + "       , FILLER2, FILLER3, FILLER4, FILLER5, REG_DT \n"
                          + "       , USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', {4} \n"
                          + "       , '{5}', '{6}', '{7}', N'{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}' ) \n";

                sDelQuery = "DELETE FROM POSMST..MST_BILL_TYPE \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_BILL_TYPE 테이블은 INSERT 전 모든 데이터 삭제
                // 황권일C 요청 - 2016/12/02
                //m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);
                // 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss")
                                            , aParams[16]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_BILL_TYPE.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region 27 - 영수증유형그룹 마스터 Download / Insert
        /// <summary>
        /// 영수증유형그룹 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_BILL_TYPE_GRP(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_BILL_TYPE_GRP.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_BILL_TYPE_GRP.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_BILL_TYPE_GRP.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_BILL_TYPE_GRP(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 영수증유형그룹 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_BILL_TYPE_GRP(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_BILL_TYPE_GRP \n"
                          + "   SET BILL_TYPE_GRP_NM = N'{3}', FILLER1 = '{4}', FILLER2 = '{5}', FILLER3 = '{6}', FILLER4 = '{7}' \n"
                          + "     , FILLER5 = '{8}', UPD_DT = '{9}', USE_YN = '{10}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND BILL_TYPE_GRP_CD = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_BILL_TYPE_GRP \n"
                          + "       ( CMP_CD, STOR_CD, BILL_TYPE_GRP_CD, BILL_TYPE_GRP_NM, FILLER1 \n"
                          + "       , FILLER2, FILLER3, FILLER4, FILLER5, REG_DT \n"
                          + "       , USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', N'{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss")
                                            , aParams[11]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_BILL_TYPE_GRP.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 28 - 점포 마스터 Download / Insert
        /// <summary>
        /// 점포 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_STOR(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_STOR.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_STOR.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_STOR.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_STOR(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 점포 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_STOR(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_STOR \n"
                          + "   SET BRAND_CD = '{2}', STOR_OWN_NM = N'{3}', STORNM = N'{4}', STOR_ADDR = N'{5}', BIZ_PSN_NO = '{6}' \n"
                          + "     , TELNO = '{7}', POS_OPER_LCNT = {8}, SVC_FEE_DIV = '{9}', SVC_FEE = {10}, SVC_FEE_APPLYTRGT_DIV = '{11}' \n"
                          + "     , SVC_FEE_TAX_AMT_APPLYDIV = '{12}', VAT_RUD_DW_LOC = '{13}', VAT_RUD_DW_METHD = '{14}', DC_RUD_DW_LOC = {15}, DC_RUD_DW_METHD = '{16}' \n"
                          + "     , ITEM_RUD_DW_LOC = {17}, DRT_FRCS_DIV = '{18}', HPY_PNT_ACCUMRATE = {19}, TAX_AMT_INCLUDE_YN = '{20}', TAX_AMT_CALC_METHD = '{21}' \n"
                          + "     , TAX_AMT_APPLY_DIV = '{22}', BASIC_TAKE_IN_TAX_CD = '{23}', BASIC_TAKE_OUT_TAX_CD = '{24}', MLT_CULT_CD = '{25}', TIMEGAP = {26} \n"
                          + "     , HPYORD_AGREEYN = '{27}', GIF_SALE_YN = '{28}', BILL_MSG_DUP_PRMT_YN = '{29}', BILL_MSG_PRT_RANK = '{30}', RESERV_SALE_YN = '{31}' \n"
                          + "     , COMPLEX_SHOP_TYPE = '{32}', TEST_STOR_YN = '{33}', CDP_USE_YN = '{34}', CDP_MSG = N'{35}', LOAN_LAW_CERTF_YN = '{36}' \n"
                          + "     , HAPPY_BUZZ_USE_YN = '{37}', BROWSER_KEY = '{38}', FILLER1 = '{39}', FILLER2 = '{40}', FILLER3 = '{41}' \n"
                          + "     , FILLER4 = '{42}', FILLER5 = '{43}', USE_YN = '{44}', UPD_DT = '{45}', OUT_SD_VEND_CON_NO = '{46}' \n"
                          + "     , OUT_SD_VEND_CRNR_CD = '{47}', CORP_DIV = '{48}', CNTRY_DIV = '{49}', ETC_IF_DIV = '{50}', ETC_IF_FTP_IP = '{51}' \n"
                          + "     , ETC_IF_FTP_PORT = '{52}', ETC_IF_FTP_ID = '{53}', ETC_IF_FTP_PW = '{54}', ETC_IF_FTP_PASSIVE = '{55}', ETC_IF_FTP_PATH = '{56}' \n"
                          + "     , ETC_IF_URL1 = '{57}', ETC_IF_URL2 = '{58}', ETC_IF_POS_DIV = '{59}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_STOR \n"
                          + "       ( CMP_CD, STOR_CD, BRAND_CD, STOR_OWN_NM, STORNM \n"
                          + "       , STOR_ADDR, BIZ_PSN_NO, TELNO, POS_OPER_LCNT, SVC_FEE_DIV \n"
                          + "       , SVC_FEE, SVC_FEE_APPLYTRGT_DIV, SVC_FEE_TAX_AMT_APPLYDIV, VAT_RUD_DW_LOC, VAT_RUD_DW_METHD \n"
                          + "       , DC_RUD_DW_LOC, DC_RUD_DW_METHD, ITEM_RUD_DW_LOC, DRT_FRCS_DIV, HPY_PNT_ACCUMRATE \n"
                          + "       , TAX_AMT_INCLUDE_YN, TAX_AMT_CALC_METHD, TAX_AMT_APPLY_DIV, BASIC_TAKE_IN_TAX_CD, BASIC_TAKE_OUT_TAX_CD \n"
                          + "       , MLT_CULT_CD, TIMEGAP, HPYORD_AGREEYN, GIF_SALE_YN, BILL_MSG_DUP_PRMT_YN \n"
                          + "       , BILL_MSG_PRT_RANK, RESERV_SALE_YN, COMPLEX_SHOP_TYPE, TEST_STOR_YN, CDP_USE_YN \n"
                          + "       , CDP_MSG, LOAN_LAW_CERTF_YN, HAPPY_BUZZ_USE_YN, BROWSER_KEY, FILLER1 \n"
                          + "       , FILLER2, FILLER3, FILLER4, FILLER5, USE_YN \n"
                          + "       , REG_DT, OUT_SD_VEND_CON_NO, OUT_SD_VEND_CRNR_CD, CORP_DIV, CNTRY_DIV \n"
                          + "       , ETC_IF_DIV, ETC_IF_FTP_IP, ETC_IF_FTP_PORT, ETC_IF_FTP_ID, ETC_IF_FTP_PW \n"
                          + "       , ETC_IF_FTP_PASSIVE, ETC_IF_FTP_PATH, ETC_IF_URL1, ETC_IF_URL2, ETC_IF_POS_DIV ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', N'{3}', N'{4}' \n"
                          + "       , N'{5}', '{6}', '{7}', {8}, '{9}' \n"
                          + "       , {10}, '{11}', '{12}', {13}, '{14}' \n"
                          + "       , {15}, '{16}', {17}, '{18}', {19} \n"
                          + "       , '{20}', '{21}', '{22}', '{23}', '{24}' \n"
                          + "       , '{25}', {26}, '{27}', '{28}', '{29}' \n"
                          + "       , '{30}', '{31}', '{32}', '{33}', '{34}' \n"
                          + "       , N'{35}', '{36}', '{37}', '{38}', '{39}' \n"
                          + "       , '{40}', '{41}', '{42}', '{43}', '{44}' \n"
                          + "       , '{45}', '{46}', '{47}', '{48}', '{49}' \n"
                          + "       , '{50}', '{51}', '{52}', '{53}', '{54}' \n"
                          + "       , '{55}', '{56}', '{57}', '{58}', '{59}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], aParams[21], aParams[22], aParams[23], aParams[24]
                                          , aParams[25], aParams[26], aParams[27], aParams[28], aParams[29]
                                          , aParams[30], aParams[31], aParams[32], aParams[33], aParams[34]
                                          , aParams[35], aParams[36], aParams[37], aParams[38], aParams[39]
                                          , aParams[40], aParams[41], aParams[42], aParams[43], aParams[44]
                                          , DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[47], aParams[48], aParams[49], aParams[50]
                                          , aParams[51], aParams[52], aParams[53], aParams[54], aParams[55]
                                          , aParams[56], aParams[57], aParams[58], aParams[59], aParams[60]);
                    
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_STOR.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 29 - 정산지 타입 그룹 마스터 Download / Insert
        /// <summary>
        /// 정산지 타입 그룹 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_ADMT_TYPE_GRP(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_ADMT_TYPE_GRP.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_ADMT_TYPE_GRP.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ADMT_TYPE_GRP.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_ADMT_TYPE_GRP(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 정산지 타입 그룹 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_ADMT_TYPE_GRP(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_ADMT_TYPE_GRP \n"
                          + "   SET ADMT_TYPE_GRP_CD_NM = N'{3}', FILLER1 = '{4}', FILLER2 = '{5}', FILLER3 = '{6}', FILLER4 = '{7}' \n"
                          + "     , FILLER5 = '{8}', UPD_DT = '{9}', USE_YN = '{10}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND ADMT_TYPE_GRP_CD = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_ADMT_TYPE_GRP \n"
                          + "       ( CMP_CD, STOR_CD, ADMT_TYPE_GRP_CD, ADMT_TYPE_GRP_CD_NM, FILLER1 \n"
                          + "       , FILLER2, FILLER3, FILLER4, FILLER5, REG_DT \n"
                          + "       , USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', N'{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss")
                                            , DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[11]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ADMT_TYPE_GRP.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 30 - 정산지 타입 마스터 Download / Insert
        /// <summary>
        /// 정산지 타입 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_ADMT_TYPE(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_ADMT_TYPE.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_ADMT_TYPE.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ADMT_TYPE.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_ADMT_TYPE(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 정산지 타입 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_ADMT_TYPE(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_ADMT_TYPE \n"
                          + "   SET ADMT_CD = '{5}', PRT_DIV = '{6}', FILLER1 = '{7}', FILLER2 = '{8}', FILLER3 = '{9}' \n"
                          + "     , FILLER4 = '{10}', FILLER5 = '{11}', UPD_DT = '{12}', USE_YN = '{13}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND ADMT_TYPE_GRP_CD = '{2}' \n"
                          + "   AND ADMT_TYPE = '{3}' \n"
                          + "   AND SEQ_NO = {4} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_ADMT_TYPE \n"
                          + "       ( CMP_CD, STOR_CD, ADMT_TYPE_GRP_CD, ADMT_TYPE, SEQ_NO \n"
                          + "       , ADMT_CD, PRT_DIV, FILLER1, FILLER2, FILLER3 \n"
                          + "       , FILLER4, FILLER5, REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', {4} \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"), DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[14]);
                    
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ADMT_TYPE.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 31 - 주방 Device 마스터 Download / Insert
        /// <summary>
        /// 주방 Device 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_KTCH_DEVICE(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_KTCH_DEVICE.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_KTCH_DEVICE.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_KTCH_DEVICE.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_KTCH_DEVICE(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 주방 Device 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_KTCH_DEVICE(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_KTCH_DEVICE \n"
                          + "   SET KTCH_SYS_NM = N'{3}', KTCH_SYS_DIV = '{4}', KTCH_SYS_USE_DIV = '{5}', KTCH_PRINTER_COMM_PORT = {6}, KTCH_PRINTER_COMM_SPEED = {7} \n"
                          + "     , KTCH_PRINTER_OPOS_NM = '{8}', KTCH_PRINTER_IP = '{9}', KTCH_PRINTER_PORT = {10}, KTCH_DSP_IP = '{11}', KTCH_DSP_PORT = {12} \n"
                          + "     , KTCH_DSP_DB_NM = '{13}', KTCH_DSP_DB_USER_ID = '{14}', KTCH_DSP_DB_PW = '{15}', KTCH_PRINTER_BAK1 = '{16}', KTCH_PRINTER_BAK2 = '{17}' \n"
                          + "     , KTCH_PRINTER_BAK3 = '{18}', KTCH_PRINTER_BAK4 = '{19}', KTCH_PRINTER_BAK5 = '{20}', KTCH_PRINTER_BAK6 = '{21}', FILLER1 = '{22}' \n"
                          + "     , FILLER2 = '{23}', FILLER3 = '{24}', FILLER4 = '{25}', FILLER5 = '{26}', UPD_DT = '{27}' \n"
                          + "     , USE_YN = '{28}', PRT_CNT = {30} \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND SUB_STOR_CD = '{29}' \n"
                          + "   AND POS_NO = '{31}' \n"
                          + "   AND KTCH_SYS_CD = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_KTCH_DEVICE \n"
                          + "       ( CMP_CD, STOR_CD, KTCH_SYS_CD, KTCH_SYS_NM, KTCH_SYS_DIV \n"
                          + "       , KTCH_SYS_USE_DIV, KTCH_PRINTER_COMM_PORT, KTCH_PRINTER_COMM_SPEED, KTCH_PRINTER_OPOS_NM, KTCH_PRINTER_IP \n"
                          + "       , KTCH_PRINTER_PORT, KTCH_DSP_IP, KTCH_DSP_PORT, KTCH_DSP_DB_NM, KTCH_DSP_DB_USER_ID \n"
                          + "       , KTCH_DSP_DB_PW, KTCH_PRINTER_BAK1, KTCH_PRINTER_BAK2, KTCH_PRINTER_BAK3, KTCH_PRINTER_BAK4 \n"
                          + "       , KTCH_PRINTER_BAK5, KTCH_PRINTER_BAK6, FILLER1, FILLER2, FILLER3 \n"
                          + "       , FILLER4, FILLER5, REG_DT, USE_YN, SUB_STOR_CD \n"
                          + "       , PRT_CNT, POS_NO ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', N'{3}', '{4}' \n"
                          + "       , '{5}', {6}, {7}, '{8}', '{9}' \n"
                          + "       , {10}, '{11}', {12}, '{13}', '{14}' \n"
                          + "       , '{15}', '{16}', '{17}', '{18}', '{19}' \n"
                          + "       , '{20}', '{21}', '{22}', '{23}', '{24}' \n"
                          + "       , '{25}', '{26}', '{27}', '{28}', '{29}' "
                          + "       , {30}, '{31}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], aParams[21], aParams[22], aParams[23], aParams[24]
                                          , aParams[25], aParams[26], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[29], aParams[30]
                                          , aParams[31], aParams[32]);
                    
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_KTCH_DEVICE.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 32 - 주방 Device 상품 마스터 Download / Insert
        /// <summary>
        /// 주방 Device 상품 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_KTCH_DEVICE_ITEM(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_KTCH_DEVICE_ITEM.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_KTCH_DEVICE_ITEM.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_KTCH_DEVICE_ITEM.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                //DateTime dtStart = DateTime.Now;

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    
                    // DB Insert

                    //#20170912 스퀘어 점포 마스터 수신 마지막 점포만 받는 현상 수정 start
                    //기존
                    //if ((MasterListManager.IsBackgroundMaster(MasterLists.MST_ITEM.ID) ? sBGUpdateDT : sUpdateDT) == PosConst.BEGINNING_MST_DOWN_DATE)
                    //변경
                    if (((MasterListManager.IsBackgroundMaster(MasterLists.MST_ITEM.ID) ? sBGUpdateDT : sUpdateDT) == PosConst.BEGINNING_MST_DOWN_DATE) &&
                        (m_cPosStatus.Mst.ComplexShopType == "0"))
                    //#20170912 스퀘어 점포 마스터 수신 마지막 점포만 받는 현상 수정 end
                    {
                        // 마스터 전체 수신
                        bReturn = UpdateEntireMST_KTCH_DEVICE_ITEM(aRowDatas);
                    }
                    else
                    {
                        // 마스터 변경 분 수신
                        bReturn = UpdateMST_KTCH_DEVICE_ITEM(aRowDatas);
                    }
                }
                else
                {
                    return false;
                }

                //DateTime dtEnd = DateTime.Now;
                //TimeSpan duration = dtEnd.Subtract(dtStart);

                //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 (함수명))
                //                     MasterLists.MST_KTCH_DEVICE_ITEM.ID + " duration : " + duration);

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

        private bool UpdateEntireMST_KTCH_DEVICE_ITEM(string[] aRowDatas)
        {
            string[] aParams = null;

            try
            {
                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                string sTheName = System.Reflection.MethodBase.GetCurrentMethod().Name.Substring(12);
                string tmpTableDboNm = "[POSMST].[dbo].[temp_" + sTheName + "]";
                string orgTableDboNm = "[POSMST].[dbo].[" + sTheName + "]";
                string orgTableNm = sTheName;

                string tmpPKDboNm = "[POSMST].[dbo].[PK_temp_" + sTheName + "]";
                string orgPKNm = "PK_" + sTheName;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                #region ## POSMST..MST_KTCH_DEVICE_ITEM 과 반드시 동기화 되어야 되는 DataTable ##
                DataTable tempTable = new DataTable();
                tempTable.Columns.Add("CMP_CD", typeof(string));
                tempTable.Columns.Add("STOR_CD", typeof(string));
                tempTable.Columns.Add("KTCH_SYS_CD", typeof(string));
                tempTable.Columns.Add("FLOOR_CD", typeof(string));
                tempTable.Columns.Add("ITEM_CD", typeof(string));
                tempTable.Columns.Add("FILLER1", typeof(string));
                tempTable.Columns.Add("FILLER2", typeof(string));
                tempTable.Columns.Add("FILLER3", typeof(string));
                tempTable.Columns.Add("FILLER4", typeof(string));
                tempTable.Columns.Add("FILLER5", typeof(string));
                tempTable.Columns.Add("UPD_DT", typeof(string));
                tempTable.Columns.Add("REG_DT", typeof(string));
                tempTable.Columns.Add("USE_YN", typeof(string));
                tempTable.Columns.Add("SUB_STOR_CD", typeof(string));
                #endregion ## POSMST..MST_KTCH_DEVICE_ITEM 과 반드시 동기화 되어야 되는 DataTable ##

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

                    tempTable.Rows.Add( aParams[0], aParams[1], aParams[2], aParams[3], aParams[4]
                                      , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9]
                                      , DateTime.Now.ToString("yyyyMMddHHmmsss"), DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[12], aParams[13]);

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % 100 == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + sTheName + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                string strSqlConnectionString = "Data Source=" + m_cPosStatus.Base.LocalDbSource + "; Initial Catalog = " + m_cPosStatus.Base.LocalDbCatalog +
                                                    " ; uid = " + m_cPosStatus.Base.LocalDbUserID + "; Password = " + m_cPosStatus.Base.LocalDbPassword;

                try
                {
                    using (SqlBulkCopy bulkCopy = new SqlBulkCopy(strSqlConnectionString))
                    {
                        // 입력할 테이블 지정
                        bulkCopy.DestinationTableName = tmpTableDboNm;
                        //bulkCopy.BatchSize = 1000;
                        // 데이터 입력
                        bulkCopy.WriteToServer(tempTable);
                    }
                }
                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);

                    // 임시테이블 DROP
                    m_cDatabaseSql.DBExecuteNonQuery("DROP TABLE " + tmpTableDboNm);

                    return false;
                }

                // 기존 테이블 DROP
                m_cDatabaseSql.DBExecuteNonQuery("DROP TABLE " + orgTableDboNm);

                // 임시 테이블을 본 테이블로 Rename
                m_cDatabaseSql.DBExecuteNonQuery("EXEC sp_rename '" + tmpTableDboNm + "', '" + orgTableNm + "'");
                m_cDatabaseSql.DBExecuteNonQuery("EXEC sp_rename '" + tmpPKDboNm + "', '" + orgPKNm + "'");

                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>
        /// 주방 Device 상품 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_KTCH_DEVICE_ITEM(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_KTCH_DEVICE_ITEM \n"
                          + "   SET FILLER1 = '{5}', FILLER2 = '{6}', FILLER3 = '{7}', FILLER4 = '{8}', FILLER5 = '{9}' \n"
                          + "     , UPD_DT = '{10}', USE_YN = '{11}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND SUB_STOR_CD = '{12}' \n"
                          + "   AND KTCH_SYS_CD = '{2}' \n"
                          + "   AND FLOOR_CD = '{3}' \n"
                          + "   AND ITEM_CD = '{4}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_KTCH_DEVICE_ITEM \n"
                          + "       ( CMP_CD, STOR_CD, KTCH_SYS_CD, FLOOR_CD, ITEM_CD \n"
                          + "       , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n"
                          + "       , REG_DT, USE_YN, SUB_STOR_CD ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]
                                          , DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[12], aParams[13]);
                    
                    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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_KTCH_DEVICE_ITEM.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region (삭제) 33 - 주방프린터유형 마스터
        #endregion

        #region (삭제) 34 - 주방프린터유형그룹 마스터
        #endregion

        #region (삭제) 35 - 층 마스터 Download / Insert
        ///// <summary>
        ///// 층 마스터 다운로드 처리
        ///// </summary>
        ///// <param name="sUpdateDT"></param>
        ///// <param name="sStoreCd"></param>
        ///// <param name="sSubStoreCd"></param>
        ///// <returns></returns>
        //public bool MST_FLOOR(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        //{
        //    bool bReturn = false;
        //    string sIrtData = string.Empty;
        //    string sRecvData = string.Empty;
        //    Hashtable htReqData = null;
        //    StringBuilder sbRecvData = null;
        //    int iReturn = BaseCom.NG;

        //    try
        //    {
        //        htReqData = new Hashtable();

        //        // 마스터 요청 Hashtable Data 생성
        //        htReqData = GetPosMasterReqData(MasterLists.MST_FLOOR.DIV,
        //                                        (MasterListManager.IsBackgroundMaster(MasterLists.MST_FLOOR.ID) ? sBGUpdateDT : sUpdateDT), 
        //                                        sStoreCd, 
        //                                        sSubStoreCd, 
        //                                        "0");

        //        m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_FLOOR.ID + " Downloading ... ");
        //        m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

        //        iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
        //                                                  , (int)m_cPosStatus.Base.MstPort
        //                                                  , 60000
        //                                                  , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
        //                                                  , htReqData
        //                                                  , ref sbRecvData);
        //        if (iReturn == BaseCom.OK)
        //        {
        //            // 행구분자(#~)로 구분한 Row Data를 string array에 저장
        //            string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
        //            // DB Insert
        //            bReturn = UpdateMST_FLOOR(aRowDatas);
        //        }
        //        else
        //        {
        //            return false;
        //        }

        //        return bReturn;
        //    }
        //    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>
        ///// 층 마스터 Update
        ///// </summary>
        ///// <param name="aRowDatas"></param>
        ///// <returns></returns>
        //private bool UpdateMST_FLOOR(string[] aRowDatas)
        //{
        //    string sQuery = string.Empty;
        //    string sInsQuery = string.Empty;
        //    string sDelQuery = string.Empty;
        //    string[] aParams = null;
        //    try
        //    {
        //        //sDelQuery  = " DELETE FROM POSMST..MST_FLOOR ";
        //        //sDelQuery += "  WHERE CMP_CD = '{0}' ";
        //        //sDelQuery += "    AND STOR_CD = '{1}' ";
        //        //sDelQuery += "    AND FLOOR_CD = '{2}' ";

        //        //sInsQuery  = " INSERT INTO POSMST..MST_FLOOR ";
        //        //sInsQuery += "        ( CMP_CD, STOR_CD, FLOOR_CD, FLOOR_NM, FILLER1 ";
        //        //sInsQuery += "        , FILLER2, FILLER3, FILLER4, FILLER5, UPD_DT ";
        //        //sInsQuery += "        , REG_DT, USE_YN ) ";
        //        //sInsQuery += "        VALUES ";
        //        //sInsQuery += "        ( '{0}', '{1}', '{2}', N'{3}', '{4}' ";
        //        //sInsQuery += "        , '{5}', '{6}', '{7}', '{8}', '{9}' ";
        //        //sInsQuery += "        , '{10}', '{11}' ) ";

        //        sInsQuery += "UPDATE POSMST..MST_FLOOR ";
        //        sInsQuery += "   SET FLOOR_NM = N'{3}', FILLER1 = '{4}', FILLER2 = '{5}', FILLER3 = '{6}', FILLER4 = '{7}' ";
        //        sInsQuery += "     , FILLER5 = '{8}', UPD_DT = '{9}', USE_YN = '{10}' ";
        //        sInsQuery += " WHERE CMP_CD = '{0}' ";
        //        sInsQuery += "   AND STOR_CD = '{1}' ";
        //        sInsQuery += "   AND FLOOR_CD = '{2}' ";
        //        sInsQuery += "IF @@ROWCOUNT = 0 ";
        //        sInsQuery += "INSERT INTO POSMST..MST_FLOOR ";
        //        sInsQuery += "       ( CMP_CD, STOR_CD, FLOOR_CD, FLOOR_NM, FILLER1 ";
        //        sInsQuery += "       , FILLER2, FILLER3, FILLER4, FILLER5, REG_DT ";
        //        sInsQuery += "       , USE_YN ) ";
        //        sInsQuery += "VALUES ";
        //        sInsQuery += "       ( '{0}', '{1}', '{2}', N'{3}', '{4}' ";
        //        sInsQuery += "       , '{5}', '{6}', '{7}', '{8}', '{9}' ";
        //        sInsQuery += "       , '{10}' ) ";

        //        // 현재 Row Counting
        //        int nCnt = 0;
        //        // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
        //        int nCntToStepUp = aRowDatas.Length / 100;
        //        // nCntToStepUp 값을 체크하기 위한 Counting
        //        int nCheckToStepUp = 0;

        //        // ProgressBar Style 변경
        //        m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

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

        //            if (nCheckToStepUp == nCntToStepUp)
        //            {
        //                m_cFormSaleOpen.ProgressProgressBar(1);
        //                nCheckToStepUp = 0;
        //            }
        //            else
        //            {
        //                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_FLOOR.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
        //                nCheckToStepUp++;
        //            }

        //            //sQuery = string.Format(sDelQuery
        //            //                      , aParams[0]
        //            //                      , aParams[1]
        //            //                      , aParams[2]);

        //            //m_cDatabaseSql.DBExecuteNonQuery(sQuery);

        //            sQuery = string.Format(sInsQuery
        //                                  , aParams[0], aParams[1], aParams[2], aParams[3], aParams[4]
        //                                  , aParams[5], aParams[6], aParams[7], aParams[8], DateTime.Now.ToString("yyyyMMddHHmmsss")
        //                                  , aParams[11]);

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

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

        //        return false;
        //    }
        //}
        #endregion

        #region 36 - 캠페인 상품 그룹관리 마스터 Download / Insert
        /// <summary>
        /// 캠페인 상품 그룹관리 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_CPI_COMPNT(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_CPI_COMPNT.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_CPI_COMPNT.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CPI_COMPNT.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                //DateTime dtStart = DateTime.Now;

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    // DB Insert
                    bReturn = UpdateMST_CPI_COMPNT(aRowDatas);
                }
                else
                {
                    return false;
                }

                //DateTime dtEnd = DateTime.Now;
                //TimeSpan duration = dtEnd.Subtract(dtStart);

                //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 (함수명))
                //                     MasterLists.MST_CPI_COMPNT.ID + " duration : " + duration);

                return bReturn;
            }
            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>
        /// 캠페인 상품 그룹관리 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_CPI_COMPNT(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_CPI_COMPNT \n"
                          + "   SET CPI_COND_TYPE = '{4}', QTY_AMT = {5}, CPI_DC_TYPE = '{6}', DC_RATE_QTY_AMT = {7}, DC_MAX_AMT = {8} \n"
                          + "     , FILLER1 = '{9}', FILLER2 = '{10}', FILLER3 = '{11}', FILLER4 = '{12}', FILLER5 = '{13}' \n"
                          + "     , USE_YN = '{14}', UPD_DT = '{15}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND CPI_CD = '{2}' \n"
                          + "   AND CPI_ITEM_GRP_CD = '{3}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_CPI_COMPNT \n"
                          + "       ( CMP_CD, STOR_CD, CPI_CD, CPI_ITEM_GRP_CD, CPI_COND_TYPE \n"
                          + "       , QTY_AMT, CPI_DC_TYPE, DC_RATE_QTY_AMT, DC_MAX_AMT, FILLER1 \n"
                          + "       , FILLER2, FILLER3, FILLER4, FILLER5, USE_YN \n"
                          + "       , REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , {5}, '{6}', {7}, {8}, '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]
                                          , DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CPI_COMPNT.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 37 - 캠페인 마스터 Download / Insert
        /// <summary>
        /// 캠페인 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_CPI(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_CPI.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_CPI.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CPI.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                //DateTime dtStart = DateTime.Now;

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    // DB Insert
                    bReturn = UpdateMST_CPI(aRowDatas);
                }
                else
                {
                    return false;
                }

                //DateTime dtEnd = DateTime.Now;
                //TimeSpan duration = dtEnd.Subtract(dtStart);

                //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 (함수명))
                //                     MasterLists.MST_CPI.ID + " duration : " + duration);

                return bReturn;
            }
            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>
        /// 캠페인 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_CPI(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_CPI \n"
                          + "   SET CPI_NM = N'{3}', STARTDAY = '{4}', FNSHDAY = '{5}', REPT_YN = '{6}', REPT_APPNT_TYPE = '{7}' \n"
                          + "     , REPT_WEEK = '{8}', REPT_DT = '{9}', DUP_APPLY_YN = '{10}', BASIC_RULE_EXCEP_YN = '{11}', TELECOM_COOP_DUP_PRMT_YN = '{12}' \n"
                          + "     , PRRTY = {13}, TRGT_CUST_TYPE = '{14}', CPI_CUST_BNFT_TYPE = '{15}', ITEM_APPLY_METHD = '{16}', CUST_PAY_TYPE = '{17}' \n"
                          + "     , TRGT_AMT_TYPE = '{18}', TRGT_AMT = {19}, QTY_LMT_YN = '{20}', LMT_QTY = {21}, QTY_LMT_STD = '{22}' \n"
                          + "     , HP_CUST_JOIN_LMT_YN = '{23}', HP_CUST_MAX_JOIN_CNT = {24}, HP_CUST_JOIN_LMT_STD = '{25}', BASIC_HP_ACCUM_YN = '{26}', BASIC_HP_ACCUM_STD = '{27}' \n"
                          + "     , ADD_HP_ACCUM_TELECOM_DIV = '{28}', ADD_HP_ACCUM_TRGT_STD = '{29}', ADD_HP_ACCUM_RATE = {30}, ADD_HP_ACCUM_AF_DIV = '{31}', ADD_HP_ACCUM_CD1 = '{32}' \n"
                          + "     , ADD_HP_ACCUM_CD2 = '{33}', OFFER_ID = '{34}', FREE_GIFT_PROVD_STD = '{35}', FREE_GIFT_STD_AMT = {36}, FREE_GIFT_PROVD_QTY = {37} \n"
                          + "     , FREE_GIFT_ADD_SALE_YN = '{38}', CPI_INFO = N'{39}', CPI_EXPLN = N'{40}', LTTR_MAX_GRADE = {41}, CUST_DSP_FILE_DIV = '{42}' \n"
                          + "     , CUST_DSP_FILENM = '{43}', STAMP_QTY = {44}, SOUND_FILE_DIV = '{45}', SOUND_FILE_NM = '{46}', TTS_DSCRP = N'{47}' \n"
                          + "     , SOUND_FILE_PLAY_CHK_PNT = '{48}', USE_YN = '{49}', FILLER1 = '{50}', FILLER2 = '{51}', FILLER3 = '{52}' \n"
                          + "     , FILLER4 = '{53}', FILLER5 = '{54}', UPD_DT = '{55}', JOIN_QUSTN_YN = '{56}', PRGRS_STATUS = '{57}' \n"
                          + "     , ITEM_DUP_PRMT_YN = '{58}', LTTR_MULTI_PRT_YN = '{59}', CPI_DC_PAY_WAY = '{60}', CPI_BILL_NM = N'{61}', QTY_LIMIT_MSG = N'{62}' \n"
                          + "     , HP_CUST_LVL = '{63}', DC_NOADM_PASS_YN = '{64}' \n"

                          //#15583 캠페인 기능 개선 요청 start
                          + "     , MOBILE_CPN_DUP_PRMT_YN = '{65}', HPY_CPN_DUP_PRMT_YN = '{66}' \n"
                          //#15583 캠페인 기능 개선 요청 end

                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND CPI_CD = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_CPI \n"
                          + "       ( CMP_CD, STOR_CD, CPI_CD, CPI_NM, STARTDAY \n"
                          + "       , FNSHDAY, REPT_YN, REPT_APPNT_TYPE, REPT_WEEK, REPT_DT \n"
                          + "       , DUP_APPLY_YN, BASIC_RULE_EXCEP_YN, TELECOM_COOP_DUP_PRMT_YN, PRRTY, TRGT_CUST_TYPE \n"
                          + "       , CPI_CUST_BNFT_TYPE, ITEM_APPLY_METHD, CUST_PAY_TYPE, TRGT_AMT_TYPE, TRGT_AMT \n"
                          + "       , QTY_LMT_YN, LMT_QTY, QTY_LMT_STD, HP_CUST_JOIN_LMT_YN, HP_CUST_MAX_JOIN_CNT \n"
                          + "       , HP_CUST_JOIN_LMT_STD, BASIC_HP_ACCUM_YN, BASIC_HP_ACCUM_STD, ADD_HP_ACCUM_TELECOM_DIV, ADD_HP_ACCUM_TRGT_STD \n"
                          + "       , ADD_HP_ACCUM_RATE, ADD_HP_ACCUM_AF_DIV, ADD_HP_ACCUM_CD1, ADD_HP_ACCUM_CD2, OFFER_ID \n"
                          + "       , FREE_GIFT_PROVD_STD, FREE_GIFT_STD_AMT, FREE_GIFT_PROVD_QTY, FREE_GIFT_ADD_SALE_YN, CPI_INFO \n"
                          + "       , CPI_EXPLN, LTTR_MAX_GRADE, CUST_DSP_FILE_DIV, CUST_DSP_FILENM, STAMP_QTY \n"
                          + "       , SOUND_FILE_DIV, SOUND_FILE_NM, TTS_DSCRP, SOUND_FILE_PLAY_CHK_PNT, USE_YN \n"
                          + "       , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n"
                          + "       , REG_DT, JOIN_QUSTN_YN, PRGRS_STATUS, ITEM_DUP_PRMT_YN, LTTR_MULTI_PRT_YN \n"
                          
                          //#15583 캠페인 기능 개선 요청 start
                          //기존
                          //+ "       , CPI_DC_PAY_WAY, CPI_BILL_NM, QTY_LIMIT_MSG, HP_CUST_LVL, DC_NOADM_PASS_YN ) \n"
                          //변경
                          + "       , CPI_DC_PAY_WAY, CPI_BILL_NM, QTY_LIMIT_MSG, HP_CUST_LVL, DC_NOADM_PASS_YN \n"
                          + "       , MOBILE_CPN_DUP_PRMT_YN, HPY_CPN_DUP_PRMT_YN ) \n"
                          //#15583 캠페인 기능 개선 요청 end

                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', N'{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', {13}, '{14}' \n"
                          + "       , '{15}', '{16}', '{17}', '{18}', {19} \n"
                          + "       , '{20}', {21}, '{22}', '{23}', {24} \n"
                          + "       , '{25}', '{26}', '{27}', '{28}', '{29}' \n"
                          + "       , {30}, '{31}', '{32}', '{33}', '{34}' \n"
                          + "       , '{35}', {36}, {37}, '{38}', N'{39}' \n"
                          + "       , N'{40}', {41}, '{42}', '{43}', {44} \n"
                          + "       , '{45}', '{46}', N'{47}', '{48}', '{49}' \n"
                          + "       , '{50}', '{51}', '{52}', '{53}', '{54}' \n"
                          + "       , '{55}', '{56}', '{57}', '{58}', '{59}' \n"
                          
                          //#15583 캠페인 기능 개선 요청 start
                          //기존
                          //+ "       , '{60}', N'{61}', N'{62}', '{63}', '{64}' ) \n";
                          //변경
                          + "       , '{60}', N'{61}', N'{62}', '{63}', '{64}' \n"
                          + "       , '{65}', '{66}' ) \n";
                          //#15583 캠페인 기능 개선 요청 end

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], aParams[21], aParams[22], aParams[23], aParams[24]
                                          , aParams[25], aParams[26], aParams[27], aParams[28], aParams[29]
                                          , aParams[30], aParams[31], aParams[32], aParams[33], aParams[34]
                                          , aParams[35], aParams[36], aParams[37], aParams[38], aParams[39]
                                          , aParams[40], aParams[41], aParams[42], aParams[43], aParams[44]
                                          , aParams[45], aParams[46], aParams[47], aParams[48], aParams[49]
                                          , aParams[50], aParams[51], aParams[52], aParams[53], aParams[54]
                                          , DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[57], aParams[58], aParams[59], aParams[60]
                                          
                                          //#15583 캠페인 기능 개선 요청 start
                                          //기존
                                          //, aParams[61], aParams[62], aParams[63], aParams[64], aParams[65] );
                                          //변경
                                          , aParams[61], aParams[62], aParams[63], aParams[64], aParams[65]
                                          , aParams[66], aParams[67]);
                                          //#15583 캠페인 기능 개선 요청 end

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CPI.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 38 - 캠페인 시간 마스터 Download / Insert
        /// <summary>
        /// 캠페인 시간 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_CPI_HOUR(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_CPI_HOUR.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_CPI_HOUR.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CPI_HOUR.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                //DateTime dtStart = DateTime.Now;

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    
                    
                    // DB Insert
                    bReturn = UpdateMST_CPI_HOUR(aRowDatas);
                }
                else
                {
                    return false;
                }

                //DateTime dtEnd = DateTime.Now;
                //TimeSpan duration = dtEnd.Subtract(dtStart);

                //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 (함수명))
                //                     MasterLists.MST_CPI_HOUR.ID + " duration : " + duration);

                return bReturn;
            }
            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>
        /// 캠페인 시간 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_CPI_HOUR(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_CPI_HOUR \n"
                          + "   SET START_HOUR = '{4}', FNSH_HOUR = '{5}', FILLER1 = '{6}', FILLER2 = '{7}', FILLER3 = '{8}' \n"
                          + "     , FILLER4 = '{9}', FILLER5 = '{10}', UPD_DT = '{11}', USE_YN = '{12}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND CPI_CD = '{2}' \n"
                          + "   AND DOW_DIV = '{3}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_CPI_HOUR \n"
                          + "       ( CMP_CD, STOR_CD, CPI_CD, DOW_DIV, START_HOUR \n"
                          + "       , FNSH_HOUR, FILLER1, FILLER2, FILLER3, FILLER4 \n"
                          + "       , FILLER5, REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[13]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CPI_HOUR.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 39 - 캠페인 상품 마스터 Download / Insert
        /// <summary>
        /// 캠페인 상품 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_CPI_ITEM(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_CPI_ITEM.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_CPI_ITEM.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CPI_ITEM.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);
                
                //DateTime dtStart = DateTime.Now;

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    // DB Insert
                    bReturn = UpdateMST_CPI_ITEM(aRowDatas);

                }
                else
                {
                    return false;
                }

                //DateTime dtEnd = DateTime.Now;
                //TimeSpan duration = dtEnd.Subtract(dtStart);

                //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 (함수명))
                //                     MasterLists.MST_CPI_ITEM.ID + " duration : " + duration);

                return bReturn;
            }
            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>
        /// 캠페인 상품 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_CPI_ITEM(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_CPI_ITEM \n"
                          + "   SET CPI_DC_TYPE = '{7}', DC_RATE_AMT = {8}, FILLER1 = '{9}', FILLER2 = '{10}', FILLER3 = '{11}' \n"
                          + "     , FILLER4 = '{12}', FILLER5 = '{13}', UPD_DT = '{14}', USE_YN = '{15}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND CPI_CD = '{2}' \n"
                          + "   AND SUB_STOR_CD = '{3}' \n"
                          + "   AND CPI_ITEM_GRP_CD = '{4}' \n"
                          + "   AND ITEM_LVL = '{5}' \n"
                          + "   AND ITEM_CD = '{6}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_CPI_ITEM \n"
                          + "       ( CMP_CD, STOR_CD, CPI_CD, SUB_STOR_CD, CPI_ITEM_GRP_CD \n"
                          + "       , ITEM_LVL, ITEM_CD, CPI_DC_TYPE, DC_RATE_AMT, FILLER1 \n"
                          + "       , FILLER2, FILLER3, FILLER4, FILLER5, REG_DT \n"
                          + "       , USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', {8}, '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

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

                    sQuery = string.Format(sInsQuery
                                          , aParams[0], m_cPosStatus.Base.StoreNo, aParams[2], aParams[3], aParams[4]
                                          , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9]
                                          , aParams[10], aParams[11], aParams[12], aParams[13], DateTime.Now.ToString("yyyyMMddHHmmsss")
                                          , aParams[16]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CPI_ITEM.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 40 - 캠페인 출력메시지 마스터 Download / Insert
        /// <summary>
        /// 캠페인 출력메시지 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_CPI_PRT_MSG(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_CPI_PRT_MSG.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_CPI_PRT_MSG.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CPI_PRT_MSG.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                //DateTime dtStart = DateTime.Now;

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    
                    // DB Insert
                    bReturn = UpdateMST_CPI_PRT_MSG(aRowDatas);
                }
                else
                {
                    return false;
                }

                //DateTime dtEnd = DateTime.Now;
                //TimeSpan duration = dtEnd.Subtract(dtStart);

                //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 (함수명))
                //                     MasterLists.MST_CPI_PRT_MSG.ID + " duration : " + duration);

                return bReturn;
            }
            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>
        /// 캠페인 출력메시지 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_CPI_PRT_MSG(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_CPI_PRT_MSG \n"
                          + "   SET PRT_EXPAND_TYPE = '{5}', BOLD_YN = '{6}', ALIGN_TYPE = '{7}', MSG_VAL = N'{8}', FILLER1 = '{9}' \n"
                          + "     , FILLER2 = '{10}', FILLER3 = '{11}', FILLER4 = '{12}', FILLER5 = '{13}', UPD_DT = '{14}', PRT_YN = '{15}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND CPI_CD = '{2}' \n"
                          + "   AND CPI_BILL_PRT_AREA_TYPE = '{3}' \n"
                          + "   AND PRT_SEQ = {4} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_CPI_PRT_MSG \n"
                          + "       ( CMP_CD, STOR_CD, CPI_CD, CPI_BILL_PRT_AREA_TYPE, PRT_SEQ \n"
                          + "       , PRT_EXPAND_TYPE, BOLD_YN, ALIGN_TYPE, MSG_VAL, FILLER1 \n"
                          + "       , FILLER2, FILLER3, FILLER4, FILLER5, REG_DT \n"
                          + "       , PRT_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', {4} \n"
                          + "       , '{5}', '{6}', '{7}', N'{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss")
                                          , aParams[16]);                                          

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CPI_PRT_MSG.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 41 - 캠페인 카드 마스터 Download / Insert
        /// <summary>
        /// 캠페인 카드 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_CPI_CARD(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_CPI_CARD.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_CPI_CARD.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CPI_CARD.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                //DateTime dtStart = DateTime.Now;

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    // DB Insert
                    bReturn = UpdateMST_CPI_CARD(aRowDatas);
                }
                else
                {
                    return false;
                }

                //DateTime dtEnd = DateTime.Now;
                //TimeSpan duration = dtEnd.Subtract(dtStart);

                //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 (함수명))
                //                     MasterLists.MST_CPI_CARD.ID + " duration : " + duration);

                return bReturn;
            }
            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>
        /// 캠페인 카드 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_CPI_CARD(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_CPI_CARD \n"
                          + "   SET CHECK_VAL = '{4}', LOC = {5}, FILLER1 = '{6}', FILLER2 = '{7}', FILLER3 = '{8}' \n"
                          + "     , FILLER4 = '{9}', FILLER5 = '{10}', UPD_DT = '{11}', USE_YN = '{12}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND CPI_CD = '{2}' \n"
                          + "   AND CARD_PRFX_CD = '{3}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_CPI_CARD \n"
                          + "       ( CMP_CD, STOR_CD, CPI_CD, CARD_PRFX_CD, CHECK_VAL \n"
                          + "       , LOC, FILLER1, FILLER2, FILLER3, FILLER4 \n"
                          + "       , FILLER5, REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , {5}, '{6}', '{7}' ,'{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[13]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CPI_CARD.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 42 - 캠페인 복권 출력 메시지 관리 마스터 Download / Insert
        /// <summary>
        /// 캠페인 복권 출력 메시지 관리 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_CPI_LTTR_PRT(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_CPI_LTTR_PRT.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_CPI_LTTR_PRT.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CPI_LTTR_PRT.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                //DateTime dtStart = DateTime.Now;

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    // DB Insert
                    bReturn = UpdateMST_CPI_LTTR_PRT(aRowDatas);
                }
                else
                {
                    return false;
                }

                //DateTime dtEnd = DateTime.Now;
                //TimeSpan duration = dtEnd.Subtract(dtStart);

                //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 (함수명))
                //                     MasterLists.MST_CPI_LTTR_PRT.ID + " duration : " + duration);

                return bReturn;
            }
            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>
        /// 캠페인 복권 출력 메시지 관리 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_CPI_LTTR_PRT(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sInsQuery = "UPDATE POSMST..MST_CPI_LTTR_PRT \n"
                          + "   SET MSG_VAL = N'{5}', PRT_EXPAND_TYPE = '{6}', BOLD_YN = '{7}', ALIGN_TYPE = '{8}', FILLER1 = '{9}' \n"
                          + "     , FILLER2 = '{10}', FILLER3 = '{11}', FILLER4 = '{12}', FILLER5 = '{13}', PRT_YN = '{14}' \n"
                          + "     , UPD_DT = '{15}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND CPI_CD = '{2}' \n"
                          + "   AND GRADE = {3} \n"
                          + "   AND PRT_SEQ = {4} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_CPI_LTTR_PRT \n"
                          + "       ( CMP_CD, STOR_CD, CPI_CD, GRADE, PRT_SEQ \n"
                          + "       , MSG_VAL, PRT_EXPAND_TYPE, BOLD_YN, ALIGN_TYPE, FILLER1 \n"
                          + "       , FILLER2, FILLER3, FILLER4, FILLER5, PRT_YN \n"
                          + "       , REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', {3}, {4} \n"
                          + "       , N'{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]
                                          , DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CPI_LTTR_PRT.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region (삭제) 43 - 테이블 마스터 Download / Insert
        ///// <summary>
        ///// 테이블 마스터 다운로드 처리
        ///// </summary>
        ///// <param name="sUpdateDT"></param>
        ///// <param name="sStoreCd"></param>
        ///// <param name="sSubStoreCd"></param>
        ///// <returns></returns>
        //public bool MST_TBL(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        //{
        //    bool bReturn = false;
        //    string sIrtData = string.Empty;
        //    string sRecvData = string.Empty;
        //    Hashtable htReqData = null;
        //    StringBuilder sbRecvData = null;
        //    int iReturn = BaseCom.NG;

        //    try
        //    {
        //        htReqData = new Hashtable();

        //        // 마스터 요청 Hashtable Data 생성
        //        htReqData = GetPosMasterReqData(MasterLists.MST_TBL.DIV,
        //                                        (MasterListManager.IsBackgroundMaster(MasterLists.MST_TBL.ID) ? sBGUpdateDT : sUpdateDT), 
        //                                        sStoreCd, 
        //                                        sSubStoreCd, 
        //                                        "0");

        //        m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_TBL.ID + " Downloading ... ");
        //        m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

        //        iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
        //                                                  , (int)m_cPosStatus.Base.MstPort
        //                                                  , 60000
        //                                                  , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
        //                                                  , htReqData
        //                                                  , ref sbRecvData);
        //        if (iReturn == BaseCom.OK)
        //        {
        //            // 행구분자(#~)로 구분한 Row Data를 string array에 저장
        //            string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
        //            // DB Insert
        //            bReturn = UpdateMST_TBL(aRowDatas);
        //        }
        //        else
        //        {
        //            return false;
        //        }

        //        return bReturn;
        //    }
        //    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>
        ///// 테이블 마스터 Update
        ///// </summary>
        ///// <param name="aRowDatas"></param>
        ///// <returns></returns>
        //private bool UpdateMST_TBL(string[] aRowDatas)
        //{
        //    string sQuery = string.Empty;
        //    string sInsQuery = string.Empty;
        //    string sDelQuery = string.Empty;
        //    string[] aParams = null;
        //    try
        //    {
        //        //sDelQuery  = " DELETE FROM POSMST..MST_TBL ";
        //        //sDelQuery += "  WHERE CMP_CD = '{0}' ";
        //        //sDelQuery += "    AND STOR_CD = '{1}' ";
        //        //sDelQuery += "    AND FLOOR_CD = '{2}' ";
        //        //sDelQuery += "    AND TBL_NO = '{3}' ";

        //        //sInsQuery  = " INSERT INTO POSMST..MST_TBL ";
        //        //sInsQuery += "        ( CMP_CD, STOR_CD, FLOOR_CD, TBL_NO, TBL_NM ";
        //        //sInsQuery += "        , TBL_TYPE, TBL_TYPE_SHAPE, BACKGRCOLOR, BACKGR_IMG, FONTCOLOR ";
        //        //sInsQuery += "        , FONT_NM, FONT_SIZE, X_COORD, Y_COORD, WIDTH ";
        //        //sInsQuery += "        , HGT, TBL_DISP_DIV, SEAT_CNT, SEAT_CNT_DISP_DIV, TBL_OP_DIV ";
        //        //sInsQuery += "        , OP_FLOOR_CD, OP_TBL_NO, TBL_USE_DIV, CUST_CNT, FIRST_ORD_HOUR ";
        //        //sInsQuery += "        , ORD_AMT, RESERV_DIV, RESERV_HOUR, ORD_COLOR, PAY_CMPT_COLOR ";
        //        //sInsQuery += "        , PAY_CMPT_DIV, FILLER1, FILLER2, FILLER3, FILLER4 ";
        //        //sInsQuery += "        , FILLER5, UPD_DT, REG_DT, USE_YN ) ";
        //        //sInsQuery += " VALUES ";
        //        //sInsQuery += "        ( '{0}', '{1}', '{2}', '{3}', N'{4}' ";
        //        //sInsQuery += "        , '{5}', '{6}', '{7}', '{8}', '{9}' ";
        //        //sInsQuery += "        , N'{10}', {11}, {12}, {13}, {14} ";
        //        //sInsQuery += "        , {15}, '{16}', {17}, '{18}', '{19}' ";
        //        //sInsQuery += "        , '{20}', '{21}', '{22}', {23}, '{24}' ";
        //        //sInsQuery += "        , {25}, '{26}', '{27}', '{28}', '{29}' ";
        //        //sInsQuery += "        , '{30}', '{31}', '{32}', '{33}', '{34}' ";
        //        //sInsQuery += "        , '{35}', '{36}', '{37}', '{38}' ) ";

        //        sInsQuery += "UPDATE POSMST..MST_TBL ";
        //        sInsQuery += "   SET TBL_NM = N'{4}', TBL_TYPE = '{5}', TBL_TYPE_SHAPE = '{6}', BACKGRCOLOR = '{7}', BACKGR_IMG = '{8}' ";
        //        sInsQuery += "     , FONTCOLOR = '{9}', FONT_NM = N'{10}', FONT_SIZE = {11}, X_COORD = {12}, Y_COORD = {13} ";
        //        sInsQuery += "     , WIDTH = {14}, HGT = {15}, TBL_DISP_DIV = '{16}', SEAT_CNT = {17}, SEAT_CNT_DISP_DIV = '{18}' ";
        //        sInsQuery += "     , TBL_OP_DIV = '{19}', OP_FLOOR_CD = '{20}', OP_TBL_NO = '{21}', TBL_USE_DIV = '{22}', CUST_CNT = {23} ";
        //        sInsQuery += "     , FIRST_ORD_HOUR = '{24}', ORD_AMT = {25}, RESERV_DIV = '{26}', RESERV_HOUR = '{27}', ORD_COLOR = '{28}' ";
        //        sInsQuery += "     , PAY_CMPT_COLOR = '{29}', PAY_CMPT_DIV = '{30}', FILLER1 = '{31}', FILLER2 = '{32}', FILLER3 = '{33}' ";
        //        sInsQuery += "     , FILLER4 = '{34}', FILLER5 = '{35}', UPD_DT = '{36}', USE_YN = '{37}' ";
        //        sInsQuery += " WHERE CMP_CD = '{0}' ";
        //        sInsQuery += "   AND STOR_CD = '{1}' ";
        //        sInsQuery += "   AND FLOOR_CD = '{2}' ";
        //        sInsQuery += "   AND TBL_NO = '{3}' ";
        //        sInsQuery += "IF @@ROWCOUNT = 0 ";
        //        sInsQuery += "INSERT INTO POSMST..MST_TBL ";
        //        sInsQuery += "       ( CMP_CD, STOR_CD, FLOOR_CD, TBL_NO, TBL_NM ";
        //        sInsQuery += "       , TBL_TYPE, TBL_TYPE_SHAPE, BACKGRCOLOR, BACKGR_IMG, FONTCOLOR ";
        //        sInsQuery += "       , FONT_NM, FONT_SIZE, X_COORD, Y_COORD, WIDTH ";
        //        sInsQuery += "       , HGT, TBL_DISP_DIV, SEAT_CNT, SEAT_CNT_DISP_DIV, TBL_OP_DIV ";
        //        sInsQuery += "       , OP_FLOOR_CD, OP_TBL_NO, TBL_USE_DIV, CUST_CNT, FIRST_ORD_HOUR ";
        //        sInsQuery += "       , ORD_AMT, RESERV_DIV, RESERV_HOUR, ORD_COLOR, PAY_CMPT_COLOR ";
        //        sInsQuery += "       , PAY_CMPT_DIV, FILLER1, FILLER2, FILLER3, FILLER4 ";
        //        sInsQuery += "       , FILLER5, REG_DT, USE_YN ) ";
        //        sInsQuery += "VALUES ";
        //        sInsQuery += "       ( '{0}', '{1}', '{2}', '{3}', N'{4}' ";
        //        sInsQuery += "       , '{5}', '{6}', '{7}', '{8}', '{9}' ";
        //        sInsQuery += "       , N'{10}', {11}, {12}, {13}, {14} ";
        //        sInsQuery += "       , {15}, '{16}', {17}, '{18}', '{19}' ";
        //        sInsQuery += "       , '{20}', '{21}', '{22}', {23}, '{24}' ";
        //        sInsQuery += "       , {25}, '{26}', '{27}', '{28}', '{29}' ";
        //        sInsQuery += "       , '{30}', '{31}', '{32}', '{33}', '{34}' ";
        //        sInsQuery += "       , '{35}', '{36}', '{37}' ) ";

        //        // 현재 Row Counting
        //        int nCnt = 0;
        //        // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
        //        int nCntToStepUp = aRowDatas.Length / 100;
        //        // nCntToStepUp 값을 체크하기 위한 Counting
        //        int nCheckToStepUp = 0;

        //        // ProgressBar Style 변경
        //        m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

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

        //            if (nCheckToStepUp == nCntToStepUp)
        //            {
        //                m_cFormSaleOpen.ProgressProgressBar(1);
        //                nCheckToStepUp = 0;
        //            }
        //            else
        //            {
        //                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_TBL.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
        //                nCheckToStepUp++;
        //            }

        //            //sQuery = string.Format(sDelQuery
        //            //                      , aParams[0]
        //            //                      , aParams[1]
        //            //                      , aParams[2]
        //            //                      , aParams[3]);

        //            //m_cDatabaseSql.DBExecuteNonQuery(sQuery);

        //            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], aParams[21], aParams[22], aParams[23], aParams[24]
        //                                  , aParams[25], aParams[26], aParams[27], aParams[28], aParams[29]
        //                                  , aParams[30], aParams[31], aParams[32], aParams[33], aParams[34]
        //                                  , aParams[35], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[38]);

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

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

        //        return false;
        //    }
        //}
        #endregion

        #region 44 - 플레이버 마스터 Download / Insert
        /// <summary>
        /// 플레이버 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_FLAVOUR(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_FLAVOUR.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_FLAVOUR.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_FLAVOUR.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    // DB Insert
                    bReturn = UpdateMST_FLAVOUR(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 플레이버 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_FLAVOUR(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sUpdQuery = "UPDATE POSMST..MST_FLAVOUR \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND SUB_STOR_CD = '" + m_sSubStorNo + "' \n";

                sInsQuery = "UPDATE POSMST..MST_FLAVOUR \n"
                          + "   SET BTN_COLOR1 = '{4}', BTN_COLOR2 = '{5}', FONT_COLOR = '{6}', FONT_SIZE = {7}, IMG_USE_YN = '{8}' \n"
                          + "     , IMG_PATH = N'{9}', ITEM_LOC = {10}, USE_YN = '{11}', FILLER1 = '{12}', FILLER2 = '{13}' \n"
                          + "     , FILLER3 = '{14}', FILLER4 = '{15}', FILLER5 = '{16}', UPD_DT = '{17}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND SUB_STOR_CD = '{2}' \n"
                          + "   AND ITEM_CD = '{3}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_FLAVOUR \n"
                          + "       ( CMP_CD, STOR_CD, SUB_STOR_CD, ITEM_CD, BTN_COLOR1 \n"
                          + "       , BTN_COLOR2, FONT_COLOR, FONT_SIZE, IMG_USE_YN, IMG_PATH \n"
                          + "       , ITEM_LOC, USE_YN, FILLER1, FILLER2, FILLER3 \n"
                          + "       , FILLER4, FILLER5, REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , '{5}', '{6}', {7}, '{8}', N'{9}' \n"
                          + "       , {10}, '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}', '{16}', '{17}' ) \n";

                sDelQuery = "DELETE FROM POSMST..MST_FLAVOUR \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND SUB_STOR_CD = '" + m_sSubStorNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_FLAVOUR 테이블은 INSERT 전 모든 데이터 삭제
                // 안호성C 요청 - 2016/12/08
                //m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);
                // 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);

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

                    sQuery = string.Format(sInsQuery
                                          , aParams[0], m_cPosStatus.Base.StoreNo, 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], DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_FLAVOUR.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region 45 - 환율 마스터 Download / Insert
        /// <summary>
        /// 환율 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_EXCHG_RATE(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_EXCHG_RATE.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_EXCHG_RATE.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_EXCHG_RATE.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_EXCHG_RATE(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 환율 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_EXCHG_RATE(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_EXCHG_RATE \n"
                          + "   SET EXCHG_RATE_NM = N'{3}', EXCHG_RATE_AMT = {4}, EXCHG_RATE_UNIT = {5}, FILLER1 = '{6}', FILLER2 = '{7}' \n"
                          + "     , FILLER3 = '{8}', FILLER4 = '{9}', FILLER5 = '{10}', UPD_DT = '{11}', USE_YN = '{12}' \n"
                          + " WHERE EXCHG_RATE_REG_DT = '{0}' \n"
                          + "   AND EXCHG_RATE_REG_DGRE = {1} \n"
                          + "   AND EXCHG_RATE_CD = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_EXCHG_RATE \n"
                          + "       ( EXCHG_RATE_REG_DT, EXCHG_RATE_REG_DGRE, EXCHG_RATE_CD, EXCHG_RATE_NM, EXCHG_RATE_AMT \n"
                          + "       , EXCHG_RATE_UNIT, FILLER1, FILLER2, FILLER3, FILLER4 \n"
                          + "       , FILLER5, REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', {1}, '{2}', N'{3}', {4} \n"
                          + "       , {5}, '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[13]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_EXCHG_RATE.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 46 - 상품 키 구성 마스터 Download / Insert
        /// <summary>
        /// 상품 키 구성 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_ITEM_KEY_COMPNT(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_ITEM_KEY_COMPNT.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_ITEM_KEY_COMPNT.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM_KEY_COMPNT.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                //DateTime dtStart = DateTime.Now;

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    // DB Insert
                    bReturn = UpdateMST_ITEM_KEY_COMPNT(aRowDatas);
                }
                else
                {
                    return false;
                }

                //DateTime dtEnd = DateTime.Now;
                //TimeSpan duration = dtEnd.Subtract(dtStart);

                //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 (함수명))
                //                     MasterLists.MST_ITEM_KEY_COMPNT.ID + " duration : " + duration);

                return bReturn;
            }
            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>
        /// 상품 키 구성 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_ITEM_KEY_COMPNT(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;
            try
            {
                sUpdQuery = "UPDATE POSMST..MST_ITEM_KEY_COMPNT \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND SUB_STOR_CD = '" + m_sSubStorNo + "' \n";

                sInsQuery = "UPDATE POSMST..MST_ITEM_KEY_COMPNT \n"
                          + "   SET POS_SCRN_TYPE = '{2}', FUNC_SCROLL_USE_YN = '{3}', THEME_COLOR = '{4}', LOGIN_IMG = '{5}', BRAND_CI_IMG = '{6}' \n"
                          + "     , MAIN_IMG = '{7}', WAIT_IMG = '{8}', BOOKMK_USE_YN = '{9}', BOOKMK_ITEM_KEY_ARRAY = '{10}', HQ_ITEMKEY_LAYOUT = '{11}' \n"
                          + "     , SHOP_ITEMKEY_LAYOUT = '{12}', L_CLSS_KEY_BASIC_COLOR = '{13}', L_CLSS_KEY_BASIC_FONT_COLOR = '{14}', L_CLSS_KEY_SEL_COLOR = '{15}', L_CLSS_KEY_SEL_FONT_COLOR = '{16}' \n"
                          + "     , ITEM_KEY_BASIC_COLOR = '{17}', ITEM_KEY_BASIC_FONT_COLOR = '{18}', ITEM_KEY_SEL_COLOR = '{19}', ITEM_KEY_SEL_FONT_COLOR = '{20}', FIX_ITEM_CLSS_CNT = {21} \n"
                          + "     , UPD_DT = '{22}', USE_YN = '{23}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND SUB_STOR_CD = '{24}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_ITEM_KEY_COMPNT \n"
                          + "       ( CMP_CD, STOR_CD, POS_SCRN_TYPE, FUNC_SCROLL_USE_YN, THEME_COLOR \n"
                          + "       , LOGIN_IMG, BRAND_CI_IMG, MAIN_IMG, WAIT_IMG, BOOKMK_USE_YN \n"
                          + "       , BOOKMK_ITEM_KEY_ARRAY, HQ_ITEMKEY_LAYOUT, SHOP_ITEMKEY_LAYOUT, L_CLSS_KEY_BASIC_COLOR, L_CLSS_KEY_BASIC_FONT_COLOR \n"
                          + "       , L_CLSS_KEY_SEL_COLOR, L_CLSS_KEY_SEL_FONT_COLOR, ITEM_KEY_BASIC_COLOR, ITEM_KEY_BASIC_FONT_COLOR, ITEM_KEY_SEL_COLOR \n"
                          + "       , ITEM_KEY_SEL_FONT_COLOR, FIX_ITEM_CLSS_CNT, REG_DT, USE_YN, SUB_STOR_CD ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}', '{16}', '{17}', '{18}', '{19}' \n"
                          + "       , '{20}', {21}, '{22}', '{23}', '{24}' ) \n";

                sDelQuery = "DELETE FROM POSMST..MST_ITEM_KEY_COMPNT \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND SUB_STOR_CD = '" + m_sSubStorNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_ITEM_KEY_COMPNT 테이블은 INSERT 전 모든 데이터 삭제
                // 안호성C 요청 - 2016/11/01
                //m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);
                // 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);

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

                    sQuery = string.Format(sInsQuery
                                            , aParams[0], m_cPosStatus.Base.StoreNo, aParams[2], aParams[3], aParams[4]
                                            , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9]
                                            , aParams[10], aParams[11], aParams[12], aParams[13], aParams[14]
                                            , aParams[15], aParams[16], aParams[17], aParams[18], aParams[19]
                                            , aParams[20], aParams[21], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[24], aParams[25]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM_KEY_COMPNT.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region 47 - 상품 키 대분류 마스터 Download / Insert
        /// <summary>
        /// 상품 키 대분류 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_ITEM_KEY_L_CLSS(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_ITEM_KEY_L_CLSS.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_ITEM_KEY_L_CLSS.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM_KEY_L_CLSS.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                //DateTime dtStart = DateTime.Now;

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_ITEM_KEY_L_CLSS(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                //DateTime dtEnd = DateTime.Now;
                //TimeSpan duration = dtEnd.Subtract(dtStart);

                //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 (함수명))
                //                     MasterLists.MST_ITEM_KEY_L_CLSS.ID + " duration : " + duration);

                return bReturn;
            }
            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>
        /// 상품 키 대분류 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_ITEM_KEY_L_CLSS(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sUpdQuery = "UPDATE POSMST..MST_ITEM_KEY_L_CLSS \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND SUB_SHOP_CD = '" + m_sSubStorNo + "' \n";

                sInsQuery = "UPDATE POSMST..MST_ITEM_KEY_L_CLSS \n"
                          + "   SET L_CLSS_NM = N'{5}', HQ_KEY_DIV = '{6}', UPD_DT = '{7}', USE_YN = '{8}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND SUB_SHOP_CD = '{2}' \n"
                          + "   AND SEQ = {3} \n"
                          + "   AND L_CLSS_CD = '{4}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_ITEM_KEY_L_CLSS \n"
                          + "       ( CMP_CD, STOR_CD, SUB_SHOP_CD, SEQ, L_CLSS_CD \n"
                          + "       , L_CLSS_NM, HQ_KEY_DIV, REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', {3}, '{4}' \n"
                          + "       , N'{5}', '{6}', '{7}', '{8}' ) \n";

                sDelQuery = "DELETE FROM POSMST..MST_ITEM_KEY_L_CLSS \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND SUB_SHOP_CD = '" + m_sSubStorNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_ITEM_KEY_L_CLSS 테이블은 INSERT 전 모든 데이터 삭제
                // 안호성C 요청 - 2016/11/01
                //m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);
                // 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);

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

                    sQuery = string.Format(sInsQuery
                                            , aParams[0], m_cPosStatus.Base.StoreNo, aParams[2], aParams[3], aParams[4]
                                            , aParams[5], aParams[6], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[9]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM_KEY_L_CLSS.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region 48 - 상품 키 분류 배치 마스터 Download / Insert
        /// <summary>
        /// 상품 키 분류 배치 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_ITEM_KEY_CLSS_BATCH(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_ITEM_KEY_CLSS_BATCH.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_ITEM_KEY_CLSS_BATCH.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM_KEY_CLSS_BATCH.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                //DateTime dtStart = DateTime.Now;

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_ITEM_KEY_CLSS_BATCH(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                //DateTime dtEnd = DateTime.Now;
                //TimeSpan duration = dtEnd.Subtract(dtStart);

                //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 (함수명))
                //                     MasterLists.MST_ITEM_KEY_CLSS_BATCH.ID + " duration : " + duration);

                return bReturn;
            }
            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>
        /// 상품 키 분류 배치 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_ITEM_KEY_CLSS_BATCH(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sUpdQuery = "UPDATE POSMST..MST_ITEM_KEY_CLSS_BATCH \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";

                sInsQuery = "UPDATE POSMST..MST_ITEM_KEY_CLSS_BATCH \n"
                          + "   SET GRP_KEY_BATCH_YN = '{4}', BATCH_SEQ = {5}, UPD_DT = '{6}', USE_YN = '{7}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND L_CLSS_CD = '{2}' \n"
                          + "   AND ITEM_GRP_CD = '{3}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_ITEM_KEY_CLSS_BATCH \n"
                          + "       ( CMP_CD, STOR_CD, L_CLSS_CD, ITEM_GRP_CD, GRP_KEY_BATCH_YN \n"
                          + "       , BATCH_SEQ, REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , {5}, '{6}', '{7}' ) \n";

                sDelQuery = "DELETE FROM POSMST..MST_ITEM_KEY_CLSS_BATCH \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_ITEM_KEY_CLSS_BATCH 테이블은 INSERT 전 모든 데이터 삭제
                // 안호성C 요청 - 2016/11/01
                //m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);
                // 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);

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

                    sQuery = string.Format(sInsQuery
                                            , aParams[0], aParams[1], aParams[2], aParams[3], aParams[4]
                                            , aParams[5], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[8]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM_KEY_CLSS_BATCH.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region 49 - 상품 키 분류 마스터 Download / Insert
        /// <summary>
        /// 상품 키 분류 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_ITEM_KEY_CLSS(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_ITEM_KEY_CLSS.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_ITEM_KEY_CLSS.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM_KEY_CLSS.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                //DateTime dtStart = DateTime.Now;

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_ITEM_KEY_CLSS(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                //DateTime dtEnd = DateTime.Now;
                //TimeSpan duration = dtEnd.Subtract(dtStart);

                //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 (함수명))
                //                     MasterLists.MST_ITEM_KEY_CLSS.ID + " duration : " + duration);

                return bReturn;
            }
            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>
        /// 상품 키 분류 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_ITEM_KEY_CLSS(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sUpdQuery = "UPDATE POSMST..MST_ITEM_KEY_CLSS \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND SUB_STOR_CD = '" + m_sSubStorNo + "' \n";

                sInsQuery = "UPDATE POSMST..MST_ITEM_KEY_CLSS \n"
                          + "   SET ITEM_GRP_NM = N'{6}', FONT_SIZE = '{7}', BACKGR_COLOR = '{8}', UPD_DT = '{9}', USE_YN = '{10}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND SUB_STOR_CD = '{2}' \n"
                          + "   AND L_CLSS_CD = '{3}' \n"
                          + "   AND FIX_YN = '{4}' \n"
                          + "   AND GRP_SEQ = {5} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_ITEM_KEY_CLSS \n"
                          + "       ( CMP_CD, STOR_CD, SUB_STOR_CD, L_CLSS_CD, FIX_YN \n"
                          + "       , GRP_SEQ, ITEM_GRP_NM, FONT_SIZE, BACKGR_COLOR, REG_DT \n"
                          + "       , USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , {5}, N'{6}', '{7}', '{8}', '{9}' \n"
                          + "       ,  '{10}' ) \n";

                sDelQuery = "DELETE FROM POSMST..MST_ITEM_KEY_CLSS \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND SUB_STOR_CD = '" + m_sSubStorNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_ITEM_KEY_CLSS 테이블은 INSERT 전 모든 데이터 삭제
                // 안호성C 요청 - 2016/11/01
                //m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);
                // 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);

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

                    sQuery = string.Format(sInsQuery
                                            , aParams[0], m_cPosStatus.Base.StoreNo, aParams[2], aParams[3], aParams[4]
                                            , aParams[5], aParams[6], aParams[7], aParams[8], DateTime.Now.ToString("yyyyMMddHHmmsss")
                                            , aParams[11]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM_KEY_CLSS.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region 50 - 상품 키 마스터 Download / Insert
        /// <summary>
        /// 상품 키 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_ITEM_KEY(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_ITEM_KEY.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_ITEM_KEY.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM_KEY.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                //DateTime dtStart = DateTime.Now;

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_ITEM_KEY(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                //DateTime dtEnd = DateTime.Now;
                //TimeSpan duration = dtEnd.Subtract(dtStart);

                //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 (함수명))
                //                     MasterLists.MST_ITEM_KEY.ID + " duration : " + duration);

                return bReturn;
            }
            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>
        /// 상품 키 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_ITEM_KEY(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sUpdQuery = "UPDATE POSMST..MST_ITEM_KEY \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND SUB_STOR_CD = '" + m_sSubStorNo + "' \n";

                sInsQuery = "UPDATE POSMST..MST_ITEM_KEY \n"
                          + "   SET ITEM_CD = '{7}', SHTCUT_ITEM_NM = N'{8}', FONT_SIZE = '{9}', BACKGR_COLOR = '{10}', BTN_SIZE = '{11}' \n"
                          //#20171018 메뉴명 폰트 색상 변경 기능 start
                          //기존
                          //+ "     , SUBPRC_MENU_POPUP_YN = '{12}', UPD_DT = '{13}', USE_YN = '{14}' \n"
                          //변경
                          + "     , SUBPRC_MENU_POPUP_YN = '{12}', UPD_DT = '{13}', USE_YN = '{14}', FONT_COLOR = '{15}' \n"
                          //#20171018 메뉴명 폰트 색상 변경 기능 end
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND SUB_STOR_CD = '{2}' \n"
                          + "   AND L_CLSS_CD = '{3}' \n"
                          + "   AND FIX_YN = '{4}' \n"
                          + "   AND GRP_SEQ = {5} \n"
                          + "   AND SEQ = {6} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_ITEM_KEY \n"
                          + "       ( CMP_CD, STOR_CD, SUB_STOR_CD, L_CLSS_CD, FIX_YN \n"
                          + "       , GRP_SEQ, SEQ, ITEM_CD, SHTCUT_ITEM_NM, FONT_SIZE \n"
                          //#20171018 메뉴명 폰트 색상 변경 기능 start
                          //기존
                          //+ "       , BACKGR_COLOR, BTN_SIZE, SUBPRC_MENU_POPUP_YN, REG_DT, USE_YN ) \n"
                          //변경
                          + "       , BACKGR_COLOR, BTN_SIZE, SUBPRC_MENU_POPUP_YN, REG_DT, USE_YN, FONT_COLOR ) \n"
                          //#20171018 메뉴명 폰트 색상 변경 기능 end
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , {5}, {6}, '{7}', N'{8}', '{9}' \n"
                          //#20171018 메뉴명 폰트 색상 변경 기능 start
                          //기존
                          //+ "       , '{10}', '{11}', '{12}', '{13}', '{14}' ) \n";
                          //변경
                          +"       , '{10}', '{11}', '{12}', '{13}', '{14}', '{15}' ) \n";
                          //#20171018 메뉴명 폰트 색상 변경 기능 end
                
                sDelQuery = "DELETE FROM POSMST..MST_ITEM_KEY \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND SUB_STOR_CD = '" + m_sSubStorNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_ITEM_KEY 테이블은 INSERT 전 모든 데이터 삭제
                // 안호성C 요청 - 2016/11/01
                //m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);
                // 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);

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

                    //#20171018 메뉴명 폰트 색상 변경 기능 start
                    //기존
                    /*
                    sQuery = string.Format(sInsQuery
                                            , aParams[0], m_cPosStatus.Base.StoreNo, aParams[2], aParams[3], aParams[4]
                                            , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9]
                                            , aParams[10], aParams[11], aParams[12], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[15]);
                    */
                    //변경
                    
                    //폰트 색상 필드가 안내려온 경우(서버 반영 안된 경우)
                    if (aParams.Length == 16)
                    {
                        sQuery = string.Format(sInsQuery
                                                , aParams[0], m_cPosStatus.Base.StoreNo, aParams[2], aParams[3], aParams[4]
                                                , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9]
                                                , aParams[10], aParams[11], aParams[12], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[15]
                                                , "");
                    }
                    else
                    {
                        sQuery = string.Format(sInsQuery
                                                , aParams[0], m_cPosStatus.Base.StoreNo, aParams[2], aParams[3], aParams[4]
                                                , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9]
                                                , aParams[10], aParams[11], aParams[12], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[15]
                                                , aParams[16]);
                    }
                    
                    //#20171018 메뉴명 폰트 색상 변경 기능 end

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ITEM_KEY.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region 51 - 즐겨찾기 마스터 Download / Insert
        /// <summary>
        /// 즐겨찾기 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_BOOKMK(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_BOOKMK.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_BOOKMK.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_BOOKMK.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_BOOKMK(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 즐겨찾기 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_BOOKMK(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sUpdQuery = "UPDATE POSMST..MST_BOOKMK \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND SUB_STOR_CD = '" + m_sSubStorNo + "' \n";

                sInsQuery = "UPDATE POSMST..MST_BOOKMK \n"
                          + "   SET SHTCUT_ITEM_NM = N'{5}', ITEM_PRC = {6}, FONT_SIZE = '{7}', BACKGR_COLOR = '{8}', BTN_SIZE = '{9}' \n"
                          + "     , SUBPRC_MENU_POPUP_YN = '{10}', UPD_DT = '{11}', USE_YN = '{12}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND SUB_STOR_CD = '{2}' \n"
                          + "   AND ITEM_CD = '{3}' \n"
                          + "   AND SEQ = {4} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_BOOKMK \n"
                          + "       ( CMP_CD, STOR_CD, SUB_STOR_CD, ITEM_CD, SEQ \n"
                          + "       , SHTCUT_ITEM_NM, ITEM_PRC, FONT_SIZE, BACKGR_COLOR, BTN_SIZE \n"
                          + "       , SUBPRC_MENU_POPUP_YN, REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', {4} \n"
                          + "       , N'{5}', {6}, '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}' ) \n";

                sDelQuery = "DELETE FROM POSMST..MST_BOOKMK \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND SUB_STOR_CD = '" + m_sSubStorNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_BOOKMK 테이블은 INSERT 전 모든 데이터 삭제
                // 안호성C 요청 - 2016/11/01
                //m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);
                // 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);

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

                    sQuery = string.Format(sInsQuery
                                            , aParams[0], m_cPosStatus.Base.StoreNo, aParams[2], aParams[3], aParams[4]
                                            , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9]
                                            , aParams[10], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[13]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_BOOKMK.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region (미존재) 52 - 다운로드 정보 마스터 Download / Insert
        #endregion

        #region (미존재) 53 - 이미지 정보 마스터 Download / Insert
        #endregion

        #region 54 - 고객화면 마스터 Download / Insert
        /// <summary>
        /// 고객화면 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_CUST_DSP(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_CUST_DSP.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_CUST_DSP.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CUST_DSP.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_CUST_DSP(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 고객화면 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_CUST_DSP(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sUpdQuery = "UPDATE POSMST..MST_CUST_DSP \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";

                sInsQuery = "UPDATE POSMST..MST_CUST_DSP \n"
                          + "   SET FILE_TYPE = '{5}', START_DT = '{6}', FNSH_DT = '{7}', FILE_TIME = {8}, FILE_NM = '{9}' \n"
                          + "     , FILLER1 = '{10}', FILLER2 = '{11}', FILLER3 = '{12}', FILLER4 = '{13}',  FILLER5 = '{14}' \n"
                          + "     , USE_YN = '{15}', UPD_DT = '{16}', START_HOUR = '{17}', FNSH_HOUR = '{18}', DOW = '{19}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND DISP_KIND = '{2}' \n"
                          + "   AND DISP_DIV = '{3}' \n"
                          + "   AND SEQ = {4} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_CUST_DSP \n"
                          + "       ( CMP_CD, STOR_CD, DISP_KIND, DISP_DIV, SEQ \n"
                          + "       , FILE_TYPE, START_DT, FNSH_DT, FILE_TIME, FILE_NM \n"
                          + "       , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n"
                          + "       , USE_YN, REG_DT, START_HOUR, FNSH_HOUR, DOW ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', {4} \n"
                          + "       , '{5}', '{6}', '{7}', {8}, '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}', '{16}', '{17}', '{18}', '{19}' ) \n";

                sDelQuery = "DELETE FROM MST_CUST_DSP \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_CUST_DSP 테이블은 INSERT 전 모든 데이터 삭제
                // 안호성C 요청 - 2017/04/03
                // 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"), 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 false;
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CUST_DSP.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region 55 - 시험모드 마스터 Download / Insert
        /// <summary>
        /// 시험모드 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_TEST_MODE(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_TEST_MODE.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_TEST_MODE.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_TEST_MODE.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_TEST_MODE(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 시험모드 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_TEST_MODE(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_TEST_MODE \n"
                          + "   SET SEQ = {3}, TEST_ENTRY_NM = N'{4}', ERR_PRMT_CNT = {5}, TEST_LMT_TIME = {6}, TEST_ENTRY_EXPLN1 = N'{7}' \n"
                          + "     , TEST_ENTRY_EXPLN2 = N'{8}', TEST_ENTRY_EXPLN3 = N'{9}', TEST_ENTRY_EXPLN4 = N'{10}', TEST_ENTRY_EXPLN5 = N'{11}', FILLER1 = '{12}' \n"
                          + "     , FILLER2 = '{13}', FILLER3 = '{14}', FILLER4 = '{15}', FILLER5 = '{16}', USE_YN = '{17}', UPD_DT = '{18}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND TEST_ENTRY_ID = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_TEST_MODE \n"
                          + "       ( CMP_CD, STOR_CD, TEST_ENTRY_ID, SEQ, TEST_ENTRY_NM \n"
                          + "       , ERR_PRMT_CNT, TEST_LMT_TIME, TEST_ENTRY_EXPLN1, TEST_ENTRY_EXPLN2, TEST_ENTRY_EXPLN3 \n"
                          + "       , TEST_ENTRY_EXPLN4, TEST_ENTRY_EXPLN5, FILLER1, FILLER2, FILLER3 \n"
                          + "       , FILLER4, FILLER5, USE_YN, REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', {3}, N'{4}' \n"
                          + "       , {5}, {6}, N'{7}', N'{8}', N'{9}' \n"
                          + "       , N'{10}', N'{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}', '{16}', '{17}', '{18}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_TEST_MODE.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region (삭제) 56 - 시험모드 설명 마스터 Download / Insert
        #endregion

        #region 57 - 시험모드 상세 정보 마스터 Download / Insert
        /// <summary>
        /// 시험모드 상세 정보 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_TEST_MODE_DTL_INFO(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_TEST_MODE_DTL_INFO.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_TEST_MODE_DTL_INFO.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_TEST_MODE_DTL_INFO.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_TEST_MODE_DTL_INFO(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 시험모드 상세 정보 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_TEST_MODE_DTL_INFO(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_TEST_MODE_DTL_INFO \n"
                          + "   SET DTL_SEQ_EXPLN = N'{4}', POS_SCRN_TYPE = '{5}', SCRN_DISP_HOUR = {6}, NUM_PAD_USE_TYPE = '{7}', INPUT_BOX_USE_YN = '{8}' \n"
                          + "     , INPUT_BOX_DATA_MIN_LEN = {9}, INPUT_BOX_DATA_MAX_LEN = {10}, INPUT_BOX_CHECK_PREFIX = '{11}', DEVICE_USE_TYPE = '{12}', DEVICE_DATA_MIN_LEN = {13} \n"
                          + "     , DEVICE_DATA_MAX_LEN = {14}, DEVICE_PREFIX_CHECK = '{15}', TOUCH_USE_YN = '{16}', FILLER1 = '{17}', FILLER2 = '{18}' \n"
                          + "     , FILLER3 = '{19}', FILLER4 = '{20}', FILLER5 = '{21}', USE_YN = '{22}', UPD_DT = '{23}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND TEST_ENTRY_ID = '{2}' \n"
                          + "   AND DTL_SEQ = {3} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_TEST_MODE_DTL_INFO \n"
                          + "       ( CMP_CD, STOR_CD, TEST_ENTRY_ID, DTL_SEQ, DTL_SEQ_EXPLN \n"
                          + "       , POS_SCRN_TYPE, SCRN_DISP_HOUR, NUM_PAD_USE_TYPE, INPUT_BOX_USE_YN, INPUT_BOX_DATA_MIN_LEN \n"
                          + "       , INPUT_BOX_DATA_MAX_LEN, INPUT_BOX_CHECK_PREFIX, DEVICE_USE_TYPE, DEVICE_DATA_MIN_LEN, DEVICE_DATA_MAX_LEN \n"
                          + "       , DEVICE_PREFIX_CHECK, TOUCH_USE_YN, FILLER1, FILLER2, FILLER3 \n"
                          + "       , FILLER4, FILLER5, USE_YN, REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', {3}, N'{4}' \n"
                          + "       , '{5}', {6}, '{7}', '{8}', {9} \n"
                          + "       , {10}, '{11}', '{12}', {13}, {14} \n"
                          + "       , '{15}', '{16}', '{17}', '{18}', '{19}' \n"
                          + "       , '{20}', '{21}', '{22}', '{23}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], aParams[21], aParams[22], DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_TEST_MODE_DTL_INFO.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 58 - 시험모드 상세 위치 마스터 Download / Insert
        /// <summary>
        /// 시험모드 상세 위치 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_TEST_MODE_DTL_LOC(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_TEST_MODE_DTL_LOC.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_TEST_MODE_DTL_LOC.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_TEST_MODE_DTL_LOC.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_TEST_MODE_DTL_LOC(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 시험모드 상세 위치 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_TEST_MODE_DTL_LOC(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_TEST_MODE_DTL_LOC \n"
                          + "   SET IMG_FILE_NM = '{5}', NUM_PAD_START_LOC_X = {6}, NUM_PAD_START_LOC_Y = {7}, INPUT_BOX_START_LOC_X = {8}, INPUT_BOX_START_LOC_Y = {9} \n"
                          + "     , INPUT_BOX_FNSH_LOC_X = {10}, INPUT_BOX_FNSH_LOC_Y = {11}, TOUCH_START_LOC_X = {12}, TOUCH_START_LOC_Y = {13}, TOUCH_FNSH_LOC_X = {14} \n"
                          + "     , TOUCH_FNSH_LOC_Y = {15}, FILLER1 = '{16}', FILLER2 = '{17}', FILLER3 = '{18}', FILLER4 = '{19}' \n"
                          + "     , FILLER5 = '{20}', USE_YN = '{21}', UPD_DT = '{22}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND TEST_ENTRY_ID = '{2}' \n"
                          + "   AND DTL_SEQ = {3} \n"
                          + "   AND POS_SCRN_TYPE = '{4}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_TEST_MODE_DTL_LOC \n"
                          + "       ( CMP_CD, STOR_CD, TEST_ENTRY_ID, DTL_SEQ, POS_SCRN_TYPE \n"
                          + "       , IMG_FILE_NM, NUM_PAD_START_LOC_X, NUM_PAD_START_LOC_Y, INPUT_BOX_START_LOC_X, INPUT_BOX_START_LOC_Y \n"
                          + "       , INPUT_BOX_FNSH_LOC_X, INPUT_BOX_FNSH_LOC_Y, TOUCH_START_LOC_X, TOUCH_START_LOC_Y, TOUCH_FNSH_LOC_X \n"
                          + "       , TOUCH_FNSH_LOC_Y, FILLER1, FILLER2, FILLER3, FILLER4 \n"
                          + "       , FILLER5, USE_YN, REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', {3}, '{4}' \n"
                          + "       , '{5}', {6}, {7}, {8}, {9} \n"
                          + "       , {10}, {11}, {12}, {13}, {14} \n"
                          + "       , {15}, '{16}', '{17}', '{18}', '{19}' \n"
                          + "       , '{20}', '{21}', '{22}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], aParams[21], DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_TEST_MODE_DTL_LOC.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 59 - 결제 할인 마스터 Download / Insert
        /// <summary>
        /// 결제 할인 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_PAY_DC(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                //  2019-05-17 - 1997fx11 : Down요청 경로를 POS에서 KIOSK CMS로 변경.
                // 마스터 요청 Hashtable Data 생성
                //htReqData = GetPosMasterReqData(MasterLists.MST_PAY_DC.DIV,
                //                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_PAY_DC.ID) ? sBGUpdateDT : sUpdateDT), 
                //                                sStoreCd, 
                //                                sSubStoreCd, 
                //                                "0");
                htReqData = GetKioskReqData("0",
                                        (MasterListManager.IsBackgroundMaster(MasterLists.MST_PAY_DC.ID) ? sBGUpdateDT : sUpdateDT),
                                        sStoreCd,
                                        MasterLists.MST_PAY_DC.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_PAY_DC.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                //  2019-05-17 - 1997fx11 : Down요청 경로를 POS에서 KIOSK CMS로 변경.
                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_PAY_DC(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 결제 할인 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_PAY_DC(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_PAY_DC \n"
                          + "   SET PAY_DC_NM = N'{4}', PAY_DC_TYPE = '{5}', APPR_VEND_CD = '{6}', CASH_BILL_ISSUE_YN = '{7}', BLNC_AMT_EXCHNG_CPN_PRT_YN = '{8}' \n"
                          + "     , CNNT_ITEM_CHECK_YN = '{9}', COOP_CMP_CNNT_YN = '{10}', PRFX_TRGT_YN = '{11}', PAY_DC_METHD = '{12}', PAY_DC_VAL = {13} \n"
                          + "     , DC_APPLY_TRGT = '{14}', HP_BASIC_ACCUM_YN = '{15}', DC_TRGT_AMT_TYPE = '{16}', CPI_DUP_YN = '{17}', DC_TELECOM_DUP_YN = '{18}' \n"
                          + "     , DC_POINT_DUP_YN = '{19}', DC_CPN_DUP_YN = '{20}', DC_EMP_DC_DUP_YN = '{21}', DC_GNRL_DUP_YN = '{22}', PAY_GNRL_DUP_YN = '{23}' \n"
                          + "     , PAY_MOBILE_DUP_YN = '{24}', PAY_POINT_DUP_YN = '{25}', SALE_POS_PRT_QUE = {26}, USE_YN = '{27}', UPD_DT = '{28}' \n"
                          + "     , HP_ADD_ACCUM_DIV = '{29}', MOBILE_DC_DIV = '{30}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND PAY_DC_GRP_TYPE = '{2}' \n"
                          + "   AND PAY_DC_CD = '{3}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_PAY_DC \n"
                          + "       ( CMP_CD, STOR_CD, PAY_DC_GRP_TYPE, PAY_DC_CD, PAY_DC_NM \n"
                          + "       , PAY_DC_TYPE, APPR_VEND_CD, CASH_BILL_ISSUE_YN, BLNC_AMT_EXCHNG_CPN_PRT_YN, CNNT_ITEM_CHECK_YN \n"
                          + "       , COOP_CMP_CNNT_YN, PRFX_TRGT_YN, PAY_DC_METHD, PAY_DC_VAL, DC_APPLY_TRGT \n"
                          + "       , HP_BASIC_ACCUM_YN, DC_TRGT_AMT_TYPE, CPI_DUP_YN, DC_TELECOM_DUP_YN, DC_POINT_DUP_YN \n"
                          + "       , DC_CPN_DUP_YN, DC_EMP_DC_DUP_YN, DC_GNRL_DUP_YN, PAY_GNRL_DUP_YN, PAY_MOBILE_DUP_YN \n"
                          + "       , PAY_POINT_DUP_YN, SALE_POS_PRT_QUE, USE_YN, REG_DT, HP_ADD_ACCUM_DIV \n"
                          + "       , MOBILE_DC_DIV )  \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', N'{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', {13}, '{14}' \n"
                          + "       , '{15}', '{16}', '{17}', '{18}', '{19}' \n"
                          + "       , '{20}', '{21}', '{22}', '{23}', '{24}' \n"
                          + "       , '{25}', {26}, '{27}', '{28}', '{29}' \n"
                          + "       , '{30}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], aParams[21], aParams[22], aParams[23], aParams[24]
                                            , aParams[25], aParams[26], aParams[27], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[30]
                                            , aParams[31]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_PAY_DC.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 60 - 결제 할인 쿠폰 마스터 Download / Insert
        /// <summary>
        /// 결제 할인 쿠폰 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_PAY_DC_CPN(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_PAY_DC_CPN.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_PAY_DC_CPN.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_PAY_DC_CPN.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_PAY_DC_CPN(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 결제 할인 쿠폰 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_PAY_DC_CPN(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_PAY_DC_CPN \n"
                          + "   SET PRODUCT_CD = '{3}', PAY_DC_GRP_TYPE = '{4}', PAY_DC_CD = '{5}', SALE_START_DT = '{6}', SALE_FNSH_DT = '{7}' \n"
                          + "     , ITEM_CHECK_YN = '{8}', PRFX_INFO = '{9}', SHEETCNT_LMT_YN = '{10}', LMT_QTY = {11}, VALID_TERM_NOD = {12} \n"
                          + "     , USE_YN = '{13}', UPD_DT = '{14}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND MOBILE_CPN_MNG_NO = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_PAY_DC_CPN \n"
                          + "       ( CMP_CD, STOR_CD, MOBILE_CPN_MNG_NO, PRODUCT_CD, PAY_DC_GRP_TYPE \n"
                          + "       , PAY_DC_CD, SALE_START_DT, SALE_FNSH_DT, ITEM_CHECK_YN, PRFX_INFO \n"
                          + "       , SHEETCNT_LMT_YN, LMT_QTY, VALID_TERM_NOD, USE_YN, REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', {11}, {12}, '{13}', '{14}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_PAY_DC_CPN.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 61 - 결제 할인 쿠폰 상품 마스터 Download / Insert
        /// <summary>
        /// 결제 할인 쿠폰 상품 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_PAY_DC_CPN_ITEM(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_PAY_DC_CPN_ITEM.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_PAY_DC_CPN_ITEM.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_PAY_DC_CPN_ITEM.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_PAY_DC_CPN_ITEM(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 결제 할인 쿠폰 상품 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_PAY_DC_CPN_ITEM(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_PAY_DC_CPN_ITEM \n"
                          + "   SET QTY = {4}, USE_YN = '{5}', REG_USER_ID = '{6}', UPD_DT = '{7}', DC_AMT = {8} \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND MOBILE_CPN_MNG_NO = '{2}' \n"
                          + "   AND ITEM_CD = '{3}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_PAY_DC_CPN_ITEM \n"
                          + "       ( CMP_CD, STOR_CD, MOBILE_CPN_MNG_NO, ITEM_CD, QTY \n"
                          + "       , USE_YN, REG_USER_ID, REG_DT, DC_AMT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', {4} \n"
                          + "       , '{5}', '{6}', '{7}', {8} ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

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

                    sQuery = string.Format(sInsQuery
                                            , aParams[0], aParams[1], aParams[2], aParams[3], aParams[4]
                                            , aParams[5], aParams[6], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[9]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_PAY_DC_CPN_ITEM.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 62 - 기간 제휴사 할인 상품 마스터 Download / Insert
        /// <summary>
        /// 기간 제휴사 할인 상품 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_TERM_COOP_CMP_DC_ITEM(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_TERM_COOP_CMP_DC_ITEM.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_TERM_COOP_CMP_DC_ITEM.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_TERM_COOP_CMP_DC_ITEM.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_TERM_COOP_CMP_DC_ITEM(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 기간 제휴사 할인 상품 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_TERM_COOP_CMP_DC_ITEM(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_TERM_COOP_CMP_DC_ITEM \n"
                          + "   SET USE_YN = '{7}', UPD_DT = '{8}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND PAY_DC_GRP_TYPE = '{2}' \n"
                          + "   AND PAY_DC_CD = '{3}' \n"
                          + "   AND COOP_CMP_GRADE_CD = '{4}' \n"
                          + "   AND START_DT = '{5}' \n"
                          + "   AND ITEM_CD = '{6}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_TERM_COOP_CMP_DC_ITEM \n"
                          + "       ( CMP_CD, STOR_CD, PAY_DC_GRP_TYPE, PAY_DC_CD, COOP_CMP_GRADE_CD \n"
                          + "       , START_DT, ITEM_CD, USE_YN, REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

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

                    sQuery = string.Format(sInsQuery
                                            , aParams[0], aParams[1], aParams[2], aParams[3], aParams[4]
                                            , aParams[5], aParams[6], aParams[7], DateTime.Now.ToString("yyyyMMddHHmmsss"), DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_TERM_COOP_CMP_DC_ITEM.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 63 - 기간 제휴사 결제 할인 마스터 Download / Insert
        /// <summary>
        /// 기간 제휴사 결제 할인 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_TERM_COOP_CMP_PAY_DC(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_TERM_COOP_CMP_PAY_DC.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_TERM_COOP_CMP_PAY_DC.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_TERM_COOP_CMP_PAY_DC.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_TERM_COOP_CMP_PAY_DC(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 기간 제휴사 결제 할인 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_TERM_COOP_CMP_PAY_DC(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sUpdQuery = "UPDATE POSMST..MST_TERM_COOP_CMP_PAY_DC \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";

                sInsQuery = "UPDATE POSMST..MST_TERM_COOP_CMP_PAY_DC \n"
                          + "   SET FNSH_DT = '{6}', DC_APPLY_TRGT = '{7}', PAY_DC_METHD = '{8}', PAY_DC_VAL = {9}, PAY_DC_AMT_STD_PAY_AMT = {10} \n"
                          + "     , PAY_DC_DEC_PNT_CALC_METHD = '{11}', PAY_DC_CALC_DIGT_NO = {12}, UPD_DT = '{13}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND PAY_DC_GRP_TYPE = '{2}' \n"
                          + "   AND PAY_DC_CD = '{3}' \n"
                          + "   AND COOP_CMP_GRADE_CD = '{4}' \n"
                          + "   AND START_DT = '{5}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_TERM_COOP_CMP_PAY_DC \n"
                          + "       ( CMP_CD, STOR_CD, PAY_DC_GRP_TYPE, PAY_DC_CD, COOP_CMP_GRADE_CD \n"
                          + "       , START_DT, FNSH_DT, DC_APPLY_TRGT, PAY_DC_METHD, PAY_DC_VAL \n"
                          + "       , PAY_DC_AMT_STD_PAY_AMT, PAY_DC_DEC_PNT_CALC_METHD, PAY_DC_CALC_DIGT_NO, REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', {9} \n"
                          + "       , {10}, '{11}', {12}, '{13}' ) \n";

                sDelQuery = "DELETE FROM MST_TERM_COOP_CMP_PAY_DC \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_TERM_COOP_CMP_PAY_DC 테이블은 INSERT 전 모든 데이터 삭제
                // 안호성C 요청 - 2016/11/01
                //m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);
                // 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);


                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_TERM_COOP_CMP_PAY_DC.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region 64 - 카드 프리픽스 마스터 Download / Insert
        /// <summary>
        /// 카드 프리픽스 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_CARD_PREFIX(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_CARD_PREFIX.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_CARD_PREFIX.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CARD_PREFIX.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    if ((MasterListManager.IsBackgroundMaster(MasterLists.MST_CARD_PREFIX.ID) ? sBGUpdateDT : sUpdateDT) == PosConst.BEGINNING_MST_DOWN_DATE)
                    {
                        // 마스터 전체 수신
                        bReturn = UpdateEntireMST_CARD_PREFIX(aRowDatas);
                    }
                    else
                    {
                        // 마스터 변경 분 수신
                        bReturn = UpdateMST_CARD_PREFIX(aRowDatas);
                    }

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 카드 프리픽스 마스터 전체 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateEntireMST_CARD_PREFIX(string[] aRowDatas)
        {
            string[] aParams = null;

            try
            {
                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                string sTheName = System.Reflection.MethodBase.GetCurrentMethod().Name.Substring(12);
                string tmpTableDboNm = "[POSMST].[dbo].[temp_" + sTheName + "]";
                string orgTableDboNm = "[POSMST].[dbo].[" + sTheName + "]";
                string orgTableNm = sTheName;

                string tmpPKDboNm = "[POSMST].[dbo].[PK_temp_" + sTheName + "]";
                string orgPKNm = "PK_" + sTheName;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                #region ## POSMST..MST_CARD_PREFIX 과 반드시 동기화 되어야 되는 DataTable ##
                DataTable tempTable = new DataTable();
                tempTable.Columns.Add("CMP_CD", typeof(string));
                tempTable.Columns.Add("PRFX_CD", typeof(string));
                tempTable.Columns.Add("CARD_DIV", typeof(string));
                tempTable.Columns.Add("PRFX_NM", typeof(string));
                tempTable.Columns.Add("CARD_CMP_CD", typeof(string));
                tempTable.Columns.Add("LOC", typeof(int));
                tempTable.Columns.Add("CHECK_VAL", typeof(string));
                tempTable.Columns.Add("BANK_CD", typeof(string));
                tempTable.Columns.Add("COOP_CARD_DIV", typeof(string));
                tempTable.Columns.Add("USE_YN", typeof(string));
                tempTable.Columns.Add("UPD_DT", typeof(string));
                tempTable.Columns.Add("REG_DT", typeof(string));
                #endregion ## POSMST..MST_CARD_PREFIX 과 반드시 동기화 되어야 되는 DataTable ##

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

                    tempTable.Rows.Add( aParams[0], aParams[1], aParams[2], aParams[3], aParams[4]
                                      , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9]
                                      , DateTime.Now.ToString("yyyyMMddHHmmsss"), DateTime.Now.ToString("yyyyMMddHHmmsss"));

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % 100 == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + sTheName + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                string strSqlConnectionString = "Data Source=" + m_cPosStatus.Base.LocalDbSource + "; Initial Catalog = " + m_cPosStatus.Base.LocalDbCatalog +
                                                    " ; uid = " + m_cPosStatus.Base.LocalDbUserID + "; Password = " + m_cPosStatus.Base.LocalDbPassword;

                try
                {
                    using (SqlBulkCopy bulkCopy = new SqlBulkCopy(strSqlConnectionString))
                    {
                        // 입력할 테이블 지정
                        bulkCopy.DestinationTableName = tmpTableDboNm;
                        //bulkCopy.BatchSize = 1000;
                        // 데이터 입력
                        bulkCopy.WriteToServer(tempTable);
                    }
                }
                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);

                    // 임시테이블 DROP
                    m_cDatabaseSql.DBExecuteNonQuery("DROP TABLE " + tmpTableDboNm);

                    return false;
                }

                // 기존 테이블 DROP
                m_cDatabaseSql.DBExecuteNonQuery("DROP TABLE " + orgTableDboNm);

                // 임시 테이블을 본 테이블로 Rename
                m_cDatabaseSql.DBExecuteNonQuery("EXEC sp_rename '" + tmpTableDboNm + "', '" + orgTableNm + "'");
                m_cDatabaseSql.DBExecuteNonQuery("EXEC sp_rename '" + tmpPKDboNm + "', '" + orgPKNm + "'");

                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>
        /// 카드 프리픽스 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_CARD_PREFIX(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_CARD_PREFIX \n"
                          + "   SET PRFX_NM = N'{3}', CARD_CMP_CD = '{4}', LOC = {5}, CHECK_VAL = '{6}', BANK_CD = '{7}' \n"
                          + "     , COOP_CARD_DIV = '{8}', USE_YN = '{9}', UPD_DT = '{10}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND PRFX_CD = '{1}' \n"
                          + "   AND CARD_DIV = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_CARD_PREFIX \n"
                          + "       ( CMP_CD, PRFX_CD, CARD_DIV, PRFX_NM, CARD_CMP_CD \n"
                          + "       , LOC, CHECK_VAL, BANK_CD, COOP_CARD_DIV, USE_YN \n"
                          + "       , REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', N'{3}', '{4}' \n"
                          + "       , {5}, '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]
                                            , DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CARD_PREFIX.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 65 - 결제 할인 프리픽스 마스터 Download / Insert
        /// <summary>
        /// 결제 할인 프리픽스 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_PAY_DC_PRFX(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_PAY_DC_PRFX.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_PAY_DC_PRFX.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_PAY_DC_PRFX.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_PAY_DC_PRFX(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 결제 할인 프리픽스 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_PAY_DC_PRFX(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_PAY_DC_PRFX \n"
                          + "   SET PAY_DC_GRP_TYPE = '{2}', PAY_DC_CD = '{3}', USE_YN = '{4}', UPD_DT = '{5}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND PRFX_INFO = '{1}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_PAY_DC_PRFX \n"
                          + "       ( CMP_CD, PRFX_INFO, PAY_DC_GRP_TYPE, PAY_DC_CD, USE_YN \n"
                          + "       , REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , '{5}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

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

                    sQuery = string.Format(sInsQuery
                                            , aParams[0], aParams[1], aParams[2], aParams[3], aParams[4]
                                            , DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_PAY_DC_PRFX.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 66 - 복합매장점포 마스터 Download / Insert
        /// <summary>
        /// 복합매장점포 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_COMPLEX_SHOP_STOR(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_COMPLEX_SHOP_STOR.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_COMPLEX_SHOP_STOR.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_COMPLEX_SHOP_STOR.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_COMPLEX_SHOP_STOR(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 복합매장점포 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_COMPLEX_SHOP_STOR(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sUpdQuery = "UPDATE POSMST..MST_COMPLEX_SHOP_STOR \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";

                sInsQuery = "UPDATE POSMST..MST_COMPLEX_SHOP_STOR \n"
                          + "   SET COMPLEX_SHOP_STOR_NM = N'{4}', DISP_SEQ = {5}, USE_YN = '{6}', UPD_DT = '{7}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND COMPLEX_SHOP_BRAND_CD = '{2}' \n"
                          + "   AND COMPLEX_SHOP_STOR_CD = '{3}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_COMPLEX_SHOP_STOR \n"
                          + "       ( CMP_CD, STOR_CD, COMPLEX_SHOP_BRAND_CD, COMPLEX_SHOP_STOR_CD, COMPLEX_SHOP_STOR_NM \n"
                          + "       , DISP_SEQ, USE_YN, REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', N'{4}' \n"
                          + "       , {5}, '{6}', '{7}' ) \n";

                sDelQuery = "DELETE FROM POSMST..MST_COMPLEX_SHOP_STOR \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // 복합매장점포 마스터 전체 수신(20170619)
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);

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

                    sQuery = string.Format(sInsQuery
                                            , aParams[0], aParams[1], aParams[2], aParams[3], aParams[4]
                                            , aParams[5], aParams[6], DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_COMPLEX_SHOP_STOR.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region 67 - 입출금 계정 코드 마스터 Download / Insert
        /// <summary>
        /// 입출금 계정 코드 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_DPST_WTHDR_ACC(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_DPST_WTHDR_ACC.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_DPST_WTHDR_ACC.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_DPST_WTHDR_ACC.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_DPST_WTHDR_ACC(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 입출금 계정 코드 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_DPST_WTHDR_ACC(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_DPST_WTHDR_ACC \n"
                          + "   SET DPST_WTHDR_ACC_NM = N'{3}', DPST_WTHDR_TYPE = '{4}', ACC_CD = '{5}', PRNLS_TYPE = '{6}', SPPLR_INPUT_TYPE = '{7}' \n"
                          + "     , SALE_POS_USE_YN = '{8}', UPD_DT = '{9}', USE_YN = '{10}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND DRT_FRCS_DIV = '{1}' \n"
                          + "   AND DPST_WTHDR_ACC_CD = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_DPST_WTHDR_ACC \n"
                          + "       ( CMP_CD, DRT_FRCS_DIV, DPST_WTHDR_ACC_CD, DPST_WTHDR_ACC_NM, DPST_WTHDR_TYPE \n"
                          + "       , ACC_CD, PRNLS_TYPE, SPPLR_INPUT_TYPE, SALE_POS_USE_YN, REG_DT \n"
                          + "       , USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', N'{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss")
                                            , aParams[11]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_DPST_WTHDR_ACC.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 68 - POS 다운 테이블 리스트 마스터 Download / Insert
        /// <summary>
        /// POS DOWN TABLE LIST 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_POSMST_TABLE_LST(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_POSMST_TABLE_LST.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_POSMST_TABLE_LST.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_POSMST_TABLE_LST.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_POSMST_TABLE_LST(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// POS DOWN TABLE LIST 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_POSMST_TABLE_LST(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_POSMST_TABLE_LST \n"
                          + "   SET MST_TBL_ID = '{2}', MST_TBL_NM = N'{3}', EMG_DIV = '{4}', FILLER1 = '{5}', FILLER2 = '{6}' \n"
                          + "     , FILLER3 = '{7}', FILLER4 = '{8}', FILLER5 = '{9}', UPD_DT = '{10}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND MST_TBL_CD = '{1}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_POSMST_TABLE_LST \n"
                          + "       ( CMP_CD, MST_TBL_CD, MST_TBL_ID, MST_TBL_NM, EMG_DIV \n"
                          + "       , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n"
                          + "       , REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', N'{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

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

                    sQuery = string.Format(sInsQuery
                                            , aParams[0], aParams[1], aParams[2], aParams[3], "0"
                                            , "", "", "", "", ""
                                            , DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_POSMST_TABLE_LST.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 69 - 상품 조회 조건(금액) 마스터 Download / Insert
        /// <summary>
        /// 상품 조회 조건(금액) 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_PLU_AMT(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_PLU_AMT.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_PLU_AMT.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_PLU_AMT.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_PLU_AMT(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 상품 조회 조건(금액) 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_PLU_AMT(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_PLU_AMT \n"
                          + "   SET PLU_AMT_NM = N'{3}', P_POSITION = {4}, FROM_AMT = {5}, TO_AMT = {6}, USE_YN = '{7}' \n"
                          + "     , UPD_DT = '{8}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND PLU_SEQ = {2} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_PLU_AMT \n"
                          + "       ( CMP_CD, STOR_CD, PLU_SEQ, PLU_AMT_NM, P_POSITION \n"
                          + "       , FROM_AMT, TO_AMT, USE_YN, REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', {2}, N'{3}', {4} \n"
                          + "       , {5}, {6}, '{7}', '{8}' ) \n";
                
                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

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

                    sQuery = string.Format(sInsQuery
                                            , aParams[0], aParams[1], aParams[2], aParams[3], aParams[4]
                                            , aParams[5], aParams[6], aParams[7], DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_PLU_AMT.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 70 - 상품 조회 조건(상품) 마스터 Download / Insert
        /// <summary>
        /// 상품 조회 조건(상품) 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_PLU_NM(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_PLU_NM.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_PLU_NM.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_PLU_NM.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_PLU_NM(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 상품 조회 조건(상품) 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_PLU_NM(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_PLU_NM \n"
                          + "   SET PLU_NM = N'{4}', P_POSITION = {5}, PLU_1_FR = N'{6}', PLU_1_TO = N'{7}', PLU_2_FR = N'{8}' \n"
                          + "     , PLU_2_TO = N'{9}', PLU_3_FR = N'{10}', PLU_3_TO = N'{11}', USE_YN = '{12}', UPD_DT = '{13}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND KEY_MODE = '{2}' \n"
                          + "   AND PLU_SEQ = {3} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_PLU_NM \n"
                          + "       ( CMP_CD, STOR_CD, KEY_MODE, PLU_SEQ, PLU_NM \n"
                          + "       , P_POSITION, PLU_1_FR, PLU_1_TO, PLU_2_FR, PLU_2_TO \n"
                          + "       , PLU_3_FR, PLU_3_TO, USE_YN, REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', {3}, N'{4}' \n"
                          + "       , {5}, N'{6}', N'{7}', N'{8}', N'{9}' \n"
                          + "       , N'{10}', N'{11}', '{12}', '{13}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_PLU_NM.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 71 - 외부 업체 상품 마스터 Download / Insert
        /// <summary>
        /// 외부 업체 상품 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_OUT_SD_VEND_ITEM(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                //if (m_cPosStatus.Base.ExPos == "0")
                //if (m_cPosStatus.Base.ExPos != "1")
                if (m_cPosStatus.Mst.ETC_IF_DIV != ItemConst.TranInterfaceOutside.IF_KOR_01)
                {
                    return true;
                }

                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_OUT_SD_VEND_ITEM.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_OUT_SD_VEND_ITEM.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_OUT_SD_VEND_ITEM.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_OUT_SD_VEND_ITEM(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 외부 업체 상품 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_OUT_SD_VEND_ITEM(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_OUT_SD_VEND_ITEM \n"
                          + "   SET ENTR_CMP_ITEM_CD = '{3}', USE_YN = '{4}', FILLER1 = '{5}', FILLER2 = '{6}', FILLER3 = '{7}' \n"
                          + "     , FILLER4 = '{8}', FILLER5 = '{9}', UPD_DT = '{10}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND OUT_SD_CMP_CD = '{1}' \n"
                          + "   AND ITEM_CD = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_OUT_SD_VEND_ITEM \n"
                          + "       ( CMP_CD, OUT_SD_CMP_CD, ITEM_CD, ENTR_CMP_ITEM_CD, USE_YN \n"
                          + "       , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n"
                          + "       , REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]
                                            , DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_OUT_SD_VEND_ITEM.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion 71 - 외부 업체 상품 마스터 Download / Insert

        #region 72 - 점포점검 스케쥴 마스터 Download / Insert
        /// <summary>
        /// 점포점검 스케쥴 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_STOR_INSPCT(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_STOR_INSPCT.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_STOR_INSPCT.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_STOR_INSPCT.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_STOR_INSPCT(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 점포점검 스케쥴 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_STOR_INSPCT(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_STOR_INSPCT \n"
                          + "   SET INSPCT_ENTRY_GRP_NM = N'{2}', POS_DIV = '{3}', SALE_POS_ALARM_TYPE = '{4}', SCORE_MNG_YN = '{5}', QUE = {6} \n"
                          + "     , SALE_POS_ALARM_DT_APPNT_TYPE = '{7}', DATE_1 = '{8}', DATE_2 = '{9}', WEEK = '{10}', DOW = '{11}' \n"
                          + "     , START_HOUR = '{12}', FNSH_HOUR = '{13}', SV_CONFRM_YN = '{14}', ANSWR_POSS_DAY_CNT = {15}, USE_YN = '{16}', UPD_DT = '{17}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND INSPCT_ENTRY_GRP_CD = '{1}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_STOR_INSPCT \n"
                          + "       ( CMP_CD, INSPCT_ENTRY_GRP_CD, INSPCT_ENTRY_GRP_NM, POS_DIV, SALE_POS_ALARM_TYPE \n"
                          + "       , SCORE_MNG_YN, QUE, SALE_POS_ALARM_DT_APPNT_TYPE, DATE_1, DATE_2 \n"
                          + "       , WEEK, DOW, START_HOUR, FNSH_HOUR, SV_CONFRM_YN \n"
                          + "       , ANSWR_POSS_DAY_CNT, USE_YN, REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', N'{2}', '{3}', '{4}' \n"
                          + "       , '{5}', {6}, '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , {15}, '{16}', '{17}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_STOR_INSPCT.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion 72 - 점포점검 스케쥴 마스터 Download / Insert

        #region 73 - 점포점검내역 그룹 마스터 Download / Insert
        /// <summary>
        /// 점포점검내역 그룹 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_SALESORG_INSPCT_GRP(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_SALESORG_INSPCT_GRP.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_SALESORG_INSPCT_GRP.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_SALESORG_INSPCT_GRP.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_SALESORG_INSPCT_GRP(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 점포점검내역 그룹 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_SALESORG_INSPCT_GRP(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_SALESORG_INSPCT_GRP \n"
                          + "   SET INSPCT_ENTRY_L_CLSS_NM = N'{4}', INSPCT_GRP_DIV = '{5}', TOT_SCORE = {6}, USE_YN = '{7}', UPD_DT = '{8}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND BRAND_CD = '{1}' \n"
                          + "   AND INSPCT_ENTRY_GRP_CD = '{2}' \n"
                          + "   AND INSPCT_ENTRY_L_CLSS_CD = '{3}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_SALESORG_INSPCT_GRP \n"
                          + "       ( CMP_CD, BRAND_CD, INSPCT_ENTRY_GRP_CD, INSPCT_ENTRY_L_CLSS_CD, INSPCT_ENTRY_L_CLSS_NM \n"
                          + "       , INSPCT_GRP_DIV, TOT_SCORE, USE_YN, REG_DT ) \n"
                          + " VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', N'{4}' \n"
                          + "       , '{5}', {6}, '{7}', '{8}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

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

                    sQuery = string.Format(sInsQuery
                                            , aParams[0], aParams[1], aParams[2], aParams[3], aParams[4]
                                            , aParams[5], aParams[6], aParams[7], DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_SALESORG_INSPCT_GRP.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion 73 - 점포점검내역 그룹 마스터 Download / Insert

        #region 74 - 점포점검내역 상세 마스터 Download / Insert
        /// <summary>
        /// 점포점검내역 상세 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_SALESORG_INSPCT_DTL(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_SALESORG_INSPCT_DTL.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_SALESORG_INSPCT_DTL.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_SALESORG_INSPCT_DTL.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_SALESORG_INSPCT_DTL(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 점포점검내역 상세 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_SALESORG_INSPCT_DTL(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_SALESORG_INSPCT_DTL \n"
                          + "   SET INSPCT_ENTRY_NM = N'{5}', INPUT_DIV = '{6}', SEL_ENTRY_CNT = {7}, SEL_ENTRY_1 = N'{8}', SEL_ENTRY_2 = N'{9}' \n"
                          + "     , SEL_ENTRY_3 = N'{10}', SEL_ENTRY_4 = N'{11}', SEL_ENTRY_5 = N'{12}', SCORE_1 = {13}, SCORE_2 = {14} \n"
                          + "     , SCORE_3 = {15}, SCORE_4 = {16}, SCORE_5 = {17}, QUE = {18}, NOTE_MNDTRY_INPUT_YN = '{19}' \n"
                          + "     , TRGT_DIV = '{20}', EXEC_CYCLE_DIV = '{21}', USE_YN = '{22}', UPD_DT = '{23}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND BRAND_CD = '{1}' \n"
                          + "   AND INSPCT_ENTRY_GRP_CD = '{2}' \n"
                          + "    AND INSPCT_ENTRY_L_CLSS_CD = '{3}' \n"
                          + "    AND INSPCT_ENTRY = {4} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_SALESORG_INSPCT_DTL \n"
                          + "       ( CMP_CD, BRAND_CD, INSPCT_ENTRY_GRP_CD, INSPCT_ENTRY_L_CLSS_CD, INSPCT_ENTRY \n"
                          + "       , INSPCT_ENTRY_NM, INPUT_DIV, SEL_ENTRY_CNT, SEL_ENTRY_1, SEL_ENTRY_2 \n"
                          + "       , SEL_ENTRY_3, SEL_ENTRY_4, SEL_ENTRY_5, SCORE_1, SCORE_2 \n"
                          + "       , SCORE_3, SCORE_4, SCORE_5, QUE, NOTE_MNDTRY_INPUT_YN \n"
                          + "       , TRGT_DIV, EXEC_CYCLE_DIV, USE_YN, REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', {4} \n"
                          + "       , N'{5}', '{6}', {7}, N'{8}', N'{9}' \n"
                          + "       , N'{10}', N'{11}', N'{12}', {13}, {14} \n"
                          + "       , {15}, {16}, {17}, {18}, '{19}' \n"
                          + "       , '{20}', '{21}', '{22}', '{23}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                bool isQueryError = false;//2017.11.23;여러개 행 중에 중간에 오류 발생 했는지 여부;girak.kim

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], aParams[21], aParams[22], DateTime.Now.ToString("yyyyMMddHHmmsss"));

                    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 false; 기존 소스      
                        //Strat;2017.11.23;한 행 만 실패하더라도 해당 테이블에 그 다음 내용은 추가,수정이 안 되므로 그 이 후 내용 수정, 추가 되도록 변경;girak.kim;
                        isQueryError = true;//중간 오류 발생함.
                        //nCheckToStepUp++;// nCheckToStepUp 는 일단 증가 시키지 않았음
                        continue;
                        //End
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_SALESORG_INSPCT_DTL.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //기존 소스
                //return true;
                //Start;2017.11.23;여러개 행 중에 중간 오류 발생 했는지 체크 하여 결과 리턴;girak.kim
                if (isQueryError) return false;
                else return true;
                //End;
            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.LOG_ERROR,
                                     System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                     System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                     ex.Message);

                return false;
            }
        }
        #endregion 74 - 점포점검내역 상세 마스터 Download / Insert

        #region 75 - 영수증 설문조사 메시지 마스터 Downlaod / Insert
        /// <summary>
        /// 영수증 설문조사 메시지 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_SALESORG_SURVY_MSG(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_SALESORG_SURVY_MSG.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_SALESORG_SURVY_MSG.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_SALESORG_SURVY_MSG.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_SALESORG_SURVY_MSG(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 영수증 설문조사 메시지 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_SALESORG_SURVY_MSG(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sUpdQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sUpdQuery = "UPDATE POSMST..MST_SALESORG_SURVY_MSG \n"
                          + "   SET UPD_DT = 'DELETE' \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";

                sInsQuery = "UPDATE POSMST..MST_SALESORG_SURVY_MSG \n"
                          + "   SET PRT_SEQ = {4}, APPLY_FNSH_DT = '{5}', APPLY_START_HOUR = '{6}', MSG_VAL = N'{7}', DOW = '{8}' \n"
                          + "     , BOLD_YN = '{9}', PRT_EXPAND_TYPE = '{10}', ALIGN_TYPE = '{11}', FILLER1 = '{12}', FILLER2 = '{13}' \n"
                          + "     , FILLER3 = '{14}', FILLER4 = '{15}', FILLER5 = '{16}', USE_YN = '{17}', UPD_DT = '{18}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND APPLY_START_DT = '{2}' \n"
                          + "   AND SEQ_NO = {3} \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_SALESORG_SURVY_MSG \n"
                          + "       ( CMP_CD, STOR_CD, APPLY_START_DT, SEQ_NO, PRT_SEQ \n"
                          + "       , APPLY_FNSH_DT, APPLY_START_HOUR, MSG_VAL, DOW, BOLD_YN \n"
                          + "       , PRT_EXPAND_TYPE, ALIGN_TYPE, FILLER1, FILLER2, FILLER3 \n"
                          + "       , FILLER4, FILLER5, USE_YN, REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', {3}, {4} \n"
                          + "       , '{5}', '{6}', N'{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' \n"
                          + "       , '{15}', '{16}', '{17}', '{18}' ) \n";

                sDelQuery = "DELETE FROM MST_SALESORG_SURVY_MSG \n"
                          + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"
                          + "   AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"
                          + "   AND UPD_DT = 'DELETE' \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                // MST_SALESORG_SURVY_MSG 테이블은 INSERT 전 모든 데이터 삭제
                // 안호성C 요청 - 2017/04/10
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_SALESORG_SURVY_MSG.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                // DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery);

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

                return false;
            }
        }
        #endregion

        #region 76 - 할인 상세 마스터 Downlaod / Insert
        public bool MST_DC_DTL(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_DC_DTL.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_DC_DTL.ID) ? sBGUpdateDT : sUpdateDT), 
                                                sStoreCd, 
                                                sSubStoreCd, 
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_DC_DTL.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_DC_DTL(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 할인 상세 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_DC_DTL(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_DC_DTL \n"
                          + "   SET CPN_DC_NM = N'{6}', DC_RATE = {7}, USE_YN = '{8}', UPD_DT = '{9}', DC_DIV = '{10}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "    AND STOR_CD = '{1}' \n"
                          + "    AND BRAND_CD = '{2}' \n"
                          + "    AND PAY_DC_GRP_TYPE = '{3}' \n"
                          + "    AND PAY_DC_CD = '{4}' \n"
                          + "    AND CPN_DC_CD = '{5}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_DC_DTL \n"
                          + "       ( CMP_CD, STOR_CD, BRAND_CD, PAY_DC_GRP_TYPE, PAY_DC_CD \n"
                          + "       , CPN_DC_CD, CPN_DC_NM, DC_RATE, USE_YN, REG_DT \n"
                          + "       , DC_DIV ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , '{5}', N'{6}', {7}, '{8}', '{9}' \n"
                          + "       , '{10}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss")
                                            , aParams[11]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_DC_DTL.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 77 - 중국 선불카드 마스터 Download / Insert
        public bool MST_PRECARD(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_PRECARD.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_PRECARD.ID) ? sBGUpdateDT : sUpdateDT),
                                                sStoreCd,
                                                sSubStoreCd,
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_PRECARD.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_PRECARD(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 중국 선불카드 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_PRECARD(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_PRECARD \n"
                          + "   SET PRECARD_SHORT_NM = N'{3}', PRECARD_NM = N'{4}', PRECARD_AMT = {5}, SORT_QUE = {6}, FILLER1 = '{7}' \n"
                          + "     , FILLER2 = '{8}', FILLER3 = '{9}', FILLER4 = '{10}', FILLER5 = '{11}', UPD_DT = '{12}', USE_YN = '{13}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND PRECARD_ID = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_PRECARD \n"
                          + "       ( CMP_CD, STOR_CD, PRECARD_ID, PRECARD_SHORT_NM, PRECARD_NM \n"
                          + "       , PRECARD_AMT, SORT_QUE, FILLER1, FILLER2, FILLER3 \n"
                          + "       , FILLER4, FILLER5, REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', N'{3}', N'{4}' \n"
                          + "       , {5}, {6}, '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[14]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_PRECARD.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion 77 - 중국 선불카드 마스터 Download / Insert

        #region 78 - 점포 일일 장비 점검 마스터 Download / Insert
        public bool MST_STR_DAILY_INSPCT_LIST(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_STR_DAILY_INSPCT_LIST.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_STR_DAILY_INSPCT_LIST.ID) ? sBGUpdateDT : sUpdateDT),
                                                sStoreCd,
                                                sSubStoreCd,
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_STR_DAILY_INSPCT_LIST.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_STR_DAILY_INSPCT_LIST(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 점포 일일 장비 점검 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_STR_DAILY_INSPCT_LIST(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_STR_DAILY_INSPCT_LIST \n"
                          + "   SET USE_YN = '{3}', UPD_DT = '{4}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND INSPCT_CD = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_STR_DAILY_INSPCT_LIST \n"
                          + "       ( CMP_CD, STOR_CD, INSPCT_CD, USE_YN, UPD_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

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

                    sQuery = string.Format(sInsQuery
                                            , aParams[0], aParams[1], aParams[2], aParams[3], DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_STR_DAILY_INSPCT_LIST.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion 78 - 점포 일일 장비 점검 마스터 Download / Insert

        #region 79 - 카드사 마스터 Downlaod / Insert
        public bool MST_CARD_CMP(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_CARD_CMP.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_CARD_CMP.ID) ? sBGUpdateDT : sUpdateDT),
                                                sStoreCd,
                                                sSubStoreCd,
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CARD_CMP.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_CARD_CMP(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 카드사 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_CARD_CMP(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_CARD_CMP \n"
                          + "   SET CARD_CMP_NM = N'{2}', CARD_CMP_DIV = '{3}', CMMSNRATE = {4}, BIZ_PSN_NO = '{5}', TEL_NO = '{6}' \n"
                          + "     , FAX_NO = '{7}', HOME_PAGE = '{8}', SALES_ORG_CD = '{9}', GRP_CD = '{10}', TERM_DIV = '{11}' \n"
                          + "     , TERM_RTN_NO = '{12}', UPD_DT = '{13}', USE_YN = '{14}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND CARD_CMP_CD = '{1}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_CARD_CMP \n"
                          + "       ( CMP_CD, CARD_CMP_CD, CARD_CMP_NM, CARD_CMP_DIV, CMMSNRATE \n"
                          + "       , BIZ_PSN_NO, TEL_NO, FAX_NO, HOME_PAGE, SALES_ORG_CD \n"
                          + "       , GRP_CD, TERM_DIV, TERM_RTN_NO, REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', N'{2}', '{3}', {4} \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[15]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CARD_CMP.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion 79 - 카드사 마스터 Downlaod / Insert

        #region 80 - 온라인 쿠폰 마스터 Download / Insert
        /// <summary>
        /// 온라인 쿠폰 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sBGUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubBrandCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_ONLINE_CPN(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_ONLINE_CPN.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_ONLINE_CPN.ID) ? sBGUpdateDT : sUpdateDT),
                                                sStoreCd,
                                                sSubStoreCd,
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ONLINE_CPN.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_ONLINE_CPN(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 온라인 쿠폰 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_ONLINE_CPN(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_ONLINE_CPN \n"
                          + "   SET CPN_STAT = '{3}', START_DAY = '{4}', FNSH_DAY = '{5}', PRRTY = '{6}', PRT_MSG = N'{7}' \n"
                          + "     , FILLER1 = '{8}', FILLER2 = '{9}', FILLER3 = '{10}', FILLER4 = '{11}', FILLER5 = '{12}' \n"
                          + "     , UPD_DT = '{13}', USE_YN = '{14}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND CPN_DIV = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_ONLINE_CPN \n"
                          + "       ( CMP_CD, STOR_CD, CPN_DIV, CPN_STAT, START_DAY \n"
                          + "       , FNSH_DAY, PRRTY, PRT_MSG, FILLER1, FILLER2 \n"
                          + "       , FILLER3, FILLER4, FILLER5, REG_DT, USE_YN ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}', '{14}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[15]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_ONLINE_CPN.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 81 - 외부I/F 점포 코드 관리 마스터 Download / Insert
        /// <summary>
        /// 외부 I/F 점포 코드 관리 마스터 다운로드 처리
        /// </summary>
        /// <param name="sUpdateDT"></param>
        /// <param name="sBGUpdateDT"></param>
        /// <param name="sStoreCd"></param>
        /// <param name="sSubBrandCd"></param>
        /// <param name="sSubStoreCd"></param>
        /// <returns></returns>
        public bool MST_OUT_SD_VEND_STOR(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                // 마스터 요청 Hashtable Data 생성
                htReqData = GetPosMasterReqData(MasterLists.MST_OUT_SD_VEND_STOR.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_OUT_SD_VEND_STOR.ID) ? sBGUpdateDT : sUpdateDT),
                                                sStoreCd,
                                                sSubStoreCd,
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_OUT_SD_VEND_STOR.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_OUT_SD_VEND_STOR(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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>
        /// 외부I/F 점포 코드 관리 마스터 Update
        /// </summary>
        /// <param name="aRowDatas"></param>
        /// <returns></returns>
        private bool UpdateMST_OUT_SD_VEND_STOR(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                sInsQuery = "UPDATE POSMST..MST_OUT_SD_VEND_STOR \n"
                          + "   SET JOIN_CMP_CD = '{3}', JOIN_BRAND_CD = '{4}', JOIN_STOR_CD = '{5}', JOIN_ITEM_CD = '{6}', USE_YN = '{7}' \n"
                          + "     , FILLER1 = '{8}', FILLER2 = '{9}', FILLER3 = '{10}', FILLER4 = '{11}', FILLER5 = '{12}' \n"
                          + "     , UPD_DT = '{13}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND POS_NO = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_OUT_SD_VEND_STOR \n"
                          + "       ( CMP_CD, STOR_CD, POS_NO, JOIN_CMP_CD, JOIN_BRAND_CD \n"
                          + "       , JOIN_STOR_CD, JOIN_ITEM_CD, USE_YN, FILLER1, FILLER2 \n"
                          + "       , FILLER3, FILLER4, FILLER5, REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}', '{12}', '{13}' ) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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], DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_OUT_SD_VEND_STOR.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion

        #region 82 - 레시피 마스터 Download / Insert
        public bool MST_KTCH_ITEM_INFO(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetPosMasterReqData(MasterLists.MST_KTCH_ITEM_INFO.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_KTCH_ITEM_INFO.ID) ? sBGUpdateDT : sUpdateDT),
                                                sStoreCd,
                                                sSubStoreCd,
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_KTCH_ITEM_INFO.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);

                    //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString());

                    // DB Insert
                    bReturn = UpdateMST_KTCH_ITEM_INFO(aRowDatas);

                    //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff"));
                }
                else
                {
                    return false;
                }

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

        private bool UpdateMST_KTCH_ITEM_INFO(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                //#20180515 KPS 출력시 라벨프린터 출력 start
                //기존
                /*
                sInsQuery = "UPDATE POSMST..MST_KTCH_ITEM_INFO \n"
                          + "   SET ITEM_INFO = '{4}', USE_YN = '{5}', FILLER1 = '{6}', FILLER2 = '{7}', FILLER3 = '{8}' \n"
                          + "     , FILLER4 = '{9}', FILLER5 = '{10}', UPD_DT = '{11}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND SUB_STOR_CD = '{2}' \n"
                          + "   AND ITEM_CD = '{3}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_KTCH_ITEM_INFO \n"
                          + "       ( CMP_CD, STOR_CD, SUB_STOR_CD, ITEM_CD, ITEM_INFO \n"
                          + "       , USE_YN, FILLER1, FILLER2, FILLER3, FILLER4 \n"
                          + "       , FILLER5, REG_DT ) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', N'{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}' ) \n";
                */
                //변경
                sInsQuery = "UPDATE POSMST..MST_KTCH_ITEM_INFO \n"
                          + "   SET ITEM_INFO = '{4}', USE_YN = '{5}', FILLER1 = '{6}', FILLER2 = '{7}', FILLER3 = '{8}' \n"
                          + "     , FILLER4 = '{9}', FILLER5 = '{10}', UPD_DT = '{11}' \n"
                          + "     , LBL_QRCODE_URL = '{12}', LBL_QRCODE_MSG = '{13}', LBL_TOP_MSG = '{14}', LBL_BTM_MSG = '{15}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND SUB_STOR_CD = '{2}' \n"
                          + "   AND ITEM_CD = '{3}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_KTCH_ITEM_INFO \n"
                          + "       ( CMP_CD, STOR_CD, SUB_STOR_CD, ITEM_CD, ITEM_INFO \n"
                          + "       , USE_YN, FILLER1, FILLER2, FILLER3, FILLER4 \n"
                          + "       , FILLER5, REG_DT \n"
                          + "       , LBL_QRCODE_URL, LBL_QRCODE_MSG, LBL_TOP_MSG, LBL_BTM_MSG) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', N'{4}' \n"
                          + "       , '{5}', '{6}', '{7}', '{8}', '{9}' \n"
                          + "       , '{10}', '{11}' \n"
                          + "       , '{12}', '{13}', '{14}', '{15}') \n";
                //#20180515 KPS 출력시 라벨프린터 출력 end

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

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

                    //#20180515 KPS 출력시 라벨프린터 출력 start
                    //기존
                    /*
                    sQuery = string.Format(sInsQuery
                                          , aParams[0], aParams[1], aParams[2], aParams[3], aParams[4].Replace("'", "''")
                                          , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9]
                                          , aParams[10], DateTime.Now.ToString("yyyyMMddHHmmsss"));
                    */
                    //변경
                    sQuery = string.Format(sInsQuery
                                          , aParams[0], aParams[1], aParams[2], aParams[3], aParams[4].Replace("'", "''")
                                          , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9]
                                          , aParams[10], DateTime.Now.ToString("yyyyMMddHHmmsss")
                                          , aParams[13], aParams[14], aParams[15], aParams[16]);
                    //#20180515 KPS 출력시 라벨프린터 출력 end

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_KTCH_ITEM_INFO.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion 82 - 레시피 마스터 Download / Insert

        //#20171116 온라인 쿠폰 제품군코드,상품코드 존재 시 할인 대상이 변경되도록 추가 start, phj
        #region 83 - 온라인 쿠폰 제품군 마스터 Download / Insert
        public bool MST_CPN_ITEM_GRP_MNG(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetPosMasterReqData(MasterLists.MST_CPN_ITEM_GRP_MNG.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_CPN_ITEM_GRP_MNG.ID) ? sBGUpdateDT : sUpdateDT),
                                                sStoreCd,
                                                sSubStoreCd,
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CPN_ITEM_GRP_MNG.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateMST_CPN_ITEM_GRP_MNG(aRowDatas);
                }
                else
                {
                    return false;
                }

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

        private bool UpdateMST_CPN_ITEM_GRP_MNG(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {

                //#20180502 온라인쿠폰 제품군, 상품코드 할인 적용 기능 적용 start
                //기존
                //sInsQuery = "UPDATE POSMST..MST_CPN_ITEM_GRP_MNG \n"
                //          + "   SET ITEM_GRP_NM = '{2}', USE_YN = '{3}', UPD_DATE = '{4}' \n"
                //          + " WHERE CMP_CD = '{0}' \n"
                //          + "   AND ITEM_GRP_CD = '{1}' \n"
                //          + "IF @@ROWCOUNT = 0 \n"
                //          + "INSERT INTO POSMST..MST_CPN_ITEM_GRP_MNG \n"
                //          + "       (CMP_CD, ITEM_GRP_CD, ITEM_GRP_NM, USE_YN, REG_DATE) \n"
                //          + "VALUES \n"
                //          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}') \n";
              
                //변경
                sInsQuery = "UPDATE POSMST..MST_CPN_ITEM_GRP_MNG \n"
                          + "   SET ITEM_GRP_NM = '{2}', USE_YN = '{3}', UPD_DATE = '{4}', GUBUN = '{5}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND ITEM_GRP_CD = '{1}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_CPN_ITEM_GRP_MNG \n"
                          + "       (CMP_CD, ITEM_GRP_CD, ITEM_GRP_NM, USE_YN, REG_DATE, GUBUN) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}', '{5}') \n";
                //#20180502 온라인쿠폰 제품군, 상품코드 할인 적용 기능 적용 end

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);
                              

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

                    //#20180502 온라인쿠폰 제품군, 상품코드 할인 적용 기능 적용 start
                    //기존
                    //sQuery = string.Format(sInsQuery, aParams[0], aParams[1], aParams[2], aParams[3], DateTime.Now.ToString("yyyyMMddHHmmsss"));
                    //변경
                    sQuery = string.Format(sInsQuery, aParams[0], aParams[1], aParams[2], aParams[3], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[6]);
                    //#20180502 온라인쿠폰 제품군, 상품코드 할인 적용 기능 적용 end

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CPN_ITEM_GRP_MNG.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion 83 - 온라인 쿠폰 제품군 마스터 Download / Insert
        //#20171116 온라인 쿠폰 제품군코드,상품코드 존재 시 할인 대상이 변경되도록 추가 end, phj

        //#20171116 온라인 쿠폰 제품군코드,상품코드 존재 시 할인 대상이 변경되도록 추가 start, phj
        #region 84 - 온라인 쿠폰 제품군 상세 마스터 Download / Insert
        public bool MST_CPN_ITEM_GRP_MNG_DTL(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetPosMasterReqData(MasterLists.MST_CPN_ITEM_GRP_MNG_DTL.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.MST_CPN_ITEM_GRP_MNG_DTL.ID) ? sBGUpdateDT : sUpdateDT),
                                                sStoreCd,
                                                sSubStoreCd,
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CPN_ITEM_GRP_MNG_DTL.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateMST_CPN_ITEM_GRP_MNG_DTL(aRowDatas);
                }
                else
                {
                    return false;
                }

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


        private bool UpdateMST_CPN_ITEM_GRP_MNG_DTL(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {

                sInsQuery = "UPDATE POSMST..MST_CPN_ITEM_GRP_MNG_DTL \n"
                          + "   SET USE_YN = '{3}',  UPD_DATE = '{4}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND ITEM_GRP_CD = '{1}' \n"
                          + "   AND ITEM_CD = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..MST_CPN_ITEM_GRP_MNG_DTL \n"
                          + "       (CMP_CD, ITEM_GRP_CD, ITEM_CD, USE_YN, REG_DATE) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}') \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    aParams = sRowData.Split('|');
                    sQuery = string.Format(sInsQuery, aParams[0], aParams[1], aParams[2], aParams[3], DateTime.Now.ToString("yyyyMMddHHmmsss"));
                    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);
                    }

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.MST_CPN_ITEM_GRP_MNG.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion 84 - 온라인 쿠폰 제품군 상세 마스터 Download / Insert
        //#20171116 온라인 쿠폰 제품군코드,상품코드 존재 시 할인 대상이 변경되도록 추가 end, phj

        //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 start, 20180510
        #region 85 - 고객 구매이력 조회 마스터 Download / Insert
        public bool STR_SEND_CPN_MST(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetPosMasterReqData(MasterLists.STR_SEND_CPN_MST.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.STR_SEND_CPN_MST.ID) ? sBGUpdateDT : sUpdateDT),
                                                sStoreCd,
                                                sSubStoreCd,
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.STR_SEND_CPN_MST.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateSTR_SEND_CPN_MST(aRowDatas);
                }
                else
                {
                    return false;
                }

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

        private bool UpdateSTR_SEND_CPN_MST(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 start, 20180528
                //쿠폰 발송 횟수 제한 기능
                //기존
                /*
                sInsQuery = "UPDATE POSMST..STR_SEND_CPN_MST \n"
                          + "   SET HAPPY_YN = '{2}', PRINT_YN = '{3}', SEND_YN = '{4}', UPD_DATE = '{5}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..STR_SEND_CPN_MST \n"
                          + "       (CMP_CD, STOR_CD, HAPPY_YN, PRINT_YN, SEND_YN, REG_DATE) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}', '{5}') \n";
                */
                //변경
                
                sInsQuery = "UPDATE POSMST..STR_SEND_CPN_MST \n"
                          + "   SET HAPPY_YN = '{2}', PRINT_YN = '{3}', SEND_YN = '{4}', UPD_DATE = '{5}', CPN_SEND_LIMIT_CNT = {6} \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..STR_SEND_CPN_MST \n"
                          + "       (CMP_CD, STOR_CD, HAPPY_YN, PRINT_YN, SEND_YN, REG_DATE, CPN_SEND_LIMIT_CNT) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}', '{5}', {6} ) \n";
                
                //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 end, 20180528

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

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

                    //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 start, 20180528
                    //쿠폰 발송 횟수 제한 기능
                    //기존
                    //sQuery = string.Format(sInsQuery, aParams[0], aParams[1], aParams[2], aParams[3], aParams[4], DateTime.Now.ToString("yyyyMMddHHmmsss"));
                    //변경
                    sQuery = string.Format(sInsQuery, aParams[0], aParams[1], aParams[2], aParams[3], aParams[4], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[7]);
                    //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 end, 20180528

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.STR_SEND_CPN_MST.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion 85 - 고객 구매이력 조회 마스터 Download / Insert

        #region 86 - 고객 구매이력 조회 상세(발송 쿠폰) Download / Insert
        public bool STR_SEND_CPN_DTL(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetPosMasterReqData(MasterLists.STR_SEND_CPN_DTL.DIV,
                                                (MasterListManager.IsBackgroundMaster(MasterLists.STR_SEND_CPN_DTL.ID) ? sBGUpdateDT : sUpdateDT),
                                                sStoreCd,
                                                sSubStoreCd,
                                                "0");

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.STR_SEND_CPN_DTL.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp
                                                          , (int)m_cPosStatus.Base.MstPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateSTR_SEND_CPN_DTL(aRowDatas);
                }
                else
                {
                    return false;
                }

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

        private bool UpdateSTR_SEND_CPN_DTL(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sDelQuery = string.Empty;
            string[] aParams = null;

            try
            {
                //변경
                sInsQuery = "UPDATE POSMST..STR_SEND_CPN_DTL \n"
                          + "   SET USE_YN = '{3}', UPD_DATE = '{4}' \n"
                          + " WHERE CMP_CD = '{0}' \n"
                          + "   AND STOR_CD = '{1}' \n"
                          + "   AND CODE = '{2}' \n"
                          + "IF @@ROWCOUNT = 0 \n"
                          + "INSERT INTO POSMST..STR_SEND_CPN_DTL \n"
                          + "       (CMP_CD, STOR_CD, CODE, USE_YN, REG_DATE) \n"
                          + "VALUES \n"
                          + "       ( '{0}', '{1}', '{2}', '{3}', '{4}') \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);


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

                    sQuery = string.Format(sInsQuery, aParams[0], aParams[1], aParams[2], aParams[3], DateTime.Now.ToString("yyyyMMddHHmmsss"));

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + MasterLists.STR_SEND_CPN_DTL.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

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

                return false;
            }
        }
        #endregion 86 - 고객 구매이력 조회 상세(발송 쿠폰) Download / Insert
        //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 end, 20180510


        //*----------------------------------------------------------------------------------------------------------*/
        // 2019-02-25 - 1997fx11 : Kiosk Download / Insert 처리
        // 2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET 및 적용 후 DELETE 플래그 해당 DATA 삭제
        // 2019-03-07 - 1997fx11 : 'NHS_CUST_BUY_HIST' Table 관련 삭제
        // 2019-03-07 - 1997fx11 : 'NHS_LANG_MSG' Table 에서 'PRD_CATE_CD', 'ITEM_CD' Column 삭제
        // 2019-03-08 - 1997fx11 : 'NHS_STORE_PRD_KEY' Table에 'FILE_NAME' Column 추가
        // 2019-03-08 - 1997fx11 : 'NHS_PRD_OPTN' Table 에서 'PRD_CATE_CD' Column 삭제
        // 2019-03-11 - 1997fx11 : Class명, Table명을 'NHS_STORE_PRD_CATE'에서 'NHS_STOR_PRD_CATE' 로 변경
        // 2019-03-11 - 1997fx11 : Class명, Table명을 'NHS_STORE_PRD_KEY'에서 'NHS_STOR_PRD_KEY' 로 변경
        // 2019-03-11 - 1997fx11 : 'NHS_STOR_PRD_TAG' Table 관련 추가
        // 2019-03-11 - 1997fx11 : 'NHS_STOR_PRD_KEY' Table 관련 삭제
        // 2019-03-11 - 1997fx11 : 'NHS_PRD_CATE_L' Table 관련 삭제
        // 2019-03-11 - 1997fx11 : 'NHS_PRD_CATE_M' Table 관련 삭제
        //*----------------------------------------------------------------------------------------------------------*/
        #region 01 : 점포별 대기화면 Download / Insert
        public bool NHS_SCREEN(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_SCREEN.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_SCREEN.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_SCREEN.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_SCREEN(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_SCREEN(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_SCREEN ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                .AppendFormat("AND [STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);

                sDelQuery.Append("DELETE POSMST..NHS_SCREEN ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                .AppendFormat("AND [STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_SCREEN \n"
                                + "     SET [SCREEN_NM] = '{5}' \n"
                                + "         ,[SCREEN_DESC] = '{6}' \n"
                                + "         ,[LAYOUT_CD] = '{4}' \n"
                                + "         ,[DISPLAY_YN] = '{7}' \n"
                                + "         ,[DISPLAY_START_DT] = '{8}' \n"
                                + "         ,[DISPLAY_END_DT] = '{9}' \n"
                                + "         ,[UPD_USER_ID] = '{12}' \n"
                                + "         ,[UPD_DATE] = GETDATE() \n"
                                + "         ,[SCREEN_KIND] = '{14}' \n"
                                + "     WHERE [CMP_CD] = '{0}' \n"
                                + "         AND [SALES_ORG_CD] = '{1}' \n"
                                + "         AND [STOR_CD] = '{2}' \n"
                                + "         AND [SCREEN_CD] = '{3}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_SCREEN \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[STOR_CD] \n"
                                + "    ,[SCREEN_CD] \n"
                                + "    ,[LAYOUT_CD] \n"
                                + "    ,[SCREEN_NM] \n"
                                + "    ,[SCREEN_DESC] \n"
                                + "    ,[DISPLAY_YN] \n"
                                + "    ,[DISPLAY_START_DT] \n"
                                + "    ,[DISPLAY_END_DT] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE] \n"
                                + "    ,[SCREEN_KIND]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}',GETDATE(),'{14}') \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_SCREEN.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        #endregion


        #region 02 : 대기화면 레이어별 리소스 Download / Insert
        public bool NHS_SCREEN_CONTENTS(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_SCREEN_CONTENTS.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_SCREEN_CONTENTS.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_SCREEN_CONTENTS.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_SCREEN_CONTENTS(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_SCREEN_CONTENTS(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_SCREEN_CONTENTS ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                .AppendFormat("AND [STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);

                sDelQuery.Append("DELETE POSMST..NHS_SCREEN_CONTENTS ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                .AppendFormat("AND [STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo)
                                .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_SCREEN_CONTENTS \n"
                                + "     SET [SCREEN_CD] = '{5}' \n"
                                + "         ,[FRAME_CD] = '{6}' \n"
                                + "         ,[DISPLAY_ORDER] = '{7}' \n"
                                + "         ,[DISPLAY_START_TIME] = '{8}' \n"
                                + "         ,[DISPLAY_END_TIME] = '{9}' \n"
                                + "         ,[FILE_FULLPATH] = '{10}' \n"
                                + "         ,[FILE_NAME] = '{11}' \n"
                                + "         ,[FILE_MIME_TYPE] = '{12}' \n"
                                + "         ,[PLAY_TIME] = '{13}' \n"
                                + "         ,[LINK_YN] = '{14}' \n"
                                + "         ,[PRD_CATE_L] = '{15}' \n"
                                + "         ,[PRD_CATE_M] = '{16}' \n"
                                + "         ,[UPD_USER_ID] = '{19}' \n"
                                + "         ,[UPD_DATE] = GETDATE() \n"
                                + "         ,[SCREEN_KIND] = '{21}' \n"
                                + "     WHERE [CMP_CD] = '{0}' \n"
                                + "         AND [SALES_ORG_CD] = '{1}' \n"
                                + "         AND [STOR_CD] = '{2}' \n"
                                + "         AND [LAYER_CD] = '{3}' \n"
                                + "         AND [CONTENTS_ID] = '{4}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_SCREEN_CONTENTS \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[STOR_CD] \n"
                                + "    ,[LAYER_CD] \n"
                                + "    ,[CONTENTS_ID] \n"
                                + "    ,[SCREEN_CD] \n"
                                + "    ,[FRAME_CD] \n"
                                + "    ,[DISPLAY_ORDER] \n"
                                + "    ,[DISPLAY_START_TIME] \n"
                                + "    ,[DISPLAY_END_TIME] \n"
                                + "    ,[FILE_FULLPATH] \n"
                                + "    ,[FILE_NAME] \n"
                                + "    ,[FILE_MIME_TYPE] \n"
                                + "    ,[PLAY_TIME] \n"
                                + "    ,[LINK_YN] \n"
                                + "    ,[PRD_CATE_L] \n"
                                + "    ,[PRD_CATE_M] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE] \n"
                                + "    ,[SCREEN_KIND]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}',GETDATE(),'{21}') \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]
                                                    , aParams[21]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_SCREEN_CONTENTS.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        #endregion


        #region 03 : 대기화면 레이어 Download / Insert
        public bool NHS_SCREEN_LAYER(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_SCREEN_LAYER.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_SCREEN_LAYER.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_SCREEN_LAYER.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_SCREEN_LAYER(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_SCREEN_LAYER(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_SCREEN_LAYER ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                .AppendFormat("AND [STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);

                sDelQuery.Append("DELETE POSMST..NHS_SCREEN_LAYER ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                .AppendFormat("AND [STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_SCREEN_LAYER \n"
                                + "     SET [SCREEN_CD] = '{5}' \n"
                                + "         ,[FRAME_VERTICAL_SIZE] = '{6}' \n"
                                + "         ,[LAYER_DISPLAY_ORDER] = '{7}' \n"
                                + "         ,[FIX_YN] = '{8}' \n"
                                + "         ,[UPD_USER_ID] = '{11}' \n"
                                + "         ,[UPD_DATE] = GETDATE() \n"
                                + "         ,[SCREEN_KIND] = '{13}' \n"
                                + "     WHERE [CMP_CD] = '{0}' \n"
                                + "         AND [SALES_ORG_CD] = '{1}' \n"
                                + "         AND [STOR_CD] = '{2}' \n"
                                + "         AND [FRAME_CD] = '{3}' \n"
                                + "         AND [LAYER_CD] = '{4}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_SCREEN_LAYER \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[STOR_CD] \n"
                                + "    ,[FRAME_CD] \n"
                                + "    ,[LAYER_CD] \n"
                                + "    ,[SCREEN_CD] \n"
                                + "    ,[FRAME_VERTICAL_SIZE] \n"
                                + "    ,[LAYER_DISPLAY_ORDER] \n"
                                + "    ,[FIX_YN] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE] \n"
                                + "    ,[SCREEN_KIND]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',GETDATE(),'{13}') \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_SCREEN_LAYER.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        #endregion


        #region 04 : 점포별 제품카테고리 Download / Insert (사용안함)
        /*
        public bool NHS_STOR_PRD_CATE(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_STOR_PRD_CATE.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_STOR_PRD_CATE.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_STOR_PRD_CATE.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_STOR_PRD_CATE(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_STOR_PRD_CATE(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_STOR_PRD_CATE ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                .AppendFormat("AND [STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);

                sDelQuery.Append("DELETE POSMST..NHS_STOR_PRD_CATE ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                .AppendFormat("AND [STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_STOR_PRD_CATE \n"
                                + "     SET [FILE_FULLPATH] = '{5}' \n"
                                + "         ,[FILE_NAME] = '{6}' \n"
                                + "         ,[DISPLAY_ORDER] = '{7}' \n"
                                + "         ,[USE_YN] = '{8}' \n"
                                + "         ,[HIDE_YN] = '{9}' \n"
                                + "         ,[UPD_USER_ID] = '{12}' \n"
                                + "         ,[UPD_DATE] = GETDATE() \n"
                                + "     WHERE [CMP_CD] = '{0}' \n"
                                + "         AND [SALES_ORG_CD] = '{1}' \n"
                                + "         AND [STOR_CD] = '{2}' \n"
                                + "         AND [PRD_CATE_UP_CD] = '{3}' \n"
                                + "         AND [PRD_CATE_CD] = '{4}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_STOR_PRD_CATE \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[STOR_CD] \n"
                                + "    ,[PRD_CATE_UP_CD] \n"
                                + "    ,[PRD_CATE_CD] \n"
                                + "    ,[FILE_FULLPATH] \n"
                                + "    ,[FILE_NAME] \n"
                                + "    ,[DISPLAY_ORDER] \n"
                                + "    ,[USE_YN] \n"
                                + "    ,[HIDE_YN] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}',GETDATE()) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_STOR_PRD_CATE.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        */
        #endregion


        #region 05 : 점포별 제품 터치키 Download / Insert
        public bool NHS_STOR_PRD_KEY(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_STOR_PRD_KEY.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_STOR_PRD_KEY.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_STOR_PRD_KEY.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_STOR_PRD_KEY(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_STOR_PRD_KEY(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            string sExQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_STOR_PRD_KEY ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                .AppendFormat("AND [STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);

                sDelQuery.Append("DELETE POSMST..NHS_STOR_PRD_KEY ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                .AppendFormat("AND [STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");


                //  2019-04-18 - 1997fx11 : update or insert 받은 [NHS_STOR_PRD_KEY] 정보의 SALES_PRC 로 [MST_ITEM]의 TAKE_IN_SALE_AMT, TAKE_OUT_SALE_AMT 를 update
                sExQuery = "UPDATE POSMST..MST_ITEM \n"
                                + "     SET [TAKE_IN_SALE_AMT] = '{3}' \n"
                                + "         ,[TAKE_OUT_SALE_AMT] = '{3}' \n"
                                + "     WHERE [CMP_CD] = '{0}' \n"
                                + "         AND [STOR_CD] = '{1}' \n"
                                + "         AND [ITEM_CD] = '{2}' \n";


                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] = '{15}' \n"
                                + "         ,[FILE_NAME] = '{16}' \n"
                                + "         ,[BAR_CD] = '{17}' \n"
                                + "         ,[ORDER_TYPE] = '{18}' \n"
                                + "         ,[UPD_USER_ID] = '{21}' \n"

                                + "         ,[UPD_DATE] = GETDATE() \n"


                                + "         ,[TOUCH_KEY_KIND] = '{23}' \n"
                                + "         ,[MAPPING_CD] = '{24}' \n"
                                + "         ,[PRD_LINK_PAGE1] = '{25}' \n"
                                + "         ,[PRD_LINK_PAGE2] = '{26}' \n"
                                + "         ,[SET_YN] = '{27}' \n"
                                + "         ,[SET_ITEM_CD] = '{28}' \n"
                                + "         ,[SET_ITEM_CNT] = '{29}' \n"
                                + "         ,[FLAVOR_YN] = '{30}' \n"
                                + "         ,[FLAVOR_CNT] = '{31}' \n"
                                + "         ,[OPTN_CNT_CHG_YN] = '{32}' \n"
                                + "         ,[SET_CHANGE_YN] = '{33}' \n"
                                + "         ,[SET_CHANGE_ITEM_CD] = '{34}' \n"
                                + "         ,[EVENT_CHANGE_YN] = '{35}' \n"
                                + "         ,[EVENT_ITEM_CD] = '{36}' \n"
                                + "         ,[D2_USE_YN] = '{37}' \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"
                                + "    ,[FILE_NAME] \n"
                                + "    ,[BAR_CD] \n"
                                + "    ,[ORDER_TYPE] \n"
                                + "    ,[REG_USER_ID] \n"

                                + "    ,[REG_DATE] \n"

                                + "    ,[TOUCH_KEY_KIND] \n"
                                + "    ,[MAPPING_CD] \n"
                                + "    ,[PRD_LINK_PAGE1] \n"
                                + "    ,[PRD_LINK_PAGE2] \n"
                                + "    ,[SET_YN] \n"

                                + "    ,[SET_ITEM_CD] \n"
                                + "    ,[SET_ITEM_CNT] \n"
                                + "    ,[FLAVOR_YN] \n"
                                + "    ,[FLAVOR_CNT] \n"
                                + "    ,[OPTN_CNT_CHG_YN] \n"

                                + "    ,[SET_CHANGE_YN] \n"
                                + "    ,[SET_CHANGE_ITEM_CD] \n"
                                + "    ,[EVENT_CHANGE_YN] \n"
                                + "    ,[EVENT_ITEM_CD] \n"
                                + "    ,[D2_USE_YN]  ) \n"

                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}',GETDATE(),'{23}','{24}','{25}','{26}','{27}','{28}','{29}','{30}','{31}','{32}','{33}','{34}','{35}','{36}','{37}') \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]
                                                    , aParams[21]
                                                    , aParams[22]
                                                    , aParams[23]
                                                    , aParams[24]
                                                    , aParams[25]
                                                    , aParams[26]
                                                    , aParams[27]
                                                    , aParams[28]
                                                    , aParams[29]
                                                    , aParams[30]
                                                    , aParams[31]
                                                    , aParams[32]
                                                    , aParams[33]
                                                    , aParams[34]
                                                    , aParams[35]
                                                    , aParams[36]
                                                    , aParams[37]);

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


                    //  2019-04-18 - 1997fx11 : update or insert 받은 [NHS_STOR_PRD_KEY] 정보의 SALES_PRC 로 [MST_ITEM]의 TAKE_IN_SALE_AMT, TAKE_OUT_SALE_AMT 를 update
                    //sQuery = string.Format(sExQuery
                    //                                , aParams[0]
                    //                                , aParams[2]
                    //                                , aParams[5]
                    //                                , aParams[12]);


                    sQuery = string.Format(sExQuery
                                                    , aParams[0]
                                                    , aParams[2]
                                                    , aParams[5]
                                                    , aParams[12]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_STOR_PRD_KEY.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        #endregion


        #region 06 : 점포별 UI템플릿 Download / Insert
        public bool NHS_UI_TEMPLATE(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_UI_TEMPLATE.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_UI_TEMPLATE.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_UI_TEMPLATE.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_UI_TEMPLATE(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_UI_TEMPLATE(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_UI_TEMPLATE ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                .AppendFormat("AND [STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);

                sDelQuery.Append("DELETE POSMST..NHS_UI_TEMPLATE ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                .AppendFormat("AND [STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_UI_TEMPLATE \n"
                                + "     SET [TEMPL_NM] = '{4}' \n"
                                + "         ,[LOGO_FILE_NAME] = '{5}' \n"
                                + "         ,[LOGO_FILE_FULLPATH] = '{6}' \n"
                                + "         ,[GNB_BACK_COLOR] = '{7}' \n"
                                + "         ,[MAIN_BACK_COLOR] = '{8}' \n"
                                + "         ,[MAIN_FONT_COLOR] = '{9}' \n"
                                + "         ,[HPC_GNB_BACK_COLOR] = '{10}' \n"
                                + "         ,[HPC_MAIN_BACK_COLOR] = '{11}' \n"
                                + "         ,[HPC_MAIN_FONT_COLOR] = '{12}' \n"
                                + "         ,[USE_YN] = '{13}' \n"
                                + "         ,[UPD_USER_ID] = '{16}' \n"
                                + "         ,[UPD_DATE] = GETDATE() \n"
                                + "     WHERE [CMP_CD] = '{0}' \n"
                                + "         AND [SALES_ORG_CD] = '{1}' \n"
                                + "         AND [STOR_CD] = '{2}' \n"
                                + "         AND [TEMPL_CD] = '{3}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_UI_TEMPLATE \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[STOR_CD] \n"
                                + "    ,[TEMPL_CD] \n"
                                + "    ,[TEMPL_NM] \n"
                                + "    ,[LOGO_FILE_NAME] \n"
                                + "    ,[LOGO_FILE_FULLPATH] \n"
                                + "    ,[GNB_BACK_COLOR] \n"
                                + "    ,[MAIN_BACK_COLOR] \n"
                                + "    ,[MAIN_FONT_COLOR] \n"
                                + "    ,[HPC_GNB_BACK_COLOR] \n"
                                + "    ,[HPC_MAIN_BACK_COLOR] \n"
                                + "    ,[HPC_MAIN_FONT_COLOR] \n"
                                + "    ,[USE_YN] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}',GETDATE()) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_UI_TEMPLATE.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        #endregion


        #region 07 : 캠페인 리소스 Download / Insert
        public bool NHS_CPI_CONTENTS(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_CPI_CONTENTS.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_CPI_CONTENTS.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_CPI_CONTENTS.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_CPI_CONTENTS(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_CPI_CONTENTS(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_CPI_CONTENTS ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);

                sDelQuery.Append("DELETE POSMST..NHS_CPI_CONTENTS ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_CPI_CONTENTS \n"
                                + "    SET [FILE_FULLPATH] = '{3}' \n"
                                + "         ,[FILE_NAME] = '{4}' \n"
                                + "         ,[UPD_USER_ID] = '{7}' \n"
                                + "         ,[UPD_DATE] = GETDATE() \n"
                                + "    WHERE [CMP_CD] = '{0}' \n"
                                + "		    AND [SALES_ORG_CD] = '{1}' \n"
                                + "    	    AND [CPI_CD] = '{2}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_CPI_CONTENTS \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[CPI_CD] \n"
                                + "    ,[FILE_FULLPATH] \n"
                                + "    ,[FILE_NAME] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}',GETDATE()) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

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

                    //기존
                    sQuery = string.Format(sInsQuery
                                                    , aParams[0]
                                                    , aParams[1]
                                                    , aParams[2]
                                                    , aParams[3]
                                                    , aParams[4]
                                                    , aParams[5]
                                                    , aParams[6]
                                                    , aParams[7]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_CPI_CONTENTS.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        #endregion


        #region 08 : 고객구매이력 Download / Insert (사용안함)
        /* 사용안함
        public bool NHS_CUST_BUY_HIST(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_CUST_BUY_HIST.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_CUST_BUY_HIST.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_CUST_BUY_HIST.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_CUST_BUY_HIST(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_CUST_BUY_HIST(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_CUST_BUY_HIST ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);

                sDelQuery.Append("DELETE POSMST..NHS_CUST_BUY_HIST ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_CUST_BUY_HIST \n"
                                + "    SET [ITEM_NM] = '{4}' \n"
                                + "         ,[BUY_DT] = '{5}' \n"
                                + "         ,[UPD_USER_ID] = '{6}' \n"
                                + "         ,[UPD_DATE] = GETDATE() \n"
                                + "    WHERE [CMP_CD] = '{0}' \n"
                                + "		    AND [SALES_ORG_CD] = '{1}' \n"
                                + "    	    AND [HPC_CUST_CD] = '{2}' \n"
                                + "    	    AND [ITEM_CD] = '{3}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_CUST_BUY_HIST \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[HPC_CUST_CD] \n"
                                + "    ,[ITEM_CD] \n"
                                + "    ,[ITEM_NM] \n"
                                + "    ,[BUY_DT] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}',GETDATE()) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

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

                    //기존
                    sQuery = string.Format(sInsQuery, aParams[0], aParams[1], aParams[2], aParams[3], aParams[4], aParams[5], aParams[6]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_CUST_BUY_HIST.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        */
        #endregion


        #region 09 : 제품 다국어 Download / Insert
        public bool NHS_LANG_MSG(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_LANG_MSG.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_LANG_MSG.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_LANG_MSG.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_LANG_MSG(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_LANG_MSG(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_LANG_MSG ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);

                sDelQuery.Append("DELETE POSMST..NHS_LANG_MSG ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_LANG_MSG \n"
                                + "    SET [LANG_MESSAGE] = '{5}' \n"
                                + "		    ,[UPD_USER_ID] = '{8}' \n"
                                + "		    ,[UPD_DATE] = GETDATE() \n"
                                + "    WHERE [CMP_CD] = '{0}' \n"
                                + "		    AND [SALES_ORG_CD] = '{1}' \n"
                                + "    	    AND [LANG_GBN_CD] = '{2}' \n"
                                + "    	    AND [LANG_CD] = '{3}' \n"
                                + "    	    AND [LANG_MESSAGE_CD] = '{4}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_LANG_MSG \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[LANG_GBN_CD] \n"
                                + "    ,[LANG_CD] \n"
                                + "    ,[LANG_MESSAGE_CD] \n"
                                + "    ,[LANG_MESSAGE] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}',GETDATE()) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_LANG_MSG.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        #endregion


        #region 10 : 화면구성 Download / Insert
        public bool NHS_LAYOUT(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_LAYOUT.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_LAYOUT.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_LAYOUT.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_LAYOUT(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_LAYOUT(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_LAYOUT ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);

                sDelQuery.Append("DELETE POSMST..NHS_LAYOUT ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_LAYOUT \n"
                                + "    SET [LAYOUT_NM] = '{3}' \n"
                                + "    	    ,[LAYOUT_RESOLUTION] = '{4}' \n"
                                + "		    ,[FRAME_COUNT] = '{5}' \n"
                                + "		    ,[RESOLUTION_HORIZEN] = '{6}' \n"
                                + "		    ,[RESOLUTION_VERTICAL] = '{7}' \n"
                                + "		    ,[UPD_USER_ID] = '{10}' \n"
                                + "		    ,[UPD_DATE] = GETDATE() \n"
                                + "    WHERE [CMP_CD] = '{0}' \n"
                                + "		    AND [SALES_ORG_CD] = '{1}' \n"
                                + "    	    AND [LAYOUT_CD] = '{2}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_LAYOUT \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[LAYOUT_CD] \n"
                                + "    ,[LAYOUT_NM] \n"
                                + "    ,[LAYOUT_RESOLUTION] \n"
                                + "    ,[FRAME_COUNT] \n"
                                + "    ,[RESOLUTION_HORIZEN] \n"
                                + "    ,[RESOLUTION_VERTICAL] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',GETDATE()) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_LAYOUT.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        #endregion


        
        #region 11 : 제품카테고리(대분류) Download / Insert (사용안함)
        /*
        public bool NHS_PRD_CATE_L(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_PRD_CATE_L.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_PRD_CATE_L.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_PRD_CATE_L.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_PRD_CATE_L(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_PRD_CATE_L(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_PRD_CATE_L ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);

                sDelQuery.Append("DELETE POSMST..NHS_PRD_CATE_L ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_PRD_CATE_L \n"
                                + "    SET [FILE_FULLPATH] = '{4}' \n"
                                + "		    ,[FILE_NAME] = '{5}' \n"
                                + "		    ,[DISPLAY_ORDER] = '{6}' \n"
                                + "		    ,[USE_YN] = '{7}' \n"
                                + "		    ,[HIDE_YN] = '{8}' \n"
                                + "		    ,[UPD_USER_ID] = '{11}' \n"
                                + "		    ,[UPD_DATE] = GETDATE() \n"
                                + "    WHERE [CMP_CD] = '{0}' \n"
                                + "		    AND [SALES_ORG_CD] = '{1}' \n"
                                + "    	    AND [PRD_CATE_CD] = '{2}' \n"
                                + "    	    AND [PRD_CATE_UP_CD] = '{3}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_PRD_CATE_L \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[PRD_CATE_CD] \n"
                                + "    ,[PRD_CATE_UP_CD] \n"
                                + "    ,[FILE_FULLPATH] \n"
                                + "    ,[FILE_NAME] \n"
                                + "    ,[DISPLAY_ORDER] \n"
                                + "    ,[USE_YN] \n"
                                + "    ,[HIDE_YN] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',GETDATE()) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_PRD_CATE_L.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        */
        #endregion


        #region 12 : 제품카테고리(중분류) Download / Insert (사용안함)
        /*
        public bool NHS_PRD_CATE_M(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_PRD_CATE_M.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_PRD_CATE_M.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_PRD_CATE_M.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_PRD_CATE_M(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_PRD_CATE_M(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_PRD_CATE_M ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);

                sDelQuery.Append("DELETE POSMST..NHS_PRD_CATE_M ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_PRD_CATE_M \n"
                                + "    SET [PRD_CATE_UP_CD] = '{3}' \n"
                                + "    	    ,[FILE_FULLPATH] = '{4}' \n"
                                + "		    ,[FILE_NAME] = '{5}' \n"
                                + "		    ,[DISPLAY_ORDER] = '{6}' \n"
                                + "		    ,[USE_YN] = '{7}' \n"
                                + "		    ,[HIDE_YN] = '{8}' \n"
                                + "		    ,[UPD_USER_ID] = '{11}' \n"
                                + "		    ,[UPD_DATE] = GETDATE() \n"
                                + "    WHERE [CMP_CD] = '{0}' \n"
                                + "		    AND [SALES_ORG_CD] = '{1}' \n"
                                + "    	    AND [LAYOUT_CD] = '{2}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_PRD_CATE_M \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[PRD_CATE_UP_CD] \n"
                                + "    ,[FILE_FULLPATH] \n"
                                + "    ,[FILE_NAME] \n"
                                + "    ,[DISPLAY_ORDER] \n"
                                + "    ,[USE_YN] \n"
                                + "    ,[HIDE_YN] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',GETDATE()) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_PRD_CATE_M.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        */
        #endregion


        #region 13 : 제품마스터 Download / Insert
        public bool NHS_PRD_MST(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_PRD_MST.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_PRD_MST.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_PRD_MST.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_PRD_MST(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_PRD_MST(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_PRD_MST ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);

                sDelQuery.Append("DELETE POSMST..NHS_PRD_MST ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_PRD_MST \n"
                                + "    SET [ITEM_NM] = '{4}' \n"
                                + "		    ,[FILE_FULLPATH] = '{5}' \n"
                                + "		    ,[FILE_NAME] = '{6}' \n"
                                + "		    ,[ORDER_TYPE] = '{7}' \n"
                                + "		    ,[RECOMMAND_YN] = '{8}' \n"
                                + "		    ,[NEW_YN] = '{9}' \n"
                                + "		    ,[DISPLAY_ORDER] = '{10}' \n"
                                + "		    ,[USE_YN] = '{11}' \n"
                                + "		    ,[PRESENT_YN] = '{12}' \n"
                                + "		    ,[BAR_CD] = '{13}' \n"
                                + "		    ,[UPD_USER_ID] = '{16}' \n"
                                + "		    ,[UPD_DATE] = GETDATE() \n"
                                + "    WHERE [CMP_CD] = '{0}' \n"
                                + "		    AND [SALES_ORG_CD] = '{1}' \n"
                                + "    	    AND [PRD_CATE_CD] = '{2}' \n"
                                + "    	    AND [ITEM_CD] = '{3}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_PRD_MST \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[PRD_CATE_CD] \n"
                                + "    ,[ITEM_CD] \n"
                                + "    ,[ITEM_NM] \n"
                                + "    ,[FILE_FULLPATH] \n"
                                + "    ,[FILE_NAME] \n"
                                + "    ,[ORDER_TYPE] \n"
                                + "    ,[RECOMMAND_YN] \n"
                                + "    ,[NEW_YN] \n"
                                + "    ,[DISPLAY_ORDER] \n"
                                + "    ,[USE_YN] \n"
                                + "    ,[PRESENT_YN] \n"
                                + "    ,[BAR_CD] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}',GETDATE()) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_PRD_MST.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        #endregion


        #region 14 : 부가옵션 Download / Insert
        public bool NHS_OPTN_MST(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_OPTN_MST.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_OPTN_MST.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_OPTN_MST.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_OPTN_MST(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_OPTN_MST(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_OPTN_MST ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);

                sDelQuery.Append("DELETE POSMST..NHS_OPTN_MST ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_OPTN_MST \n"
                                + "    SET [ITEM_OPTN_NM] = '{4}' \n"
                                + "		    ,[KIND] = '{5}' \n"
                                + "		    ,[OPTN_MTD] = '{6}' \n"
                                + "		    ,[KIND_CODE] = '{7}' \n"
                                + "		    ,[AMT] = '{8}' \n"
                                + "		    ,[MIN_AMT] = '{9}' \n"
                                + "		    ,[MAX_AMT] = '{10}' \n"
                                + "		    ,[UPD_USER_ID] = '{13}' \n"
                                + "		    ,[UPD_DATE] = GETDATE() \n"
                                + "    WHERE [CMP_CD] = '{0}' \n"
                                + "		    AND [SALES_ORG_CD] = '{1}' \n"
                                + "    	    AND [ITEM_OPTN_GRP_CD] = '{2}' \n"
                                + "    	    AND [ITEM_OPTN_CD] = '{3}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_OPTN_MST \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[ITEM_OPTN_GRP_CD] \n"
                                + "    ,[ITEM_OPTN_CD] \n"
                                + "    ,[ITEM_OPTN_NM] \n"
                                + "    ,[KIND] \n"
                                + "    ,[OPTN_MTD] \n"
                                + "    ,[KIND_CODE] \n"
                                + "    ,[AMT] \n"
                                + "    ,[MIN_AMT] \n"
                                + "    ,[MAX_AMT] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}',GETDATE()) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_OPTN_MST.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        #endregion


        #region 15 : 부가옵션그룹 Download / Insert
        public bool NHS_PRD_OPTN_GRP(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_PRD_OPTN_GRP.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_PRD_OPTN_GRP.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_PRD_OPTN_GRP.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_PRD_OPTN_GRP(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_PRD_OPTN_GRP(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_PRD_OPTN_GRP ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);

                sDelQuery.Append("DELETE POSMST..NHS_PRD_OPTN_GRP ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_PRD_OPTN_GRP \n"
                                + "    SET [OPTN_GRP_NM] = '{3}' \n"
                                + "         ,[FILE_FULLPATH] = '{4}' \n"
                                + "         ,[FILE_NAME] = '{5}' \n"
                                + "		     ,[SEL_MTD] = '{6}' \n"
                                + "		     ,[RQRD_YN] = '{7}' \n"
                                + "		     ,[USE_YN] = '{8}' \n"
                                + "		     ,[UPD_USER_ID] = '{11}' \n"
                                + "		     ,[UPD_DATE] = GETDATE() \n"
                                + "    WHERE [CMP_CD] = '{0}' \n"
                                + "		     AND [SALES_ORG_CD] = '{1}' \n"
                                + "    	     AND [ITEM_OPTN_GRP_CD] = '{2}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_PRD_OPTN_GRP \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[ITEM_OPTN_GRP_CD] \n"
                                + "    ,[OPTN_GRP_NM] \n"
                                + "    ,[FILE_FULLPATH] \n"
                                + "    ,[FILE_NAME] \n"
                                + "    ,[SEL_MTD] \n"
                                + "    ,[RQRD_YN] \n"
                                + "    ,[USE_YN] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',GETDATE()) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_PRD_OPTN_GRP.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        #endregion


        #region 16 : 제품별 부가옵션 Download / Insert
        public bool NHS_PRD_OPTN(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_PRD_OPTN.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_PRD_OPTN.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_PRD_OPTN.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_PRD_OPTN(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_PRD_OPTN(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_PRD_OPTN ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                .AppendFormat("AND [STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);

                sDelQuery.Append("DELETE POSMST..NHS_PRD_OPTN ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                .AppendFormat("AND [STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_PRD_OPTN \n"
                                + "    SET [DISPLAY_ORDER] = '{5}' \n"
                                + "		     ,[UPD_USER_ID] = '{8}' \n"
                                + "		     ,[UPD_DATE] = GETDATE() \n"
                                + "    WHERE [CMP_CD] = '{0}' \n"
                                + "		     AND [SALES_ORG_CD] = '{1}' \n"
                                + "    	     AND [STOR_CD] = '{2}' \n"
                                + "    	     AND [ITEM_CD] = '{3}' \n"
                                + "         AND [ITEM_OPTN_GRP_CD] = '{4}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_PRD_OPTN \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[STOR_CD] \n"
                                + "    ,[ITEM_CD] \n"
                                + "    ,[ITEM_OPTN_GRP_CD] \n"
                                + "    ,[DISPLAY_ORDER] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}',GETDATE()) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_PRD_OPTN.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        #endregion


        #region 17 : 제품카테고리 전체 Download / Insert
        public bool NHS_PRD_CATE(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_PRD_CATE.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_PRD_CATE.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_PRD_CATE.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_PRD_CATE(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_PRD_CATE(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_PRD_CATE ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);

                sDelQuery.Append("DELETE POSMST..NHS_PRD_CATE ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_PRD_CATE \n"
                                + "    SET [FILE_FULLPATH] = '{4}' \n"
                                + "		    ,[FILE_NAME] = '{5}' \n"
                                + "		    ,[DISPLAY_ORDER] = '{6}' \n"
                                + "		    ,[USE_YN] = '{7}' \n"
                                + "		    ,[HIDE_YN] = '{8}' \n"
                                + "		    ,[UPD_USER_ID] = '{11}' \n"
                                + "		    ,[UPD_DATE] = GETDATE() \n"
                                + "    WHERE [CMP_CD] = '{0}' \n"
                                + "		    AND [SALES_ORG_CD] = '{1}' \n"
                                + "    	    AND [PRD_CATE_CD] = '{2}' \n"
                                + "    	    AND [PRD_CATE_UP_CD] = '{3}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_PRD_CATE \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[PRD_CATE_CD] \n"
                                + "    ,[PRD_CATE_UP_CD] \n"
                                + "    ,[FILE_FULLPATH] \n"
                                + "    ,[FILE_NAME] \n"
                                + "    ,[DISPLAY_ORDER] \n"
                                + "    ,[USE_YN] \n"
                                + "    ,[HIDE_YN] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',GETDATE()) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_PRD_CATE.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        #endregion


        #region 18 : 점포별 제품 터치키 태그 전체 Download / Insert
        public bool NHS_STOR_PRD_TAG(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_STOR_PRD_TAG.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_STOR_PRD_TAG.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_STOR_PRD_TAG.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_STOR_PRD_TAG(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_STOR_PRD_TAG(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_STOR_PRD_TAG ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);

                sDelQuery.Append("DELETE POSMST..NHS_STOR_PRD_TAG ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_STOR_PRD_TAG \n"
                                + "    SET [FILE_NAME] = '{5}' \n"
                                + "		     ,[NEW_START_DT] = '{6}' \n"
                                + "		     ,[NEW_END_DT] = '{7}' \n"
                                + "		     ,[UPD_USER_ID] = '{10}' \n"
                                + "		     ,[UPD_DATE] = GETDATE() \n"
                                + "    WHERE [CMP_CD] = '{0}' \n"
                                + "		     AND [SALES_ORG_CD] = '{1}' \n"
                                + "    	     AND [STOR_CD] = '{2}' \n"
                                + "    	     AND [ITEM_CD] = '{3}' \n"
                                + "         AND [TAG_KIND] = '{4}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_STOR_PRD_TAG \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[STOR_CD] \n"
                                + "    ,[ITEM_CD] \n"
                                + "    ,[TAG_KIND] \n"
                                + "    ,[FILE_NAME] \n"
                                + "    ,[NEW_START_DT] \n"
                                + "    ,[NEW_END_DT] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',GETDATE()) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_STOR_PRD_TAG.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        #endregion

        #region 19 : 점포별 링크상품(BR) 전체 Download / Insert
        public bool NHS_LINK_ITEM(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_LINK_ITEM.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_LINK_ITEM.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_LINK_ITEM.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_LINK_ITEM(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_LINK_ITEM(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_LINK_ITEM ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd);

                sDelQuery.Append("DELETE POSMST..NHS_LINK_ITEM ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_LINK_ITEM \n"
                                + "    SET [LINK_NM] = '{3}' \n"
                                + "		     ,[UPCHARGE_YN] = '{5}' \n"
                                + "		     ,[UPCHARGE_ITEM_CD] = '{6}' \n"
                                + "		     ,[DISPLAY_ORDER] = '{7}' \n"
                                + "		     ,[USE_YN] = '{8}' \n"
                                + "		     ,[UPD_USER_ID] = '{11}' \n"
                                + "		     ,[UPD_DATE] = GETDATE() \n"
                                + "    WHERE [CMP_CD] = '{0}' \n"
                                + "		     AND [SALES_ORG_CD] = '{1}' \n"
                                + "    	     AND [LINK_CD] = '{2}' \n"
                                + "    	     AND [LINK_ITEM_CD] = '{4}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_LINK_ITEM \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[LINK_CD] \n"
                                + "    ,[LINK_NM] \n"
                                + "    ,[LINK_ITEM_CD] \n"
                                + "    ,[UPCHARGE_YN] \n"
                                + "    ,[UPCHARGE_ITEM_CD] \n"
                                + "    ,[DISPLAY_ORDER] \n"
                                + "    ,[USE_YN] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',GETDATE()) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_LINK_ITEM.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        #endregion

        #region 21 : 점포별 플레이버(BR) 전체 Download / Insert
        public bool NHS_STOR_FLAVOR(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_STOR_FLAVOR.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_STOR_FLAVOR.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_STOR_FLAVOR.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_STOR_FLAVOR(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_STOR_FLAVOR(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_STOR_FLAVOR ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                .AppendFormat("AND [STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);

                sDelQuery.Append("DELETE POSMST..NHS_STOR_FLAVOR ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                .AppendFormat("AND [STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_STOR_FLAVOR \n"
                                + "    SET [ITEM_NM] = '{4}' \n"
                                + "		     ,[DISPLAY_ORDER] = '{5}' \n"
                                + "		     ,[USE_YN] = '{6}' \n"
                                + "		     ,[DESC1] = '{7}' \n"
                                + "		     ,[DESC2] = '{8}' \n"
                                + "		     ,[INFO] = '{9}' \n"
                                + "		     ,[UPD_DATE] = GETDATE() \n"
                                + "		     ,[UPD_USER_ID] = '{12}' \n"
                                + "    WHERE [CMP_CD] = '{0}' \n"
                                + "		     AND [SALES_ORG_CD] = '{1}' \n"
                                + "    	     AND [STOR_CD] = '{2}' \n"
                                + "    	     AND [ITEM_CD] = '{3}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_STOR_FLAVOR \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[STOR_CD] \n"
                                + "    ,[ITEM_CD] \n"
                                + "    ,[ITEM_NM] \n"
                                + "    ,[DISPLAY_ORDER] \n"
                                + "    ,[USE_YN] \n"
                                + "    ,[DESC1] \n"
                                + "    ,[DESC2] \n"
                                + "    ,[INFO] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}',GETDATE()) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_STOR_FLAVOR.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        #endregion

        #region 22 : 점포별  결제수단 사용여부 전체 Download / Insert
        public bool NHS_FUNC_INFO(string sUpdateDT, string sBGUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd)
        {
            bool bReturn = false;
            string sIrtData = string.Empty;
            string sRecvData = string.Empty;
            Hashtable htReqData = null;
            StringBuilder sbRecvData = null;
            int iReturn = BaseCom.NG;

            try
            {
                htReqData = new Hashtable();

                htReqData = GetKioskReqData("0",
                                                        (MasterListManager.IsBackgroundMaster(KioskLists.NHS_FUNC_INFO.ID) ? sBGUpdateDT : sUpdateDT),
                                                        sStoreCd,
                                                        KioskLists.NHS_FUNC_INFO.DIV);

                m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_FUNC_INFO.ID + " Downloading ... ");
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Marquee);

                iReturn = m_cNetworkJson.MstIRTSendReceive(m_cPosStatus.Base.CmsSvrIp
                                                          , (int)m_cPosStatus.Base.CmsPort
                                                          , 60000
                                                          , ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd)
                                                          , htReqData
                                                          , ref sbRecvData);
                if (iReturn == BaseCom.OK)
                {
                    // 행구분자(#~)로 구분한 Row Data를 string array에 저장
                    string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries);
                    bReturn = UpdateNHS_FUNC_INFO(aRowDatas);
                }
                else
                {
                    return false;
                }

                return bReturn;
            }
            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;
            }
        }
        private bool UpdateNHS_FUNC_INFO(string[] aRowDatas)
        {
            string sQuery = string.Empty;
            string sInsQuery = string.Empty;
            StringBuilder sUpdQuery = new StringBuilder();
            StringBuilder sDelQuery = new StringBuilder();
            string[] aParams = null;

            try
            {
                sUpdQuery.Append("UPDATE POSMST..NHS_FUNC_INFO ")
                                .Append("SET [UPD_USER_ID] = 'DELETE' ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                .AppendFormat("AND [STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo);

                sDelQuery.Append("DELETE POSMST..NHS_FUNC_INFO ")
                                .AppendFormat("WHERE [CMP_CD] = '{0}' ", m_cPosStatus.Base.CmpCd)
                                .AppendFormat("AND [SALES_ORG_CD] = '{0}' ", m_cPosStatus.Base.BrandCd)
                                .AppendFormat("AND [STOR_CD] = '{0}' ", m_cPosStatus.Base.StoreNo)
                                        .Append("AND [UPD_USER_ID] = 'DELETE' ");

                sInsQuery = "UPDATE POSMST..NHS_FUNC_INFO \n"
                                + "    SET   [USE_YN] = '{10}' \n"
                                + "		     ,[UPD_DATE] = GETDATE() \n"
                                + "		     ,[UPD_USER_ID] = '{13}' \n"
                                + "    WHERE [CMP_CD] = '{0}' \n"
                                + "		     AND [SALES_ORG_CD] = '{1}' \n"
                                + "    	     AND [STOR_CD] = '{2}' \n"
                                + "    	     AND [STEP_GRP_CD] = '{3}' \n"
                                + "    	     AND [FUNC_GRP_CD] = '{4}' \n"
                                + "    	     AND [FUNC_CD] = '{5}' \n"
                                + "IF @@ROWCOUNT = 0 \n"
                                + "INSERT INTO POSMST..NHS_FUNC_INFO \n"
                                + "    ([CMP_CD] \n"
                                + "    ,[SALES_ORG_CD] \n"
                                + "    ,[STOR_CD] \n"
                                + "    ,[STEP_GRP_CD] \n"
                                + "    ,[FUNC_GRP_CD] \n"
                                + "    ,[FUNC_CD] \n"
                                + "    ,[STEP_GRP_NM] \n"
                                + "    ,[FUNC_GRP_NM] \n"
                                + "    ,[FUNC_NM] \n"
                                + "    ,[DISPLAY_ORDER] \n"
                                + "    ,[USE_YN] \n"
                                + "    ,[REG_USER_ID] \n"
                                + "    ,[REG_DATE]) \n"
                                + "    VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}',GETDATE()) \n";

                // 현재 Row Counting
                int nCnt = 0;
                // ProgressBar 진행상태가 변경이 되기 위한 Row Counting
                float nCntToStepUp = aRowDatas.Length / 100;
                // nCntToStepUp 값을 체크하기 위한 Counting
                float nCheckToStepUp = 0;

                // ProgressBar Style 변경
                m_cFormSaleOpen.SetProgressbarStyle(System.Windows.Forms.ProgressBarStyle.Continuous);

                //  2019-03-06 - 1997fx11 : 모든 DATA의 DELETE 플래그 SET
                m_cDatabaseSql.DBExecuteNonQuery(sUpdQuery.ToString());

                foreach (string sRowData in aRowDatas)
                {
                    nCnt++;
                    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]);

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

                    if (nCheckToStepUp >= nCntToStepUp)
                    {
                        m_cFormSaleOpen.ProgressProgressBar(nCntToStepUp >= 1 ? 1 : 100 / aRowDatas.Length);
                        nCheckToStepUp = 0;
                    }
                    else
                    {
                        if (nCnt % nRefreshCnt == 0 || nCnt == aRowDatas.Length)
                        {
                            m_cFormSaleOpen.SetLabelMsg("(" + nCurMstCnt.ToString() + "/" + nTotalMstCnt.ToString() + ")" + KioskLists.NHS_FUNC_INFO.ID + " Inserting ... (" + Convert.ToString(nCnt) + "/" + aRowDatas.Length + ")");
                        }
                        nCheckToStepUp++;
                    }
                }

                //  2019-03-06 - 1997fx11 : DELETE 플래그 SET DATA 삭제
                m_cDatabaseSql.DBExecuteNonQuery(sDelQuery.ToString());

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

                return false;
            }
        }
        #endregion
    }
}
