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

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

/*-----------------------------------------------------------------------------------------------*/
// 설      명 : 테스트 모드(스테프 시험모드) 처리
// 작  성  자 : 
// 변경  이력 : 
/*-----------------------------------------------------------------------------------------------*/
namespace Cosmos.Service
{
    public class TestMode : IDataServiceUs
    {
        private SManager sManager = new SManager();                                 // 이 객체를 통해 업무 Service 호출
        private StateServer StateObject = (StateServer)StateServer.GetInstance();   // StateObject : StateServer Object (객체)
        private PosStatus m_cPosStatus = new PosStatus();                           // 기본정보 참조
        private TranStatus m_cTrnStatus = new TranStatus();                         // 거래정보 참조

        private IDatabaseSQL m_cSqlDbService = null;                                // 데이터베이스 관리
        private IDataProcessUs m_cDataService = null;                               // 거래데이터 합계금액 계산 및 관리
        private IMasterUs m_cMstService = null;                                     // 마스터 인터페이스
        protected IDataCommonUs m_cDataCommon = null;       

        public TestMode()
        {
            m_cPosStatus = (PosStatus)StateObject.POS;
            m_cTrnStatus = (TranStatus)StateObject.TRAN;

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

        /// <summary>
        /// 테이터 조회
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public object GetData(string[] aParam)
        {
            string sQuery = "";
            
            try
            {
                string sTableName = aParam[0];          // 조회 테이블 명

                if (sTableName == PosMst.MST_TEST_MODE.TABLE_NAME)
                {
                    string sCashierNo = aParam[1];        // 캐셔번호

                    // 테스트모드 리스트 조회
                    sQuery += " SELECT A.*, ISNULL(B.TEST_PASS_YN,'0') TEST_PASS_YN ";
                    sQuery += " FROM POSMST..MST_TEST_MODE A ";
                    sQuery += " LEFT JOIN (SELECT DISTINCT CMP_CD, STOR_CD, TEST_ENTRY_ID, TEST_PASS_YN FROM POSLOG..TR_CASHIER_TEST ";
                    sQuery += "            WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' AND CASHIER_NO='" + sCashierNo + "' ";
                    sQuery += "               AND TEST_KIND='1' AND TEST_PASS_YN='1') B ON A.CMP_CD=B.CMP_CD AND A.STOR_CD=B.STOR_CD AND A.TEST_ENTRY_ID=B.TEST_ENTRY_ID ";
                    sQuery += " WHERE A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' ";
                    sQuery += "   AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' ";
                    sQuery += "   AND A.USE_YN  = '" + PosConst.MST_USE_YN.YES + "' ";
                    sQuery += " ORDER BY A.SEQ ";

                    //sQuery = "  SELECT A.*, ISNULL(B.TEST_PASS_YN,'0') TEST_PASS_YN, ISNULL(B.TEST_DATE,'') TEST_DATE, ISNULL(B.SEND_DIV,'0') SEND_DIV ";
                    //sQuery += " FROM POSMST..MST_TEST_MODE A ";
                    //sQuery += "   LEFT JOIN (SELECT * FROM POSLOG..TR_CASHIER_TEST WHERE CASHIER_NO='" + m_cPosStatus.Base.CashierNo + "') B ON A.CMP_CD=B.CMP_CD AND A.STOR_CD=B.STOR_CD AND A.TEST_ENTRY_ID=B.TEST_ENTRY_ID ";
                    //sQuery += " WHERE A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    //sQuery += "   AND A.USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                    //sQuery += " ORDER BY A.SEQ";
                }
                else if (sTableName == PosMst.MST_TEST_MODE_DTL_INFO.TABLE_NAME)
                {
                    string sTestEntryId = aParam[1];        // 시험항목 ID

                    // 테스트모드 상세정보
                    sQuery = "  SELECT * ";
                    sQuery += " FROM POSMST..MST_TEST_MODE_DTL_INFO  ";
                    sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "   AND TEST_ENTRY_ID  = '" + sTestEntryId + "'";
                    sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                    sQuery += " ORDER BY DTL_SEQ";
                }
                else if (sTableName == PosMst.MST_TEST_MODE_DTL_LOC.TABLE_NAME)
                {
                    string sTestEntryId = aParam[1];        // 시험항목 ID
                    string sDtlSeqNo = aParam[2];           // 시험항목 순번
                    string sPosScrnType = aParam[3];        // POS 화면 타입

                    // 테스트모드 상세위치
                    sQuery = "  SELECT * ";
                    sQuery += " FROM POSMST..MST_TEST_MODE_DTL_LOC  ";
                    sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                    sQuery += "   AND TEST_ENTRY_ID  = '" + sTestEntryId + "'";
                    sQuery += "   AND DTL_SEQ  = '" + sDtlSeqNo + "'";
                    sQuery += "   AND POS_SCRN_TYPE  = '" + sPosScrnType + "'";
                    sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                }
                else if (sTableName ==  Column.TR_CASHIER_TEST.ITEM)
                {
                    //시험결과 조회
                    string sTestKind = aParam[1];       // 시험종류
                    string sCashierNo = aParam[2];      // 캐셔번호
                    string sDateStart = aParam[3];      // 시작일자
                    string sDateEnd = aParam[4];        // 종료일자

                    if (sTestKind == "1")              
                    {
                        // 시험 결과 조회
                        sQuery += " SELECT B.*, A.TEST_ENTRY_NM ";
                        sQuery += " FROM POSMST..MST_TEST_MODE A ";
                        sQuery += " JOIN POSLOG..TR_CASHIER_TEST B ON A.CMP_CD=B.CMP_CD AND A.STOR_CD=B.STOR_CD AND A.TEST_ENTRY_ID=B.TEST_ENTRY_ID ";
                        sQuery += " WHERE A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'  ";
                        sQuery += "    AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'   ";
                        sQuery += "    AND A.USE_YN  = '" + PosConst.MST_USE_YN.YES + "'  ";
                        sQuery += "    AND B.TEST_KIND = '1' ";
                        sQuery += "    AND B.CASHIER_NO = '" + sCashierNo + "' ";
                        sQuery += "    AND B.SALE_DT BETWEEN '" + sDateStart + "' AND '" + sDateEnd + "'  ";
                        sQuery += " ORDER BY B.SALE_DT DESC, B.TEST_DATE DESC  ";
                    }
                    else
                    {
                        // 상품교육 결과 조히
                        sQuery += " SELECT * FROM POSLOG..TR_CASHIER_TEST ";
                        sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'  ";
                        sQuery += "    AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'   ";
                        sQuery += "    AND TEST_KIND IN ('2', '3') ";
                        sQuery += "    AND CASHIER_NO = '" + sCashierNo + "' ";
                        sQuery += "    AND SALE_DT BETWEEN '" + sDateStart + "' AND '" + sDateEnd + "'  ";
                        sQuery += " ORDER BY SALE_DT DESC, TEST_DATE DESC  ";
                    }
                }
                else if (sTableName == "TEST_MODE_PLU_ALL")
                {
                    // 전체상품 교육
                    sQuery += " SELECT A.* ";
                    sQuery += " FROM POSMST..MST_ITEM A ";
                    sQuery += " JOIN POSMST..MST_ITEM_KEY  B ON A.CMP_CD=B.CMP_CD AND A.STOR_CD=B.STOR_CD AND A.SUB_STOR_CD = B.SUB_STOR_CD AND A.ITEM_CD = B.ITEM_CD ";
                    sQuery += " WHERE A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' ";
                    sQuery += "    AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' ";
                    sQuery += "    AND A.USE_YN  = '" + PosConst.MST_USE_YN.YES + "' ";
                    //sQuery += "    AND (A.SALE_IMG_FILE_NM <> '' OR A.BTN_ITEM_IMG <> '') ";
                }
                else if (sTableName == "TEST_MODE_PLU_NEW")
                {
                    // 신상품 교육
                    sQuery += " SELECT A.* ";
                    sQuery += " FROM POSMST..MST_ITEM A ";
                    sQuery += " JOIN POSMST..MST_ITEM_KEY  B ON A.CMP_CD=B.CMP_CD AND A.STOR_CD=B.STOR_CD AND A.SUB_STOR_CD = B.SUB_STOR_CD AND A.ITEM_CD = B.ITEM_CD ";
                    sQuery += " WHERE A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' ";
                    sQuery += "    AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' ";
                    sQuery += "    AND A.USE_YN  = '" + PosConst.MST_USE_YN.YES + "' ";
                    //sQuery += "    AND (A.SALE_IMG_FILE_NM <> '' OR A.BTN_ITEM_IMG <> '') ";
                    sQuery += "    AND '" + m_cPosStatus.Base.SaleDate + "' BETWEEN NEW_ITEM_START_DT AND NEW_ITEM_FNSH_DT ";
                }

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

                if (sTableName == PosMst.MST_TEST_MODE.TABLE_NAME)
                {
                    if (dtDataInfo != null && dtDataInfo.Rows.Count > 0) SearchTestModePosIrt(dtDataInfo);    // 시험모드 조회
                }
                return dtDataInfo;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return null;
        }

        public string SetData(object oParam)
        {
            string sQuery = "";
            string sRet = UserCom.RST_ERR;
            //try
            //{
            //    DataTable dtTestMode = (DataTable)oParam;

            //    bool bRet = ResultTestModePosIrt(dtTestMode);     // 시험모드 결과 전송
                
            //    sQuery = " UPDATE POSLOG..TR_CASHIER_TEST SET ";
            //    sQuery += " TEST_PASS_YN = '{4}', ";
            //    sQuery += "  TEST_DATE = '{5}', ";
            //    sQuery += " SEND_DIV = '{6}', ";
            //    sQuery += " UPD_DATE = '{8}' ";
            //    sQuery += " WHERE CMP_CD = '{0}' AND STOR_CD = '{1}' ";
            //    sQuery += " AND CASHIER_NO = '{2}' ";
            //    sQuery += " AND TEST_ENTRY_ID  = '{3}'  ";
            //    sQuery += " IF @@ROWCOUNT = 0 ";
            //    sQuery += " INSERT INTO POSLOG..TR_CASHIER_TEST ";
            //    sQuery += " (CMP_CD, STOR_CD, CASHIER_NO, TEST_ENTRY_ID, TEST_PASS_YN, TEST_DATE, SEND_DIV, REG_DATE, UPD_DATE)VALUES ";
            //    sQuery += " ('{0}' ,'{1}','{2}', '{3}', '{4}','{5}','{6}','{7}', '{8}') ";

            //    string[] saQuery = new string[dtTestMode.Rows.Count];
            //    for(int i = 0; i < dtTestMode.Rows.Count; i++)
            //    {
            //        DataRow dr = dtTestMode.Rows[i];
            //        saQuery[i] = string.Format(sQuery, m_cPosStatus.Base.CmpCd, m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.CashierNo
            //                                         , CmUtil.GetDataRowStr(dr, PosMst.MST_TEST_MODE.DATA.TEST_ENTRY_ID)
            //                                         , CmUtil.GetDataRowStr(dr, PosMst.MST_TEST_MODE.DATA.TEST_PASS_YN)
            //                                         , CmUtil.GetDataRowStr(dr, PosMst.MST_TEST_MODE.DATA.TEST_DATE)
            //                                         , CmUtil.GetDataRowStr(dr, PosMst.MST_TEST_MODE.DATA.SEND_DIV)
            //                                         , DateTime.Now.ToString("yyyyMMddHHmmss"), DateTime.Now.ToString("yyyyMMddHHmmss"));   
            //    }
            //    if (m_cMstService.Update(saQuery) != UserCom.OK)
            //    {
            //        WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0173));        // 시험결과 저장을 실패 하였습니다
            //        return sRet;
            //    }

            //    if (bRet == true)
            //    {
            //        WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0176));
            //        sRet = UserCom.RST_OK;
            //    }
            //}
            //catch (Exception ex)
            //{
            //    WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
            //        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            //}
            return sRet;
        }

        /// <summary>
        /// 시험결과 저장(TEST_KIND, CASHIER_NO, TEST_ENTRY_ID, PASS_CNT, TEST_CNT, TEST_PASS_YN)
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public string Execute(string[] aParam)
        {
            string sQuery = "";
            string sRet = UserCom.RST_ERR;
            try
            {
                string sTestKind = aParam[0];
                string sCashierNo = aParam[1];
                string sTestEntryID = aParam[2];
                string sPassCnt = aParam[3];
                string sTestCnt = aParam[4];
                string sTestPassYn = aParam[5];

                sQuery += " INSERT INTO POSLOG..TR_CASHIER_TEST ";
                sQuery += " (CMP_CD, SALE_DT, STOR_CD, POS_NO, SEQ_NO, TEST_KIND, TEST_DATE, CASHIER_NO, TEST_ENTRY_ID, PASS_CNT, TEST_CNT, TEST_PASS_YN, SEND_YN, REG_DATE, UPD_DATE) ";
                sQuery += " SELECT '{0}' ,'{1}','{2}', '{3}', ISNULL(MAX(SEQ_NO),0)+1,'{4}','{5}','{6}','{7}', '{8}','{9}','{10}','{11}','{12}', '{13}'";
                sQuery += " FROM POSLOG..TR_CASHIER_TEST WHERE CMP_CD = '{0}' AND SALE_DT='{1}' AND STOR_CD = '{2}' AND POS_NO = '{3}' ";

                string[] saQuery = new string[1];
                saQuery[0] = string.Format(sQuery, m_cPosStatus.Base.CmpCd, m_cPosStatus.Base.SaleDate, m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.PosNo
                                                     , sTestKind, DateTime.Now.ToString("yyyyMMddHHmmss"), sCashierNo
                                                     , sTestEntryID, sPassCnt, sTestCnt, sTestPassYn, '0'
                                                     , DateTime.Now.ToString("yyyyMMddHHmmss"), DateTime.Now.ToString("yyyyMMddHHmmss"));

                if (m_cMstService.Update(saQuery) != UserCom.OK)
                {
                    WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0173));        // 시험결과 저장을 실패 하였습니다
                    return sRet;
                }
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return sRet;
        }

        /// <summary>
        /// 테스트모드 결과 조회 IRT 처리
        /// </summary>
        /// <param name="sInqType"></param>
        /// <param name="dtTestMode"></param>
        /// <returns></returns>
        public bool SearchTestModePosIrt(DataTable dtTestMode)
        {
            try
            {
                Hashtable htSendData = new Hashtable();
                Hashtable htRecvData = new Hashtable();

                int nTestModeCnt = 0;           // 항목건수
                string sTestModeData = "";      // 항목데이터
                foreach (DataRow dr in dtTestMode.Rows)
                {
                    //if (CmUtil.GetDataRowStr(dr, PosMst.MST_TEST_MODE.DATA.TEST_PASS_YN) == "1") continue;

                    nTestModeCnt++;
                    sTestModeData += CmUtil.RPadH(CmUtil.GetDataRowStr(dr, PosMst.MST_TEST_MODE.DATA.TEST_ENTRY_ID), 5) + "0";
                }
                if (nTestModeCnt == 0) return true;

                htSendData.Add(Column.IQ_TEST_MODE.DATA.INQ_TYPE, ItemConst.IRT_INQ_TYPE.TEST_MODE_SEARCH_REQ);
                htSendData.Add(Column.IQ_TEST_MODE.DATA.CMP_CD, m_cPosStatus.Base.CmpCd);
                htSendData.Add(Column.IQ_TEST_MODE.DATA.STOR_CD, m_cPosStatus.Base.StoreNo);
                htSendData.Add(Column.IQ_TEST_MODE.DATA.CASHIER_NO, m_cPosStatus.Base.CashierNo);
                htSendData.Add(Column.IQ_TEST_MODE.DATA.RES_CD, "00");
                htSendData.Add(Column.IQ_TEST_MODE.DATA.TEST_CNT, nTestModeCnt);
                htSendData.Add(Column.IQ_TEST_MODE.DATA.TEST_MODE_INFO, sTestModeData);

                string sRet = m_cDataCommon.ExecutePosIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.PayInqPort, 10000, htSendData, ref htRecvData);
                if (sRet != UserCom.RST_OK)
                {
                    // WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0174));        // 시험결과 서버 요청을 실패 하였습니다
                    return false;
                }

                if (htRecvData[Column.IQ_TEST_MODE.DATA.RES_CD].ToString() != "00")
                {
                    // WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0174));
                    return false;
                }

                // 시험결과 조회 결과 설정
                nTestModeCnt = CmUtil.IntParse(htRecvData[Column.IQ_TEST_MODE.DATA.TEST_CNT].ToString());
                sTestModeData = htRecvData[Column.IQ_TEST_MODE.DATA.TEST_MODE_INFO].ToString();
                for (int i = 0; i < nTestModeCnt; i++)
                {
                    string sEntryId = sTestModeData.Substring(i * 6, 5);        // 항목ID
                    string sPassYn = sTestModeData.Substring(i * 6 + 5, 1);     // 시험결과
                    
                    foreach (DataRow dr in dtTestMode.Rows)
                    {
                        if (sEntryId != CmUtil.GetDataRowStr(dr, PosMst.MST_TEST_MODE.DATA.TEST_ENTRY_ID)) continue;

                        dr[PosMst.MST_TEST_MODE.DATA.TEST_PASS_YN] = sPassYn;
                        break;
                    }
                }

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

        ///// <summary>
        ///// 테스트모드 시험결과 전송 IRT 처리
        ///// </summary>
        ///// <param name="sInqType"></param>
        ///// <param name="dtTestMode"></param>
        ///// <returns></returns>
        //public bool ResultTestModePosIrt(DataTable dtTestMode)
        //{
        //    try
        //    {
        //        Hashtable htSendData = new Hashtable();
        //        Hashtable htRecvData = new Hashtable();

        //        int nTestModeCnt = 0;           // 항목건수
        //        string sTestModeData = "";      // 항목데이터
        //        foreach (DataRow dr in dtTestMode.Rows)
        //        {
        //            if (CmUtil.GetDataRowStr(dr, PosMst.MST_TEST_MODE.DATA.TEST_PASS_YN) != "1") continue;
        //            if (CmUtil.GetDataRowStr(dr, PosMst.MST_TEST_MODE.DATA.SEND_DIV) == "1") continue;

        //            nTestModeCnt++;
        //            sTestModeData += CmUtil.RPadH(CmUtil.GetDataRowStr(dr, PosMst.MST_TEST_MODE.DATA.TEST_ENTRY_ID), 5) + "1";
        //        }

        //        if (nTestModeCnt == 0) return true;

        //        htSendData.Add(Column.IQ_TEST_MODE.DATA.INQ_TYPE, ItemConst.IRT_INQ_TYPE.TEST_MODE_RESULT_REQ);
        //        htSendData.Add(Column.IQ_TEST_MODE.DATA.CMP_CD, m_cPosStatus.Base.CmpCd);
        //        htSendData.Add(Column.IQ_TEST_MODE.DATA.STOR_CD, m_cPosStatus.Base.StoreNo);
        //        htSendData.Add(Column.IQ_TEST_MODE.DATA.CASHIER_NO, m_cPosStatus.Base.CashierNo);
        //        htSendData.Add(Column.IQ_TEST_MODE.DATA.RES_CD, "00");
        //        htSendData.Add(Column.IQ_TEST_MODE.DATA.TEST_CNT, nTestModeCnt);
        //        htSendData.Add(Column.IQ_TEST_MODE.DATA.TEST_MODE_INFO, sTestModeData);

        //        string sRet = m_cDataCommon.ExecutePosIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.PayInqPort, 10000, htSendData, ref htRecvData);
        //        if (sRet != UserCom.RST_OK)
        //        {
        //            WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0174));        // 시험결과 서버 요청을 실패 하였습니다
        //            return false;
        //        }

        //        if (htRecvData[Column.IQ_TEST_MODE.DATA.RES_CD].ToString() != "00")
        //        {
        //            WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0174));
        //            return false;
        //        }

        //        // 시험결과 전송 결과 설정
        //        nTestModeCnt = CmUtil.IntParse(htRecvData[Column.IQ_TEST_MODE.DATA.TEST_CNT].ToString());
        //        sTestModeData = htRecvData[Column.IQ_TEST_MODE.DATA.TEST_MODE_INFO].ToString();
        //        for (int i = 0; i < nTestModeCnt; i++)
        //        {
        //            string sEntryId = sTestModeData.Substring(i * 6, 5);

        //            foreach (DataRow dr in dtTestMode.Rows)
        //            {
        //                if (sEntryId != CmUtil.GetDataRowStr(dr, PosMst.MST_TEST_MODE.DATA.TEST_ENTRY_ID)) continue;

        //                dr[PosMst.MST_TEST_MODE.DATA.SEND_DIV] = "1";
        //                break;
        //            }
        //        }
                
        //        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;
        //}

        
    }
}
