using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Data; using System.Data.SqlClient; using Cosmos.Common; using Cosmos.BaseFrame; using Cosmos.UserFrame; using Cosmos.CommonManager; using Cosmos.ServiceProvider; using Newtonsoft.Json; using System.Xml; using System.IO; using System.Net; using System.Runtime.InteropServices; /*-----------------------------------------------------------------------------------------------*/ // 설 명 : 통신서버로 // 01:Tran/02:저널/03:서명/04:전자영수증/05:현금IC/06:기타서명 데이터 100ms간격, 전송 // 실패시 에러카운트증가시켜 1회 이상부터 5초로 조정. // 실패시 에러카운트증가시켜 5회 이상부터 1분으로 조정. // 성공시 에러카운트감소시켜 0으로 초기화 되면 다시 100ms로 조정. // 전송할 데이터 없을 시 5초로 조정. // 작 성 자 : // 변경 이력 : /*-----------------------------------------------------------------------------------------------*/ namespace Cosmos.Network { public class NetworkTranSend : INetworkTranSend { #region 한국공항공사 I/F 관련 MKACCLT.dll 함수정의 ///// ///// 프로그램 시작 ///// ///// //[DllImport("MKACCLT.dll")] //public static extern int MKACCLTOpen(); ///// ///// 매출저장 ///// ///// 매출구분(4) ///// 계약구분(10) ///// 영업일자(8) ///// 매장정보(10) ///// POS번호(10) ///// 영수증번호(30) ///// 매출정보(Variable) ///// 아이템건수(4) ///// 아이템정보(Variable) ///// //[DllImport("MKACCLT.dll")] //public static extern int ReceiptDB(string pSendType, string pConNo, string pSaleDt, string pStorCd, string pPosNo, string pReceiptNo, string sTranHeader, int iItemCount, string sTranItem); ///// ///// 프로그램 종료 ///// ///// //[DllImport("MKACCLT.dll")] //public static extern int MKACCLTClose(); #endregion 한국공항공사 I/F 관련 MKACCLT.dll 함수정의 #region 클래스 변수 선언 /// /// Sending Socket (전송 소켓) /// private static TcpSocket m_sendSocket = null; /// /// IP /// private string m_ServerIp = ""; /// /// Port /// private int m_ServerPort = 0; /// /// /// private int m_ServerTimeout = 1; protected SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출 /// /// StateServer Object (StateServer 객체) /// private StateServer StateObject = (StateServer)StateServer.GetInstance(); /// /// POS Status Value (POS 상태값) /// private PosStatus m_cPosStatus = null; //#20180322 휴게소pos매출연동 start,phj private IDataCommonUs m_cDataCommon = null; //#20180322 휴게소pos매출연동 end,phj /// /// IRT 통신 /// private bool m_bIRTComplete = false; // 통신 완료 상태 Hashtable m_htRecvData = null; // 통신 수신 데이터 (JSON) /// /// Sending Socket (전송 소켓) /// private static TcpSocket m_IrtSocket = null; /// /// Thread Waiting Time (스레드 대기시간) /// private int m_ThreadSleepTerm = 100; /// /// Recv Timeout 정의 /// //private int m_RecvTimeout = 10000; /// /// Server Send Operation Yes/No (SVR Send 작동여부) /// private bool m_TranSVRSendRunning = true; /// /// Server SEND Thread (Server SEND 스레드) /// private Thread m_tSVRSend = null; /// /// 전송할 데이터 건수가 0 일 때, 0 설정 /// private int iSendDataCnt = 0; /// /// CommHeader 길이 /// private int CommHeadLen = 0; /// /// TranSend 응답 에러발생이 지속될 경우 ThreadTerm을 조정하기 위함 /// iErrorCount 가 5 이상이면 Thread Term을 1분으로 조정하며, 다시 0으로 돌아가면 1초로 조정 /// private int iErrorCount = 0; private int iOldErrorCount = 0; /// /// 기동하면서 읽어 온 통신서버 IP /// private string sCommSvrIp = string.Empty; /// /// MSSQL DB 관련 객체 /// private static SqlDB sqlDb = null; ///// ///// 고속도로 휴게소 POS 매출DATA 전송 URL ///// //private string sExTranUrl = string.Empty; ///// ///// 고속도로 휴게소 POS 정산DATA 전송 URL ///// //private string sExCalcUrl = string.Empty; #endregion #region 생성자 public NetworkTranSend() { m_cPosStatus = (PosStatus)StateObject.POS; CommHeadLen = ItemColumn.LenMessage(Column.COMM_HEADER.LEN); //#20180322 휴게소pos매출연동 end,phj CommHeadLen = ItemColumn.LenMessage(Column.COMM_HEADER.LEN); //m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON); //#20180322 휴게소pos매출연동 start,phj m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON); //#20180322 휴게소pos매출연동 end,phj } #endregion #region TranSend Thread Start/Stop /// /// Server Send Thread Start /// public void StartTranSend() { this.sCommSvrIp = m_cPosStatus.Base.CommSvrIp; sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, m_cPosStatus.Base.LocalDbCatalog, m_cPosStatus.Base.LocalDbUserID, m_cPosStatus.Base.LocalDbPassword); //SetExUrl(); // 한국공항공사 매출 I/F 프로그램 실행 //if (m_cPosStatus.Mst.ETC_IF_DIV == ItemConst.TranInterfaceOutside.IF_KOR_02) //{ // int iRet = MKACCLTOpen(); // if(iRet == 0) // { // 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 (함수명)) // "* 공항공사 MKACCLT.dll [ MKACCLT.dll Open Call. ]"); // } //} m_tSVRSend = new Thread(new ThreadStart(ThreadSVRSendRun)); m_TranSVRSendRunning = true; m_tSVRSend.Start(); } /// /// NetworkTranSend Thread Stop시 처리 /// public void StopTranSend() { try { UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.INFO_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 (함수명)) "NetworkTranSend Service Stop!!!"); // 통신서버 Send Terminated (SC Send 종료) m_TranSVRSendRunning = false; int count = 0; while (count < 10) { if (m_tSVRSend != null && m_tSVRSend.IsAlive) m_TranSVRSendRunning = false; else break; count++; Thread.Sleep(300); } if (count >= 10) { UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.INFO_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 (함수명)) "Force NetworkTranSend Service Stop!!!"); m_tSVRSend.Abort(); } // DB Close sqlDb.DBClose(); // 한국공항공사 매출 I/F 프로그램 종료 //if (m_cPosStatus.Mst.ETC_IF_DIV == ItemConst.TranInterfaceOutside.IF_KOR_02) //{ // int iRet = MKACCLTClose(); // if (iRet == 0) // { // 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 (함수명)) // "* 공항공사 MKACCLT.dll [ MKACCLT.dll Close Call. ]"); // } //} } 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); if (m_tSVRSend != null && m_tSVRSend.IsAlive) m_tSVRSend.Abort(); } } #endregion //#region 초기화 //private void SetExUrl() //{ // try // { // CmMessage PosConfig = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosConfig); // sExTranUrl = PosConfig.GetMessage("SERVER").GetMessageValue("ExTranUrl"); // sExCalcUrl = PosConfig.GetMessage("SERVER").GetMessageValue("ExCalcUrl"); // //if (string.IsNullOrWhiteSpace(sExTranUrl)) sExTranUrl = @"http://skhiway.com/SvrApp/SL000.java"; // //if (string.IsNullOrWhiteSpace(sExCalcUrl)) sExCalcUrl = @"http://skhiway.com/SvrApp/PS000.java"; // } // 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); // } //} //#endregion #region TranSend Main /// /// Server Send Run /// private void ThreadSVRSendRun() { UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.INFO_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 (함수명)) "ThreadSVRSendRun Run!!"); while(m_TranSVRSendRunning) { try { // 전송 데이터 건수 초기화 iSendDataCnt = 0; #region 01 - 선불 또는 후불메인 일 경우에만 전송 if (m_cPosStatus.Base.PosType == PosConst.POS_TYPE.PRE_PAYMENT || (m_cPosStatus.Base.PosType == PosConst.POS_TYPE.DEFERRED_PAYMENT && m_cPosStatus.Base.PosCommunicationType == PosConst.MAIN_POS_DIV.MAIN_POS)) { // 1 - TranLog Send (TranLog 전송) this.TranLogSendProcess(); // 2 - Journal Send (Journal 전송) this.JournalSendProcess(); // 3 - ApprovalLog Send (승인로그 전송) this.ApprovalLogSendProcess(); // 4 - ETC TRAN Send (ETC TRAN 전송) this.ETCTranLogSendProcess(); // 5 - ETC Journal Send (ETC Journal 전송) this.ETCJournalSendProcess(); // 6 - Cashier Test Log Send (계산원 시험Log 전송) this.CashierTestLogSendProcess(); // 외부업체 I/F 의 경우 실 OPEN 전 까지 주석 처리 함(20170213) // 고속도로 휴게소 입점 POS //if(m_cPosStatus.Base.ExPos == "1") if (m_cPosStatus.Mst.ETC_IF_DIV == ItemConst.TranInterfaceOutside.IF_KOR_01) { // 7 - 도로공사(고속도로 휴게소 입점POS) 매출 I/F XML 파일 생성 this.MakeTranToExProcess(); // 8 - 도로공사(고속도로 휴게소 입점POS) 매출 전송 //this.TranSendToExProcess(); } //#20180322 휴게소pos매출연동 start,phj else if (m_cPosStatus.Mst.ETC_IF_DIV == ItemConst.TranInterfaceOutside.IF_KOR_03) { // 17 - 휴게소pos매출연동 I/F JSON 파일 생성 this.MakeTranToRestArea(); } //#20180322 휴게소pos매출연동 end,phj //else if (m_cPosStatus.Mst.ETC_IF_DIV == ItemConst.TranInterfaceOutside.IF_KOR_02) //// 한국공항공사 관리 공항 입점 POS //{ // // 9 - 한국공항공사 매출 전송 // this.TranSendToKacProcess(); //} // 11. 점포점검 내역 전송 this.StoreCheckSendProcess(); // 12. 일일점검 내역 전송 this.StoreEquipCheckSendProcess(); // 13. Scale Log Send (Scale Log 전송) this.ScaleLogSendProcess(); // 14. 보류 로그 이력 (ETC_HOLD_LOG 전송) this.HoldLogSendProcess(); //#해피앱 추후적립 start, sskim // 15. 해피앱 추후적립 내역 전송(TR_HPAPP_AFTER_SAVE 전송) this.HpAppAfterSaveSendProcess(); //#해피앱 추후적립 end, sskim //#20171120 유통기한 바코드 인식률 start, phj // 16. 유통기한 바코드 인식률 전송 (TR_BAR_SUCESS_RATE 전송) this.BarcodeSucessRateSendProcess(); //#20171120 유통기한 바코드 인식률 end, phj //#15945 해피오더 자동주문 상세기능 start // 해피오더 자동주문 로그 전송(HPO_AUTOORDER_LOG) this.HappyOrderAutoOrderLogSendProcess(); //#15945 해피오더 자동주문 상세기능 end } #endregion #region 02 - 상시 전송 // 10. 긴급메세지 전송 this.EmgNoteSendProcess(); #endregion // 기본 : 100ms, 에러 5건 이상 : 5000ms, 에러 10회 이상 발생 시 : 60000ms, 데이터 없을 때 : 5000ms if(iErrorCount >= 10) { iErrorCount = 10; m_ThreadSleepTerm = 60000; } else if (iErrorCount == 5 || iSendDataCnt == 0) { m_ThreadSleepTerm = 5000; } else if(iErrorCount == 0) { m_ThreadSleepTerm = 100; } // Error Count 감소로 전환 시 기본 ThreadTerm으로 설정 if(iOldErrorCount > iErrorCount) { iErrorCount = 0; m_ThreadSleepTerm = 100; } iOldErrorCount = iErrorCount; int nNowSleepTerm = 0; while (nNowSleepTerm < m_ThreadSleepTerm) { if (m_TranSVRSendRunning == false) break; Thread.Sleep(100); nNowSleepTerm += 100; } } 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 (함수명)) "ThreadSVRSendRun Exception : " + ex.Message); break; } } UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.INFO_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 (함수명)) "ThreadSVRSendRun Exit!!"); } #endregion #region TRAN / 승인로그 / JOURNAL / ETC TRAN / ETC JOURNAL 전송 모듈 private string MakeCommHeader(int nMsgLen, string sMsgType, string sEncType, string sCmpCd, string sBrandCd, string sStorCd, string sSaleDt, string sPosNo, string sTradeNo, string sSysYmd, string sSysHms) { try { string[] aCommHead = new string[Column.COMM_HEADER.LEN.Length]; // 통신헤더의 전문 길이는 통신헤더길이 제외 // 박동철B, 조충연K - 2016.0818 //int nHeadLen = nMsgLen + LenMessage(Column.COMM_HEADER.LEN); int nHeadLen = nMsgLen; aCommHead[Column.COMM_HEADER.SEQ.MsgLen] = nHeadLen.ToString(); aCommHead[Column.COMM_HEADER.SEQ.MsgType] = sMsgType; aCommHead[Column.COMM_HEADER.SEQ.CmpCd] = sCmpCd; aCommHead[Column.COMM_HEADER.SEQ.BrandCd] = sBrandCd; aCommHead[Column.COMM_HEADER.SEQ.StoreCd] = sStorCd; aCommHead[Column.COMM_HEADER.SEQ.PosNo] = sPosNo; aCommHead[Column.COMM_HEADER.SEQ.TradeNo] = sTradeNo; aCommHead[Column.COMM_HEADER.SEQ.TranYmd] = sSaleDt; aCommHead[Column.COMM_HEADER.SEQ.SysYmd] = sSysYmd; aCommHead[Column.COMM_HEADER.SEQ.SysHms] = sSysHms; aCommHead[Column.COMM_HEADER.SEQ.EncType] = sEncType; aCommHead[Column.COMM_HEADER.SEQ.ErrCd] = "000"; return ItemColumn.MakeMessage(aCommHead, Column.COMM_HEADER.LEN, Column.COMM_HEADER.TYPE); } 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 ""; } private string SendProcess(string sSvrIp, int iPort, int iTimeout, string[] aKey, string sMsgType, Hashtable htSendData) { string sRet = UserCom.RST_ERR; try { // JSON 객체로 변환 string sJsonSendData = JsonConvert.SerializeObject(htSendData); string sJsonRecvData = string.Empty; string sCmpCd = aKey[0]; string sBrandCd = aKey[1]; string sStorCd = aKey[2]; string sSaleDt = aKey[3]; string sPosNo = aKey[4]; string sTradeNo = aKey[5]; string sSysYmd = DateTime.Now.ToString("yyyyMMdd"); string sSysHms = DateTime.Now.ToString("HHmmss"); if(sPosNo.Length < 2) { sPosNo = sPosNo.PadLeft(2, ' '); } // 암호화 데이터로 변환 string sEncryptedSendData = UserLog.UserAES.DynamicKeyEncrypt(sPosNo, sSysYmd + sSysHms, sJsonSendData); // JSON string 길이를 구하기 위해 byte 변환 Byte[] arTempData = Encoding.UTF8.GetBytes(sEncryptedSendData); string sCommHeader = this.MakeCommHeader(arTempData.Length, sMsgType, PosConst.ENCRYPT_MODE.ENC_ON, sCmpCd, sBrandCd, sStorCd, sSaleDt, sPosNo, sTradeNo, sSysYmd, sSysHms); //UserLog.WriteLogFile(UserCom.LOG_SOCK, // UserCom.INFO_LEVEL, // System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) // System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) // System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)), // CmUtil.RPadH("[SEND" + ":" + sSvrIp + ":" + iPort, 27) + "] " + sCommHeader + sJsonSendData); int iRet = DataSendReceive(sSvrIp, iPort, iTimeout, sCommHeader + sEncryptedSendData); if (iRet == UserCom.OK) { // 성공 시 Thread Term 조정 위한 Error 발생 카운트 감소. 0 이상일 경우만 감소. if (iErrorCount > 0) iErrorCount -= 1; sRet = UserCom.RST_OK; } else { // 실패 시 Thread Term 조정 위해 Error 발생 카운트 증가 iErrorCount += 1; UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.INFO_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 (함수명)) "Failed sending Tran/Log. [MsgType:" + sMsgType + "][CmpCd:" + sCmpCd + "][BrandCd:" + sBrandCd + "][StoreCd:" + sStorCd + "][SaleDt:" + sSaleDt + "][Pos:" + sPosNo + "][TradeNo:" + sTradeNo + "]"); } } 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 sRet; } private int DataSendReceive(string sIP, int iPort, int iTimeout, string sSendData) { int iRet = UserCom.NG; try { m_ServerIp = sIP; m_ServerPort = iPort; m_ServerTimeout = iTimeout; iRet = SendReceiveData(sSendData); } 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; } private int SendReceiveData(string sSendData) { int iRet = UserCom.NG; int nRecvLen = 0; string sRecvData = string.Empty; try { m_sendSocket = new TcpSocket(m_ServerIp, m_ServerPort); // Data Send & Receive nRecvLen = m_sendSocket.SendReceiveData(sSendData, ref sRecvData, m_ServerTimeout); //UserLog.WriteLogFile(UserCom.LOG_SOCK, // UserCom.INFO_LEVEL, // System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) // System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) // System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)), // CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sRecvData); if (sRecvData.Length == TcpSocket.COMM_HEAD_LEN) { if (sRecvData.Substring(56, 3).Equals("000")) { 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 (함수명)) "NetworkTranSend Error : Exception !!! " + ex.Message); } return iRet; } #endregion #region 점포점검 저장 데이터 전송 #region POS IRT 전문 송/수신 public string ExecutePosIrt(string sMsgType, string sSvrIP, int nSvrPort, int nTimeout, Hashtable htSendData, ref Hashtable htRecvData, bool bVisibleMode) { string sRet = UserCom.RST_ERR; Hashtable m_htRecvData = null; // 통신 수신 데이터 (JSON) try { string sCommHead = ItemColumn.MakeCommHeader(0, sMsgType); // 통신해더 생성 if (bVisibleMode == false) { // 팝업 화면 미표시 m_bIRTComplete = true; m_htRecvData = null; Thread thrSecondDisp = new Thread(() => sRet = OnNetworkIRT(sSvrIP, nSvrPort, nTimeout, sCommHead, htSendData)); thrSecondDisp.Start(); while (m_bIRTComplete == true) { Thread.Sleep(100); } htRecvData = m_htRecvData; } } catch (Exception ex) { WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); } return sRet; } #endregion #region POS IRT 전문 송수신 - 화면 미표시용 private string OnNetworkIRT(string sServerIp, int nServerPort, int nTimeOut, string sCommHead, Hashtable htSendData) { string sRet = UserCom.RST_ERR; int nRecvRet = -1; try { m_bIRTComplete = true; //if (m_cNetService == null) m_cNetJSONService = (INetworkJSON)sManager.InitServiceInstance(ServiceLists.AGENT_NETWORK.DLL, ServiceLists.AGENT_NETWORK.NETWORK_IRT); nRecvRet = IRTSendReceive(sServerIp, nServerPort, nTimeOut, sCommHead, htSendData, ref m_htRecvData); if (nRecvRet == BaseCom.OK) sRet = UserCom.RST_OK; } catch (Exception ex) { UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "Process Exception !!! " + ex.Message); } finally { m_bIRTComplete = false; } return sRet; } #endregion #region IRT Byte로의 Send/Recv (공통헤더의 전문길이 0으로 세팅해서 송신. 자동 계산) public int IRTSendReceive(string sIP, int iPort, int iTimeOut, string sCommData, Hashtable htData, ref Hashtable htRecvData) { int nStat = 9; string sReturn = string.Empty; string sRecvCommHeader = string.Empty; string sRecvData = string.Empty; m_ServerIp = sIP; m_ServerPort = iPort; m_ServerTimeout = iTimeOut; string sJsonSendData = ""; string sJsonReceiveData = ""; try { if (m_ServerIp != "" && m_ServerPort != 0) { if (htData != null) { sJsonSendData = JsonConvert.SerializeObject(htData); //sJsonSendData 암호화 처리 ... Byte[] sBytTempBuff = Encoding.UTF8.GetBytes(sJsonSendData); string sDataLen = string.Format("{0:000000}", sBytTempBuff.Length); sCommData = sDataLen + sCommData.Substring(TcpSocket.COMM_MSGLEN); UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) "NetworkJSON.IRTSendReceive()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sCommData + sJsonSendData); } //Send Receive nStat = SendReceiveData(sCommData + sJsonSendData, ref sJsonReceiveData); if (sJsonReceiveData != null && sJsonReceiveData != "") { sRecvCommHeader = sJsonReceiveData.Substring(0, TcpSocket.COMM_HEAD_LEN); sRecvData = sJsonReceiveData.Substring(TcpSocket.COMM_HEAD_LEN); //sJsonReceiveData 복호화 처리 ... htRecvData = JsonConvert.DeserializeObject(sRecvData); UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) "NetworkJSON.IRTSendReceive()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sRecvCommHeader + sRecvData); } } } catch (Exception e) { UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, "NetworkJSON.IRTSendReceive()", e.ToString()); } return nStat; } #endregion #region IRT전문의 Send/Receive private int SendReceiveData(string pSendData, ref string pRecvData, bool bIsDmbIf = false) { int nRecvLen = 0; int nStat = BaseCom.NG; string rRecvData = ""; try { m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); // Data Send & Receive System.Diagnostics.Debug.Print("요청:" + pSendData); nRecvLen = m_IrtSocket.SendReceiveData(pSendData, ref rRecvData, m_ServerTimeout, bIsDmbIf); System.Diagnostics.Debug.Print("응답:" + rRecvData); if (nRecvLen > 0) { pRecvData = rRecvData; nStat = BaseCom.OK; } else { pRecvData = ""; nStat = nRecvLen; } m_IrtSocket.Close(); } catch (Exception e) { if (m_IrtSocket != null) m_IrtSocket.Close(); UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, "NetworkJSON.SendReceiveData()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); } finally { } System.Threading.Thread.Sleep(100); return nStat; } #endregion #endregion //*----------------------------------------------------------------------------------------------------------*/ // TranLog / Journal / ApprovalLog / ETC Tran / ETC Journal 데이터 생성 //*----------------------------------------------------------------------------------------------------------*/ #region 01 - TranLog 전송 /// /// TranLog Sending Execution (TranLog 전송 실행) /// public void TranLogSendProcess() { string sendFlag = string.Empty; string sCMP_CD = string.Empty; string sSTOR_CD = string.Empty; string sSALE_DT = string.Empty; string sPOS_NO = string.Empty; string sTRADE_NO = string.Empty; string sREG_NO = string.Empty; string sTRADE_DIV = string.Empty; string sTRAIN_MODE_YN = string.Empty; string sTRADE_KINDPER = string.Empty; string sSYS_DT = string.Empty; string sPAY_TIME = string.Empty; string sORG_SALE_DT = string.Empty; string sORG_POS_NO = string.Empty; string sORG_TRADE_NO = string.Empty; string sQTY = string.Empty; string sTOTSALE_AMT = string.Empty; string sTOTDC_AMT = string.Empty; string sNET_SALE_AMT = string.Empty; DataTable dtReturn = null; try { // 전송할 TR 데이터 생성 string sTranLog = GetTranLog(ref dtReturn); if(sTranLog == "" || dtReturn.Rows.Count == 0) { return; } else { iSendDataCnt += 1; } sendFlag = "0"; // 0:미전송, 1:전송, 9:에러 DataRow dr = dtReturn.Rows[0]; sCMP_CD = CmUtil.GetDataRowStr(dr, "CMP_CD"); sSTOR_CD = CmUtil.GetDataRowStr(dr, "STOR_CD"); sSALE_DT = CmUtil.GetDataRowStr(dr, "SALE_DT"); sPOS_NO = CmUtil.GetDataRowStr(dr, "POS_NO"); sTRADE_NO = CmUtil.GetDataRowStr(dr, "TRADE_NO"); sREG_NO = CmUtil.GetDataRowStr(dr, "REG_NO"); sTRADE_DIV = CmUtil.GetDataRowStr(dr, "TRADE_DIV"); sTRAIN_MODE_YN = CmUtil.GetDataRowStr(dr, "TRAIN_MODE_YN"); sTRADE_KINDPER = CmUtil.GetDataRowStr(dr, "TRADE_KINDPER"); sSYS_DT = CmUtil.GetDataRowStr(dr, "SYS_DT"); sPAY_TIME = CmUtil.GetDataRowStr(dr, "PAY_TIME"); sORG_SALE_DT = CmUtil.GetDataRowStr(dr, "ORG_BILLDT"); sORG_POS_NO = CmUtil.GetDataRowStr(dr, "ORG_BILL_POSNO"); sORG_TRADE_NO = CmUtil.GetDataRowStr(dr, "ORG_BILL_NO"); sQTY = CmUtil.GetDataRowStr(dr, "QTY"); sTOTSALE_AMT = CmUtil.GetDataRowStr(dr, "TOTSALE_AMT"); sTOTDC_AMT = CmUtil.GetDataRowStr(dr, "TOTDC_AMT"); sNET_SALE_AMT = CmUtil.GetDataRowStr(dr, "NET_SALE_AMT"); string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, Convert.ToInt32(m_cPosStatus.Base.TranPort), 10000, new string[] { sCMP_CD, m_cPosStatus.Base.BrandCd, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO }, ItemConst.COMM_MSG_TYPE.TRAN, MakeTranLogJsonData(dr, sTranLog)); if(sReturn == UserCom.RST_OK) { sendFlag = "1"; // 정상 전송 // 전송 건수 증가 if( sSTOR_CD == m_cPosStatus.Base.StoreNo && sSALE_DT == m_cPosStatus.Base.SaleDate) { m_cPosStatus.Sale.TranSndCount++; } m_cPosStatus.Sale.OnLineStatus = "1"; } else { sendFlag = "9"; // 에러 m_cPosStatus.Sale.OnLineStatus = "0"; } } 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); sendFlag = "9"; } finally { // Flag Update TranLogFlgUpdate(sCMP_CD, sSTOR_CD, sPOS_NO, sSALE_DT, sTRADE_NO, sendFlag); } } private Hashtable MakeTranLogJsonData(DataRow drData, string sTranLog) { Hashtable htData = new Hashtable(); try { // 01 - 회사코드 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.CmpCd, CmUtil.GetDataRowStr(drData, "CMP_CD")); // 02 - 판매일자 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.SaleDt, CmUtil.GetDataRowStr(drData, "SALE_DT")); // 03 - 점포코드 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.StorCd, CmUtil.GetDataRowStr(drData, "STOR_CD")); // 04 - 포스번호 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.PosNo, CmUtil.GetDataRowStr(drData, "POS_NO")); // 05 - 거래번호 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.TradeNo, CmUtil.GetDataRowStr(drData, "TRADE_NO")); // 06 - 등록번호 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.RegNo, CmUtil.GetDataRowStr(drData, "REG_NO")); // 07 - 거래구분 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.TradeDiv, CmUtil.GetDataRowStr(drData, "TRADE_DIV")); // 08 - 연습모드 여부 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.TrainModeYn, CmUtil.GetDataRowStr(drData, "TRAIN_MODE_YN")); // 09 - 거래종별 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.TradeKindper, CmUtil.GetDataRowStr(drData, "TRADE_KINDPER")); // 10 - 시스템 일시 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.SysDt, CmUtil.GetDataRowStr(drData, "SYS_DT")); // 11 - 결제 시간 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.PayTime, CmUtil.GetDataRowStr(drData, "PAY_TIME")); // 12 - 원거래판매 일자 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.OrgSaleDt, CmUtil.GetDataRowStr(drData, "ORG_BILLDT")); // 13 - 원거래포스번호 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.OrgPosNo, CmUtil.GetDataRowStr(drData, "ORG_BILL_POSNO")); // 14 - 원거래 거래번호 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.OrgTradeNo, CmUtil.GetDataRowStr(drData, "ORG_BILL_NO")); // 15 - 수량 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.Qty, CmUtil.GetDataRowStr(drData, "QTY")); // 16 - 총매출금액 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.TotSaleAmt, CmUtil.GetDataRowStr(drData, "TOTSALE_AMT")); // 17 - 총할인금액 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.TotDcAmt, CmUtil.GetDataRowStr(drData, "TOTDC_AMT")); // 18 - 순매출금액 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.NetSaleAmt, CmUtil.GetDataRowStr(drData, "NET_SALE_AMT")); // 19 - 거래데이터 htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.DealData, sTranLog); } 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 (함수명)) "ThreadSVRSendRun Exception : " + ex.Message); } return htData; } /// /// 정상으로 송신한 경우 Flg추가용 쿼리 /// /// /// /// /// /// /// /// public int TranLogFlgUpdate(string pCompanyCd, string pStoreNo, string pPosNo, string pSaleDate, string pTradeNo, string pSendFlag) { int iRet = UserCom.NG; string sQuery = ""; try { if (pCompanyCd.Trim() == "") return iRet; if (pSaleDate.Trim() == "") return iRet; if (pStoreNo.Trim() == "") return iRet; if (pPosNo.Trim() == "") return iRet; if (pTradeNo.Trim() == "") return iRet; sQuery = "UPDATE POSLOG..TR_SALE_HEADER "; sQuery += " SET SEND_YN = '" + pSendFlag + "' "; sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; sQuery += " WHERE CMP_CD = '" + pCompanyCd + "' "; sQuery += " AND STOR_CD = '" + pStoreNo + "' "; sQuery += " AND SALE_DT = '" + pSaleDate + "' "; sQuery += " AND POS_NO = '" + pPosNo + "' "; sQuery += " AND TRADE_NO = '" + pTradeNo + "' "; iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); } 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; } /// /// TranLog 조회 /// /// 0:미전송, 1:전송, 9:에러 /// public string GetTranLog(ref DataTable dtReturn) { string sQuery = ""; string sCMP_CD = ""; string sSTOR_CD = ""; string sSALE_DT = ""; string sPOS_NO = ""; string sTRADE_NO = ""; string sTranData = ""; DataTable dtTempReturn = null; try { sQuery = " SELECT TOP 1 "; sQuery += " CMP_CD, SALE_DT, STOR_CD, POS_NO, TRADE_NO "; sQuery += " , '' AS REG_NO, TRADE_DIV, TRAIN_MODE_YN, TRADE_KINDPER, SYS_DT "; sQuery += " , PAY_TIME, ORG_BILLDT, ORG_BILL_POSNO, ORG_BILL_NO, QTY "; sQuery += " , TOTSALE_AMT, TOTDC_AMT, NET_SALE_AMT "; sQuery += " FROM POSLOG..TR_SALE_HEADER "; sQuery += " WHERE SEND_YN <> '1' "; //#20180131 인천공항 통합POS 사용유무가 사용이면 SEND_YN을 A로 설정 start //grayber@20180228 [BRKR] 인천공항 SEND_YN 매출전송유무 'A' 제거 start if (m_cPosStatus.Mst.CorpDiv.Equals(ItemConst.CORP_DIV.BR) != true) sQuery += " AND SEND_YN <> 'A' "; //grayber@20180228 [BRKR] 인천공항 SEND_YN 매출전송유무 'A' 제거 end //#20180131 인천공항 통합POS 사용유무가 사용이면 SEND_YN을 A로 설정 end sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; sQuery += " ORDER BY SEND_YN, SALE_DT, TRADE_NO "; if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn.Rows.Count == 1) { DataRow drTempReturn = dtTempReturn.Rows[0]; sCMP_CD = drTempReturn["CMP_CD"].ToString(); sSTOR_CD = drTempReturn["STOR_CD"].ToString(); sSALE_DT = drTempReturn["SALE_DT"].ToString(); sPOS_NO = drTempReturn["POS_NO"].ToString(); sTRADE_NO = drTempReturn["TRADE_NO"].ToString(); sTranData = GetTranHeader(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO) + GetTranDetail(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO) + GetTranPay(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO) //+ GetTranDC(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO) + GetTranCpiRslt(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO) + GetTranEtc(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO) //+ GetTranDpst(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO) + GetTranAdmt(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO) + GetTranGuestCnt(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO) + GetTranReservInfo(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO); } } dtReturn = dtTempReturn; } catch (Exception ex) { sTranData = ""; 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 sTranData; } private string GetTranHeader(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) { StringBuilder sbTranData = new StringBuilder(); string sQuery = ""; string sSQL = ""; DataTable dtTempReturn = null; try { sQuery += " SELECT '" + ItemConst.IRT_TRAN_TYPE.TranHeader + "' + '|' + '000000' + '|' + '0' + '|' + ISNULL(TRADE_DIV, '') + '|' + ISNULL(TRAIN_MODE_YN, '') + '|' + ISNULL(TRADE_KINDPER, '') + '|' + ISNULL(SYS_DT, '') + '|' + ISNULL(ORD_TIME, '') + '|' + "; sQuery += " ISNULL(PAY_TIME, '') + '|' + ISNULL(PIC_NO, '') + '|' + ISNULL(ORD_PIC_NO, '') + '|' + ISNULL(STOR_OWN_PART_TIME_DIV, '') + '|' + ISNULL(ORG_BILL_POSNO, '') + '|' + "; sQuery += " ISNULL(ORG_BILLDT, '') + '|' + ISNULL(ORG_BILL_NO, '') + '|' + ISNULL(RTN_RSN_CD, '') + '|' + ISNULL(RTN_RSN_MEMO, '') + '|' + ISNULL(NONSALES_RSN_CD, '') + '|' + "; sQuery += " ISNULL(RESERV_NO, '') + '|' + ISNULL(RESERV_DT, '') + '|' + ISNULL(CUST_NO, '') + '|' + ISNULL(ORD_DIV, '') + '|' + ISNULL(FLOOR_CD, '') + '|' + "; sQuery += " ISNULL(TBL_NO, '') + '|' + ISNULL(GUESTFLOOR, '') + '|' + ISNULL(FRGNR_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(CUSTCNT, 0)) + '|' + ISNULL(PAY_GNDR_DIV, '') + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(PAY_AGE, 0)) + '|' + CONVERT(VARCHAR, ISNULL(MAN_CMPNPSN_CNT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(WOMAN_CMPNPSN_CNT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(TOTSALE_AMT, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(TOTDC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(NET_SALE_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ITEM_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPI_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(COOP_CARD_DC_AMT, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(POINT_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPN_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(EMP_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SET_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ETC_AMT, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(EXCEP_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(TOT_VAT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_VAT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ETC_VAT, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(AF_ACCUM_POINT_AMT, 0)) + '|' + ISNULL(AF_ACCUM_POINT_INFO, '') + '|' + ISNULL(PPCARD_CUSTNM, '') + '|' + ISNULL(AMT_DUTCHPAY_YN, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_CNT, 0)) + '|'+ ISNULL(ORDER_NO, '') + '|' + "; //#20170828 해피포인트 적립 제외 버튼 추가 phj, start //기존 //sQuery += " ISNULL(SLACK_FIELD, '') + '|' + ISNULL(MID_CLOSE_SEQ, '') + '|' + ISNULL(PPCARD_CUSTID, '') + '|' + ISNULL(PACK_TRADE_DIV, '') + '|' + ISNULL(VIP_TY, '') "; //변경 sQuery += " ISNULL(SLACK_FIELD, '') + '|' + ISNULL(MID_CLOSE_SEQ, '') + '|' + ISNULL(PPCARD_CUSTID, '') + '|' + ISNULL(PACK_TRADE_DIV, '') + '|' + ISNULL(VIP_TY, '') + '|' + ISNULL(HP_EXCLUDE_YN, '0')"; //#20170828 해피포인트 적립 제외 버튼 추가 phj, end sQuery += " AS TR_HEADER "; sQuery += " FROM POSLOG..TR_SALE_HEADER "; sQuery += " WHERE CMP_CD = '{0}' "; sQuery += " AND SALE_DT = '{1}' "; sQuery += " AND STOR_CD = '{2}' "; sQuery += " AND POS_NO = '{3}' "; sQuery += " AND TRADE_NO = '{4}' "; sSQL = string.Format(sQuery , sCMP_CD , sSALE_DT , sSTOR_CD , sPOS_NO , sTRADE_NO); if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) { foreach (DataRow dr in dtTempReturn.Rows) { sbTranData.Append(dr[0].ToString()); } } } } 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 sbTranData.ToString(); } private string GetTranDetail(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) { StringBuilder sbTranData = new StringBuilder(); string sQuery = ""; string sSQL = ""; DataTable dtTempReturn = null; try { sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranDetail + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(ORD_TIME, '') + '|' + ISNULL(FLOOR_CD, '') + '|' + ISNULL(TBL_NO, '') + '|' + "; sQuery += " ISNULL(SUB_SHOP_CD, '') + '|' + ISNULL(ITEM_PLU_CD, '') + '|' + ISNULL(ITEM_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(SALE_QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SALE_PRC, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(SALE_AMT, 0)) + '|' + ISNULL(FLAVOUR_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(FLAVOUR_WEIGHT, 0)) + '|' + ISNULL(ITEM_INPUT_DIV, '') + '|' + ISNULL(ITEM_BAR_CD, '') + '|' + "; sQuery += " ISNULL(TAKE_IN_OUT_DIV, '') + '|' + ISNULL(ITEM_TAX_DIV, '') + '|' + ISNULL(TAX_AMT_INCLUDE_YN, '') + '|' + ISNULL(TAXRATE_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(APPLY_TAX_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_VAT, 0)) + '|' + "; sQuery += " ISNULL(SVC_TAXREATE_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(BILL_AMT, 0)) + '|' + ISNULL(NONSALES_RSN_CD, '') + '|' + ISNULL(DC_DIV, '') + '|' + ISNULL(DC_TYPE, '') + '|' + CONVERT(VARCHAR, ISNULL(DC_RATE, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ITEM_DC_AMT, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(SUM_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPI_DC_QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPI_DC_AMT, 0)) + '|' + ISNULL(COOP_CARD_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(COOP_CARD_DC_AMT, 0)) + '|' + ISNULL(POINT_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(POINT_DC_AMT, 0)) + '|' + "; sQuery += " ISNULL(CPN_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(CPN_DC_AMT, 0)) + '|' + ISNULL(EMP_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(EMP_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SET_DC_AMT, 0)) + '|' + ISNULL(ETC_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(ETC_DC_AMT, 0)) + '|' + "; sQuery += " ISNULL(EXCEP_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(EXCEP_DC_AMT, 0)) + '|' + ISNULL(PACK_DIV, '') + '|' + ISNULL(SET_MENU_CD, '') + '|' + ISNULL(SUBPRC_MENU_KEY_DIV, '') + '|' + "; //#20180903 해피오더 매출 생성 시 tr_sale_detail에 구분자 추가 start //기존 //sQuery += " ISNULL(CPI_PRESENT_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(SALE_GIFT_NO, '') + '|' + ISNULL(CPN_NO, '') + '|' + ISNULL(SLACK_FIELD, '') + '|' + ISNULL(DISPO_ITEM_DIV, '') + '|' + ISNULL(CANCEL_DIV, '0') + '|' + ISNULL(NOTAX_DIV, '') AS TR_DETAIL"; //변경 sQuery += " ISNULL(CPI_PRESENT_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(SALE_GIFT_NO, '') + '|' + ISNULL(CPN_NO, '') + '|' + ISNULL(SLACK_FIELD, '') + '|' + ISNULL(DISPO_ITEM_DIV, '') + '|' + ISNULL(CANCEL_DIV, '0') + '|' + ISNULL(NOTAX_DIV, '') + '|' + ISNULL(HPO_REG_YN, '') AS TR_DETAIL"; //#20180903 해피오더 매출 생성 시 tr_sale_detail에 구분자 추가 end sQuery += " FROM POSLOG..TR_SALE_DETAIL "; sQuery += " WHERE CMP_CD = '{0}' "; sQuery += " AND SALE_DT = '{1}' "; sQuery += " AND STOR_CD = '{2}' "; sQuery += " AND POS_NO = '{3}' "; sQuery += " AND TRADE_NO = '{4}' "; sSQL = string.Format(sQuery , sCMP_CD , sSALE_DT , sSTOR_CD , sPOS_NO , sTRADE_NO); if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) { foreach (DataRow dr in dtTempReturn.Rows) { sbTranData.Append(dr[0].ToString()); } } } } 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 sbTranData.ToString(); } private string GetTranPay(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) { StringBuilder sbTranData = new StringBuilder(); string sQuery = ""; string sSQL = ""; DataTable dtTempReturn = null; try { sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranPay + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(PAY_WAY_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(PAY_AMT, 0)) + '|' + ISNULL(PAY_DTL_CD_01, '') + '|' + ISNULL(PAY_DTL_CD_02, '') + '|' + "; sQuery += " ISNULL(PAY_DTL_CD_03, '') + '|' + ISNULL(PAY_DTL_CD_04, '') + '|' + ISNULL(PAY_DTL_CD_05, '') + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_02, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(QTY_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_05, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_02, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(AMT_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_05, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_06, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_07, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(AMT_ENTRY_08, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_09, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_10, 0)) + '|' + ISNULL(OCCUR_ENTRY_01, '') + '|' + ISNULL(OCCUR_ENTRY_02, '') + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_03, '') + '|' + ISNULL(OCCUR_ENTRY_04, '') + '|' + ISNULL(OCCUR_ENTRY_05, '') + '|' + ISNULL(OCCUR_ENTRY_06, '') + '|' + ISNULL(OCCUR_ENTRY_07, '') + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_08, '') + '|' + ISNULL(OCCUR_ENTRY_09, '') + '|' + ISNULL(OCCUR_ENTRY_10, '') + '|' + ISNULL(OCCUR_ENTRY_11, '') + '|' + ISNULL(OCCUR_ENTRY_12, '') + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_13, '') + '|' + ISNULL(OCCUR_ENTRY_14, '') + '|' + ISNULL(OCCUR_ENTRY_15, '') + '|' + ISNULL(OCCUR_ENTRY_16, '') + '|' + ISNULL(OCCUR_ENTRY_17, '') + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_18, '') + '|' + ISNULL(OCCUR_ENTRY_19, '') + '|' + ISNULL(OCCUR_ENTRY_20, '') + '|' + ISNULL(OCCUR_ENTRY_21, '') + '|' + ISNULL(OCCUR_ENTRY_22, '') + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_23, '') + '|' + ISNULL(OCCUR_ENTRY_24, '') + '|' + ISNULL(OCCUR_ENTRY_25, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(CANCEL_DIV, '') AS TR_PAY"; sQuery += " FROM POSLOG..TR_SALE_PAY "; sQuery += " WHERE CMP_CD = '{0}' "; sQuery += " AND SALE_DT = '{1}' "; sQuery += " AND STOR_CD = '{2}' "; sQuery += " AND POS_NO = '{3}' "; sQuery += " AND TRADE_NO = '{4}' "; sSQL = string.Format(sQuery , sCMP_CD , sSALE_DT , sSTOR_CD , sPOS_NO , sTRADE_NO); if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) { foreach (DataRow dr in dtTempReturn.Rows) { sbTranData.Append(dr[0].ToString()); } } } } 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 sbTranData.ToString(); } //private string GetTranDC(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) //{ // StringBuilder sbTranData = new StringBuilder(); // string sQuery = ""; // string sSQL = ""; // DataTable dtTempReturn = null; // try // { // sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranDC + "' + '|' + DC_WAY_CD + '|' + CONVERT(VARCHAR, DC_AMT) + '|' + DC_DTL_CD_01 + '|' + DC_DTL_CD_02 + '|' + "; // sQuery += " DC_DTL_CD_03 + '|' + DC_DTL_CD_04 + '|' + DC_DTL_CD_05 + '|' + CONVERT(VARCHAR, QTY_ENTRY_01) + '|' + CONVERT(VARCHAR, QTY_ENTRY_02) + '|' + "; // sQuery += " CONVERT(VARCHAR, QTY_ENTRY_03) + '|' + CONVERT(VARCHAR, QTY_ENTRY_04) + '|' + CONVERT(VARCHAR, QTY_ENTRY_05) + '|' + CONVERT(VARCHAR, AMT_ENTRY_01) + '|' + CONVERT(VARCHAR, AMT_ENTRY_02) + '|' + "; // sQuery += " CONVERT(VARCHAR, AMT_ENTRY_03) + '|' + CONVERT(VARCHAR, AMT_ENTRY_04) + '|' + CONVERT(VARCHAR, AMT_ENTRY_05) + '|' + CONVERT(VARCHAR, AMT_ENTRY_06) + '|' + CONVERT(VARCHAR, AMT_ENTRY_07) + '|' + "; // sQuery += " CONVERT(VARCHAR, AMT_ENTRY_08) + '|' + CONVERT(VARCHAR, AMT_ENTRY_09) + '|' + CONVERT(VARCHAR, AMT_ENTRY_10) + '|' + OCCUR_ENTRY_01 + '|' + OCCUR_ENTRY_02 + '|' + "; // sQuery += " OCCUR_ENTRY_03 + '|' + OCCUR_ENTRY_04 + '|' + OCCUR_ENTRY_05 + '|' + OCCUR_ENTRY_06 + '|' + OCCUR_ENTRY_07 + '|' + "; // sQuery += " OCCUR_ENTRY_08 + '|' + OCCUR_ENTRY_09 + '|' + OCCUR_ENTRY_10 + '|' + OCCUR_ENTRY_11 + '|' + OCCUR_ENTRY_12 + '|' + "; // sQuery += " OCCUR_ENTRY_13 + '|' + OCCUR_ENTRY_14 + '|' + OCCUR_ENTRY_15 + '|' + OCCUR_ENTRY_16 + '|' + OCCUR_ENTRY_17 + '|' + "; // sQuery += " OCCUR_ENTRY_18 + '|' + OCCUR_ENTRY_19 + '|' + OCCUR_ENTRY_20 + '|' + OCCUR_ENTRY_21 + '|' + OCCUR_ENTRY_22 + '|' + "; // sQuery += " OCCUR_ENTRY_23 + '|' + OCCUR_ENTRY_24 + '|' + OCCUR_ENTRY_25 + '|' + CONVERT(VARCHAR, BILLSPR_NO) + '|' + CANCEL_DIV AS TR_DC"; // sQuery += " FROM POSLOG..TR_SALE_DC "; // sQuery += " WHERE CMP_CD = '{0}' "; // sQuery += " AND STOR_CD = '{1}' "; // sQuery += " AND SALE_DT = '{2}' "; // sQuery += " AND POS_NO = '{3}' "; // sQuery += " AND TRADE_NO = '{4}' "; // sSQL = string.Format(sQuery // , sCMP_CD // , sSTOR_CD // , sSALE_DT // , sPOS_NO // , sTRADE_NO); // if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) // { // if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) // { // foreach (DataRow dr in dtTempReturn.Rows) // { // sbTranData.Append(dr[0].ToString()); // } // } // } // } // 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 sbTranData.ToString(); //} private string GetTranCpiRslt(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) { StringBuilder sbTranData = new StringBuilder(); string sQuery = ""; string sSQL = ""; DataTable dtTempReturn = null; try { sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranCpiRslt + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(CPI_TYPE, '') + '|' + CONVERT(VARCHAR, ISNULL(NMTAX_SEQ, 0)) + '|' + ISNULL(CPI_CD, '') + '|' + ISNULL(SUB_SHOP_CD, '') + '|' + "; sQuery += " ISNULL(ITEM_PLU_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(DC_QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(DC_SUM_AMT, 0)) + '|' + ISNULL(CPI_DIV, '') + '|' + "; sQuery += " ISNULL(PAYMNT_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(ACCUM_POINT, 0)) + '|' + ISNULL(LTTR_NMPLAT_NO, '') + '|' + ISNULL(CPI_CUST_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + "; sQuery += " ISNULL(SLACK_FIELD, '') + '|' + ISNULL(CANCEL_DIV, '') AS TR_CPI_RSLT "; sQuery += " FROM POSLOG..TR_SALE_CPI_RSLT "; sQuery += " WHERE CMP_CD = '{0}' "; sQuery += " AND SALE_DT = '{1}' "; sQuery += " AND STOR_CD = '{2}' "; sQuery += " AND POS_NO = '{3}' "; sQuery += " AND TRADE_NO = '{4}' "; sSQL = string.Format(sQuery , sCMP_CD , sSALE_DT , sSTOR_CD , sPOS_NO , sTRADE_NO); if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) { foreach (DataRow dr in dtTempReturn.Rows) { sbTranData.Append(dr[0].ToString()); } } } } 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 sbTranData.ToString(); } private string GetTranEtc(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) { StringBuilder sbTranData = new StringBuilder(); string sQuery = ""; string sSQL = ""; DataTable dtTempReturn = null; try { sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranEtc + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(ETC_WAY_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(ETC_AMT, 0)) + '|' + "; sQuery += " ISNULL(ETC_DTL_CD_01, '') + '|' + ISNULL(ETC_DTL_CD_02, '') + '|' + ISNULL(ETC_DTL_CD_03, '') + '|' + ISNULL(ETC_DTL_CD_04, '') + '|' + ISNULL(ETC_DTL_CD_05, '') + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(QTY_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_02, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_05, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(AMT_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_02, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_05, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(AMT_ENTRY_06, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_07, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_08, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_09, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_10, 0)) + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_01, '') + '|' + ISNULL(OCCUR_ENTRY_02, '') + '|' + ISNULL(OCCUR_ENTRY_03, '') + '|' + ISNULL(OCCUR_ENTRY_04, '') + '|' + ISNULL(OCCUR_ENTRY_05, '') + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_06, '') + '|' + ISNULL(OCCUR_ENTRY_07, '') + '|' + ISNULL(OCCUR_ENTRY_08, '') + '|' + ISNULL(OCCUR_ENTRY_09, '') + '|' + ISNULL(OCCUR_ENTRY_10, '') + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_11, '') + '|' + ISNULL(OCCUR_ENTRY_12, '') + '|' + ISNULL(OCCUR_ENTRY_13, '') + '|' + ISNULL(OCCUR_ENTRY_14, '') + '|' + ISNULL(OCCUR_ENTRY_15, '') + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_16, '') + '|' + ISNULL(OCCUR_ENTRY_17, '') + '|' + ISNULL(OCCUR_ENTRY_18, '') + '|' + ISNULL(OCCUR_ENTRY_19, '') + '|' + ISNULL(OCCUR_ENTRY_20, '') + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_21, '') + '|' + ISNULL(OCCUR_ENTRY_22, '') + '|' + ISNULL(OCCUR_ENTRY_23, '') + '|' + ISNULL(OCCUR_ENTRY_24, '') + '|' + ISNULL(OCCUR_ENTRY_25, '') + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(CANCEL_DIV, '') AS TR_ETC"; sQuery += " FROM POSLOG..TR_SALE_ETC "; sQuery += " WHERE CMP_CD = '{0}' "; sQuery += " AND SALE_DT = '{1}' "; sQuery += " AND STOR_CD = '{2}' "; sQuery += " AND POS_NO = '{3}' "; sQuery += " AND TRADE_NO = '{4}' "; sSQL = string.Format(sQuery , sCMP_CD , sSALE_DT , sSTOR_CD , sPOS_NO , sTRADE_NO); if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) { foreach (DataRow dr in dtTempReturn.Rows) { sbTranData.Append(dr[0].ToString()); } } } } 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 sbTranData.ToString(); } //private string GetTranDpst(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) //{ // StringBuilder sbTranData = new StringBuilder(); // string sQuery = ""; // string sSQL = ""; // DataTable dtTempReturn = null; // try // { // sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranDpst + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(DPST_WTHDR_TYPE, '') + '|' + ISNULL(DPST_WTHDR_CD, '') + '|' + ISNULL(DPST_WTHDR_ACC_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(DPST_WTHDR_QTY, 0)) + '|' + "; // sQuery += " CONVERT(VARCHAR, ISNULL(DPST_WTHDR_AMT, 0)) + '|' + ISNULL(DPST_WTHDR_NM, '') + '|' + ISNULL(CUST_NO, '') + '|' + ISNULL(STOR_PAY_TYPE, '') + '|' + ISNULL(ETC_REASON, '') + '|' + ISNULL(SLACK_FIELD_01, '') + '|' + ISNULL(SLACK_FIELD_02, '') + '|' + ISNULL(SLACK_FIELD_03, '') + '|' + "; // sQuery += " ISNULL(SLACK_FIELD_04, '') + '|' + SLACK_FIELD_05 AS TR_DPST "; // sQuery += " FROM POSLOG..TR_SALE_DPST_WTHDR "; // sQuery += " WHERE CMP_CD = '{0}' "; // sQuery += " AND SALE_DT = '{1}' "; // sQuery += " AND STOR_CD = '{2}' "; // sQuery += " AND POS_NO = '{3}' "; // sQuery += " AND TRADE_NO = '{4}' "; // sSQL = string.Format(sQuery // , sCMP_CD // , sSALE_DT // , sSTOR_CD // , sPOS_NO // , sTRADE_NO); // if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) // { // if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) // { // foreach (DataRow dr in dtTempReturn.Rows) // { // sbTranData.Append(dr[0].ToString()); // } // } // } // } // 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 sbTranData.ToString(); //} private string GetTranAdmt(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) { StringBuilder sbTranData = new StringBuilder(); string sQuery = ""; string sSQL = ""; DataTable dtTempReturn = null; try { sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranAdmt + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(ADMT_TYPE, '') + '|' + ISNULL(ADMT_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT, 0)) + '|' + "; sQuery += " ISNULL(SLACK_FIELD_01, '') + '|' + ISNULL(SLACK_FIELD_02, '') + '|' + ISNULL(SLACK_FIELD_03, '') + '|' + ISNULL(SLACK_FIELD_04, '') + '|' + "; sQuery += " ISNULL(SLACK_FIELD_05, '') AS TR_ADMT "; sQuery += " FROM POSLOG..TR_SALE_ADMT "; sQuery += " WHERE CMP_CD = '{0}' "; sQuery += " AND SALE_DT = '{1}' "; sQuery += " AND STOR_CD = '{2}' "; sQuery += " AND POS_NO = '{3}' "; sQuery += " AND TRADE_NO = '{4}' "; sSQL = string.Format(sQuery , sCMP_CD , sSALE_DT , sSTOR_CD , sPOS_NO , sTRADE_NO); if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) { foreach (DataRow dr in dtTempReturn.Rows) { sbTranData.Append(dr[0].ToString()); } } } } 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 sbTranData.ToString(); } private string GetTranGuestCnt(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) { StringBuilder sbTranData = new StringBuilder(); string sQuery = ""; string sSQL = ""; DataTable dtTempReturn = null; try { sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranGuestCnt + "' + '|' + '000000' + '|' + '0' + '|' + CONVERT(VARCHAR, ISNULL(MALE_10L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(MALE_20L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(MALE_30L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(MALE_40L, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(MALE_50L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(FMALE_10L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(FMALE_20L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(FMALE_30L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(FMALE_40L, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(FMALE_50L, 0)) AS TR_GUESTCNT "; sQuery += " FROM POSLOG..TR_SALE_GUESTCNT "; sQuery += " WHERE CMP_CD = '{0}' "; sQuery += " AND SALE_DT = '{1}' "; sQuery += " AND STOR_CD = '{2}' "; sQuery += " AND POS_NO = '{3}' "; sQuery += " AND TRADE_NO = '{4}' "; sSQL = string.Format(sQuery , sCMP_CD , sSALE_DT , sSTOR_CD , sPOS_NO , sTRADE_NO); if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) { foreach (DataRow dr in dtTempReturn.Rows) { sbTranData.Append(dr[0].ToString()); } } } } 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 sbTranData.ToString(); } private string GetTranReservInfo(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) { StringBuilder sbTranData = new StringBuilder(); string sQuery = ""; string sSQL = ""; DataTable dtTempReturn = null; try { sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranReservInfo + "' + '|' + '000000' + '|' + '0' + '|' + ISNULL(RESERV_NO, 0) + '|' +ISNULL(RESERV_REG_DT, 0) + '|' + ISNULL(RESERV_REG_TM, 0) + '|' + ISNULL(ONOFF_DIV, 0) + '|' + "; sQuery += " ISNULL(CUSTNM, 0) + '|' + ISNULL(CUST_PHN_NO, 0) + '|' + ISNULL(RESERV_DT, 0) + '|' + ISNULL(RESERV_TM, 0) + '|' + ISNULL(RESERV_MEMO, 0) AS TR_RESERVINFO "; sQuery += " FROM POSLOG..TR_RESERV_INFO "; sQuery += " WHERE CMP_CD = '{0}' "; sQuery += " AND SALE_DT = '{1}' "; sQuery += " AND STOR_CD = '{2}' "; sQuery += " AND POS_NO = '{3}' "; sQuery += " AND TRADE_NO = '{4}' "; sSQL = string.Format(sQuery , sCMP_CD , sSALE_DT , sSTOR_CD , sPOS_NO , sTRADE_NO); if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) { foreach (DataRow dr in dtTempReturn.Rows) { sbTranData.Append(dr[0].ToString()); } } } } 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 sbTranData.ToString(); } #endregion #region 02 - Journal 전송 /// /// Journal Sending Execution (Journal 전송 실행) /// public void JournalSendProcess() { DataTable dtReturn = null; Hashtable htData = null; string sSendFlag = string.Empty; string sCmpCd = string.Empty; string sStorCd = string.Empty; string sSaleDt = string.Empty; string sPosNo = string.Empty; string sTradeNo = string.Empty; try { // 전송할 Journal 데이터 생성 htData = GetJournalData(ref dtReturn); if(dtReturn == null || dtReturn.Rows.Count == 0) { return; } else { iSendDataCnt += 1; } sCmpCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "CMP_CD"); sStorCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STOR_CD"); sSaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SALE_DT"); sPosNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "POS_NO"); sTradeNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "TRADE_NO"); string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, Convert.ToInt32(m_cPosStatus.Base.JrnlPort), Convert.ToInt32(m_cPosStatus.Base.JrnlTimeout), new string[] { sCmpCd, m_cPosStatus.Base.BrandCd, sStorCd, sSaleDt, sPosNo, sTradeNo }, ItemConst.COMM_MSG_TYPE.JOURNAL, htData); if (sReturn == UserCom.RST_OK) { sSendFlag = "1"; // 정상 전송 // 전송 건수 증가 if (sStorCd == m_cPosStatus.Base.StoreNo && sSaleDt == m_cPosStatus.Base.SaleDate) { m_cPosStatus.Sale.JourSndCount++; } m_cPosStatus.Sale.OnLineStatus = "1"; } else { sSendFlag = "9"; // 에러 m_cPosStatus.Sale.OnLineStatus = "0"; } } 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); sSendFlag = "9"; } finally { // Flag Update JournalFlgUpdate(sCmpCd, sStorCd, sPosNo, sSaleDt, sTradeNo, sSendFlag); } } private int JournalFlgUpdate(string sCmpCd, string sStorCd, string sPosNo, string sSaleDt, string sTradeNo, string sSendFlag) { int iRet = UserCom.NG; string sQuery = string.Empty; try { if (sCmpCd.Trim() == "") return iRet; if (sStorCd.Trim() == "") return iRet; if (sPosNo.Trim() == "") return iRet; if (sSaleDt.Trim() == "") return iRet; if (sTradeNo.Trim() == "") return iRet; sQuery += " UPDATE POSLOG..TR_SALE_JOURNAL "; sQuery += " SET SEND_YN = '" + sSendFlag + "' "; sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; sQuery += " AND SALE_DT = '" + sSaleDt + "' "; sQuery += " AND STOR_CD = '" + sStorCd + "' "; sQuery += " AND POS_NO = '" + sPosNo + "' "; sQuery += " AND TRADE_NO = '" + sTradeNo + "' "; iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); } 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; } public Hashtable GetJournalData(ref DataTable dtReturn) { Hashtable htReturn = null; string sQuery = string.Empty; string sCmpCd = string.Empty; string sSaleDt = string.Empty; string sStorCd = string.Empty; string sPosNo = string.Empty; string sTradeNo = string.Empty; DataTable dtTempReturn = null; try { sQuery += " SELECT TOP 1 "; sQuery += " CMP_CD, SALE_DT, STOR_CD, POS_NO, TRADE_NO "; sQuery += " , '' AS REG_NO, TRADE_DIV, TRAIN_MODE_YN, TRADE_KINDPER, SYS_DT "; sQuery += " , SYS_TIME, PIC_NO, BILL_AMT, JOURNAL_DATA "; //grayber@20180212 해피포인트 전자영수증 I/F 개선 #13924 start sQuery += " , HPC_SAVE_APPR_DT, HPC_SAVE_APPR_NO, HPC_USE_APPR_DT, HPC_USE_APPR_NO "; //grayber@20180212 해피포인트 전자영수증 I/F 개선 #13924 end sQuery += " FROM POSLOG..TR_SALE_JOURNAL "; sQuery += " WHERE SEND_YN <> '1' "; //#20180131 인천공항 통합POS 사용유무가 사용이면 SEND_YN을 A로 설정 start //grayber@20180228 [BRKR] 인천공항 SEND_YN 매출전송유무 'A' 제거 start if(m_cPosStatus.Mst.CorpDiv.Equals(ItemConst.CORP_DIV.BR) != true) sQuery += " AND SEND_YN <> 'A' "; //grayber@20180228 [BRKR] 인천공항 SEND_YN 매출전송유무 'A' 제거 end //#20180131 인천공항 통합POS 사용유무가 사용이면 SEND_YN을 A로 설정 end sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; sQuery += " ORDER BY SEND_YN, SALE_DT, TRADE_NO "; if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if(dtTempReturn.Rows.Count == 1) { DataRow drTempReturn = dtTempReturn.Rows[0]; htReturn = MakeJournalJsonData(drTempReturn); } } dtReturn = dtTempReturn; } 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 htReturn; } private Hashtable MakeJournalJsonData(DataRow drData) { Hashtable htData = new Hashtable(); try { // 01 - 회사코드 htData.Add(Column.IQ_JOURNAL_REQ.DATA.CmpCd, CmUtil.GetDataRowStr(drData, "CMP_CD")); // 02 - 점포코드 htData.Add(Column.IQ_JOURNAL_REQ.DATA.StorCd, CmUtil.GetDataRowStr(drData, "STOR_CD")); // 03 - 판매일자 htData.Add(Column.IQ_JOURNAL_REQ.DATA.SaleDt, CmUtil.GetDataRowStr(drData, "SALE_DT")); // 04 - 포스번호 htData.Add(Column.IQ_JOURNAL_REQ.DATA.PosNo, CmUtil.GetDataRowStr(drData, "POS_NO")); // 05 - 거래번호 htData.Add(Column.IQ_JOURNAL_REQ.DATA.TradeNo, CmUtil.GetDataRowStr(drData, "TRADE_NO")); // 06 - 등록번호 htData.Add(Column.IQ_JOURNAL_REQ.DATA.RegNo, CmUtil.GetDataRowStr(drData, "REG_NO")); // 07 - 거래구분 htData.Add(Column.IQ_JOURNAL_REQ.DATA.TradeDiv, CmUtil.GetDataRowStr(drData, "TRADE_DIV")); // 08 - 연습모드 여부 htData.Add(Column.IQ_JOURNAL_REQ.DATA.TrainModeYn, CmUtil.GetDataRowStr(drData, "TRAIN_MODE_YN")); // 09 - 거래종별 htData.Add(Column.IQ_JOURNAL_REQ.DATA.TradeKindper, CmUtil.GetDataRowStr(drData, "TRADE_KINDPER")); // 10 - 시스템일자 htData.Add(Column.IQ_JOURNAL_REQ.DATA.SysDt, CmUtil.GetDataRowStr(drData, "SYS_DT")); // 11 - 시스템시간 htData.Add(Column.IQ_JOURNAL_REQ.DATA.SysTime, CmUtil.GetDataRowStr(drData, "SYS_TIME")); // 12 - 담당자번호 htData.Add(Column.IQ_JOURNAL_REQ.DATA.PicNo, CmUtil.GetDataRowStr(drData, "PIC_NO")); // 13 - 영수금액 htData.Add(Column.IQ_JOURNAL_REQ.DATA.BillAmt, CmUtil.GetDataRowStr(drData, "BILL_AMT")); // 14 - 저널데이터 htData.Add(Column.IQ_JOURNAL_REQ.DATA.JournalData, CmUtil.GetDataRowStr(drData, "JOURNAL_DATA")); //grayber@20180212 해피포인트 전자영수증 I/F 개선 #13924 start // 15 - 해피포인트 적립 승인일자 htData.Add(Column.IQ_JOURNAL_REQ.DATA.HpcSaveApprDt, CmUtil.GetDataRowStr(drData, "HPC_SAVE_APPR_DT")); // 16 - 해피포인트 적립 승인번호 htData.Add(Column.IQ_JOURNAL_REQ.DATA.HpcSaveApprNo, CmUtil.GetDataRowStr(drData, "HPC_SAVE_APPR_NO")); // 17 - 해피포인트 사용 승인일자 htData.Add(Column.IQ_JOURNAL_REQ.DATA.HpcUseApprDt, CmUtil.GetDataRowStr(drData, "HPC_USE_APPR_DT")); // 18 - 해피포인트 사용 승인번호 htData.Add(Column.IQ_JOURNAL_REQ.DATA.HpcUseApprNo, CmUtil.GetDataRowStr(drData, "HPC_USE_APPR_NO")); //grayber@20180212 해피포인트 전자영수증 I/F 개선 #13924 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 htData; } #endregion #region 03 - ApprovalLog 전송 public void ApprovalLogSendProcess() { DataTable dtReturn = null; Hashtable htData = null; string sSendFlag = string.Empty; string sCmpCd = string.Empty; string sStorCd = string.Empty; string sSaleDt = string.Empty; string sPosNo = string.Empty; string sTradeNo = string.Empty; string sSeq = string.Empty; try { // 전송할 승인로그 데이터 생성 htData = GetApprovalLog(ref dtReturn); if (dtReturn == null || dtReturn.Rows.Count == 0) { return; } else { iSendDataCnt += 1; } sCmpCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "CMP_CD"); sStorCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STOR_CD"); sSaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SALE_DT"); sPosNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "POS_NO"); sTradeNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "TRADE_NO"); sSeq = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SEQ"); string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, Convert.ToInt32(m_cPosStatus.Base.JrnlPort), Convert.ToInt32(m_cPosStatus.Base.JrnlTimeout), new string[] { sCmpCd, m_cPosStatus.Base.BrandCd, sStorCd, sSaleDt, sPosNo, sTradeNo }, ItemConst.COMM_MSG_TYPE.APPRLOG, htData); if (sReturn == UserCom.RST_OK) { sSendFlag = "1"; // 정상 전송 m_cPosStatus.Sale.OnLineStatus = "1"; } else { sSendFlag = "9"; // 에러 m_cPosStatus.Sale.OnLineStatus = "0"; } } 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); sSendFlag = "9"; } finally { // Flag Update ApprovalLogFlgUpdate(sCmpCd, sStorCd, sPosNo, sSaleDt, sTradeNo, sSeq, sSendFlag); } } private int ApprovalLogFlgUpdate(string sCmpCd, string sStorCd, string sPosNo, string sSaleDt, string sTradeNo, string sSeq, string sSendFlag) { int iRet = UserCom.NG; string sQuery = string.Empty; try { if (sCmpCd.Trim() == "") return iRet; if (sSaleDt.Trim() == "") return iRet; if (sStorCd.Trim() == "") return iRet; if (sPosNo.Trim() == "") return iRet; if (sTradeNo.Trim() == "") return iRet; if (sSeq.Trim() == "") return iRet; sQuery += " UPDATE POSLOG..TR_SALE_APPR_LOG "; sQuery += " SET SEND_YN = '" + sSendFlag + "' "; sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; sQuery += " AND SALE_DT = '" + sSaleDt + "' "; sQuery += " AND STOR_CD = '" + sStorCd + "' "; sQuery += " AND POS_NO = '" + sPosNo + "' "; sQuery += " AND TRADE_NO = '" + sTradeNo + "' "; sQuery += " AND SEQ = '" + sSeq + "' "; iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); } 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; } public Hashtable GetApprovalLog(ref DataTable dtReturn) { Hashtable htReturn = null; string sQuery = string.Empty; DataTable dtTempReturn = null; try { sQuery += " SELECT TOP 1 "; sQuery += " CMP_CD, STOR_CD, SALE_DT, POS_NO, TRADE_NO, SEQ, TRADE_DIV "; sQuery += " , PAY_WAY_CD, PAY_DTL_CD, INQ_TYPE, TRAN_TYPE, CARD_NO, RES_CD, RES_MSG, PAY_AMT "; sQuery += " , APPR_NO, APPR_DT, APPR_TIME, APPR_LOG, SEND_YN, REG_DATE, REG_ID, UPD_DATE "; sQuery += " , ISNULL(AMT_ENTRY_01, 0) AMT_ENTRY_01 "; sQuery += " , ISNULL(AMT_ENTRY_02, 0) AMT_ENTRY_02 "; sQuery += " , ISNULL(AMT_ENTRY_03, 0) AMT_ENTRY_03 "; sQuery += " , ISNULL(AMT_ENTRY_04, 0) AMT_ENTRY_04 "; sQuery += " , ISNULL(AMT_ENTRY_05, 0) AMT_ENTRY_05 "; sQuery += " , ISNULL(AMT_ENTRY_06, 0) AMT_ENTRY_06 "; sQuery += " , ISNULL(AMT_ENTRY_07, 0) AMT_ENTRY_07 "; sQuery += " , ISNULL(AMT_ENTRY_08, 0) AMT_ENTRY_08 "; sQuery += " , ISNULL(AMT_ENTRY_09, 0) AMT_ENTRY_09 "; sQuery += " , ISNULL(OCCUR_ENTRY_01, '') OCCUR_ENTRY_01 "; sQuery += " , ISNULL(OCCUR_ENTRY_02, '') OCCUR_ENTRY_02 "; sQuery += " , ISNULL(OCCUR_ENTRY_03, '') OCCUR_ENTRY_03 "; sQuery += " , ISNULL(OCCUR_ENTRY_04, '') OCCUR_ENTRY_04 "; sQuery += " , ISNULL(OCCUR_ENTRY_05, '') OCCUR_ENTRY_05 "; sQuery += " , ISNULL(OCCUR_ENTRY_06, '') OCCUR_ENTRY_06 "; sQuery += " , ISNULL(OCCUR_ENTRY_07, '') OCCUR_ENTRY_07 "; sQuery += " , ISNULL(OCCUR_ENTRY_08, '') OCCUR_ENTRY_08 "; sQuery += " , ISNULL(OCCUR_ENTRY_09, '') OCCUR_ENTRY_09 "; sQuery += " , ISNULL(USE_YN, '1') USE_YN "; sQuery += " FROM POSLOG..TR_SALE_APPR_LOG "; sQuery += " WHERE SEND_YN <> '1' "; sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; sQuery += " ORDER BY SEND_YN, SALE_DT, TRADE_NO, SEQ "; if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn.Rows.Count == 1) { DataRow drTempReturn = dtTempReturn.Rows[0]; htReturn = MakeApprovalLogJsonData(drTempReturn); } } dtReturn = dtTempReturn; } 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 htReturn; } private Hashtable MakeApprovalLogJsonData(DataRow drData) { Hashtable htData = new Hashtable(); try { // 01 - 회사코드 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.CmpCd, CmUtil.GetDataRowStr(drData, "CMP_CD")); // 02 - 점포코드 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.StorCd, CmUtil.GetDataRowStr(drData, "STOR_CD")); // 03 - 판매일자 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.SaleDt, CmUtil.GetDataRowStr(drData, "SALE_DT")); // 04 - 포스번호 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.PosNo, CmUtil.GetDataRowStr(drData, "POS_NO")); // 05 - 거래번호 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.TradeNo, CmUtil.GetDataRowStr(drData, "TRADE_NO")); // 06 - 순번 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.Seq, CmUtil.GetDataRowStr(drData, "SEQ")); // 07 - 판매구분 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.TradeDiv, CmUtil.GetDataRowStr(drData, "TRADE_DIV")); // 08 - 결제 구분 코드 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.PayWayCd, CmUtil.GetDataRowStr(drData, "PAY_WAY_CD")); // 09 - 결제 상세 코드 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.PayDtlCd, CmUtil.GetDataRowStr(drData, "PAY_DTL_CD")); // 10 - 승인구분 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.InqType, CmUtil.GetDataRowStr(drData, "INQ_TYPE")); // 11 - 요청구분 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.TranType, CmUtil.GetDataRowStr(drData, "TRAN_TYPE")); // 12 - 카드번호 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.CardNo, CmUtil.GetDataRowStr(drData, "CARD_NO")); // 13 - 응답상태값 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.ResCd, CmUtil.GetDataRowStr(drData, "RES_CD")); // 14 - 응답 메시지 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.ResMsg, CmUtil.GetDataRowStr(drData, "RES_MSG")); // 15 - 결제금액 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.PayAmt, CmUtil.GetDataRowStr(drData, "PAY_AMT")); // 16 - 승인번호 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.ApprNo, CmUtil.GetDataRowStr(drData, "APPR_NO")); // 17 - 승인일자 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.ApprDt, CmUtil.GetDataRowStr(drData, "APPR_DT")); // 18 - 승인시간 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.ApprTime, CmUtil.GetDataRowStr(drData, "APPR_TIME")); // 19 - 입력데이터 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.ApprLog, CmUtil.GetDataRowStr(drData, "APPR_LOG")); // 20 - 등록자ID htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.RegId, CmUtil.GetDataRowStr(drData, "REG_ID")); // 21 - 금액1 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.AMT_ENTRY_01, CmUtil.GetDataRowStr(drData, "AMT_ENTRY_01")); // 22 - 금액2 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.AMT_ENTRY_02, CmUtil.GetDataRowStr(drData, "AMT_ENTRY_02")); // 23 - 금액3 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.AMT_ENTRY_03, CmUtil.GetDataRowStr(drData, "AMT_ENTRY_03")); // 24 - 금액4 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.AMT_ENTRY_04, CmUtil.GetDataRowStr(drData, "AMT_ENTRY_04")); // 25 - 금액5 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.AMT_ENTRY_05, CmUtil.GetDataRowStr(drData, "AMT_ENTRY_05")); // 26 - 금액6 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.AMT_ENTRY_06, CmUtil.GetDataRowStr(drData, "AMT_ENTRY_06")); // 27 - 금액7 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.AMT_ENTRY_07, CmUtil.GetDataRowStr(drData, "AMT_ENTRY_07")); // 28 - 금액8 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.AMT_ENTRY_08, CmUtil.GetDataRowStr(drData, "AMT_ENTRY_08")); // 29 - 금액9 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.AMT_ENTRY_09, CmUtil.GetDataRowStr(drData, "AMT_ENTRY_09")); // 30 - 입력값1 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.OCCUR_ENTRY_01, CmUtil.GetDataRowStr(drData, "OCCUR_ENTRY_01")); // 31 - 입력값2 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.OCCUR_ENTRY_02, CmUtil.GetDataRowStr(drData, "OCCUR_ENTRY_02")); // 32 - 입력값3 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.OCCUR_ENTRY_03, CmUtil.GetDataRowStr(drData, "OCCUR_ENTRY_03")); // 33 - 입력값4 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.OCCUR_ENTRY_04, CmUtil.GetDataRowStr(drData, "OCCUR_ENTRY_04")); // 34 - 입력값5 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.OCCUR_ENTRY_05, CmUtil.GetDataRowStr(drData, "OCCUR_ENTRY_05")); // 35 - 입력값6 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.OCCUR_ENTRY_06, CmUtil.GetDataRowStr(drData, "OCCUR_ENTRY_06")); // 36 - 입력값7 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.OCCUR_ENTRY_07, CmUtil.GetDataRowStr(drData, "OCCUR_ENTRY_07")); // 37 - 입력값8 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.OCCUR_ENTRY_08, CmUtil.GetDataRowStr(drData, "OCCUR_ENTRY_08")); // 38 - 입력값9 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.OCCUR_ENTRY_09, CmUtil.GetDataRowStr(drData, "OCCUR_ENTRY_09")); // 39 - 사용여부 htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.USE_YN, CmUtil.GetDataRowStr(drData, "USE_YN")); } 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 htData; } #endregion #region 04 - ETC TRAN 전송 public void ETCTranLogSendProcess() { string sendFlag = string.Empty; string sCMP_CD = string.Empty; string sSTOR_CD = string.Empty; string sSALE_DT = string.Empty; string sPOS_NO = string.Empty; string sTRADE_NO = string.Empty; string sREG_NO = string.Empty; string sTRADE_DIV = string.Empty; string sTRAIN_MODE_YN = string.Empty; string sTRADE_KINDPER = string.Empty; string sSYS_DT = string.Empty; string sORG_SALE_DT = string.Empty; string sORG_POS_NO = string.Empty; string sORG_TRADE_NO = string.Empty; string sQTY = string.Empty; string sTOTSALE_AMT = string.Empty; string sTOTDC_AMT = string.Empty; string sNET_SALE_AMT = string.Empty; DataTable dtReturn = null; try { // 전송할 ETC TRAN 데이터 생성 string sEtcTranLog = GetEtcTranLog(ref dtReturn); if (sEtcTranLog == "" || dtReturn.Rows.Count == 0) { return; } else { iSendDataCnt += 1; } sendFlag = "0"; // 0:미전송, 1:전송, 9:에러 DataRow dr = dtReturn.Rows[0]; sCMP_CD = CmUtil.GetDataRowStr(dr, "CMP_CD"); sSTOR_CD = CmUtil.GetDataRowStr(dr, "STOR_CD"); sSALE_DT = CmUtil.GetDataRowStr(dr, "SALE_DT"); sPOS_NO = CmUtil.GetDataRowStr(dr, "POS_NO"); sREG_NO = CmUtil.GetDataRowStr(dr, "REG_NO"); sTRADE_NO = CmUtil.GetDataRowStr(dr, "TRADE_NO"); sTRADE_DIV = CmUtil.GetDataRowStr(dr, "TRADE_DIV"); sTRAIN_MODE_YN = CmUtil.GetDataRowStr(dr, "TRAIN_MODE_YN"); sTRADE_KINDPER = CmUtil.GetDataRowStr(dr, "TRADE_KINDPER"); sSYS_DT = CmUtil.GetDataRowStr(dr, "SYS_DT"); sORG_SALE_DT = CmUtil.GetDataRowStr(dr, "ORG_BILLDT"); sORG_POS_NO = CmUtil.GetDataRowStr(dr, "ORG_BILL_POSNO"); sORG_TRADE_NO = CmUtil.GetDataRowStr(dr, "ORG_BILL_NO"); sQTY = CmUtil.GetDataRowStr(dr, "QTY"); sTOTSALE_AMT = CmUtil.GetDataRowStr(dr, "TOTSALE_AMT"); sTOTDC_AMT = CmUtil.GetDataRowStr(dr, "TOTDC_AMT"); sNET_SALE_AMT = CmUtil.GetDataRowStr(dr, "NET_SALE_AMT"); string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, Convert.ToInt32(m_cPosStatus.Base.EtcTranPort), 8000, new string[] { sCMP_CD, m_cPosStatus.Base.BrandCd, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO }, ItemConst.COMM_MSG_TYPE.ETCTRAN, MakeTranLogJsonData(dr, sEtcTranLog)); if (sReturn == UserCom.RST_OK) { sendFlag = "1"; // 정상 전송 m_cPosStatus.Sale.OnLineStatus = "1"; } else { sendFlag = "9"; // 에러 m_cPosStatus.Sale.OnLineStatus = "0"; } } 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); sendFlag = "9"; } finally { // Flag Update ETCTranLogFlgUpdate(sCMP_CD, sSTOR_CD, sPOS_NO, sSALE_DT, sREG_NO, sendFlag); } } /// /// 정상으로 송신한 경우 Flg추가용 쿼리 /// /// /// /// /// /// /// /// public int ETCTranLogFlgUpdate(string pCompanyCd, string pStoreNo, string pPosNo, string pSaleDate, string pRegNo, string pSendFlag) { int iRet = UserCom.NG; ; string sQuery = ""; try { if (pCompanyCd.Trim() == "") return iRet; if (pStoreNo.Trim() == "") return iRet; if (pPosNo.Trim() == "") return iRet; if (pSaleDate.Trim() == "") return iRet; if (pRegNo.Trim() == "") return iRet; sQuery = "UPDATE POSLOG..ETC_SALE_HEADER "; sQuery += " SET SEND_YN = '" + pSendFlag + "' "; sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; sQuery += " WHERE CMP_CD = '" + pCompanyCd + "' "; sQuery += " AND SALE_DT = '" + pSaleDate + "' "; sQuery += " AND STOR_CD = '" + pStoreNo + "' "; sQuery += " AND POS_NO = '" + pPosNo + "' "; sQuery += " AND REG_NO = '" + pRegNo + "' "; iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); } 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; } /// /// ETC TranLog 조회 /// /// 0:미전송, 1:전송, 9:에러 /// public string GetEtcTranLog(ref DataTable dtReturn) { string sQuery = ""; string sCMP_CD = ""; string sSTOR_CD = ""; string sSALE_DT = ""; string sPOS_NO = ""; string sREG_NO = ""; string sTRADE_NO = ""; string sTranData = ""; DataTable dtTempReturn = null; try { sQuery += " SELECT TOP 1 "; sQuery += " CMP_CD, SALE_DT, STOR_CD, POS_NO, REG_NO "; sQuery += " , TRADE_NO, TRADE_DIV, TRAIN_MODE_YN, TRADE_KINDPER, SYS_DT "; sQuery += " , ORG_BILLDT, ORG_BILL_POSNO, ORG_BILL_NO, QTY, TOTSALE_AMT "; sQuery += " , TOTDC_AMT, NET_SALE_AMT "; sQuery += " FROM POSLOG..ETC_SALE_HEADER "; sQuery += " WHERE SEND_YN <> '1' "; sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; sQuery += " ORDER BY SEND_YN, SALE_DT, REG_NO "; if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn.Rows.Count == 1) { DataRow drTempReturn = dtTempReturn.Rows[0]; sCMP_CD = drTempReturn["CMP_CD"].ToString(); sSTOR_CD = drTempReturn["STOR_CD"].ToString(); sSALE_DT = drTempReturn["SALE_DT"].ToString(); sPOS_NO = drTempReturn["POS_NO"].ToString(); sREG_NO = drTempReturn["REG_NO"].ToString(); sTRADE_NO = drTempReturn["TRADE_NO"].ToString(); sTranData = GetEtcTranHeader(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sREG_NO) + GetEtcTranDetail(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sREG_NO) + GetEtcTranPay(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sREG_NO) + GetEtcTranEtc(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sREG_NO) + GetEtcTranDpst(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sREG_NO); } } dtReturn = dtTempReturn; } catch (Exception ex) { sTranData = ""; 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 sTranData; } private string GetEtcTranHeader(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sREG_NO) { StringBuilder sbTranData = new StringBuilder(); string sQuery = ""; string sSQL = ""; DataTable dtTempReturn = null; try { sQuery += " SELECT '" + ItemConst.IRT_TRAN_TYPE.EtcTranHeader + "' + '|' + '000000' + '|' + '0' + '|' + ISNULL(TRADE_DIV, '') + '|' + ISNULL(TRAIN_MODE_YN, '') + '|' + ISNULL(TRADE_KINDPER, '') + '|' + ISNULL(SYS_DT, '') + '|' + ISNULL(ORD_TIME, '') + '|' + "; sQuery += " ISNULL(PAY_TIME, '') + '|' + ISNULL(PIC_NO, '') + '|' + ISNULL(ORD_PIC_NO, '') + '|' + ISNULL(STOR_OWN_PART_TIME_DIV, '') + '|' + ISNULL(ORG_BILL_POSNO, '') + '|' + "; sQuery += " ISNULL(ORG_BILLDT, '') + '|' + ISNULL(ORG_BILL_NO, '') + '|' + ISNULL(RTN_RSN_CD, '') + '|' + ISNULL(RTN_RSN_MEMO, '') + '|' + ISNULL(NONSALES_RSN_CD, '') + '|' + "; sQuery += " ISNULL(RESERV_NO, '') + '|' + ISNULL(RESERV_DT, '') + '|' + ISNULL(CUST_NO, '') + '|' + ISNULL(ORD_DIV, '') + '|' + ISNULL(FLOOR_CD, '') + '|' + "; sQuery += " ISNULL(TBL_NO, '') + '|' + ISNULL(GUESTFLOOR, '') + '|' + ISNULL(FRGNR_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(CUSTCNT, 0)) + '|' + ISNULL(PAY_GNDR_DIV, '') + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(PAY_AGE, 0)) + '|' + CONVERT(VARCHAR, ISNULL(MAN_CMPNPSN_CNT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(WOMAN_CMPNPSN_CNT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(TOTSALE_AMT, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(TOTDC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(NET_SALE_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ITEM_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPI_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(COOP_CARD_DC_AMT, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(POINT_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPN_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(EMP_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SET_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ETC_AMT, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(EXCEP_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(TOT_VAT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_VAT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ETC_VAT, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(AF_ACCUM_POINT_AMT, 0)) + '|' + ISNULL(AF_ACCUM_POINT_INFO, '') + '|' + ISNULL(PPCARD_CUSTNM, '') + '|' + ISNULL(AMT_DUTCHPAY_YN, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_CNT, 0)) + '|'+ ISNULL(ORDER_NO, '') + '|' + "; //#20170828 해피포인트 적립 제외 버튼 추가 phj, start //기존 //sQuery += " ISNULL(SLACK_FIELD, '') + '|' + ISNULL(MID_CLOSE_SEQ, '') + '|' + ISNULL(PPCARD_CUSTID, '') + '|' + ISNULL(PACK_TRADE_DIV, '') + '|' + ISNULL(VIP_TY, '') "; //변경 sQuery += " ISNULL(SLACK_FIELD, '') + '|' + ISNULL(MID_CLOSE_SEQ, '') + '|' + ISNULL(PPCARD_CUSTID, '') + '|' + ISNULL(PACK_TRADE_DIV, '') + '|' + ISNULL(VIP_TY, '') + '|' + ISNULL(HP_EXCLUDE_YN, '0')"; //#20170828 해피포인트 적립 제외 버튼 추가 phj, end sQuery += " AS ETC_TR_HEADER "; sQuery += " FROM POSLOG..ETC_SALE_HEADER "; sQuery += " WHERE CMP_CD = '{0}' "; sQuery += " AND SALE_DT = '{1}' "; sQuery += " AND STOR_CD = '{2}' "; sQuery += " AND POS_NO = '{3}' "; sQuery += " AND REG_NO = '{4}' "; sSQL = string.Format(sQuery , sCMP_CD , sSALE_DT , sSTOR_CD , sPOS_NO , sREG_NO); if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) { foreach (DataRow dr in dtTempReturn.Rows) { sbTranData.Append(dr[0].ToString()); } } } } 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 sbTranData.ToString(); } private string GetEtcTranDetail(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sREG_NO) { StringBuilder sbTranData = new StringBuilder(); string sQuery = ""; string sSQL = ""; DataTable dtTempReturn = null; try { sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.EtcTranDetail + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(ORD_TIME, '') + '|' + ISNULL(FLOOR_CD, '') + '|' + ISNULL(TBL_NO, '') + '|' + "; sQuery += " ISNULL(SUB_SHOP_CD, '') + '|' + ISNULL(ITEM_PLU_CD, '') + '|' + ISNULL(ITEM_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(SALE_QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SALE_PRC, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(SALE_AMT, 0)) + '|' + ISNULL(FLAVOUR_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(FLAVOUR_WEIGHT, 0)) + '|' + ISNULL(ITEM_INPUT_DIV, '') + '|' + ISNULL(ITEM_BAR_CD, '') + '|' + "; sQuery += " ISNULL(TAKE_IN_OUT_DIV, '') + '|' + ISNULL(ITEM_TAX_DIV, '') + '|' + ISNULL(TAX_AMT_INCLUDE_YN, '') + '|' + ISNULL(TAXRATE_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(APPLY_TAX_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_VAT, 0)) + '|' + "; sQuery += " ISNULL(SVC_TAXREATE_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(BILL_AMT, 0)) + '|' + ISNULL(NONSALES_RSN_CD, '') + '|' + ISNULL(DC_DIV, '') + '|' + ISNULL(DC_TYPE, '') + '|' + CONVERT(VARCHAR, ISNULL(DC_RATE, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ITEM_DC_AMT, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(SUM_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPI_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPI_DC_AMT, 0)) + '|' + ISNULL(COOP_CARD_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(COOP_CARD_DC_AMT, 0)) + '|' + ISNULL(POINT_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(POINT_DC_AMT, 0)) + '|' + "; sQuery += " ISNULL(CPN_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(CPN_DC_AMT, 0)) + '|' + ISNULL(EMP_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(EMP_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SET_DC_AMT, 0)) + '|' + ISNULL(ETC_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(ETC_DC_AMT, 0)) + '|' + ISNULL(EXCEP_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(EXCEP_DC_AMT, 0)) + '|' + ISNULL(PACK_DIV, '') + '|' + "; sQuery += " ISNULL(SET_MENU_CD, '') + '|' + ISNULL(SUBPRC_MENU_KEY_DIV, '') + '|' + ISNULL(CPI_PRESENT_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(SALE_GIFT_NO, '') + '|' + ISNULL(CPN_NO, '') + '|' + ISNULL(SLACK_FIELD, '') + '|' + ISNULL(DISPO_ITEM_DIV, '') + '|' + ISNULL(CANCEL_DIV, '') + '|' + ISNULL(NOTAX_DIV, '0') AS ETC_TR_DETAIL"; sQuery += " FROM POSLOG..ETC_SALE_DETAIL "; sQuery += " WHERE CMP_CD = '{0}' "; sQuery += " AND SALE_DT = '{1}' "; sQuery += " AND STOR_CD = '{2}' "; sQuery += " AND POS_NO = '{3}' "; sQuery += " AND REG_NO = '{4}' "; sSQL = string.Format(sQuery , sCMP_CD , sSALE_DT , sSTOR_CD , sPOS_NO , sREG_NO); if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) { foreach (DataRow dr in dtTempReturn.Rows) { sbTranData.Append(dr[0].ToString()); } } } } 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 sbTranData.ToString(); } private string GetEtcTranPay(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sREG_NO) { StringBuilder sbTranData = new StringBuilder(); string sQuery = ""; string sSQL = ""; DataTable dtTempReturn = null; try { sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.EtcTranPay + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(PAY_WAY_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(PAY_AMT, 0)) + '|' + ISNULL(PAY_DTL_CD_01, '') + '|' + ISNULL(PAY_DTL_CD_02, '') + '|' + "; sQuery += " ISNULL(PAY_DTL_CD_03, '') + '|' + ISNULL(PAY_DTL_CD_04, '') + '|' + ISNULL(PAY_DTL_CD_05, '') + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_02, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(QTY_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_05, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_02, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(AMT_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_05, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_06, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_07, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(AMT_ENTRY_08, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_09, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_10, 0)) + '|' + ISNULL(OCCUR_ENTRY_01, '') + '|' + ISNULL(OCCUR_ENTRY_02, '') + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_03, '') + '|' + ISNULL(OCCUR_ENTRY_04, '') + '|' + ISNULL(OCCUR_ENTRY_05, '') + '|' + ISNULL(OCCUR_ENTRY_06, '') + '|' + ISNULL(OCCUR_ENTRY_07, '') + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_08, '') + '|' + ISNULL(OCCUR_ENTRY_09, '') + '|' + ISNULL(OCCUR_ENTRY_10, '') + '|' + ISNULL(OCCUR_ENTRY_11, '') + '|' + ISNULL(OCCUR_ENTRY_12, '') + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_13, '') + '|' + ISNULL(OCCUR_ENTRY_14, '') + '|' + ISNULL(OCCUR_ENTRY_15, '') + '|' + ISNULL(OCCUR_ENTRY_16, '') + '|' + ISNULL(OCCUR_ENTRY_17, '') + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_18, '') + '|' + ISNULL(OCCUR_ENTRY_19, '') + '|' + ISNULL(OCCUR_ENTRY_20, '') + '|' + ISNULL(OCCUR_ENTRY_21, '') + '|' + ISNULL(OCCUR_ENTRY_22, '') + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_23, '') + '|' + ISNULL(OCCUR_ENTRY_24, '') + '|' + ISNULL(OCCUR_ENTRY_25, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(CANCEL_DIV, '') AS ETC_TR_PAY"; sQuery += " FROM POSLOG..ETC_SALE_PAY "; sQuery += " WHERE CMP_CD = '{0}' "; sQuery += " AND SALE_DT = '{1}' "; sQuery += " AND STOR_CD = '{2}' "; sQuery += " AND POS_NO = '{3}' "; sQuery += " AND REG_NO = '{4}' "; sSQL = string.Format(sQuery , sCMP_CD , sSALE_DT , sSTOR_CD , sPOS_NO , sREG_NO); if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) { foreach (DataRow dr in dtTempReturn.Rows) { sbTranData.Append(dr[0].ToString()); } } } } 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 sbTranData.ToString(); } private string GetEtcTranEtc(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sREG_NO) { StringBuilder sbTranData = new StringBuilder(); string sQuery = ""; string sSQL = ""; DataTable dtTempReturn = null; try { sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.EtcTranEtc + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(ETC_WAY_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(ETC_AMT, 0)) + '|' + "; sQuery += " ISNULL(ETC_DTL_CD_01, '') + '|' + ISNULL(ETC_DTL_CD_02, '') + '|' + ISNULL(ETC_DTL_CD_03, '') + '|' + ISNULL(ETC_DTL_CD_04, '') + '|' + ISNULL(ETC_DTL_CD_05, '') + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(QTY_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_02, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_05, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(AMT_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_02, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_05, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(AMT_ENTRY_06, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_07, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_08, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_09, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_10, 0)) + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_01, '') + '|' + ISNULL(OCCUR_ENTRY_02, '') + '|' + ISNULL(OCCUR_ENTRY_03, '') + '|' + ISNULL(OCCUR_ENTRY_04, '') + '|' + ISNULL(OCCUR_ENTRY_05, '') + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_06, '') + '|' + ISNULL(OCCUR_ENTRY_07, '') + '|' + ISNULL(OCCUR_ENTRY_08, '') + '|' + ISNULL(OCCUR_ENTRY_09, '') + '|' + ISNULL(OCCUR_ENTRY_10, '') + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_11, '') + '|' + ISNULL(OCCUR_ENTRY_12, '') + '|' + ISNULL(OCCUR_ENTRY_13, '') + '|' + ISNULL(OCCUR_ENTRY_14, '') + '|' + ISNULL(OCCUR_ENTRY_15, '') + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_16, '') + '|' + ISNULL(OCCUR_ENTRY_17, '') + '|' + ISNULL(OCCUR_ENTRY_18, '') + '|' + ISNULL(OCCUR_ENTRY_19, '') + '|' + ISNULL(OCCUR_ENTRY_20, '') + '|' + "; sQuery += " ISNULL(OCCUR_ENTRY_21, '') + '|' + ISNULL(OCCUR_ENTRY_22, '') + '|' + ISNULL(OCCUR_ENTRY_23, '') + '|' + ISNULL(OCCUR_ENTRY_24, '') + '|' + ISNULL(OCCUR_ENTRY_25, '') + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(CANCEL_DIV, '') AS ETC_TR_ETC"; sQuery += " FROM POSLOG..ETC_SALE_ETC "; sQuery += " WHERE CMP_CD = '{0}' "; sQuery += " AND SALE_DT = '{1}' "; sQuery += " AND STOR_CD = '{2}' "; sQuery += " AND POS_NO = '{3}' "; sQuery += " AND REG_NO = '{4}' "; sSQL = string.Format(sQuery , sCMP_CD , sSALE_DT , sSTOR_CD , sPOS_NO , sREG_NO); if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) { foreach (DataRow dr in dtTempReturn.Rows) { sbTranData.Append(dr[0].ToString()); } } } } 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 sbTranData.ToString(); } private string GetEtcTranDpst(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sREG_NO) { StringBuilder sbTranData = new StringBuilder(); string sQuery = ""; string sSQL = ""; DataTable dtTempReturn = null; try { sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.EtcTranDpst + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(DPST_WTHDR_TYPE, '') + '|' + ISNULL(DPST_WTHDR_ACC_CD, '') + '|' + ISNULL(DPST_WTHDR_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(DPST_WTHDR_QTY, 0)) + '|' + "; sQuery += " CONVERT(VARCHAR, ISNULL(DPST_WTHDR_AMT, 0)) + '|' + ISNULL(DPST_WTHDR_NM, '') + '|' + ISNULL(CUST_NO, '') + '|' + ISNULL(STOR_PAY_TYPE, '') + '|' + ISNULL(ETC_REASON, '') + '|' + ISNULL(SLACK_FIELD_01, '') + '|' + ISNULL(SLACK_FIELD_02, '') + '|' + ISNULL(SLACK_FIELD_03, '') + '|' + "; sQuery += " ISNULL(SLACK_FIELD_04, '') + '|' + ISNULL(SLACK_FIELD_05, '') AS TR_DPST "; sQuery += " FROM POSLOG..ETC_SALE_DPST_WTHDR "; sQuery += " WHERE CMP_CD = '{0}' "; sQuery += " AND SALE_DT = '{1}' "; sQuery += " AND STOR_CD = '{2}' "; sQuery += " AND POS_NO = '{3}' "; sQuery += " AND REG_NO = '{4}' "; sSQL = string.Format( sQuery , sCMP_CD , sSALE_DT , sSTOR_CD , sPOS_NO , sREG_NO); if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) { foreach (DataRow dr in dtTempReturn.Rows) { sbTranData.Append(dr[0].ToString()); } } } } 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 sbTranData.ToString(); } #endregion #region 05 - ETC Journal 전송 public void ETCJournalSendProcess() { DataTable dtReturn = null; Hashtable htData = null; string sSendFlag = string.Empty; string sCmpCd = string.Empty; string sStorCd = string.Empty; string sSaleDt = string.Empty; string sPosNo = string.Empty; string sRegNo = string.Empty; string sTradeNo = string.Empty; try { // 전송할 Journal 데이터 생성 htData = GetEtcJournalData(ref dtReturn); if (dtReturn == null || dtReturn.Rows.Count == 0) { return; } else { iSendDataCnt += 1; } sCmpCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "CMP_CD"); sStorCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STOR_CD"); sSaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SALE_DT"); sPosNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "POS_NO"); sRegNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "REG_NO"); sTradeNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "TRADE_NO"); string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, Convert.ToInt32(m_cPosStatus.Base.JrnlPort), Convert.ToInt32(m_cPosStatus.Base.JrnlTimeout), new string[] { sCmpCd, m_cPosStatus.Base.BrandCd, sStorCd, sSaleDt, sPosNo, sTradeNo }, ItemConst.COMM_MSG_TYPE.ETCJNRL, htData); if (sReturn == UserCom.RST_OK) { sSendFlag = "1"; // 정상 전송 m_cPosStatus.Sale.OnLineStatus = "1"; } else { sSendFlag = "9"; // 에러 m_cPosStatus.Sale.OnLineStatus = "0"; } } 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); sSendFlag = "9"; } finally { // Flag Update EtcJournalFlgUpdate(sCmpCd, sStorCd, sPosNo, sSaleDt, sRegNo, sSendFlag); } } private int EtcJournalFlgUpdate(string sCmpCd, string sStorCd, string sPosNo, string sSaleDt, string sRegNo, string sSendFlag) { int iRet = UserCom.NG; string sQuery = string.Empty; try { if (sCmpCd.Trim() == "") return iRet; if (sStorCd.Trim() == "") return iRet; if (sPosNo.Trim() == "") return iRet; if (sSaleDt.Trim() == "") return iRet; if (sRegNo.Trim() == "") return iRet; sQuery += " UPDATE POSLOG..ETC_SALE_JOURNAL "; sQuery += " SET SEND_YN = '" + sSendFlag + "' "; sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; sQuery += " AND SALE_DT = '" + sSaleDt + "' "; sQuery += " AND STOR_CD = '" + sStorCd + "' "; sQuery += " AND POS_NO = '" + sPosNo + "' "; sQuery += " AND REG_NO = '" + sRegNo + "' "; iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); } 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; } public Hashtable GetEtcJournalData(ref DataTable dtReturn) { Hashtable htReturn = null; string sQuery = string.Empty; string sCmpCd = string.Empty; string sSaleDt = string.Empty; string sStorCd = string.Empty; string sPosNo = string.Empty; string sRegNo = string.Empty; string sTradeNo = string.Empty; DataTable dtTempReturn = null; try { sQuery += " SELECT TOP 1 "; sQuery += " CMP_CD, SALE_DT, STOR_CD, POS_NO, REG_NO "; sQuery += " , TRADE_NO, TRADE_DIV, TRAIN_MODE_YN, TRADE_KINDPER, SYS_DT "; sQuery += " , SYS_TIME, PIC_NO, BILL_AMT, JOURNAL_DATA "; sQuery += " FROM POSLOG..ETC_SALE_JOURNAL "; sQuery += " WHERE SEND_YN <> '1' "; sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; sQuery += " ORDER BY SEND_YN, SALE_DT, REG_NO "; if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn.Rows.Count == 1) { DataRow drTempReturn = dtTempReturn.Rows[0]; htReturn = MakeJournalJsonData(drTempReturn); } } dtReturn = dtTempReturn; } 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 htReturn; } #endregion #region 06 - Cashier Test Log 전송 public void CashierTestLogSendProcess() { DataTable dtReturn = null; Hashtable htData = null; string sSendFlag = string.Empty; string sCmpCd = string.Empty; string sStorCd = string.Empty; string sSaleDt = string.Empty; string sPosNo = string.Empty; string sSeq = string.Empty; try { // 전송할 승인로그 데이터 생성 htData = GetCashierTestLog(ref dtReturn); if (dtReturn == null || dtReturn.Rows.Count == 0) { return; } else { iSendDataCnt += 1; } sCmpCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "CMP_CD"); sStorCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STOR_CD"); sSaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SALE_DT"); sPosNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "POS_NO"); sSeq = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SEQ_NO"); string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, Convert.ToInt32(m_cPosStatus.Base.JrnlPort), Convert.ToInt32(m_cPosStatus.Base.JrnlTimeout), new string[] { sCmpCd, m_cPosStatus.Base.BrandCd, sStorCd, sSaleDt, sPosNo, "00000" }, ItemConst.COMM_MSG_TYPE.TESTLOG, htData); if (sReturn == UserCom.RST_OK) { sSendFlag = "1"; // 정상 전송 m_cPosStatus.Sale.OnLineStatus = "1"; } else { sSendFlag = "9"; // 에러 m_cPosStatus.Sale.OnLineStatus = "0"; } } 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); sSendFlag = "9"; } finally { // Flag Update CashierTestLogFlgUpdate(sCmpCd, sStorCd, sPosNo, sSaleDt, sSeq, sSendFlag); } } private int CashierTestLogFlgUpdate(string sCmpCd, string sStorCd, string sPosNo, string sSaleDt, string sSeq, string sSendFlag) { int iRet = UserCom.NG; string sQuery = string.Empty; try { if (sCmpCd.Trim() == "") return iRet; if (sSaleDt.Trim() == "") return iRet; if (sStorCd.Trim() == "") return iRet; if (sPosNo.Trim() == "") return iRet; if (sSeq.Trim() == "") return iRet; sQuery = " UPDATE POSLOG..TR_CASHIER_TEST "; sQuery += " SET SEND_YN = '" + sSendFlag + "' "; sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; sQuery += " AND SALE_DT = '" + sSaleDt + "' "; sQuery += " AND STOR_CD = '" + sStorCd + "' "; sQuery += " AND POS_NO = '" + sPosNo + "' "; sQuery += " AND SEQ_NO = '" + sSeq + "' "; iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); } 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; } public Hashtable GetCashierTestLog(ref DataTable dtReturn) { Hashtable htReturn = null; string sQuery = string.Empty; DataTable dtTempReturn = null; try { sQuery = " SELECT TOP 1 "; sQuery += " CMP_CD, SALE_DT, STOR_CD, POS_NO, SEQ_NO, TEST_KIND, TEST_DATE "; sQuery += " , CASHIER_NO, TEST_ENTRY_ID, PASS_CNT, TEST_CNT, TEST_PASS_YN "; sQuery += " , SEND_YN, REG_DATE, UPD_DATE "; sQuery += " FROM POSLOG..TR_CASHIER_TEST "; sQuery += " WHERE SEND_YN <> '1' "; sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; sQuery += " ORDER BY SEND_YN, SALE_DT, SEQ_NO "; if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn.Rows.Count == 1) { DataRow drTempReturn = dtTempReturn.Rows[0]; htReturn = MakeCashierTestLogJsonData(drTempReturn); } } dtReturn = dtTempReturn; } 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 htReturn; } private Hashtable MakeCashierTestLogJsonData(DataRow drData) { Hashtable htData = new Hashtable(); try { // 01 - 회사코드 htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.CmpCd, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.CmpCd)); // 02 - 판매 일자 htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.SaleDt, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.SaleDt)); // 03 - 점포 코드 htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.StorCd, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.StorCd)); // 04 - 포스 번호 htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.PosNo, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.PosNo)); // 05 - 순번 htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.SeqNo, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.SeqNo)); // 06 - 시험 종류 htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestKind, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestKind)); // 07 - 시험 일시 htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestDate, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestDate)); // 08 - 계산원 번호 htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.CashierNo, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.CashierNo)); // 09 - 시험항목 ID htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestEntryId, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestEntryId)); // 10 - 정답 항목 수 htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.PassCnt, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.PassCnt)); // 11 - 시험 항목 수 htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestCnt, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestCnt)); // 12 - 시험 합격 여부 htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestPassYn, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestPassYn)); } 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 htData; } #endregion #region 07 - 도로공사(고속도로 휴게소 입점 POS) 매출 I/F XML파일 생성 public void MakeTranToExProcess() { string sendFlag = string.Empty; string sCmpCd = string.Empty; string sSaleDt = string.Empty; string sStorCd = string.Empty; string sPosNo = string.Empty; string sTradeNo = string.Empty; DataTable dtReturn = null; try { // 전송할 데이터 조회 GetTranInfo(ref dtReturn); if(dtReturn == null || dtReturn.Rows.Count == 0) { return; } else { iSendDataCnt += 1; } sendFlag = "0"; // 0:미전송, 1:전송, 8:파일생성, 9:에러 DataRow dr = dtReturn.Rows[0]; sCmpCd = CmUtil.GetDataRowStr(dr, "CMP_CD"); sSaleDt = CmUtil.GetDataRowStr(dr, "SALE_DT"); sStorCd = CmUtil.GetDataRowStr(dr, "STOR_CD"); sPosNo = CmUtil.GetDataRowStr(dr, "POS_NO"); sTradeNo = CmUtil.GetDataRowStr(dr, "TRADE_NO"); DataTable dtTRHeader = GetTranHeaderForEx(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); DataTable dtTRDetail = GetTranDetailForEx(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); DataTable dtTRCashData = GetTranCashDataForEx(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); DataTable dtTRCardData = GetTranCardDataForEx(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); XmlDocument doc = new XmlDocument(); XmlDeclaration docClaration = doc.CreateXmlDeclaration("1.0", null, null); XmlElement root = doc.DocumentElement; doc.InsertBefore(docClaration, root); XmlElement erestNode = doc.CreateElement("EREST"); doc.AppendChild(erestNode); MakeXmlHeader(ref doc, ref erestNode, dtTRHeader); MakeXmlDetail(ref doc, ref erestNode, dtTRDetail); MakeXmlCashData(ref doc, ref erestNode, dtTRCashData); MakeXmlCardData(ref doc, ref erestNode, dtTRCardData); // 매출 TRAN XML 파일 생성 string sFileNm = "H1" + "_" + sCmpCd + "_" + sStorCd + "_" + sPosNo + "_" + sSaleDt + "_" + sTradeNo + ".xml"; doc.Save(BaseCom.NxDataPath + "SEND\\EX\\" + sFileNm); sendFlag = "8"; } 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 (함수명)) "도로공사 매출XML 파일 생성 에러-" + sSaleDt + "/" + sStorCd + "/" + sPosNo + "/" + sTradeNo + ":" + ex.Message); sendFlag = "9"; } finally { // Flag Update OutsideTranSendFlgUpdate(sCmpCd, sStorCd, sPosNo, sSaleDt, sTradeNo, sendFlag); } } private int OutsideTranSendFlgUpdate(string pCompanyCd, string pStoreNo, string pPosNo, string pSaleDate, string pTradeNo, string pSendFlag) { int iRet = UserCom.NG; string sQuery = ""; try { if (pCompanyCd.Trim() == "") return iRet; if (pSaleDate.Trim() == "") return iRet; if (pStoreNo.Trim() == "") return iRet; if (pPosNo.Trim() == "") return iRet; if (pTradeNo.Trim() == "" || pTradeNo.Trim() == "99999") return iRet; sQuery = "UPDATE POSLOG..TR_SALE_HEADER "; sQuery += " SET OUT_SEND_YN = '" + pSendFlag + "' "; sQuery += " WHERE CMP_CD = '" + pCompanyCd + "' "; sQuery += " AND STOR_CD = '" + pStoreNo + "' "; sQuery += " AND SALE_DT = '" + pSaleDate + "' "; sQuery += " AND POS_NO = '" + pPosNo + "' "; sQuery += " AND TRADE_NO = '" + pTradeNo + "' "; iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); } 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; } private void GetTranInfo(ref DataTable dtReturn) { string sQuery = string.Empty; DataTable dtTempReturn = null; try { sQuery = " SELECT TOP 1 \n" + " CMP_CD, SALE_DT, STOR_CD, POS_NO, TRADE_NO \n" + " FROM POSLOG..TR_SALE_HEADER \n" + " WHERE TRADE_KINDPER = '00' \n" + " AND OUT_SEND_YN = '0' \n" + " AND TRAIN_MODE_YN = '0' \n" + " AND TRADE_KINDPER = '00' \n" + " ORDER BY SALE_DT, TRADE_NO, OUT_SEND_YN \n"; sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn); dtReturn = dtTempReturn; } 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); } } private void MakeXmlHeader(ref XmlDocument doc, ref XmlElement upperNode, DataTable dtData) { try { DataRow dr = dtData.Rows[0]; //----------------------------------------------------------------------------------------- // TXJM-FD //----------------------------------------------------------------------------------------- XmlElement TXJMNode = doc.CreateElement("TXJM-FD"); TXJMNode.SetAttribute("SRID", "SL010"); // 1.전문ID (5) TXJMNode.SetAttribute("RETCD", "0000"); // 2.전문적합성체크 (4) TXJMNode.SetAttribute("TRHDR_CNT", "1"); // 3.헤더Count (2) TXJMNode.SetAttribute("TRDTL_CNT", CmUtil.GetDataRowStr(dr, "TRDTL_CNT")); // 4.디테일Count (2) TXJMNode.SetAttribute("TRCSH_CNT", CmUtil.GetDataRowStr(dr, "TRCSH_CNT")); // 5.현금Count (2) TXJMNode.SetAttribute("TRCRD_CNT", CmUtil.GetDataRowStr(dr, "TRCRD_CNT")); // 6.카드Count (2) TXJMNode.SetAttribute("TRCST_CNT", "0"); TXJMNode.SetAttribute("TRFOD_CNT", "0"); TXJMNode.SetAttribute("TRGFT_CNT", "0"); TXJMNode.SetAttribute("TRJCD_CNT", "0"); TXJMNode.SetAttribute("TRWES_CNT", "0"); TXJMNode.SetAttribute("TRPSQ_CNT", "0"); TXJMNode.SetAttribute("TRCSA_CNT", "0"); TXJMNode.SetAttribute("TRGFA_CNT", "0"); TXJMNode.SetAttribute("TRFOA_CNT", "0"); TXJMNode.SetAttribute("TRRFC_CNT", "0"); TXJMNode.SetAttribute("RUN_MODE", "T"); // T-테스트, R-정상 upperNode.AppendChild(TXJMNode); //----------------------------------------------------------------------------------------- // TRHDR //----------------------------------------------------------------------------------------- XmlElement TRHDRNode = doc.CreateElement("TRHDR"); //TRHDRNode.SetAttribute("SHOP_CD", m_cPosStatus.Base.ExStoreCd); // 7.매장코드 (9) //TRHDRNode.SetAttribute("SHOP_CD", m_cPosStatus.Base.OutSDVendConNo); // 7.매장코드 (9) TRHDRNode.SetAttribute("SHOP_CD", m_cPosStatus.Mst.JOIN_STOR_CD); // 7.매장코드 (9) TRHDRNode.SetAttribute("SALE_DATE", m_cPosStatus.Base.SaleDate); // 8.영업일자 (8) TRHDRNode.SetAttribute("POS_NO", m_cPosStatus.Base.PosNo); // 9.포스번호 (2) TRHDRNode.SetAttribute("BILL_NO", m_cPosStatus.Base.TradeNo.Substring(1, 4)); // 10.영수번호 (4) TRHDRNode.SetAttribute("REGI_SEQ", "01"); // 11.정산차수 (2) TRHDRNode.SetAttribute("SALE_YN", CmUtil.GetDataRowStr(dr, "SALE_YN")); // 12.판매여부 (1) TRHDRNode.SetAttribute("TOT_SALE_AMT", CmUtil.GetDataRowStr(dr, "DCM_SALE_AMT")); // 13.총매출액 (12) AS-IS 에서 TOT_SALE_AMT 가 아닌 DCM_SALE_AMT 로 값을 채움 TRHDRNode.SetAttribute("TOT_DC_AMT", CmUtil.GetDataRowStr(dr, "TOT_DC_AMT")); // 14.총할인액 (12) TRHDRNode.SetAttribute("SVC_TIP_AMT", CmUtil.GetDataRowStr(dr, "SVC_TIP_AMT")); // 15.봉사료 (12) TRHDRNode.SetAttribute("TOT_ETC_AMT", CmUtil.GetDataRowStr(dr, "TOT_ETC_AMT")); // 16.기타에누리액 (12) TRHDRNode.SetAttribute("DCM_SALE_AMT", CmUtil.GetDataRowStr(dr, "DCM_SALE_AMT")); // 17.실매출액 (12) TRHDRNode.SetAttribute("VAT_SALE_AMT", CmUtil.GetDataRowStr(dr, "VAT_SALE_AMT")); // 18.과세매출액 (12) TRHDRNode.SetAttribute("VAT_AMT", CmUtil.GetDataRowStr(dr, "VAT_AMT")); // 19.부가세 (12) TRHDRNode.SetAttribute("NO_VAT_SALE_AMT", CmUtil.GetDataRowStr(dr, "NO_VAT_SALE_AMT")); // 20.면세매출액 (12) TRHDRNode.SetAttribute("NO_TAX_SALE_AMT", CmUtil.GetDataRowStr(dr, "NO_TAX_SALE_AMT")); // 21.순매출액 (12) TRHDRNode.SetAttribute("EXP_PAY_AMT", CmUtil.GetDataRowStr(dr, "EXP_PAY_AMT")); // 22.받을금액 (12) TRHDRNode.SetAttribute("GST_PAY_AMT", CmUtil.GetDataRowStr(dr, "GST_PAY_AMT")); // 23.받은금액 (12) TRHDRNode.SetAttribute("RET_PAY_AMT", CmUtil.GetDataRowStr(dr, "RET_PAY_AMT")); // 24.거스름돈 (12) TRHDRNode.SetAttribute("CASH_AMT", CmUtil.GetDataRowStr(dr, "CASH_AMT")); // 25.결제액-현금 (12) TRHDRNode.SetAttribute("CRD_CARD_AMT", CmUtil.GetDataRowStr(dr, "CRD_CARD_AMT")); // 26.결제액-신용카드 (12) TRHDRNode.SetAttribute("WES_AMT", "0"); // 27.결제액-외상 (12) TRHDRNode.SetAttribute("TK_GFT_AMT", "0"); // 28.결제액-상품권 (12) TRHDRNode.SetAttribute("TK_FOD_AMT", "0"); // 29.결제액-식권 (12) TRHDRNode.SetAttribute("CST_POINT_AMT", "0"); // 30.결제액-회원포인트 (12) TRHDRNode.SetAttribute("JCD_CARD_AMT", "0"); // 31.결제액-제휴카드(사용) (12) TRHDRNode.SetAttribute("DC_GEN_AMT", CmUtil.GetDataRowStr(dr, "TOT_DC_AMT")); // 32.할인액-일반 (12) TRHDRNode.SetAttribute("DC_SVC_AMT", "0"); // 33.할인액-서비스 (12) TRHDRNode.SetAttribute("DC_PCD_AMT", "0"); // 34.할인액-제휴카드 (12) TRHDRNode.SetAttribute("DC_CPN_AMT", "0"); // 35.할인액-쿠폰 (12) TRHDRNode.SetAttribute("DC_CST_AMT", "0"); // 36.할인액-회원 (12) TRHDRNode.SetAttribute("DC_TFD_AMT", "0"); // 37.할인액-식권 (12) TRHDRNode.SetAttribute("DC_PRM_AMT", "0"); // 38.할인액-프로모션 (12) TRHDRNode.SetAttribute("DC_CRD_AMT", "0"); // 39.할인액-신용카드현장할인 (12) TRHDRNode.SetAttribute("DC_PACK_AMT", "0"); // 40.할인액-포장할인 (12) TRHDRNode.SetAttribute("REPAY_CASH_AMT", CmUtil.GetDataRowStr(dr, "REPAY_CASH_AMT")); TRHDRNode.SetAttribute("REPAY_TK_GFT_AMT", "0"); TRHDRNode.SetAttribute("CASH_BILL_AMT", CmUtil.GetDataRowStr(dr, "CASH_BILL_AMT")); TRHDRNode.SetAttribute("DLV_ORDER_FG", "0"); TRHDRNode.SetAttribute("FD_TBL_CD", "000"); TRHDRNode.SetAttribute("FD_GST_CNT_T", "1"); TRHDRNode.SetAttribute("FD_GST_CNT_1", "1"); TRHDRNode.SetAttribute("FD_GST_CNT_2", "0"); TRHDRNode.SetAttribute("FD_GST_CNT_3", "0"); TRHDRNode.SetAttribute("FD_GST_CNT_4", "0"); TRHDRNode.SetAttribute("ORG_BILL_NO", CmUtil.GetDataRowStr(dr, "SALE_YN") == "N" ? m_cPosStatus.Base.StoreNo + CmUtil.GetDataRowStr(dr, "ORG_BILL_NO") : ""); TRHDRNode.SetAttribute("ORDER_NO", m_cPosStatus.Base.TradeNo.Substring(1, 4)); TRHDRNode.SetAttribute("INS_DT", CmUtil.GetDataRowStr(dr, "INS_DT")); TRHDRNode.SetAttribute("EMP_NO", "0000"); TRHDRNode.SetAttribute("PAY_OUT_DT", CmUtil.GetDataRowStr(dr, "PAY_OUT_DT")); TRHDRNode.SetAttribute("CST_NM", ""); TRHDRNode.SetAttribute("DLV_EMP_NO", ""); TRHDRNode.SetAttribute("DLV_START_DT", ""); TRHDRNode.SetAttribute("DLV_PAYIN_EMP_NO", ""); TRHDRNode.SetAttribute("DLV_PAYIN_DT", ""); TRHDRNode.SetAttribute("NEW_DLV_ADDR_YN", "N"); TRHDRNode.SetAttribute("DLV_ADDR", ""); TRHDRNode.SetAttribute("DLV_ADDR_DTL", ""); TRHDRNode.SetAttribute("NEW_DLV_TEL_NO_YN", "N"); TRHDRNode.SetAttribute("DLV_TEL_NO", ""); TRHDRNode.SetAttribute("DLV_CL_CD", ""); TRHDRNode.SetAttribute("DLV_CM_CD", ""); TRHDRNode.SetAttribute("TRAVEL_CD", ""); TRHDRNode.SetAttribute("RSV_NO", ""); TRHDRNode.SetAttribute("PRE_PAY_CASH", "0"); TRHDRNode.SetAttribute("PRE_PAY_CARD", "0"); TRHDRNode.SetAttribute("RSV_USER_NM", ""); TRHDRNode.SetAttribute("RSV_USER_TEL_NO", ""); TRHDRNode.SetAttribute("PREPAY_AMT", "0"); TRHDRNode.SetAttribute("COM_AMT", "0"); upperNode.AppendChild(TRHDRNode); } 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); } } private XmlDocument MakeXmlDetail(ref XmlDocument doc, ref XmlElement upperNode, DataTable dtData) { try { //----------------------------------------------------------------------------------------- // TRDTL //----------------------------------------------------------------------------------------- XmlElement TRDTLNode = doc.CreateElement("TRDTL"); upperNode.AppendChild(TRDTLNode); if (dtData == null) return doc; for(int nLoop = 0;nLoop < dtData.Rows.Count;nLoop++) { DataRow dr = dtData.Rows[nLoop]; XmlElement DATADtlNode = doc.CreateElement("DATA-DTL"); DATADtlNode.SetAttribute("DTL_NO", string.Format("{0:0000}", nLoop + 1)); // 76.디테일번호 (4) DATADtlNode.SetAttribute("REGI_SEQ", "01"); // 77.정산차수 (2) DATADtlNode.SetAttribute("SALE_YN", CmUtil.GetDataRowStr(dr, "SALE_YN")); // 78.판매여부 (1) DATADtlNode.SetAttribute("PROD_CD", CmUtil.GetDataRowStr(dr, "PROD_CD")); // 79.상품코드 (20) DATADtlNode.SetAttribute("PROD_TYPE_FG", CmUtil.GetDataRowStr(dr, "PROD_TYPE_FG")); // 80.상품유형구분 (1) //DATADtlNode.SetAttribute("CORNER_CD", m_cPosStatus.Base.ExCornerCd); // 81.코너코드 (4) //DATADtlNode.SetAttribute("CORNER_CD", m_cPosStatus.Base.OutSDVendCrnrCd); // 81.코너코드 (4) DATADtlNode.SetAttribute("CORNER_CD", m_cPosStatus.Mst.JOIN_BRAND_CD); // 81.코너코드 (4) DATADtlNode.SetAttribute("CHG_BILL_NO", ""); // 82.교환권번호(외식-푸드코드) (4) DATADtlNode.SetAttribute("TAX_YN", CmUtil.GetDataRowStr(dr, "TAX_YN")); // 83.과세여부 (1) DATADtlNode.SetAttribute("DLV_PACK_FG", CmUtil.GetDataRowStr(dr, "DLV_PACK_FG")); // 84.배달포장구분 (1) DATADtlNode.SetAttribute("ORG_SALE_MG_CD", "0000"); // 85.원천판매마진코드 (4) DATADtlNode.SetAttribute("ORG_SALE_UPRC", "0"); // 86.원천판매단가 (12) DATADtlNode.SetAttribute("NORMAL_UPRC", CmUtil.GetDataRowStr(dr, "NORMAL_UPRC")); // 87.정상판매단가 (12) DATADtlNode.SetAttribute("SALE_MG_CD", "0000"); // 88.판매마진코드 (4) DATADtlNode.SetAttribute("SALE_QTY", CmUtil.GetDataRowStr(dr, "SALE_QTY")); // 89.판매수량 (9) DATADtlNode.SetAttribute("SALE_UPRC", CmUtil.GetDataRowStr(dr, "SALE_UPRC")); // 90.판매단가 (12) DATADtlNode.SetAttribute("SALE_AMT", CmUtil.GetDataRowStr(dr, "SALE_AMT")); // 91.매출액 (12) DATADtlNode.SetAttribute("DC_AMT", CmUtil.GetDataRowStr(dr, "DC_AMT")); // 92.할인액 (12) DATADtlNode.SetAttribute("ETC_AMT", CmUtil.GetDataRowStr(dr, "ETC_AMT")); // 93.기타에누리액(식권짜투리/에누리-끝전) (12) DATADtlNode.SetAttribute("SVC_TIP_AMT", CmUtil.GetDataRowStr(dr, "SVC_TIP_AMT")); // 94.봉사료 (12) DATADtlNode.SetAttribute("DCM_SALE_AMT", CmUtil.GetDataRowStr(dr, "DCM_SALE_AMT")); // 95.실매출액 (12) DATADtlNode.SetAttribute("VAT_AMT", CmUtil.GetDataRowStr(dr, "VAT_AMT")); // 96.부가세 (12) DATADtlNode.SetAttribute("SVC_CD", ""); // 97.서비스코드 (1) DATADtlNode.SetAttribute("TK_CPN_CD", ""); // 98.쿠폰코드 (3) DATADtlNode.SetAttribute("DC_AMT_GEN", CmUtil.GetDataRowStr(dr, "DC_AMT")); // 99.할인액-일반 (12) DATADtlNode.SetAttribute("DC_AMT_SVC", "0"); // 100.할인액-서비스 (12) DATADtlNode.SetAttribute("DC_AMT_JCD", "0"); // 101.할인액-제휴카드 (12) DATADtlNode.SetAttribute("DC_AMT_CPN", "0"); // 102.할인액-쿠폰 (12) DATADtlNode.SetAttribute("DC_AMT_CST", "0"); // 103.할인액-회원 (12) DATADtlNode.SetAttribute("DC_AMT_FOD", "0"); // 104.할인액-식권 (12) DATADtlNode.SetAttribute("DC_AMT_PRM", "0"); // 105.할인액-프로모션 (12) DATADtlNode.SetAttribute("DC_AMT_CRD", "0"); // 106.할인액-신용카드-현장할인 (12) DATADtlNode.SetAttribute("DC_AMT_PACK", "0"); // 107.할인액-포장 (12) DATADtlNode.SetAttribute("CST_SALE_POINT", "0"); // 108.회원-매출포인트 (8) DATADtlNode.SetAttribute("CST_USE_POINT", "0"); // 109.회원-사용포인트 (8) DATADtlNode.SetAttribute("PRM_PROC_YN", "N"); // 110.프로모션-적용여부 (1) DATADtlNode.SetAttribute("PRM_CD", ""); // 111.프로모션-코드 (4) DATADtlNode.SetAttribute("PRM_SEQ", ""); // 112.프로모션-차수 (2) DATADtlNode.SetAttribute("SDA_CD", ""); // 113.외식-사이드-속성코드 (10) DATADtlNode.SetAttribute("SDS_ORG_DTL_NO", ""); // 114.외식-사이드-선택메뉴-원천DTLNO(재설정필요) (4) DATADtlNode.SetAttribute("INS_DT", CmUtil.GetDataRowStr(dr, "INS_DT")); // 115.POS등록일시 (14) DATADtlNode.SetAttribute("EMP_NO", "0000"); // 116.판매원코드 (4) DATADtlNode.SetAttribute("PREPAY_AMT", "0"); // 117.선수입금액 (12) DATADtlNode.SetAttribute("COM_AMT", "0"); // 118.이익금액 (12) TRDTLNode.AppendChild(DATADtlNode); } } 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 doc; } private XmlDocument MakeXmlCashData(ref XmlDocument doc, ref XmlElement upperNode, DataTable dtData) { try { //----------------------------------------------------------------------------------------- // TRCSH //----------------------------------------------------------------------------------------- XmlElement TRCSHNode = doc.CreateElement("TRCSH"); upperNode.AppendChild(TRCSHNode); if (dtData == null) return doc; // VAN사 터미널ID 취득 string sTermNo = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.CREDITCARD_ITEM, ItemConst.TR_ITEM_ID.CREDITCARD.CREDIT_CARD, PosMst.MST_VAN.DATA.APPR_ID); for (int nLoop = 0; nLoop < dtData.Rows.Count; nLoop++) { DataRow dr = dtData.Rows[nLoop]; XmlElement DATANode = doc.CreateElement("DATA-CSH"); DATANode.SetAttribute("LINE_NO", string.Format("{0:0000}", nLoop + 1)); // 119.라인번호 (4) DATANode.SetAttribute("SEQ_NO", "01"); DATANode.SetAttribute("REGI_SEQ", "01"); DATANode.SetAttribute("SALE_YN", CmUtil.GetDataRowStr(dr, "SALE_YN")); // 판매여부 (1) DATANode.SetAttribute("VAN_CD", "02"); // VAN사코드 (2) //DATANode.SetAttribute("CORNER_CD", m_cPosStatus.Base.ExCornerCd); // 코너코드 (4) //DATANode.SetAttribute("CORNER_CD", m_cPosStatus.Base.OutSDVendCrnrCd); // 코너코드 (4) DATANode.SetAttribute("CORNER_CD", m_cPosStatus.Mst.JOIN_BRAND_CD); // 코너코드 (4) DATANode.SetAttribute("CASH_AMT", CmUtil.GetDataRowStr(dr, "APPR_AMT")); DATANode.SetAttribute("APPR_AMT", CmUtil.GetDataRowStr(dr, "APPR_AMT")); // 승인금액 (12) DATANode.SetAttribute("SVC_TIP_AMT", CmUtil.GetDataRowStr(dr, "SVC_TIP_AMT")); // 봉사료 (12) DATANode.SetAttribute("VAT_AMT", CmUtil.GetDataRowStr(dr, "VAT_AMT")); // 부가세 (12) DATANode.SetAttribute("APPR_PROC_FG", CmUtil.GetDataRowStr(dr, "APPR_PROC_FG"));// 승인처리구분 (1) DATANode.SetAttribute("APPR_IDT_TYPE", CmUtil.GetDataRowStr(dr, "APPR_IDT_TYPE")); // 승인거래자유형 (1) DATANode.SetAttribute("APPR_IDT_FG", CmUtil.GetDataRowStr(dr, "APPR_IDT_FG")); // 승인인식구분 (1) DATANode.SetAttribute("CARD_IN_FG", CmUtil.GetDataRowStr(dr, "CARD_IN_FG")); // 카드입력구분 (1) DATANode.SetAttribute("APPR_IDT_NO", CmUtil.GetDataRowStr(dr, "APPR_IDT_NO")); // 승인인식번호 (20) DATANode.SetAttribute("APPR_DATE", CmUtil.GetDataRowStr(dr, "APPR_DATE")); // 승인일자 (8) DATANode.SetAttribute("APPR_TIME", CmUtil.GetDataRowStr(dr, "APPR_TIME")); // 승인시각 (6) DATANode.SetAttribute("APPR_NO", CmUtil.GetDataRowStr(dr, "APPR_NO")); // 승인번호 (16) DATANode.SetAttribute("APPR_MSG", ""); // 승인응답메시지 (200) DATANode.SetAttribute("VAN_TERM_NO", sTermNo); // VAN사터미널번호 (15) DATANode.SetAttribute("VAN_SLIP_NO", ""); // VAN사전표번호 (12) DATANode.SetAttribute("ORG_APPR_DATE", ""); // 원거래승인일자 (8) DATANode.SetAttribute("ORG_APPR_NO", ""); // 원거래승인번호 (16) DATANode.SetAttribute("APPR_LOG_NO", ""); // 승인로그번호 (5) DATANode.SetAttribute("INS_DT", CmUtil.GetDataRowStr(dr, "INS_DT")); // 등록일시 (14) DATANode.SetAttribute("EMP_NO", "0000"); // 판매원코드 (4) DATANode.SetAttribute("EX_CD", "0"); // 통화코드 (2) DATANode.SetAttribute("EX_KRW", "0"); // 환율 (12) DATANode.SetAttribute("EX_EXP_AMT", "0"); // 통화-받을금액 (12) DATANode.SetAttribute("EX_IN_AMT", "0"); // 통화-지불액 (12) DATANode.SetAttribute("EX_RET_AMT", "0"); // 통화-거스름 (12) DATANode.SetAttribute("KR_RET_AMT", "0"); // 원화-거스름 (12) DATANode.SetAttribute("EX_PAY_AMT", "0"); // 통화-결제액(통화지불액-통화거스름) (12) DATANode.SetAttribute("KR_PAY_AMT", "0"); // 원화-결제액(통화결제액*환율) (12) DATANode.SetAttribute("KR_ETC_AMT", "0"); // 원화-에누리액(원화결제액-현금결제액-원화거스름) (12) DATANode.SetAttribute("PRE_PAY_FG", "0"); TRCSHNode.AppendChild(DATANode); } } 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 doc; } private XmlDocument MakeXmlCardData(ref XmlDocument doc, ref XmlElement upperNode, DataTable dtData) { try { //----------------------------------------------------------------------------------------- // TRCRD //----------------------------------------------------------------------------------------- XmlElement TRCRDNode = doc.CreateElement("TRCRD"); upperNode.AppendChild(TRCRDNode); if (dtData == null) return doc; for (int nLoop = 0; nLoop < dtData.Rows.Count; nLoop++) { DataRow dr = dtData.Rows[nLoop]; XmlElement DATANode = doc.CreateElement("DATA-CRD"); DATANode.SetAttribute("LINE_NO", string.Format("{0:0000}", nLoop + 1)); // 라인번호 (4) DATANode.SetAttribute("SEQ_NO", CmUtil.GetDataRowStr(dr, "SEQ_NO")); // 일련번호 (2) DATANode.SetAttribute("REGI_SEQ", "01"); // 정산차수 (2) DATANode.SetAttribute("SALE_YN", CmUtil.GetDataRowStr(dr, "SALE_YN")); // 매출구분 (1) DATANode.SetAttribute("VAN_CD", CmUtil.GetDataRowStr(dr, "VAN_CD")); // VAN사코드 (2) //DATANode.SetAttribute("CORNER_CD", m_cPosStatus.Base.ExCornerCd); // 코너코드 (4) //DATANode.SetAttribute("CORNER_CD", m_cPosStatus.Base.OutSDVendCrnrCd); // 코너코드 (4) DATANode.SetAttribute("CORNER_CD", m_cPosStatus.Mst.JOIN_BRAND_CD); // 코너코드 (4) DATANode.SetAttribute("APPR_PROC_FG", CmUtil.GetDataRowStr(dr, "APPR_PROC_FG"));// 승인구분 (1) DATANode.SetAttribute("CRD_CARD_NO", CmUtil.GetDataRowStr(dr, "CRD_CARD_NO")); // 카드번호 (20) DATANode.SetAttribute("APPR_REQ_AMT", CmUtil.GetDataRowStr(dr, "APPR_REQ_AMT"));// 승인요청금액 (12) DATANode.SetAttribute("SVC_TIP_AMT", CmUtil.GetDataRowStr(dr, "SVC_TIP_AMT")); // 봉사료 (12) DATANode.SetAttribute("VAT_AMT", CmUtil.GetDataRowStr(dr, "VAT_AMT")); // 부가세 (12) DATANode.SetAttribute("INST_MM_FG", CmUtil.GetDataRowStr(dr, "INST_MM_FG")); // 할부개월구분 (1) DATANode.SetAttribute("INST_MM_CNT", CmUtil.GetDataRowStr(dr, "INST_MM_CNT")); // 할부개월수 (2) DATANode.SetAttribute("VALID_TERM", "000000"); // 유효기간 (6) DATANode.SetAttribute("SIGN_PAD_YN", CmUtil.GetDataRowStr(dr, "SIGN_PAD_YN")); // 사인패드사용여부 (1) DATANode.SetAttribute("CARD_IN_FG", CmUtil.GetDataRowStr(dr, "CARD_IN_FG")); // 카드입력구분 (1) DATANode.SetAttribute("APPR_DATE", CmUtil.GetDataRowStr(dr, "APPR_DATE")); // 승인일자 (8) DATANode.SetAttribute("APPR_TIME", CmUtil.GetDataRowStr(dr, "APPR_TIME")); // 승인시간 (6) DATANode.SetAttribute("APPR_NO", CmUtil.GetDataRowStr(dr, "APPR_NO")); // 승인번호 (16) DATANode.SetAttribute("CRDCP_CD", ""); // 카드사코드 (3) DATANode.SetAttribute("ISS_CRDCP_CD", ""); // 카드발급사코드 (4) DATANode.SetAttribute("ISS_CRDCP_NM", ""); // 카드발급사명 (40) DATANode.SetAttribute("PUR_CRDCP_CD", CmUtil.GetDataRowStr(dr, "PUR_CRDCP_CD"));// 카드매입사코드 (4) DATANode.SetAttribute("PUR_CRDCP_NM", CmUtil.GetDataRowStr(dr, "PUR_CRDCP_NM").Trim());// 카드매입사명 (40) DATANode.SetAttribute("APPR_AMT", CmUtil.GetDataRowStr(dr, "APPR_AMT")); // 승인금액(실제승인액) DATANode.SetAttribute("APPR_DC_AMT", "0"); // 승인현장할인액 (12) DATANode.SetAttribute("APPR_MSG", ""); // 승인응답메시지 (200) DATANode.SetAttribute("VAN_TERM_NO", ""); // VAN사터미널번호 (15) DATANode.SetAttribute("VAN_SLIP_NO", ""); // VAN사전표번호 (12) DATANode.SetAttribute("CRDCP_TERM_NO", CmUtil.GetDataRowStr(dr, "CRDCP_TERM_NO").Trim()); // 카드사계약번호 (15) DATANode.SetAttribute("ORG_APPR_DATE", ""); // 원거래승인일자 (8) DATANode.SetAttribute("ORG_APPR_NO", ""); // 원거래승인번호 (16) DATANode.SetAttribute("APPR_LOG_NO", ""); // 승인로그번호 (5) DATANode.SetAttribute("INS_DT", CmUtil.GetDataRowStr(dr, "INS_DT")); // 등록일시 (14) DATANode.SetAttribute("EMP_NO", "0000"); // 판매원번호 (4) DATANode.SetAttribute("PRE_PAY_FG", "0"); // 선수금구분자 (1) TRCRDNode.AppendChild(DATANode); } } 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 doc; } private DataTable GetTranHeaderForEx(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo) { string sQuery = string.Empty; string sSelQuery = string.Empty; StringBuilder sb = new StringBuilder(); DataTable dtReturn = null; try { sSelQuery = "SELECT CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 'Y' \n" + " ELSE 'N' \n" + " END AS SALE_YN \n" + " , ISNULL(A.TOTSALE_AMT, 0) AS TOT_SALE_AMT \n" + " , ISNULL(A.TOTDC_AMT, 0) AS TOT_DC_AMT \n" + " , ISNULL(A.SVC_FEE_AMT, 0) AS SVC_TIP_AMT \n" + " , 0 AS TOT_ETC_AMT \n" + " , ISNULL(A.NET_SALE_AMT, 0) AS DCM_SALE_AMT \n" + " , ISNULL(A.TOT_VAT, 0) AS VAT_AMT \n" + " , ISNULL(A.NET_SALE_AMT, 0) - ISNULL(A.TOT_VAT, 0) AS NO_TAX_SALE_AMT \n" + " , ISNULL(A.NET_SALE_AMT, 0) AS EXP_PAY_AMT \n" + " , A.SALE_DT + A.PAY_TIME AS INS_DT \n" + " , A.SALE_DT + A.PAY_TIME AS PAY_OUT_DT \n" + " , A.ORG_BILLDT + A.POS_NO + SUBSTRING(A.ORG_BILL_NO, 2, 4) AS ORG_BILL_NO \n" + " , C.TRDTL_CNT AS TRDTL_CNT \n" + " , D.TRCSH_CNT AS TRCSH_CNT \n" + " , B.TRCRD_CNT AS TRCRD_CNT \n" + " , C.VAT_SALE_AMT AS VAT_SALE_AMT \n" + " , C.NO_VAT_SALE_AMT AS NO_VAT_SALE_AMT \n" + " , B.GST_PAY_AMT AS GST_PAY_AMT \n" + " , B.RET_PAY_AMT AS RET_PAY_AMT \n" + " , B.CASH_AMT AS CASH_AMT \n" + " , B.CRD_CARD_AMT AS CRD_CARD_AMT \n" + " , B.REPAY_CASH_AMT AS REPAY_CASH_AMT \n" + " , D.CASH_BILL_AMT AS CASH_BILL_AMT \n" + " FROM POSLOG..TR_SALE_HEADER A \n" + " , ( \n" + " SELECT SUM(CASE WHEN TSP.PAY_WAY_CD <> '02' \n" + " THEN ISNULL(TSP.AMT_ENTRY_01, 0) - ISNULL(TSP.AMT_ENTRY_02, 0) \n" + " ELSE 0 \n" + " END) AS CASH_AMT \n" + " , SUM(CASE WHEN TSP.PAY_WAY_CD = '02' \n" + " THEN 1 \n" + " ELSE 0 \n" + " END) AS TRCRD_CNT \n" + " , SUM(CASE WHEN TSP.PAY_WAY_CD = '02' \n" + " THEN ISNULL(TSP.AMT_ENTRY_01, 0) \n" + " ELSE 0 \n" + " END) AS CRD_CARD_AMT \n" + " , SUM(ISNULL(TSP.PAY_AMT, 0)) AS GST_PAY_AMT \n" + " , SUM(ISNULL(TSP.AMT_ENTRY_02, 0)) AS RET_PAY_AMT \n" + " , 0 AS REPAY_CASH_AMT \n" + " FROM POSLOG..TR_SALE_HEADER TSH \n" + " LEFT JOIN POSLOG..TR_SALE_PAY TSP \n" + " ON TSH.CMP_CD = TSP.CMP_CD \n" + " AND TSH.SALE_DT = TSP.SALE_DT \n" + " AND TSH.STOR_CD = TSP.STOR_CD \n" + " AND TSH.POS_NO = TSP.POS_NO \n" + " AND TSH.TRADE_NO = TSP.TRADE_NO \n" + " AND TSP.PAY_DTL_CD_05 = '1' \n" + " AND TSP.CANCEL_DIV = '0' \n" + " WHERE TSH.CMP_CD = '{0}' \n" + " AND TSH.SALE_DT = '{1}' \n" + " AND TSH.STOR_CD = '{2}' \n" + " AND TSH.POS_NO = '{3}' \n" + " AND TSH.TRADE_NO = '{4}' \n" + " AND TSH.TRAIN_MODE_YN = '0' \n" + " AND TSH.TRADE_KINDPER = '00' \n" + " ) B \n" + " , ( \n" + " SELECT SUM(CASE WHEN ISNULL(TSD.SALE_AMT, 0) = 0 \n" + " THEN 0 \n" + " ELSE 1 \n" + " END) AS TRDTL_CNT \n" + " , SUM(CASE WHEN ISNULL(TSD.APPLY_TAX_AMT, 0) = 0 \n" + " THEN 0 \n" + " ELSE ISNULL(TSD.BILL_AMT, 0) - ISNULL(TSD.APPLY_TAX_AMT, 0) \n" + " END) AS VAT_SALE_AMT \n" + " , SUM(CASE WHEN ISNULL(TSD.APPLY_TAX_AMT, 0) = 0 \n" + " THEN ISNULL(TSD.SALE_AMT, 0) \n" + " ELSE 0 \n" + " END) AS NO_VAT_SALE_AMT \n" + " FROM POSLOG..TR_SALE_HEADER TSH \n" + " LEFT JOIN POSLOG..TR_SALE_DETAIL TSD \n" + " ON TSH.CMP_CD = TSD.CMP_CD \n" + " AND TSH.SALE_DT = TSD.SALE_DT \n" + " AND TSH.STOR_CD = TSD.STOR_CD \n" + " AND TSH.POS_NO = TSD.POS_NO \n" + " AND TSH.TRADE_NO = TSD.TRADE_NO \n" + " AND TSD.CANCEL_DIV = '0' \n" + " WHERE TSH.CMP_CD = '{0}' \n" + " AND TSH.SALE_DT = '{1}' \n" + " AND TSH.STOR_CD = '{2}' \n" + " AND TSH.POS_NO = '{3}' \n" + " AND TSH.TRADE_NO = '{4}' \n" + " AND TSH.TRAIN_MODE_YN = '0' \n" + " AND TSH.TRADE_KINDPER = '00' \n" + " ) C \n" + " , ( \n" + " SELECT SUM(CASE WHEN TSE.ETC_WAY_CD = '00' \n" + " THEN 1 \n" + " ELSE 0 \n" + " END) AS TRCSH_CNT \n" + " , ISNULL(SUM(TSE.ETC_AMT), 0) AS CASH_BILL_AMT \n" + " FROM POSLOG..TR_SALE_HEADER TSH \n" + " LEFT JOIN POSLOG..TR_SALE_ETC TSE \n" + " ON TSH.CMP_CD = TSE.CMP_CD \n" + " AND TSH.SALE_DT = TSE.SALE_DT \n" + " AND TSH.STOR_CD = TSE.STOR_CD \n" + " AND TSH.POS_NO = TSE.POS_NO \n" + " AND TSH.TRADE_NO = TSE.TRADE_NO \n" + " AND TSE.ETC_WAY_CD = '00' \n" + " WHERE TSH.CMP_CD = '{0}' \n" + " AND TSH.SALE_DT = '{1}' \n" + " AND TSH.STOR_CD = '{2}' \n" + " AND TSH.POS_NO = '{3}' \n" + " AND TSH.TRADE_NO = '{4}' \n" + " AND TSH.TRAIN_MODE_YN = '0' \n" + " AND TSH.TRADE_KINDPER = '00' \n" + " ) D \n" + " WHERE A.CMP_CD = '{0}' \n" + " AND A.SALE_DT = '{1}' \n" + " AND A.STOR_CD = '{2}' \n" + " AND A.POS_NO = '{3}' \n" + " AND A.TRADE_NO = '{4}' \n" + " AND A.TRAIN_MODE_YN = '0' \n" + " AND A.TRADE_KINDPER = '00' \n"; sQuery = string.Format(sSelQuery, sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); } 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 dtReturn; } private DataTable GetTranDetailForEx(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo) { string sQuery = string.Empty; string sSelQuery = string.Empty; StringBuilder sb = new StringBuilder(); DataTable dtReturn = null; try { sSelQuery = "SELECT A.SEQ \n" + " , CASE WHEN B.TRADE_DIV = '0' \n" + " THEN 'Y' \n" + " ELSE 'N' \n" + " END AS SALE_YN \n" + " , C.ENTR_CMP_ITEM_CD AS PROD_CD \n" + " , CASE WHEN A.ITEM_DIV = '0' \n" + " THEN '0' \n" + " ELSE '1' \n" + " END AS PROD_TYPE_FG \n" + " , CASE WHEN A.ITEM_TAX_DIV = '0' OR A.NOTAX_DIV = '1' \n" + " THEN 'N' \n" + " ELSE 'Y' \n" + " END AS TAX_YN \n" + " , CASE WHEN A.TAKE_IN_OUT_DIV = '0' \n" + " THEN '0' \n" + " ELSE '2' \n" + " END AS DLV_PACK_FG \n" + " , CASE WHEN A.SALE_AMT = A.BILL_AMT \n" + " THEN A.SALE_PRC \n" + " ELSE A.BILL_AMT / A.SALE_QTY \n" + " END AS NORMAL_UPRC \n" + " , ISNULL(A.SALE_QTY, 0) AS SALE_QTY \n" + " , CASE WHEN A.SALE_AMT = A.BILL_AMT \n" + " THEN A.SALE_PRC \n" + " ELSE A.BILL_AMT / A.SALE_QTY \n" + " END AS SALE_UPRC \n" + " , ISNULL(A.BILL_AMT, 0) AS SALE_AMT \n" + " , ISNULL(A.ITEM_DC_AMT, 0) + ISNULL(A.SUM_DC_AMT, 0) + \n" + " ISNULL(A.CPI_DC_AMT, 0) + ISNULL(A.COOP_CARD_DC_AMT, 0) + \n" + " ISNULL(A.POINT_DC_AMT, 0) + ISNULL(A.CPN_DC_AMT, 0) + \n" + " ISNULL(A.EMP_DC_AMT, 0) + ISNULL(A.SET_DC_AMT, 0) + \n" + " ISNULL(A.ETC_DC_AMT, 0) + ISNULL(A.EXCEP_DC_AMT, 0) AS DC_AMT \n" + " , 0 AS ETC_AMT \n" + " , 0 AS SVC_TIP_AMT \n" + " , ISNULL(A.BILL_AMT, 0) AS DCM_SALE_AMT \n" + " , ISNULL(A.APPLY_TAX_AMT, 0) AS VAT_AMT \n" + " , B.SALE_DT + B.PAY_TIME AS INS_DT \n" + " FROM POSLOG..TR_SALE_DETAIL A \n" + " , POSLOG..TR_SALE_HEADER B \n" + " , POSMST..MST_OUT_SD_VEND_ITEM C \n" + " WHERE A.CMP_CD = '{0}' \n" + " AND A.SALE_DT = '{1}' \n" + " AND A.STOR_CD = '{2}' \n" + " AND A.POS_NO = '{3}' \n" + " AND A.TRADE_NO = '{4}' \n" + " AND A.CMP_CD = B.CMP_CD \n" + " AND A.SALE_DT = B.SALE_DT \n" + " AND A.STOR_CD = B.STOR_CD \n" + " AND A.POS_NO = B.POS_NO \n" + " AND A.TRADE_NO = B.TRADE_NO \n" + " AND A.CMP_CD = C.CMP_CD \n" + " AND A.ITEM_PLU_CD = C.ITEM_CD \n" + " AND B.TRAIN_MODE_YN = '0' \n" + " AND B.TRADE_KINDPER = '00' \n" + " AND A.CANCEL_DIV = '0' \n" + " AND C.USE_YN = '1' \n" + " ORDER BY A.SEQ \n"; sQuery = string.Format(sSelQuery, sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); } 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 dtReturn; } private DataTable GetTranCashDataForEx(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo) { string sQuery = string.Empty; string sSelQuery = string.Empty; StringBuilder sb = new StringBuilder(); DataTable dtReturn = null; try { sSelQuery = "SELECT CASE WHEN B.TRADE_DIV = '0' \n" + " THEN 'Y' \n" + " ELSE 'N' \n" + " END AS SALE_YN \n" + " , ISNULL(A.ETC_AMT, 0) AS APPR_AMT \n" + " , 0 AS SVC_TIP_AMT \n" + " , ISNULL(A.AMT_ENTRY_03, 0) AS VAT_AMT \n" + " , CASE WHEN A.OCCUR_ENTRY_09 = '0' \n" + " THEN '1' \n" + " ELSE '2' \n" + " END AS APPR_PROC_FG \n" + " , CASE WHEN A.OCCUR_ENTRY_08 = '0' \n" + " THEN '1' \n" + " ELSE '2' \n" + " END AS APPR_IDT_TYPE \n" + " , CASE WHEN SUBSTRING(A.OCCUR_ENTRY_01, 1, 2) = '01' \n" + " THEN '2' \n" + " ELSE '3' \n" + " END AS APPR_IDT_FG \n" + " , 'K' AS CARD_IN_FG \n" + " , A.OCCUR_ENTRY_01 AS APPR_IDT_NO \n" + " , A.OCCUR_ENTRY_03 AS APPR_DATE \n" + " , A.OCCUR_ENTRY_04 AS APPR_TIME \n" + " , A.OCCUR_ENTRY_02 AS APPR_NO \n" + " , A.OCCUR_ENTRY_03 + A.OCCUR_ENTRY_04 AS INS_DT \n" + " FROM POSLOG..TR_SALE_ETC A \n" + " , POSLOG..TR_SALE_HEADER B \n" + " WHERE A.CMP_CD = '{0}' \n" + " AND A.SALE_DT = '{1}' \n" + " AND A.STOR_CD = '{2}' \n" + " AND A.POS_NO = '{3}' \n" + " AND A.TRADE_NO = '{4}' \n" + " AND A.ETC_WAY_CD = '80' \n" + " AND A.ETC_DTL_CD_01 = '00' \n" + " AND A.CMP_CD = B.CMP_CD \n" + " AND A.STOR_CD = B.STOR_CD \n" + " AND A.POS_NO = B.POS_NO \n" + " AND A.TRADE_NO = B.TRADE_NO \n" + " AND B.TRAIN_MODE_YN = '0' \n" + " AND B.TRADE_KINDPER = '00' \n"; sQuery = string.Format(sSelQuery, sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); } 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 dtReturn; } private DataTable GetTranCardDataForEx(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo) { string sQuery = string.Empty; string sSelQuery = string.Empty; StringBuilder sb = new StringBuilder(); DataTable dtReturn = null; try { sSelQuery = "SELECT '01' AS SEQ_NO \n" + " , '02' AS VAN_CD \n" + " , CASE WHEN B.TRADE_DIV = '0' \n" + " THEN 'Y' \n" + " ELSE 'N' \n" + " END AS SALE_YN \n" + " , CASE WHEN A.OCCUR_ENTRY_08 = '0' \n" + " THEN '1' \n" + " ELSE '2' \n" + " END AS APPR_PROC_FG \n" + " , A.OCCUR_ENTRY_01 AS CRD_CARD_NO \n" + " , ISNULL(A.PAY_AMT, 0) AS APPR_REQ_AMT \n" + " , 0 AS SVC_TIP_AMT \n" + " , ISNULL(A.PAY_AMT, 0) - ROUND(A.PAY_AMT / 1.1, 0) AS VAT_AMT \n" + " , CASE WHEN A.OCCUR_ENTRY_14 = '00' \n" + " THEN '0' \n" + " ELSE '1' \n" + " END AS INST_MM_FG \n" + " , A.OCCUR_ENTRY_14 AS INST_MM_CNT \n" + " , CASE WHEN A.OCCUR_ENTRY_17 = '0' \n" + " THEN 'N' \n" + " ELSE 'Y' \n" + " END AS SIGN_PAD_YN \n" + " , CASE WHEN A.OCCUR_ENTRY_05 = 'K' \n" + " THEN 'K' \n" + " ELSE 'S' \n" + " END AS CARD_IN_FG \n" + " , A.OCCUR_ENTRY_03 AS APPR_DATE \n" + " , A.OCCUR_ENTRY_04 AS APPR_TIME \n" + " , A.OCCUR_ENTRY_02 AS APPR_NO \n" + " , A.OCCUR_ENTRY_11 AS PUR_CRDCP_CD \n" + " , A.OCCUR_ENTRY_12 AS PUR_CRDCP_NM \n" + " , ISNULL(A.PAY_AMT, 0) AS APPR_AMT \n" + " , A.OCCUR_ENTRY_18 AS CRDCP_TERM_NO \n" + " , A.OCCUR_ENTRY_03 + A.OCCUR_ENTRY_04 AS INS_DT \n" + " FROM POSLOG..TR_SALE_PAY A \n" + " , POSLOG..TR_SALE_HEADER B \n" + " WHERE A.CMP_CD = '{0}' \n" + " AND A.SALE_DT = '{1}' \n" + " AND A.STOR_CD = '{2}' \n" + " AND A.POS_NO = '{3}' \n" + " AND A.TRADE_NO = '{4}' \n" + " AND A.PAY_WAY_CD = '02' \n" + " AND A.PAY_DTL_CD_05 = '1' \n" + " AND A.CANCEL_DIV = '0' \n" + " AND A.CMP_CD = B.CMP_CD \n" + " AND A.SALE_DT = B.SALE_DT \n" + " AND A.STOR_CD = B.STOR_CD \n" + " AND A.POS_NO = B.POS_NO \n" + " AND A.TRADE_NO = B.TRADE_NO \n" + " AND B.TRAIN_MODE_YN = '0' \n" + " AND B.TRADE_KINDPER = '00' \n"; sQuery = string.Format(sSelQuery, sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); } 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 dtReturn; } #endregion 07 - 도로공사(고속도로 휴게소 입점 POS) 매출 I/F XML파일 생성 #region 08 - 도로공사(고속도로 휴게소 입점 POS) 매출 전송 public void TranSendToExProcess() { string sCmpCd = ""; string sStoreNo = ""; string sPosNo = ""; string sSaleDate = ""; string sTradeNo = ""; string sendFlag = "8"; try { DirectoryInfo di = new DirectoryInfo(BaseCom.NxDataPath + "SEND\\EX\\"); FileInfo[] xmlFiles = di.GetFiles("*.xml"); if(xmlFiles.Length < 1) { return; } else { iSendDataCnt += 1; } for(int nLoop = 0;nLoop < xmlFiles.Length;nLoop++) { // 도로공사 매출전송 파일은 한번에 5개씩만 보낸다. if(nLoop >= 5) { break; } FileInfo fi = xmlFiles[nLoop]; string[] sFile = fi.Name.Split(new char[] {'.'}, StringSplitOptions.RemoveEmptyEntries); string sFileFullName = fi.FullName; string[] sFileName = sFile[0].Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries); string sFileExtension = sFile[1]; string sFileType = sFileName[0].Trim(); sCmpCd = sFileName[1].Trim(); sStoreNo = sFileName[2].Trim(); sPosNo = sFileName[3].Trim(); sSaleDate = sFileName[4].Trim(); sTradeNo = sFileName[5].Trim(); string sUrl = string.Empty; if(sFileType == "H1") { //sUrl = sExTranUrl; sUrl = m_cPosStatus.Mst.ETC_IF_URL1; } else { //sUrl = sExCalcUrl; sUrl = m_cPosStatus.Mst.ETC_IF_URL2; } XmlDocument doc = new XmlDocument(); doc.Load(sFileFullName); string recvData = string.Empty; if(Http_SendReceive(sUrl, doc, ref recvData) == BaseCom.OK) { if(recvData.IndexOf("RETCD=") > 0) { string sRetCd = recvData.Substring(recvData.IndexOf("RETCD=") + 6, 4); if(sRetCd == "0000") { if (iErrorCount > 0) iErrorCount -= 1; sendFlag = "1"; fi.Delete(); System.Threading.Thread.Sleep(50); } else { iErrorCount += 1; sendFlag = "9"; } } } else { iErrorCount += 1; sendFlag = "9"; } } } 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); sendFlag = "9"; } finally { // Flag Update OutsideTranSendFlgUpdate(sCmpCd, sStoreNo, sPosNo, sSaleDate, sTradeNo, sendFlag); } } private int Http_SendReceive(string sUrl, XmlDocument xmlDoc, ref string recvData) { int iRet = BaseCom.NG; try { HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sUrl); req.Method = "POST"; req.ContentType = "text/xml"; req.Timeout = 30 * 1000; // create our stream to send Stream webDataStream = req.GetRequestStream(); xmlDoc.Save(webDataStream); webDataStream.Close(); // get the response from out stream WebResponse resp = req.GetResponse(); webDataStream = resp.GetResponseStream(); // convert the result into a string StreamReader respStreamReader = new StreamReader(webDataStream); string respFromServer = respStreamReader.ReadToEnd(); recvData = respFromServer; respStreamReader.Close(); iRet = BaseCom.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; } #endregion 08 - 도로공사(고속도로 휴게소 입점 POS) 매출 전송 #region 09 - 한국공항공사 매출 I/F //public void TranSendToKacProcess() //{ // string sCmpCd = string.Empty; // string sSaleDt = string.Empty; // string sStorCd = string.Empty; // string sPosNo = string.Empty; // string sTradeNo = string.Empty; // string sendFlag = "0"; // DataTable dtReturn = null; // try // { // // 전송할 데이터 조회 // GetTranInfo(ref dtReturn); // if(dtReturn == null || dtReturn.Rows.Count == 0) // { // return; // } // else // { // iSendDataCnt += 1; // } // sendFlag = "0"; // 0:미전송, 1:전송, 9:에러 // DataRow dr = dtReturn.Rows[0]; // sCmpCd = CmUtil.GetDataRowStr(dr, "CMP_CD"); // sSaleDt = CmUtil.GetDataRowStr(dr, "SALE_DT"); // sStorCd = CmUtil.GetDataRowStr(dr, "STOR_CD"); // sPosNo = CmUtil.GetDataRowStr(dr, "POS_NO"); // sTradeNo = CmUtil.GetDataRowStr(dr, "TRADE_NO"); // Column.KACReceiptHeader header = new Column.KACReceiptHeader(); // ArrayList alKACItems = new ArrayList(); // // 전송할 매출 데이터 생성 // MakeTranToKacProcess(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo, ref header, ref alKACItems); // string sReturn = SaveDataToDb("HEAD", sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo, header, alKACItems, null); // if(sReturn == UserCom.RST_OK) // { // sendFlag = "1"; // } // else // { // sendFlag = "9"; // } // } // 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); // sendFlag = "9"; // } // finally // { // // Flag Update // OutsideTranSendFlgUpdate(sCmpCd, sStorCd, sPosNo, sSaleDt, sTradeNo, sendFlag); // } //} ///// ///// 매출저장 ///// ///// ///// ///// ///// ///// ///// ///// ///// ///// //public string SaveDataToDb(string sSendType, string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo, Column.KACReceiptHeader cHeader, ArrayList alItems, Column.KACCalcData cCalcData) //{ // string sReturn = UserCom.RST_ERR; // int iItemCount = 0; // StringBuilder sbTranHeader = new StringBuilder(""); // StringBuilder sbTranItem = new StringBuilder(""); // try // { // //string sDbConNo = string.Format("{0, -10}", m_cPosStatus.Base.KacConNo); // //string sDbConNo = string.Format("{0, -10}", m_cPosStatus.Base.OutSDVendConNo); // string sDbConNo = string.Format("{0, -10}", m_cPosStatus.Mst.JOIN_STOR_CD); // string sDbStorCd = string.Format("{0, -10}", sStorCd); // string sDbPosNo = string.Format("{0, -10}", sPosNo); // string sDbTradeNo = string.Format("{0, -30}", sTradeNo); // if (sSendType == "HEAD") // { // sbTranHeader.Append(cHeader.CON_NO); // 계약번호(ERP상의 계약번호) // sbTranHeader.Append(cHeader.SALE_DT); // 영업일자 // sbTranHeader.Append(cHeader.STORE_CD); // 점번호 // sbTranHeader.Append(cHeader.POS_NO); // POS번호 // sbTranHeader.Append(cHeader.RECEIPT_SEQ); // 순차적으로 증가되는 값 // sbTranHeader.Append(cHeader.RECEIPT_NO); // 영수증번호 // sbTranHeader.Append(cHeader.ITEM_QTY); // 아이템 건수 // sbTranHeader.Append(cHeader.SALE_TM); // 매출시간 // sbTranHeader.Append(cHeader.CANCEL_YN); // 영수증 취소 여부(0:정상, 1:취소) // sbTranHeader.Append(cHeader.TOT_AMT); // 총매출금액 // sbTranHeader.Append(cHeader.SALE_AMT); // 매가금액(공급가액) // sbTranHeader.Append(cHeader.TAX_AMT); // 부가세금액 // sbTranHeader.Append(cHeader.CASH_AMT); // 현금금액 // sbTranHeader.Append(cHeader.CARD_AMT); // 카드금액 // sbTranHeader.Append(cHeader.ETC_AMT); // 기타금액 // sbTranHeader.Append(cHeader.CASH_YN); // 복합결제유문 발행 여부(복합결제 : 0, 현금결제만 : 1) // sbTranHeader.Append(cHeader.CASH_RECEIPT_YN); // 현금영수증 발행 여부(발행 : 0, 미발행 : 1) // sbTranHeader.Append(cHeader.BUY_NM); // 구매자명 // sbTranHeader.Append(cHeader.BUY_COUN_CD); // 구매자국가코드 // sbTranHeader.Append(cHeader.BUY_SEX_CD); // 구매자성별 // sbTranHeader.Append(cHeader.BUY_BIRTHDAY); // 구매자생년월일 // sbTranHeader.Append(cHeader.BUY_AGE); // 구매자나이 // sbTranHeader.Append(cHeader.AIR_NO); // 항공기정보 // sbTranHeader.Append(cHeader.CREATE_DT); // 영수증생성일자 // foreach (Column.KACReceiptItem item in alItems) // { // sbTranItem.Append(item.CON_NO); // sbTranItem.Append(item.SALE_DT); // sbTranItem.Append(item.STORE_CD); // sbTranItem.Append(item.POS_NO); // sbTranItem.Append(item.RECEIPT_NO); // sbTranItem.Append(item.PROC_SEQ); // sbTranItem.Append(item.PROD_CD); // sbTranItem.Append(item.PROD_NM); // sbTranItem.Append(item.QTY); // sbTranItem.Append(item.UNIT_PRICE); // sbTranItem.Append(item.AMT); // sbTranItem.Append(item.CREATE_DT); // iItemCount++; // } // } // else // { // sbTranHeader.Append(cCalcData.CON_NO); // 계약번호 // sbTranHeader.Append(cCalcData.SALE_DT); // 영업일자 // sbTranHeader.Append(cCalcData.STORE_CD); // 점번호 // sbTranHeader.Append(cCalcData.POS_NO); // POS번호 // sbTranHeader.Append(cCalcData.RECEIPT_SEQ); // 순차적으로 증가되는 값 // sbTranHeader.Append(cCalcData.RECEIPT_NO); // 영수증번호 // sbTranHeader.Append(cCalcData.SALE_TM); // 매출일시 // sbTranHeader.Append(cCalcData.RECEIPT_QTY); // 매출건수 // sbTranHeader.Append(cCalcData.TOTAL_AMT); // 총매출금액 // sbTranHeader.Append(cCalcData.SALE_AMT); // 총공급가액 // sbTranHeader.Append(cCalcData.TAX_AMT); // 총부가세금액 // sbTranHeader.Append(cCalcData.CASH_AMT); // 총현금금액 // sbTranHeader.Append(cCalcData.CARD_AMT); // 총카드금액 // sbTranHeader.Append(cCalcData.ETC_AMT); // 총기타금액 // sbTranHeader.Append(cCalcData.CREATE_DT); // 생성일자 // iItemCount = int.Parse(cCalcData.RECEIPT_QTY.Trim()); // 아이템건수(마감은 총매출건수) // } // try // { // int iRet = ReceiptDB(sSendType, sDbConNo, sSaleDt, sDbStorCd, sDbPosNo, sDbTradeNo, sbTranHeader.ToString(), iItemCount, sbTranItem.ToString()); // if(iRet == 0) // { // sReturn = UserCom.RST_OK; // } // } // catch(Exception ex){} // } // 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 sReturn; //} //private void MakeTranToKacProcess(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo, ref Column.KACReceiptHeader header, ref ArrayList alKACItems) //{ // try // { // DataTable dtHeader = GetTranHeaderForKac(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); // DataTable dtDetail = GetTranDetailForKac(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); // DataTable dtCash = GetTranCashForKac(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); // double dBillAmt = 0; // 영수금액 // double dNetAmt = 0; // 순매출액(부가세제외) // double dVatAmt = 0; // 부가세 // int iTotalItem = 0; // 아이템 개수 // int iSaleQty = 0; // 아이템 수량 합계 // double dSaleUprc = 0; // 아이템 단가 합계 // double dSaleAmt = 0; // 아이템 영수금액 합계 // string sSysDate = CmUtil.GetDataRowStr(dtHeader.Rows[0], "SYS_DT"); // string sSaleTm = CmUtil.GetDataRowStr(dtHeader.Rows[0], "PAY_TIME"); // int iSign = CmUtil.GetDataRowStr(dtHeader.Rows[0], "TRADE_DIV") == "0" ? 1 : -1; // for (int nLoop = 0; nLoop < dtHeader.Rows.Count; nLoop++) // { // // 아이템은 최대 30개 까지만 전송 // if (nLoop > 29) break; // DataRow drData = dtHeader.Rows[nLoop]; // ////////////////////////////////////////////////////////////// // // 영수증 정보 item(매출정보) // // ////////////////////////////////////////////////////////////// // dBillAmt = iSign * CmUtil.GetDataRowDouble(drData, "BILL_AMT"); // dNetAmt = iSign * CmUtil.GetDataRowDouble(drData, "NET_TOT_AMT"); // dVatAmt = iSign * CmUtil.GetDataRowDouble(drData, "TAX_AMT"); // Column.KACReceiptItem item = new Column.KACReceiptItem(); // //item.CON_NO = m_cPosStatus.Base.KacConNo; // //item.CON_NO = m_cPosStatus.Base.OutSDVendConNo; // item.CON_NO = m_cPosStatus.Mst.JOIN_STOR_CD; // item.SALE_DT = sSaleDt; // item.STORE_CD = sStorCd; // item.POS_NO = sPosNo; // item.RECEIPT_NO = sTradeNo; // item.PROC_SEQ = CmUtil.GetDataRowStr(drData, "SEQ"); // string sItemCd = CmUtil.GetDataRowStr(drData, "ITEM_PLU_CD"); // item.PROD_CD = sItemCd; // item.PROD_NM = CmUtil.GetDataRowStr(SeletItemMstToItemCode(sItemCd).Rows[0], PosMst.MST_ITEM.DATA.SHTCUT_ITEMNM); // item.QTY = CmUtil.GetDataRowStr(drData, "SALE_QTY"); // item.UNIT_PRICE = CmUtil.GetDataRowStr(drData, "SALE_PRC"); // item.AMT = dBillAmt.ToString(); // item.CREATE_DT = sSysDate; // // ArrayList에 영수증아이템 정보 추가 // alKACItems.Add(item); // iSaleQty = iSaleQty + CmUtil.GetDataRowInt(drData, "SALE_QTY"); // dSaleUprc = dSaleUprc + CmUtil.GetDataRowDouble(drData, "SALE_PRC"); // dSaleAmt = dSaleAmt + dBillAmt; // iTotalItem++; // } // ////////////////////////////////////////////////////////////// // // 영수증 정보 item(매출정보) - TOTAL AMOUNT // // ////////////////////////////////////////////////////////////// // DataRow drDetail = dtDetail.Rows[0]; // double dTotAmt = iSign * CmUtil.GetDataRowDouble(drDetail, "TOTAL_AMT"); // double dCashAmt = iSign * CmUtil.GetDataRowDouble(drDetail, "CASH_AMT"); // double dCardAmt = iSign * CmUtil.GetDataRowDouble(drDetail, "CARD_AMT"); // double dEtcAmt = iSign * CmUtil.GetDataRowDouble(drDetail, "ETC_AMT"); // string sCashYn = CmUtil.GetDataRowStr(drDetail, "CASH_YN"); // ////////////////////////////////////////////////////////////// // // 영수증 정보 item(매출정보) - 현금영수증 발행 FLAG // // ////////////////////////////////////////////////////////////// // DataRow drCash = dtCash.Rows[0]; // string sCashReceiptYn = CmUtil.GetDataRowStr(drCash, "CASH_RECEIPT_YN"); // ////////////////////////////////////////////////////////////// // // 영수증 정보 header(매출정보) // // ////////////////////////////////////////////////////////////// // header.TRAN_TYPE = "TRAN"; // //header.CON_NO = m_cPosStatus.Base.KacConNo; // //header.CON_NO = m_cPosStatus.Base.OutSDVendConNo; // header.CON_NO = m_cPosStatus.Mst.JOIN_STOR_CD; // header.SALE_DT = sSaleDt; // header.STORE_CD = sStorCd; // header.POS_NO = sPosNo; // header.RECEIPT_SEQ = sTradeNo; // header.RECEIPT_NO = sTradeNo; // header.ITEM_QTY = iTotalItem.ToString(); // header.SALE_TM = sSaleTm; // header.CANCEL_YN = CmUtil.GetDataRowStr(dtHeader.Rows[0], "TRADE_DIV"); // header.TOT_AMT = dTotAmt.ToString(); // header.SALE_AMT = dNetAmt.ToString(); // header.TAX_AMT = dVatAmt.ToString(); // header.CASH_AMT = dCashAmt.ToString(); // header.CARD_AMT = dCardAmt.ToString(); // header.ETC_AMT = dEtcAmt.ToString(); // header.CASH_YN = sCashYn; // header.CASH_RECEIPT_YN = sCashReceiptYn; // header.BUY_NM = ""; // header.BUY_COUN_CD = ""; // header.BUY_SEX_CD = "9"; // header.BUY_BIRTHDAY = ""; // header.BUY_AGE = ""; // header.AIR_NO = ""; // header.CREATE_DT = sSysDate; // } // 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); // } //} //private DataTable GetTranHeaderForKac(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo) //{ // string sQuery = string.Empty; // StringBuilder sb = new StringBuilder(); // DataTable dtReturn = null; // try // { // sb.Append("SELECT TSH.SYS_DT AS SYS_DT "); // sb.Append(" , TSH.PAY_TIME AS PAY_TIME "); // sb.Append(" , TSH.TRADE_NO AS TRADE_NO "); // sb.Append(" , TSH.TRADE_DIV AS TRADE_DIV "); // sb.Append(" , TSH.ORG_BILL_NO AS VOID_NO "); // sb.Append(" , TSD.* "); // sb.Append(" , ISNULL(TSH.NET_SALE_AMT, 0) - ISNULL(TSH.TOT_VAT, 0) AS NET_TOT_AMT "); // sb.Append(" , ISNULL(TSH.TOT_VAT, 0) AS TAX_AMT "); // sb.Append(" FROM POSLOG..TR_SALE_HEADER TSH "); // sb.Append(" , POSLOG..TR_SALE_DETAIL TSD "); // sb.Append(" WHERE TSH.CMP_CD = '{0}' "); // sb.Append(" AND TSH.SALE_DT = '{1}' "); // sb.Append(" AND TSH.STOR_CD = '{2}' "); // sb.Append(" AND TSH.POS_NO = '{3}' "); // sb.Append(" AND TSH.TRADE_NO = '{4}' "); // sb.Append(" AND TSH.CMP_CD = TSD.CMP_CD "); // sb.Append(" AND TSH.SALE_DT = TSD.SALE_DT "); // sb.Append(" AND TSH.STOR_CD = TSD.STOR_CD "); // sb.Append(" AND TSH.POS_NO = TSD.POS_NO "); // sb.Append(" AND TSH.TRADE_NO = TSD.TRADE_NO "); // sQuery = string.Format(sb.ToString(), sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); // sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); // } // 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 dtReturn; //} //private DataTable GetTranDetailForKac(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo) //{ // string sQuery = string.Empty; // StringBuilder sb = new StringBuilder(); // DataTable dtReturn = null; // try // { // sb.Append("SELECT (ISNULL(A.CASH_AMT, 0) + ISNULL(B.CARD_AMT, 0) + ISNULL(C.ETC_AMT, 0)) AS TOTAL_AMT "); // sb.Append(" , ISNULL(A.CASH_AMT, 0) AS CASH_AMT "); // sb.Append(" , ISNULL(B.CARD_AMT, 0) AS CARD_AMT "); // sb.Append(" , ISNULL(C.ETC_AMT, 0) AS ETC_AMT "); // sb.Append(" , CASE WHEN ((A.CASH_AMT <> 0) AND (B.CARD_AMT = 0) AND (C.ETC_AMT = 0)) "); // sb.Append(" THEN '1' "); // sb.Append(" ELSE '0' "); // sb.Append(" END AS CASH_YN "); // sb.Append(" FROM ( "); // sb.Append(" SELECT SUM(ISNULL(PAY_AMT, 0)) AS CASH_AMT "); // sb.Append(" FROM POSLOG..TR_SALE_PAY "); // sb.Append(" WHERE CMP_CD = '{0}' "); // sb.Append(" AND SALE_DT = '{1}' "); // sb.Append(" AND STOR_CD = '{2}' "); // sb.Append(" AND POS_NO = '{3}' "); // sb.Append(" AND TRADE_NO = '{4}' "); // sb.Append(" AND PAY_WAY_CD = '" + ItemConst.TR_ITEM_ID.CASH_ITEM + "' "); // sb.Append(" ) A "); // sb.Append(" , ( "); // sb.Append(" SELECT SUM(ISNULL(PAY_AMT, 0)) AS CARD_AMT "); // sb.Append(" FROM POSLOG..TR_SALE_PAY "); // sb.Append(" WHERE CMP_CD = '{0}' "); // sb.Append(" AND SALE_DT = '{1}' "); // sb.Append(" AND STOR_CD = '{2}' "); // sb.Append(" AND POS_NO = '{3}' "); // sb.Append(" AND TRADE_NO = '{4}' "); // sb.Append(" AND PAY_WAY_CD = '" + ItemConst.TR_ITEM_ID.CREDITCARD_ITEM + "' "); // sb.Append(" ) B "); // sb.Append(" , ( "); // sb.Append(" SELECT SUM(ISNULL(PAY_AMT, 0)) AS ETC_AMT "); // sb.Append(" FROM POSLOG..TR_SALE_PAY "); // sb.Append(" WHERE CMP_CD = '{0}' "); // sb.Append(" AND SALE_DT = '{1}' "); // sb.Append(" AND STOR_CD = '{2}' "); // sb.Append(" AND POS_NO = '{3}' "); // sb.Append(" AND TRADE_NO = '{4}' "); // sb.Append(" AND PAY_WAY_CD <> '" + ItemConst.TR_ITEM_ID.CASH_ITEM + "' "); // sb.Append(" AND PAY_WAY_CD <> '" + ItemConst.TR_ITEM_ID.CREDITCARD_ITEM + "' "); // sb.Append(" ) C "); // sQuery = string.Format(sb.ToString(), sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); // sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); // } // 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 dtReturn; //} //private DataTable GetTranCashForKac(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo) //{ // string sQuery = string.Empty; // StringBuilder sb = new StringBuilder(); // DataTable dtReturn = null; // try // { // sb.Append("SELECT TSH.TRADE_NO AS BILL_NO "); // sb.Append(" , TSH.ORG_BILL_NO AS VOID_NO "); // sb.Append(" , TSH.TRADE_DIV AS SALEH_DIV "); // sb.Append(" , CASE WHEN (ISNULL(TSE.OCCUR_ENTRY_02, 0) = 0) "); // sb.Append(" THEN '0' "); // sb.Append(" ELSE '1' "); // sb.Append(" END AS CASH_RECEIPT_YN "); // sb.Append(" FROM POSLOG..TR_SALE_HEADER TSH "); // sb.Append(" LEFT JOIN POSLOG..TR_SALE_ETC TSE "); // sb.Append(" ON TSH.CMP_CD = TSE.CMP_CD "); // sb.Append(" AND TSH.SALE_DT = TSE.SALE_DT "); // sb.Append(" AND TSH.STOR_CD = TSE.STOR_CD "); // sb.Append(" AND TSH.POS_NO = TSE.POS_NO "); // sb.Append(" AND TSH.TRADE_NO = TSE.TRADE_NO "); // sb.Append(" AND TSE.ETC_WAY_CD = '" + ItemConst.TR_ITEM_ID.ETC_INFO.CASHBILL + "' "); // sb.Append(" WHERE TSH.CMP_CD = '{0}' "); // sb.Append(" AND TSH.SALE_DT = '{1}' "); // sb.Append(" AND TSH.STOR_CD = '{2}' "); // sb.Append(" AND TSH.POS_NO = '{3}' "); // sb.Append(" AND TSH.TRADE_NO = '{4}' "); // sQuery = string.Format(sb.ToString(), sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); // sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); // } // 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 dtReturn; //} ///// ///// 상품마스터 조회 ///// ///// ///// //private DataTable SeletItemMstToItemCode(string sItemCode) //{ // string sQuery = ""; // DataTable dtReturn = null; // try // { // // 상품코드로 상품 마스터 조회 // sQuery += " SELECT * FROM POSMST..MST_ITEM "; // sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'"; // sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'"; // sQuery += " AND SUB_STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'"; // sQuery += " AND ITEM_CD = '" + sItemCode + "'"; // sQuery += " AND USE_YN = '" + PosConst.MST_USE_YN.YES + "'"; // sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); // } // 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 dtReturn; //} #endregion 09 - 한국공항공사 매출 I/F #region 10 - 긴급 메세지 읽음 전송(MST_EMG_NOTE) /// /// 긴급메세지 전송 메인 /// public void EmgNoteSendProcess() { DataTable dtReturn = null; Hashtable htData = null; string sSendFlag = string.Empty; string sMsgCode = string.Empty; string sStartDT = string.Empty; string sMsgDiv = string.Empty; try { // 전송할 Journal 데이터 생성 htData = GetEmgNoteData(ref dtReturn); if (dtReturn == null || dtReturn.Rows.Count == 0) { return; } else { iSendDataCnt += 1; } sStartDT = CmUtil.GetDataRowStr(dtReturn.Rows[0], Column.IQ_EMG_NOTE_SEND.DATA.START_DT); sMsgCode = CmUtil.GetDataRowStr(dtReturn.Rows[0], Column.IQ_EMG_NOTE_SEND.DATA.MSG_CODE); sMsgDiv = CmUtil.GetDataRowStr(dtReturn.Rows[0], Column.IQ_EMG_NOTE_SEND.DATA.MSG_DIV); string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, Convert.ToInt32(m_cPosStatus.Base.JrnlPort), Convert.ToInt32(m_cPosStatus.Base.JrnlTimeout), new string[] { m_cPosStatus.Base.CmpCd, m_cPosStatus.Base.BrandCd, m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.SaleDate, m_cPosStatus.Base.PosNo, m_cPosStatus.Base.TradeNo }, ItemConst.COMM_MSG_TYPE.EMG_NOTE_SEND, htData); if (sReturn == UserCom.RST_OK) { sSendFlag = "1"; // 정상 전송 m_cPosStatus.Sale.OnLineStatus = "1"; } else { sSendFlag = "9"; // 에러 m_cPosStatus.Sale.OnLineStatus = "0"; } } 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); sSendFlag = "9"; } finally { // Flag Update EmgNoteFlgUpdate(sStartDT, sMsgCode, sMsgDiv, sSendFlag); } } /// /// 전송 완료 업데이트 /// /// /// /// /// private int EmgNoteFlgUpdate(string sStartDT, string sMsgCode, string sMsgDiv, string sSendFlag) { int iRet = UserCom.NG; string sQuery = string.Empty; try { if (sStartDT.Trim() == "" || sMsgCode.Trim() == "" || sMsgDiv.Trim() == "") return iRet; sQuery += " UPDATE POSMST..MST_EMG_NOTE "; sQuery += " SET SEND_YN = '" + sSendFlag + "' "; //성공한것만 업데이트 시간 변경! if (sSendFlag == "1") sQuery += " , UPD_DT = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; sQuery += " WHERE 1 = 1 "; sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'"; sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'"; sQuery += " AND START_DT = '" + sStartDT + "'"; sQuery += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "'"; sQuery += " AND MSG_CODE = '" + sMsgCode + "' "; sQuery += " AND MSG_DIV = '" + sMsgDiv + "' "; iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); } 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; } /// /// 긴급메세지 전송 조회 /// /// /// public Hashtable GetEmgNoteData(ref DataTable dtReturn) { Hashtable htReturn = null; string sQuery = string.Empty; DataTable dtTempReturn = null; try { sQuery += " SELECT TOP 1 "; sQuery += " CMP_CD, STOR_CD, POS_NO, MSG_CODE, MSG_DIV, START_DT, UPD_DT, READ_YN "; sQuery += " FROM POSMST..MST_EMG_NOTE "; sQuery += " WHERE 1 = 1 "; sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'"; sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'"; sQuery += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "'"; sQuery += " AND START_DT BETWEEN CONVERT(VARCHAR,GETDATE()-7,112) AND CONVERT(VARCHAR,GETDATE(),112) "; //-7일 전부터 sQuery += " AND SEND_YN IN ('0','9') "; sQuery += " ORDER BY READ_YN, UPD_DT "; if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn.Rows.Count == 1) { DataRow drTempReturn = dtTempReturn.Rows[0]; htReturn = MakeEmgNoteJsonData(drTempReturn); } } dtReturn = dtTempReturn; } 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 htReturn; } /// /// 긴급메세지 전송 헤시테이블 담기 /// /// /// private Hashtable MakeEmgNoteJsonData(DataRow drData) { Hashtable htData = new Hashtable(); try { // 01 - 회사코드 htData.Add(Column.IQ_EMG_NOTE_SEND.DATA.CMP_CD, CmUtil.GetDataRowStr(drData, Column.IQ_EMG_NOTE_SEND.DATA.CMP_CD)); //"CMP_CD")); // 02 - 점포코드 htData.Add(Column.IQ_EMG_NOTE_SEND.DATA.STOR_CD, CmUtil.GetDataRowStr(drData, Column.IQ_EMG_NOTE_SEND.DATA.STOR_CD)); //"STOR_CD")); // 03 - 포스번호 htData.Add(Column.IQ_EMG_NOTE_SEND.DATA.POS_NO, CmUtil.GetDataRowStr(drData, Column.IQ_EMG_NOTE_SEND.DATA.POS_NO)); //"POS_NO")); // 04 - 메세지코드 htData.Add(Column.IQ_EMG_NOTE_SEND.DATA.MSG_CODE, CmUtil.GetDataRowStr(drData, Column.IQ_EMG_NOTE_SEND.DATA.MSG_CODE)); //"MSG_CODE")); // 05 - 메시지 구분별 유형 htData.Add(Column.IQ_EMG_NOTE_SEND.DATA.MSG_DIV, CmUtil.GetDataRowStr(drData, Column.IQ_EMG_NOTE_SEND.DATA.MSG_DIV)); // "MSG_DIV")); // 06 - 시작 시간 htData.Add(Column.IQ_EMG_NOTE_SEND.DATA.START_DT, CmUtil.GetDataRowStr(drData, Column.IQ_EMG_NOTE_SEND.DATA.START_DT)); // 07 - 업데이트 시간 htData.Add(Column.IQ_EMG_NOTE_SEND.DATA.UPD_DT, CmUtil.GetDataRowStr(drData, Column.IQ_EMG_NOTE_SEND.DATA.UPD_DT)); // "UPD_DT")); // 08 - 읽음 시간 - 2017-01-24 추가 htData.Add(Column.IQ_EMG_NOTE_SEND.DATA.READ_YN, CmUtil.GetDataRowStr(drData, Column.IQ_EMG_NOTE_SEND.DATA.READ_YN)); // "READ_YN")); } 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 htData; } #endregion #region 11 - 점포점검 내역 전송 (ITR 전송) public void StoreCheckSendProcess() { DataTable dtReturn = null; string sSendFlag = ""; string sCmpCd = ""; string sStorCd = ""; string sSaleDt = ""; string sInspctEntryGrpCd = ""; Hashtable htSendData = new Hashtable(); Hashtable htRecvData = new Hashtable(); try { // 전송할 점포점검 데이터 생성 string sStoreCheckLog = GetStoreCheckLog(ref dtReturn); if (dtReturn == null || dtReturn.Rows.Count == 0) { return; } else { iSendDataCnt += 1; } DataRow dr = dtReturn.Rows[0]; sCmpCd = CmUtil.GetDataRowStr(dr, Column.ETC_STOR_INSPCT_ANSWR_STOR.NAME.CMP_CD); sStorCd = CmUtil.GetDataRowStr(dr, Column.ETC_STOR_INSPCT_ANSWR_STOR.NAME.STOR_CD); sSaleDt = CmUtil.GetDataRowStr(dr, Column.ETC_STOR_INSPCT_ANSWR_STOR.NAME.START_DT); sInspctEntryGrpCd = CmUtil.GetDataRowStr(dr, Column.ETC_STOR_INSPCT_ANSWR_STOR.NAME.INSPCT_ENTRY_GRP_CD); htSendData = MakeStoreCheckLogJsonData(dr, sStoreCheckLog); string sReturn = ExecutePosIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.PayInqPort, 10000, htSendData, ref htRecvData, false); if (sReturn == UserCom.RST_OK) { sSendFlag = "1"; // 정상 전송 m_cPosStatus.Sale.OnLineStatus = "1"; } else { sSendFlag = "9"; // 에러 m_cPosStatus.Sale.OnLineStatus = "0"; } } 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); sSendFlag = "9"; } finally { // Flag Update StoreCheckFlgUpdate(sCmpCd, sStorCd, sSaleDt, sInspctEntryGrpCd, sSendFlag); } } private Hashtable MakeStoreCheckLogJsonData(DataRow drData, string sStoreCheckLog) { Hashtable htData = new Hashtable(); try { // 01 - INQ 종별 htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.INQ_TYPE, ItemConst.IRT_INQ_TYPE.STORE_CHECK_SAVE); // 02 - 점포 코드 htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.STOR_CD, CmUtil.GetDataRowStr(drData, Column.ETC_STOR_INSPCT_ANSWR_STOR.NAME.STOR_CD)); // 03 - 요청구분 htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.INQ_DIV, "1"); // 04 - 점포점검 데이터 htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.SAVE_DATA, sStoreCheckLog); // 05 - 응답 코드 htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.RES_CD, ""); } 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 htData; } private int StoreCheckFlgUpdate(string sCmpCd, string sStorCd, string sSaleDt, string sInspctEntryGrpCd, string sSendFlag) { int iRet = UserCom.NG; string sQuery = ""; try { if (sCmpCd.Trim() == "") return iRet; if (sSaleDt.Trim() == "") return iRet; if (sStorCd.Trim() == "") return iRet; sQuery = " UPDATE POSLOG..ETC_STOR_INSPCT_ANSWR_STOR "; sQuery += " SET SEND_YN = '" + sSendFlag + "' "; sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; sQuery += " AND START_DT = '" + sSaleDt + "' "; sQuery += " AND STOR_CD = '" + sStorCd + "' "; sQuery += " AND INSPCT_ENTRY_GRP_CD = '" + sInspctEntryGrpCd + "' "; iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); } 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; } public string GetStoreCheckLog(ref DataTable dtReturn) { string sQuery = ""; string sCMP_CD = ""; string sSTOR_CD = ""; string sSTART_DT = ""; string sINSPCT_ENTRY_GRP_CD = ""; string sStoreCheckData = ""; DataTable dtTempReturn = null; try { sQuery = " SELECT TOP 1 "; sQuery += " CMP_CD, INSPCT_ENTRY_GRP_CD, STOR_CD, START_DT "; sQuery += " FROM POSLOG..ETC_STOR_INSPCT_ANSWR_STOR "; sQuery += " WHERE SEND_YN <> '1' "; sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; sQuery += " ORDER BY SEND_YN, START_DT "; if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn.Rows.Count == 1) { DataRow drTempReturn = dtTempReturn.Rows[0]; sCMP_CD = drTempReturn[Column.ETC_STOR_INSPCT_ANSWR_STOR.NAME.CMP_CD].ToString(); sSTOR_CD = drTempReturn[Column.ETC_STOR_INSPCT_ANSWR_STOR.NAME.STOR_CD].ToString(); sSTART_DT = drTempReturn[Column.ETC_STOR_INSPCT_ANSWR_STOR.NAME.START_DT].ToString(); sINSPCT_ENTRY_GRP_CD = drTempReturn[Column.ETC_STOR_INSPCT_ANSWR_STOR.NAME.INSPCT_ENTRY_GRP_CD].ToString(); sStoreCheckData = GetStoreCheckHeader(sCMP_CD, sSTOR_CD, sSTART_DT, sINSPCT_ENTRY_GRP_CD) + GetStoreCheckDetail(sCMP_CD, sSTOR_CD, sSTART_DT, sINSPCT_ENTRY_GRP_CD); } } dtReturn = dtTempReturn; } 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 sStoreCheckData; } private string GetStoreCheckHeader(string sCMP_CD, string sSTOR_CD, string sSTART_DT, string sINSPCT_ENTRY_GRP_CD) { StringBuilder sbTranData = new StringBuilder(); string sQuery = ""; string sSQL = ""; DataTable dtTempReturn = null; try { sQuery += " SELECT '" + ItemConst.IRT_TRAN_TYPE.TranHeader + "' + '|' + ISNULL(CMP_CD, '') + '|' + ISNULL(INSPCT_ENTRY_GRP_CD, '') + '|' + ISNULL(STOR_CD, '') + '|' + ISNULL(START_DT, '') + '|' + ISNULL(ANSWR_YN, '') + '|' + "; sQuery += " ISNULL(ETC_CTNTS_1, '') + '|' + ISNULL(ETC_CTNTS_2, '') + '|' + ISNULL(ETC_CTNTS_3, '') + '|' + ISNULL(REG_USER_ID, '') + '|' + ISNULL(REG_DATE, '') + '|' + "; sQuery += " ISNULL(UPD_USER_ID, '') + '|' + ISNULL(UPD_DATE, '') AS STORE_CHECK_HEADER "; sQuery += " FROM POSLOG..ETC_STOR_INSPCT_ANSWR_STOR "; sQuery += " WHERE CMP_CD = '{0}' "; sQuery += " AND START_DT = '{1}' "; sQuery += " AND STOR_CD = '{2}' "; sQuery += " AND INSPCT_ENTRY_GRP_CD = '{3}' "; sSQL = string.Format(sQuery , sCMP_CD , sSTART_DT , sSTOR_CD , sINSPCT_ENTRY_GRP_CD); if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) { foreach (DataRow dr in dtTempReturn.Rows) { sbTranData.Append(dr[0].ToString()); } } } } 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 sbTranData.ToString(); } private string GetStoreCheckDetail(string sCMP_CD, string sSTOR_CD, string sSTART_DT, string sINSPCT_ENTRY_GRP_CD) { StringBuilder sbTranData = new StringBuilder(); string sQuery = ""; string sSQL = ""; DataTable dtTempReturn = null; try { sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranDetail + "' + '|' + ISNULL(CMP_CD, '') + '|' + ISNULL(BRAND_CD, '') + '|' + ISNULL(INSPCT_ENTRY_GRP_CD, '') + '|' + ISNULL(STOR_CD, '') + '|' + ISNULL(START_DT, '') + '|' + "; sQuery += " ISNULL(INSPCT_ENTRY_L_CLSS_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(INSPCT_ENTRY, 0)) + '|' + ISNULL(SEL_ENTRY_1_YN, '') + '|' + ISNULL(SEL_ENTRY_2_YN, '') + '|' + ISNULL(SEL_ENTRY_3_YN, '') + '|' + ISNULL(SEL_ENTRY_4_YN, '') + '|' + ISNULL(SEL_ENTRY_5_YN, '') + '|' +"; sQuery += " CONVERT(VARCHAR, ISNULL(SCORE_1, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SCORE_2, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SCORE_3, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SCORE_4, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SCORE_5, 0)) + '|' + "; sQuery += " ISNULL(SEL_ENTRY_1_CTNTS, '') + '|' + ISNULL(SEL_ENTRY_2_CTNTS, '') + '|' + ISNULL(SEL_ENTRY_3_CTNTS, '') + '|' + ISNULL(SEL_ENTRY_4_CTNTS, '') + '|' + ISNULL(SEL_ENTRY_5_CTNTS, 0) + '|' + "; sQuery += " ISNULL(NOTE, '') + '|' + ISNULL(REG_USER_ID, 0) + '|' + ISNULL(REG_DATE, '') + '|' + ISNULL(UPD_USER_ID, '') + '|' + ISNULL(UPD_DATE, '') AS STORE_CHECK_DETAIL "; sQuery += " FROM POSLOG..ETC_STOR_INSPCT_ANSWR "; sQuery += " WHERE CMP_CD = '{0}' "; sQuery += " AND START_DT = '{1}' "; sQuery += " AND STOR_CD = '{2}' "; sQuery += " AND INSPCT_ENTRY_GRP_CD = '{3}' "; sSQL = string.Format(sQuery , sCMP_CD , sSTART_DT , sSTOR_CD , sINSPCT_ENTRY_GRP_CD); if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) { foreach (DataRow dr in dtTempReturn.Rows) { sbTranData.Append(dr[0].ToString()); } } } } 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 sbTranData.ToString(); } #endregion #region 12 - 점포장비점검 내역 전송 (ITR 전송) public void StoreEquipCheckSendProcess() { DataTable dtReturn = null; string sSendFlag = ""; string sCmpCd = ""; string sStorCd = ""; string sSaleDt = ""; Hashtable htSendData = new Hashtable(); Hashtable htRecvData = new Hashtable(); try { // 전송할 점포점검 데이터 생성 string sStoreCheckLog = GetStoreEquipCheckLog(ref dtReturn); if (dtReturn == null || dtReturn.Rows.Count == 0) { return; } else { iSendDataCnt += 1; } DataRow dr = dtReturn.Rows[0]; sCmpCd = CmUtil.GetDataRowStr(dr, Column.ETC_STOR_EQU_CHECK_LIST.NAME.CMP_CD); sStorCd = CmUtil.GetDataRowStr(dr, Column.ETC_STOR_EQU_CHECK_LIST.NAME.STOR_CD); sSaleDt = CmUtil.GetDataRowStr(dr, Column.ETC_STOR_EQU_CHECK_LIST.NAME.SALE_DT); htSendData = MakeStoreEquipCheckLogJsonData(dr, sStoreCheckLog); string sReturn = ExecutePosIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.PayInqPort, 10000, htSendData, ref htRecvData, false); if (sReturn == UserCom.RST_OK) { sSendFlag = "1"; // 정상 전송 m_cPosStatus.Sale.OnLineStatus = "1"; } else { sSendFlag = "9"; // 에러 m_cPosStatus.Sale.OnLineStatus = "0"; } } 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); sSendFlag = "9"; } finally { // Flag Update StoreEquipCheckFlgUpdate(sCmpCd, sStorCd, sSaleDt, sSendFlag); } } private Hashtable MakeStoreEquipCheckLogJsonData(DataRow drData, string sStoreCheckLog) { Hashtable htData = new Hashtable(); try { // 01 - INQ 종별 htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.INQ_TYPE, ItemConst.IRT_INQ_TYPE.STR_EQUIP_CHECK_SAVE); // 02 - 점포 코드 htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.STOR_CD, CmUtil.GetDataRowStr(drData, Column.ETC_STOR_EQU_CHECK_LIST.NAME.STOR_CD)); // 03 - 요청구분 htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.INQ_DIV, "1"); // 04 - 점포점검 데이터 htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.SAVE_DATA, sStoreCheckLog); // 05 - 응답 코드 htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.RES_CD, ""); } 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 htData; } private int StoreEquipCheckFlgUpdate(string sCmpCd, string sStorCd, string sSaleDt, string sSendFlag) { int iRet = UserCom.NG; string sQuery = ""; try { if (sCmpCd.Trim() == "") return iRet; if (sSaleDt.Trim() == "") return iRet; if (sStorCd.Trim() == "") return iRet; sQuery = " UPDATE POSLOG..ETC_STOR_EQU_CHECK_LIST "; sQuery += " SET SEND_YN = '" + sSendFlag + "' "; sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; sQuery += " AND SALE_DT = '" + sSaleDt + "' "; sQuery += " AND STOR_CD = '" + sStorCd + "' "; iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); } 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; } public string GetStoreEquipCheckLog(ref DataTable dtReturn) { string sQuery = ""; string sCMP_CD = ""; string sSTOR_CD = ""; string sSTART_DT = ""; string sStoreCheckData = ""; DataTable dtTempReturn = null; try { sQuery = " SELECT TOP 1 "; sQuery += " CMP_CD, STOR_CD, SALE_DT "; sQuery += " FROM POSLOG..ETC_STOR_EQU_CHECK_LIST "; sQuery += " WHERE SEND_YN <> '1' "; sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; sQuery += " ORDER BY SEND_YN, SALE_DT "; if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn.Rows.Count == 1) { DataRow drTempReturn = dtTempReturn.Rows[0]; sCMP_CD = drTempReturn[Column.ETC_STOR_EQU_CHECK_LIST.NAME.CMP_CD].ToString(); sSTOR_CD = drTempReturn[Column.ETC_STOR_EQU_CHECK_LIST.NAME.STOR_CD].ToString(); sSTART_DT = drTempReturn[Column.ETC_STOR_EQU_CHECK_LIST.NAME.SALE_DT].ToString(); sStoreCheckData = GetStoreEquipCheckHeader(sCMP_CD, sSTOR_CD, sSTART_DT) + GetStoreEquipCheckDetail(sCMP_CD, sSTOR_CD, sSTART_DT); } } dtReturn = dtTempReturn; } 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 sStoreCheckData; } private string GetStoreEquipCheckHeader(string sCMP_CD, string sSTOR_CD, string sSALE_DT) { StringBuilder sbTranData = new StringBuilder(); string sQuery = ""; string sSQL = ""; DataTable dtTempReturn = null; try { sQuery += " SELECT '" + ItemConst.IRT_TRAN_TYPE.TranHeader + "' + '|' + ISNULL(CMP_CD, '') + '|' + ISNULL(STOR_CD, '') + '|' + ISNULL(SALE_DT, '') + '|' + ISNULL(CHECK_STATE, '') + '|' + "; sQuery += " ISNULL(REG_USER_ID, '') + '|' + ISNULL(REG_DATE, '') + '|' + ISNULL(UPD_USER_ID, '') + '|' + ISNULL(UPD_DATE, '') AS STORE_EQUIP_CHECK_HEADER "; sQuery += " FROM POSLOG..ETC_STOR_EQU_CHECK_LIST "; sQuery += " WHERE CMP_CD = '{0}' "; sQuery += " AND SALE_DT = '{1}' "; sQuery += " AND STOR_CD = '{2}' "; sSQL = string.Format(sQuery , sCMP_CD , sSALE_DT , sSTOR_CD); if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) { foreach (DataRow dr in dtTempReturn.Rows) { sbTranData.Append(dr[0].ToString()); } } } } 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 sbTranData.ToString(); } private string GetStoreEquipCheckDetail(string sCMP_CD, string sSTOR_CD, string sSALE_DT) { StringBuilder sbTranData = new StringBuilder(); string sQuery = ""; string sSQL = ""; DataTable dtTempReturn = null; try { sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranDetail + "' + '|' + ISNULL(CMP_CD, '') + '|' + ISNULL(STOR_CD, '') + '|' + ISNULL(SALE_DT, '') + '|' + "; sQuery += " ISNULL(CHECK_DIV_CD, '') + '|' + ISNULL(CHECK_EQU_CD, '') + '|' + ISNULL(CHECK_RESULT, '') + '|' + ISNULL(AS_RESULT, '') + '|' + ISNULL(STOR_RESULT, '') + '|' + "; sQuery += " ISNULL(REG_USER_ID, 0) + '|' + ISNULL(REG_DATE, '') + '|' + ISNULL(UPD_USER_ID, '') + '|' + ISNULL(UPD_DATE, '') AS STORE_EQUIP_CHECK_DETAIL "; sQuery += " FROM POSLOG..ETC_STOR_EQU_CHECK_DETAIL "; sQuery += " WHERE CMP_CD = '{0}' "; sQuery += " AND SALE_DT = '{1}' "; sQuery += " AND STOR_CD = '{2}' "; sSQL = string.Format(sQuery , sCMP_CD , sSALE_DT , sSTOR_CD); if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) { foreach (DataRow dr in dtTempReturn.Rows) { sbTranData.Append(dr[0].ToString()); } } } } 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 sbTranData.ToString(); } #endregion #region 13 - SCALE Log 전송 public void ScaleLogSendProcess() { DataTable dtReturn = null; Hashtable htData = null; string sSendFlag = string.Empty; string sCmpCd = string.Empty; string sBrandCd = string.Empty; string sStorCd = string.Empty; string sSaleDt = string.Empty; string sPosNo = string.Empty; string sScaleDt = string.Empty; string sScaleTm = string.Empty; try { // 전송할 Scale Log 데이터 생성 htData = GetScaleLogData(ref dtReturn); if(dtReturn == null || dtReturn.Rows.Count == 0) { return; } else { iSendDataCnt += 1; } sCmpCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "CMP_CD"); sBrandCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "BRAND_CD"); sStorCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STOR_CD"); sSaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SALE_DT"); sPosNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "POS_NO"); sScaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SCALE_DT"); sScaleTm = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SCALE_TM"); string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, Convert.ToInt32(m_cPosStatus.Base.ScaleLogPort), 5000, new string[] { sCmpCd, sBrandCd, sStorCd, sSaleDt, sPosNo, "" }, ItemConst.COMM_MSG_TYPE.SCALE_LOG, htData); if(sReturn == UserCom.RST_OK) { sSendFlag = "1"; // 정상 전송 m_cPosStatus.Sale.OnLineStatus = "1"; } else { sSendFlag = "9"; // 에러 m_cPosStatus.Sale.OnLineStatus = "0"; } } 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); sSendFlag = "9"; } finally { // Flag Update ScaleLogFlgUpdate(sCmpCd, sBrandCd, sSaleDt, sStorCd, sPosNo, sScaleDt, sScaleTm, sSendFlag); } } public Hashtable GetScaleLogData(ref DataTable dtReturn) { Hashtable htReturn = null; string sQuery = string.Empty; DataTable dtTempReturn = null; try { sQuery += "SELECT TOP 1 "; sQuery += " CMP_CD, BRAND_CD, SALE_DT, STOR_CD, POS_NO "; sQuery += " , SCALE_DT, SCALE_TM, WEIGHT, ITEM_NM, NORMAL_YN "; sQuery += " FROM POSLOG..ETC_SCALE_LOG "; sQuery += " WHERE SEND_YN <> '1' "; sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; sQuery += " ORDER BY SEND_YN, SALE_DT "; if(sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if(dtTempReturn.Rows.Count == 1) { DataRow drTempReturn = dtTempReturn.Rows[0]; htReturn = MakeScaleLogJsonData(drTempReturn); } } dtReturn = dtTempReturn; } 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 htReturn; } private Hashtable MakeScaleLogJsonData(DataRow drData) { Hashtable htData = new Hashtable(); try { // 01 - 회사코드 htData.Add(Column.IQ_SCALE_LOG_REQ.DATA.CmpCd, CmUtil.GetDataRowStr(drData, "CMP_CD")); // 02 - 점포코드 htData.Add(Column.IQ_SCALE_LOG_REQ.DATA.StorCd, CmUtil.GetDataRowStr(drData, "STOR_CD")); // 03 - 판매일자 htData.Add(Column.IQ_SCALE_LOG_REQ.DATA.SaleDt, CmUtil.GetDataRowStr(drData, "SALE_DT")); // 04 - 포스번호 htData.Add(Column.IQ_SCALE_LOG_REQ.DATA.PosNo, CmUtil.GetDataRowStr(drData, "POS_NO")); // 05 - 측정일자 htData.Add(Column.IQ_SCALE_LOG_REQ.DATA.ScaleDt, CmUtil.GetDataRowStr(drData, "SCALE_DT")); // 06 - 측정시간 htData.Add(Column.IQ_SCALE_LOG_REQ.DATA.ScaleTm, CmUtil.GetDataRowStr(drData, "SCALE_TM")); // 07 - 중량 htData.Add(Column.IQ_SCALE_LOG_REQ.DATA.Weight, CmUtil.GetDataRowStr(drData, "WEIGHT")); // 08 - 상품명 htData.Add(Column.IQ_SCALE_LOG_REQ.DATA.ItemNm, CmUtil.GetDataRowStr(drData, "ITEM_NM")); // 09 - 정상/미달 구분 htData.Add(Column.IQ_SCALE_LOG_REQ.DATA.NormalYn, CmUtil.GetDataRowStr(drData, "NORMAL_YN")); } 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 htData; } private int ScaleLogFlgUpdate(string sCmpCd, string sBrandCd, string sSaleDt, string sStorCd, string sPosNo, string sScaleDt, string sScaleTm, string sSendFlag) { int iRet = UserCom.NG; string sQuery = string.Empty; try { if (sCmpCd.Trim() == "") return iRet; if (sBrandCd.Trim() == "") return iRet; if (sSaleDt.Trim() == "") return iRet; if (sStorCd.Trim() == "") return iRet; if (sPosNo.Trim() == "") return iRet; if (sScaleDt.Trim() == "") return iRet; if (sScaleTm.Trim() == "") return iRet; sQuery += "UPDATE POSLOG..ETC_SCALE_LOG "; sQuery += " SET SEND_YN = '" + sSendFlag + "' "; sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; sQuery += " AND BRAND_CD = '" + sBrandCd + "' "; sQuery += " AND SALE_DT = '" + sSaleDt + "' "; sQuery += " AND STOR_CD = '" + sStorCd + "' "; sQuery += " AND POS_NO = '" + sPosNo + "' "; sQuery += " AND SCALE_DT = '" + sScaleDt + "' "; sQuery += " AND SCALE_TM = '" + sScaleTm + "' "; iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); } 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; } #endregion 13 - SCALE Log 전송 #region 14 - 보류 로그 전송 /// /// 보류로그 전송 메인 /// public void HoldLogSendProcess() { DataTable dtReturn = null; Hashtable htData = null; string sSendFlag = string.Empty; string sCmpCd = string.Empty; string sBrandCd = string.Empty; string sStorCd = string.Empty; string sSaleDt = string.Empty; string sPosNo = string.Empty; string sRegNo = string.Empty; string sSeq = string.Empty; try { // 전송할 Scale Log 데이터 생성 htData = GetHoldLogData(ref dtReturn); if (dtReturn == null || dtReturn.Rows.Count == 0) { return; } else { iSendDataCnt += 1; } sCmpCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "CMP_CD"); sBrandCd = m_cPosStatus.Base.BrandCd; sStorCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STOR_CD"); sSaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SALE_DT"); sPosNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "POS_NO"); sRegNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "REG_NO"); sSeq = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SEQ"); string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, Convert.ToInt32(m_cPosStatus.Base.ScaleLogPort), 5000, new string[] { sCmpCd, sBrandCd, sStorCd, sSaleDt, sPosNo, "" }, ItemConst.COMM_MSG_TYPE.HOLD_LOG, htData); if (sReturn == UserCom.RST_OK) { sSendFlag = "1"; // 정상 전송 m_cPosStatus.Sale.OnLineStatus = "1"; } else { sSendFlag = "9"; // 에러 m_cPosStatus.Sale.OnLineStatus = "0"; } } 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); sSendFlag = "9"; } finally { // Flag Update HoldLogFlgUpdate(sCmpCd, sSaleDt, sStorCd, sPosNo, sRegNo, sSeq, sSendFlag); } } /// /// 데이터 조회 /// /// /// public Hashtable GetHoldLogData(ref DataTable dtReturn) { Hashtable htReturn = null; string sQuery = string.Empty; DataTable dtTempReturn = null; try { ///////////////////////////////////////////////////////////////// /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! ///////////////////////////////////////////////////////////////// sQuery += "SELECT TOP 1 "; sQuery += " CMP_CD, SALE_DT, STOR_CD, POS_NO, REG_NO, SEQ, HOLD_STAT, SYS_DT, SYS_TM, REG_SEQ "; sQuery += " ,ORG_REG_SEQ, PIC_NO, ITEM_QTY, SALE_AMT, AMT_FILLER_01, AMT_FILLER_02, STR_FILLER_01, STR_FILLER_02 "; sQuery += " FROM POSLOG.dbo.ETC_HOLD_HISTORY "; sQuery += " WHERE SEND_YN <> '1' "; sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; sQuery += " ORDER BY SEND_YN ASC "; if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn.Rows.Count == 1) { DataRow drTempReturn = dtTempReturn.Rows[0]; htReturn = MakeHoldLogJsonData(drTempReturn); } } dtReturn = dtTempReturn; } 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 htReturn; } /// /// 전문 생성 /// /// /// private Hashtable MakeHoldLogJsonData(DataRow drData) { Hashtable htData = new Hashtable(); try { ///////////////////////////////////////////////////////////////// /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! ///////////////////////////////////////////////////////////////// // 전문 생성 for (int iRow = 0; iRow < drData.Table.Columns.Count; iRow++) { htData.Add(drData.Table.Columns[iRow].ColumnName, drData[iRow].ToString()); } } 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 htData; } /// /// 디비 업데이트 /// /// /// /// /// /// /// /// private int HoldLogFlgUpdate(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sRegNo, string sSeq, string sSendFlag) { int iRet = UserCom.NG; string sQuery = string.Empty; try { if (sCmpCd.Trim() == "" || sSaleDt.Trim() == "" || sStorCd.Trim() == "" || sPosNo.Trim() == "" || sRegNo.Trim() == "" || sSeq.Trim() == "") return iRet; sQuery += "UPDATE POSLOG.dbo.ETC_HOLD_HISTORY "; sQuery += " SET SEND_YN = '" + sSendFlag + "' "; sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; sQuery += " AND SALE_DT = '" + sSaleDt + "' "; sQuery += " AND STOR_CD = '" + sStorCd + "' "; sQuery += " AND POS_NO = '" + sPosNo + "' "; sQuery += " AND REG_NO = '" + sRegNo + "' "; sQuery += " AND SEQ = '" + sSeq + "' "; iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); } 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; } #endregion 14 - 보류 로그 전송 #region 15 - 해피앱 추후적립 내역 전송(TR_HPAPP_AFTER_SAVE 전송) //#해피앱 추후적립 start, sskim /// /// 보류로그 전송 메인 /// public void HpAppAfterSaveSendProcess() { DataTable dtReturn = null; Hashtable htData = null; string sSendFlag = string.Empty; string sCmpCd = string.Empty; string sBrandCd = string.Empty; string sStorCd = string.Empty; string sSaleDt = string.Empty; string sPosNo = string.Empty; string sTradeNo = string.Empty; try { // 전송할 TR_HpAppAfterSave 데이터 생성 htData = GetHpAppAfterSaveData(ref dtReturn); if (dtReturn == null || dtReturn.Rows.Count == 0) { return; } else { iSendDataCnt += 1; } sCmpCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "CMP_CD"); sBrandCd = m_cPosStatus.Base.BrandCd; sStorCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STOR_CD"); sSaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SALE_DT"); sPosNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "POS_NO"); sTradeNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "TRADE_NO"); string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, Convert.ToInt32(m_cPosStatus.Base.JrnlPort), 5000, new string[] { sCmpCd, sBrandCd, sStorCd, sSaleDt, sPosNo, sTradeNo }, ItemConst.COMM_MSG_TYPE.HPAPP_AFTER_SAVE, htData); if (sReturn == UserCom.RST_OK) { sSendFlag = "1"; // 정상 전송 m_cPosStatus.Sale.OnLineStatus = "1"; } else { sSendFlag = "9"; // 에러 m_cPosStatus.Sale.OnLineStatus = "0"; } } 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); sSendFlag = "9"; } finally { // Flag Update HpAppAfterSaveUpdate(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo, sSendFlag); } } /// /// 데이터 조회 /// /// /// public Hashtable GetHpAppAfterSaveData(ref DataTable dtReturn) { Hashtable htReturn = null; string sQuery = string.Empty; DataTable dtTempReturn = null; try { ///////////////////////////////////////////////////////////////// /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! ///////////////////////////////////////////////////////////////// sQuery += "SELECT TOP 1 "; sQuery += " CMP_CD, SALE_DT, STOR_CD, POS_NO, TRADE_NO "; sQuery += " ,BILL_BAR_CD, TMNLNO, TOT_TRADE_AMT, ACCUM_TRGT_AMT, APPR_WAY_CD "; sQuery += " ,APPR_CARD_NO, ADD_ACCUM_YN, ADD_ACCUM_CD, ADD_ACCUM_HQ_ALLOT_AMT, ADD_ACCUM_STOR_ALLOT_AMT "; sQuery += " ,SAVE_STATUS "; sQuery += " FROM POSLOG.dbo.TR_HPAPP_AFTER_SAVE "; sQuery += " WHERE SEND_YN <> '1' "; sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; sQuery += " ORDER BY SEND_YN ASC "; if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn.Rows.Count == 1) { DataRow drTempReturn = dtTempReturn.Rows[0]; htReturn = MakeHpAppAfterSaveJsonData(drTempReturn); } } dtReturn = dtTempReturn; } 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 htReturn; } /// /// 전문 생성 /// /// /// private Hashtable MakeHpAppAfterSaveJsonData(DataRow drData) { Hashtable htData = new Hashtable(); try { ///////////////////////////////////////////////////////////////// /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! ///////////////////////////////////////////////////////////////// // 전문 생성 for (int iRow = 0; iRow < drData.Table.Columns.Count; iRow++) { htData.Add(drData.Table.Columns[iRow].ColumnName, drData[iRow].ToString()); } } 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 htData; } /// /// 디비 업데이트 /// /// /// /// /// /// /// private int HpAppAfterSaveUpdate(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo, string sSendFlag) { int iRet = UserCom.NG; string sQuery = string.Empty; try { if (sCmpCd.Trim() == "" || sSaleDt.Trim() == "" || sStorCd.Trim() == "" || sPosNo.Trim() == "" || sTradeNo.Trim() == "") return iRet; sQuery += "UPDATE POSLOG.dbo.TR_HPAPP_AFTER_SAVE "; sQuery += " SET SEND_YN = '" + sSendFlag + "' "; sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; sQuery += " AND SALE_DT = '" + sSaleDt + "' "; sQuery += " AND STOR_CD = '" + sStorCd + "' "; sQuery += " AND POS_NO = '" + sPosNo + "' "; sQuery += " AND TRADE_NO = '" + sTradeNo + "' "; iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); } 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; } //#해피앱 추후적립 end, sskim #endregion 15 - 해피앱 추후적립 내역 전송(TR_HPAPP_AFTER_SAVE 전송) //#20171120 유통기한 바코드 인식률 start, phj #region 16 - 유통기한 바코드 인식률 (TR_BAR_SUCESS_RATE 전송) public void BarcodeSucessRateSendProcess() { DataTable dtReturn = null; Hashtable htData = null; string sSendFlag = string.Empty; string sCmpCd = string.Empty; string sBrandCd = string.Empty; string sStorCd = string.Empty; string sSaleDt = string.Empty; string sPosNo = string.Empty; string sTradeNo = string.Empty; string sSeq = string.Empty; try { // 전송할 TR_BAR_SUCESS_RATE 데이터 생성 htData = GetBarcodeSucessRateData(ref dtReturn); if (dtReturn == null || dtReturn.Rows.Count == 0) { return; } else { iSendDataCnt += 1; } sCmpCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "CMP_CD"); sBrandCd = m_cPosStatus.Base.BrandCd; sStorCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STOR_CD"); sSaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SALE_DT"); sPosNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "POS_NO"); sTradeNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "REG_NO"); sSeq = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SEQ"); string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, Convert.ToInt32(m_cPosStatus.Base.JrnlPort), 5000, new string[] { sCmpCd, sBrandCd, sStorCd, sSaleDt, sPosNo, sTradeNo }, ItemConst.COMM_MSG_TYPE.BAR_SUCESS_RATE, htData); if (sReturn == UserCom.RST_OK) { sSendFlag = "1"; // 정상 전송 m_cPosStatus.Sale.OnLineStatus = "1"; } else { sSendFlag = "9"; // 에러 m_cPosStatus.Sale.OnLineStatus = "0"; } } 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); sSendFlag = "9"; } finally { // Flag Update BarcodeSucessRateUpdate(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo, sSendFlag, sSeq); } } /// /// 데이터 조회 /// /// /// public Hashtable GetBarcodeSucessRateData(ref DataTable dtReturn) { Hashtable htReturn = null; string sQuery = string.Empty; DataTable dtTempReturn = null; try { ///////////////////////////////////////////////////////////////// /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! ///////////////////////////////////////////////////////////////// sQuery += "SELECT TOP 1 "; sQuery += " CMP_CD,SALE_DT,STOR_CD,POS_NO,REG_NO,SEQ,BAR_CD,SUCESS_YN,SEND_YN,UPD_DATE,REG_DATE "; sQuery += " FROM POSLOG.dbo.TR_BAR_SUCESS_RATE "; sQuery += " WHERE SEND_YN <> '1' "; sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; sQuery += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "' "; sQuery += " ORDER BY SEND_YN ASC "; if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn.Rows.Count == 1) { DataRow drTempReturn = dtTempReturn.Rows[0]; htReturn = MakeBarcodeSucessRateJsonData(drTempReturn); } } dtReturn = dtTempReturn; } 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 htReturn; } /// /// 전문 생성 /// /// /// private Hashtable MakeBarcodeSucessRateJsonData(DataRow drData) { Hashtable htData = new Hashtable(); try { ///////////////////////////////////////////////////////////////// /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! ///////////////////////////////////////////////////////////////// // 전문 생성 for (int iRow = 0; iRow < drData.Table.Columns.Count; iRow++) { htData.Add(drData.Table.Columns[iRow].ColumnName, drData[iRow].ToString()); } } 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 htData; } /// /// 디비 업데이트 /// /// /// /// /// /// /// private int BarcodeSucessRateUpdate(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo, string sSendFlag, string sSeq) { int iRet = UserCom.NG; string sQuery = string.Empty; try { if (sCmpCd.Trim() == "" || sSaleDt.Trim() == "" || sStorCd.Trim() == "" || sPosNo.Trim() == "" || sTradeNo.Trim() == "") return iRet; sQuery += "UPDATE POSLOG.dbo.TR_BAR_SUCESS_RATE "; sQuery += " SET SEND_YN = '" + sSendFlag + "' "; sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; sQuery += " AND SALE_DT = '" + sSaleDt + "' "; sQuery += " AND STOR_CD = '" + sStorCd + "' "; sQuery += " AND POS_NO = '" + sPosNo + "' "; sQuery += " AND REG_NO = '" + sTradeNo + "' "; sQuery += " AND SEQ = '" + sSeq + "' "; iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); } 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; } #endregion 16 - 유통기한 바코드 인식률 //#20171120 유통기한 바코드 인식률 end, phj //#20180322 휴게소pos매출연동 start,phj #region 17 - 휴게소pos매출연동 대상거래 조회 private void GetRestAreaTranInfo(ref DataTable dtReturn) { string sQuery = string.Empty; DataTable dtTempReturn = null; try { sQuery = " SELECT TOP 1 \n" //20180404 도로공사 재전송 기능을 제외한 기본 스레드 동작에서는 영업일자 기준으로 동작하지 않도록 수정 start, phj //기본 //+ " CMP_CD, SALE_DT, STOR_CD, POS_NO, TRADE_NO \n" //변경 + " CMP_CD, SALE_DT, STOR_CD, POS_NO, TRADE_NO, OUT_SEND_YN \n" //20180404 도로공사 재전송 기능을 제외한 기본 스레드 동작에서는 영업일자 기준으로 동작하지 않도록 수정 end, phj + " FROM POSLOG..TR_SALE_HEADER \n" + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n" + " AND TRADE_KINDPER IN ('00','20','21','42') \n" + " AND OUT_SEND_YN <> '8' \n" + " AND TRAIN_MODE_YN = '0' \n" + " ORDER BY SALE_DT desc, TRADE_NO desc, OUT_SEND_YN \n"; sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn); dtReturn = dtTempReturn; } 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); } } #endregion 17 - 휴게소pos매출연동 //#20180322 휴게소pos매출연동 end,phj //#20180322 휴게소pos매출연동 start,phj #region 17 - 휴게소pos매출연동 public void MakeTranToRestArea() { bool bRet = false; string sendFlag = string.Empty; // 빌정보 string sCmpCd = string.Empty; string sSaleDt = string.Empty; string sStorCd = string.Empty; string sPosNo = string.Empty; string sTradeNo = string.Empty; //20180404 도로공사 재전송 기능을 제외한 기본 스레드 동작에서는 영업일자 기준으로 동작하지 않도록 수정 start, phj string sOutSendYN = string.Empty; //20180404 도로공사 재전송 기능을 제외한 기본 스레드 동작에서는 영업일자 기준으로 동작하지 않도록 수정 end, phj // 텍스트 파일 생성 string sFilename = string.Empty; string sFileFullname = string.Empty; string sPath = string.Empty; // JSON 생성 string sJsonData = string.Empty; DataTable dtReturn = null; try { // 전송할 데이터 조회 GetRestAreaTranInfo(ref dtReturn); if (dtReturn == null || dtReturn.Rows.Count == 0) { return; } else { iSendDataCnt += 1; } // 0:미전송, 8:파일생성, 9:에러 sendFlag = "0"; DataRow dr = dtReturn.Rows[0]; sCmpCd = CmUtil.GetDataRowStr(dr, "CMP_CD"); sSaleDt = CmUtil.GetDataRowStr(dr, "SALE_DT"); sStorCd = CmUtil.GetDataRowStr(dr, "STOR_CD"); sPosNo = CmUtil.GetDataRowStr(dr, "POS_NO"); sTradeNo = CmUtil.GetDataRowStr(dr, "TRADE_NO"); //20180404 도로공사 재전송 기능을 제외한 기본 스레드 동작에서는 영업일자 기준으로 동작하지 않도록 수정 start, phj sOutSendYN = CmUtil.GetDataRowStr(dr, "OUT_SEND_YN"); if ((CmUtil.LongParse(sSaleDt) < CmUtil.LongParse(m_cPosStatus.Base.SaleDate)) && sOutSendYN != "R") { //20180403 영업일자보다 크거나 같거나 스레드 동작하도록 추가수정 return; } //20180404 도로공사 재전송 기능을 제외한 기본 스레드 동작에서는 영업일자 기준으로 동작하지 않도록 수정 end, phj Hashtable htData = null; htData = new Hashtable(); htData.Clear(); bRet = MakeTrSendData(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo, ref htData); if (bRet == false) { sendFlag = "9"; return; } else { // JSON 생성 m_cDataCommon.HashToJsonString(htData, ref sJsonData); //S+영업일자(YYMMDD)+운영업체코드(3자리)+휴게소코드(7자리)+포스그룹코드(2자리)+POS번호(4자리)+영수증번호(8자리).dat sFilename = string.Format("{0}{1}{2}{3}{4}{5}{6}.dat" , ItemConst.ROAD_SAVE_TYPE.SALE , sSaleDt.Substring(2, 6).Trim() //영업일자(YYMMDD) , m_cPosStatus.RestAreaPos.RestAreaPosGroupCd.PadLeft(3, '0').Trim() //운영업체코드(3자리) , m_cPosStatus.RestAreaPos.RestAreaPosCd.PadLeft(7, '0').Trim() //휴게소코드(7자리) , m_cPosStatus.RestAreaPos.RestAreaPosPosGroupCd.PadLeft(2, '0').Trim() //포스그룹코드(2자리) , m_cPosStatus.RestAreaPos.RestAreaPosPosNo.PadLeft(4, '0').Trim() //POS번호(4자리) , sTradeNo.PadLeft(8, '0')); //영수증번호(8자리) //#20180410 휴게소매출 경로 없을 경우 자동생성 안함 start,phj if (m_cPosStatus.RestAreaPos.RestAreaPosDir == "") { m_cPosStatus.RestAreaPos.RestAreaPosDir = @"C:\eRest_SPC\Sals\"; } //#20180410 휴게소매출 경로 없을 경우 자동생성 안함 end,phj sPath = m_cPosStatus.RestAreaPos.RestAreaPosDir; sFileFullname = sPath + sFilename; //if (m_cDataCommon.SaveRoadJson(ItemConst.ROAD_SAVE_TYPE.SALE, dFilename, sJsonData).Equals(UserCom.RST_OK)) if (CmUtil.WriteTextFile(sFileFullname, sJsonData) == true) { //CmUtil.FileCopy(sFilename, dFilename, false); sendFlag = "8"; } else { sendFlag = "9"; 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 (함수명)) "도로공사 Hi-쉼마루 파일 생성 오류 -> " + sFileFullname); } } } 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 (함수명)) "도로공사 Hi-쉼마루 파일 생성 오류 -> " + sFileFullname + " : " + ex.Message); sendFlag = "9"; } finally { // Flag Update OutsideTranSendFlgUpdate(sCmpCd, sStorCd, sPosNo, sSaleDt, sTradeNo, sendFlag); } } #endregion 17 - 휴게소pos매출연동 //#20180322 휴게소pos매출연동 end,phj //#20180322 휴게소pos매출연동 start,phj #region 17 - 휴게소 포스에 보낼 데이터 조립 private bool MakeTrSendData(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo, ref Hashtable htSendData) { bool bRet = false; Hashtable htData = null; htData = new Hashtable(); htData.Clear(); try { Hashtable ht_Header = null; ht_Header = new Hashtable(); ht_Header.Clear(); bRet = MakeSaleHDData(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo, ref ht_Header); if (bRet == false) { return bRet; } ArrayList Al_Detail = null; Al_Detail = new ArrayList(); Al_Detail.Clear(); bRet = MakeSaleDTData(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo, ref Al_Detail); if (bRet == false) { return bRet; } ArrayList Al_Paylist = null; Al_Paylist = new ArrayList(); Al_Paylist.Clear(); bRet = MakePaymentData(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo, ref Al_Paylist); if (bRet == false) { return bRet; } // JSON 생성 if (ht_Header.Count > 0) htData.Add(Column.RESTAREA_SALE_HD.ITEM, ht_Header); if (Al_Detail.Count > 0) htData.Add(Column.RESTAREA_SALE_DT.ITEM, Al_Detail); if (Al_Paylist.Count > 0) htData.Add(Column.RESTAREA_SALE_SP.ITEM, Al_Paylist); htSendData = htData; bRet = 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 (함수명)) "도로공사 Hi-쉼마루 SEND DATA -> " + ex.Message); } //return htData; return bRet; } #endregion 17 - 휴게소 포스에 보낼 데이터 조립 //#20180322 휴게소pos매출연동 end,phj //#20180322 휴게소pos매출연동 start,phj #region 결제조회 private bool MakePaymentData(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo, ref ArrayList AlSaleSPData) { bool bRet = false; string sQuery = string.Empty; string sSelQuery = string.Empty; DataTable dtReturn = new DataTable(); StringBuilder sb = new StringBuilder(); Column.RESTAREA_SALE_SP.RESTAREA_PAY_CASH.DATA Pay_Cash = null; Column.RESTAREA_SALE_SP.RESTAREA_PAY_CARD.DATA Pay_Card = null; Pay_Cash = new Column.RESTAREA_SALE_SP.RESTAREA_PAY_CASH.DATA(); Pay_Card = new Column.RESTAREA_SALE_SP.RESTAREA_PAY_CARD.DATA(); ArrayList al_Payment = null; al_Payment = new ArrayList(); al_Payment.Clear(); try { #region 카드결제조회 sQuery = ""; sSelQuery = ""; //PCKR 02 00 신용카드 //PCKR 04 02 삼성포인트사용 //PCKR 04 06 신한포인트사용 //PCKR 04 07 현대M포인트사용 //PCKR 07 00 알리페이 //PCKR 07 01 WechatPay //PCKR 07 02 스마일페이 //PCKR 07 03 T-PAY //PCKR 09 00 T-MONEY //PCKR 09 01 캐시비 //PCKR 10 02 해피기프트카드 (신) sSelQuery = "SELECT '01' AS SLIP_FG \n" + " ,ROUND ( CONVERT(VARCHAR, ISNULL(A.PAY_AMT, 0)) ,0) AS APPR_AMT \n" + " ,A.OCCUR_ENTRY_11 AS PURCHASE_CD \n" + " ,A.OCCUR_ENTRY_12 AS PURCHASE_CO_NM \n" + " ,A.OCCUR_ENTRY_02 AS APPR_NO \n" + " ,'20' + A.OCCUR_ENTRY_03 AS APPR_DAY \n" + " ,A.OCCUR_ENTRY_04 + '00' AS APPR_TIME \n" + " ,'0' AS CARD_GB \n" + //#20180406 도로공사 수정 start //DDC_GB : 구분되는 값 없을경우 0으로 전송 //기존 //" ,'1' AS DDC_GB \n" + //변경 " ,'0' AS DDC_GB \n" + //#20180406 도로공사 수정 end " ,'' AS STD_CARD_CORD_CD \n" + " ,'32' AS VAN_CD \n" + " ,SUBSTRING(A.OCCUR_ENTRY_01,1,6) AS CARD_NO \n" + " FROM POSLOG..TR_SALE_PAY A \n" + " , POSLOG..TR_SALE_HEADER B \n" + " WHERE A.CMP_CD = '{0}' \n" + " AND A.SALE_DT = '{1}' \n" + " AND A.STOR_CD = '{2}' \n" + " AND A.POS_NO = '{3}' \n" + " AND A.TRADE_NO = '{4}' \n" + //2018-04-03 카드기준 추가 //기존 //" AND A.PAY_WAY_CD = '02' \n" + //변경 " AND A.PAY_WAY_CD + A.PAY_DTL_CD_01 IN ('0200','0402','0406','0407','0700','0701','0702','0703','0900','0901','1002') \n" + " AND A.PAY_DTL_CD_05 = '1' \n" + " AND A.CANCEL_DIV = '0' \n" + " AND A.CMP_CD = B.CMP_CD \n" + " AND A.SALE_DT = B.SALE_DT \n" + " AND A.STOR_CD = B.STOR_CD \n" + " AND A.POS_NO = B.POS_NO \n" + " AND A.TRADE_NO = B.TRADE_NO \n" + " AND B.TRAIN_MODE_YN = '0' \n" + " AND B.TRADE_KINDPER IN ('00','20','21','42') \n"; dtReturn = null; sQuery = string.Format(sSelQuery, sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); if (dtReturn != null && dtReturn.Rows.Count != 0) { foreach (DataRow dr in dtReturn.Rows) { Hashtable ht_PAY_CARD = new Hashtable(); ht_PAY_CARD.Add(Pay_Card.SLIP_FG, CmUtil.GetDataRowStr(dr, "SLIP_FG")); ht_PAY_CARD.Add(Pay_Card.APPR_AMT, CmUtil.GetDataRowStr(dr, "APPR_AMT")); ht_PAY_CARD.Add(Pay_Card.PURCHASE_CD, CmUtil.GetDataRowStr(dr, "PURCHASE_CD")); ht_PAY_CARD.Add(Pay_Card.PURCHASE_CO_NM, CmUtil.GetDataRowStr(dr, "PURCHASE_CO_NM")); ht_PAY_CARD.Add(Pay_Card.APPR_NO, CmUtil.GetDataRowStr(dr, "APPR_NO")); ht_PAY_CARD.Add(Pay_Card.APPR_DAY, CmUtil.GetDataRowStr(dr, "APPR_DAY")); ht_PAY_CARD.Add(Pay_Card.APPR_TIME, CmUtil.GetDataRowStr(dr, "APPR_TIME")); ht_PAY_CARD.Add(Pay_Card.CARD_GB, CmUtil.GetDataRowStr(dr, "CARD_GB")); ht_PAY_CARD.Add(Pay_Card.DDC_GB, CmUtil.GetDataRowStr(dr, "DDC_GB")); ht_PAY_CARD.Add(Pay_Card.STD_CARD_CORD_CD, CmUtil.GetDataRowStr(dr, "STD_CARD_CORD_CD")); ht_PAY_CARD.Add(Pay_Card.VAN_CD, CmUtil.GetDataRowStr(dr, "VAN_CD")); al_Payment.Add(ht_PAY_CARD); ht_PAY_CARD = null; } } #endregion 카드결제조회 #region 현금승인결제조회 //카드 제외한 나머지 결제 금액 - 현금 승인 금액 뺀 거 sQuery = ""; sSelQuery = ""; sSelQuery = " SELECT A.* , ROUND (ISNULL(A.APPR_AMT, 0) - ISNULL(A.ETC_AMT, 0),0) AS RESULT_AMT \n " + " FROM \n " + " ( \n " + //2018-04-03 카드기준 추가 //기존 //" SELECT ROUND (SUM(CASE WHEN TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 <> '0200' THEN \n " + //" ISNULL(TSP.AMT_ENTRY_01, 0) - ISNULL(TSP.AMT_ENTRY_02, 0) \n " + //" ELSE 0 END),0) AS APPR_AMT ,\n " + //변경 " SELECT ROUND (ISNULL(TSP.AMT_ENTRY_01, 0) - ISNULL(TSP.AMT_ENTRY_02, 0) ,0) AS APPR_AMT,\n " + " '02' AS SLIP_FG,\n " + " '00' AS PROC_TYPE,\n " + " '' AS APPR_NO,\n " + " '' AS APPR_DAY,\n " + " '' AS APPR_TYPE,\n " + " '32' AS VAN_CD, \n" + " ( SELECT ROUND (CONVERT(VARCHAR, ISNULL(TSE.ETC_AMT, 0)) ,0) AS APPR_AMT \n " + " FROM POSLOG..TR_SALE_ETC TSE \n " + " WHERE TSE.CMP_CD = '{0}' \n " + " AND TSE.SALE_DT = '{1}' \n " + " AND TSE.STOR_CD = '{2}' \n " + " AND TSE.POS_NO = '{3}' \n " + " AND TSE.TRADE_NO = '{4}' \n " + " AND TSE.ETC_WAY_CD = '80' \n " + " AND TSE.ETC_DTL_CD_01 = '00' \n " + " AND TSE.CANCEL_DIV = '0') AS ETC_AMT \n " + " FROM POSLOG..TR_SALE_HEADER TSH LEFT JOIN POSLOG..TR_SALE_PAY TSP \n " + " ON TSH.CMP_CD = TSP.CMP_CD \n " + " AND TSH.SALE_DT = TSP.SALE_DT \n " + " AND TSH.STOR_CD = TSP.STOR_CD \n " + " AND TSH.POS_NO = TSP.POS_NO \n " + " AND TSH.TRADE_NO = TSP.TRADE_NO \n " + //2018-04-03 카드기준 추가 //추가 " AND TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 NOT IN ('0200','0402','0406','0407','0700','0701','0702','0703','0900','0901','1002') \n" + " AND TSP.PAY_DTL_CD_05 = '1' \n " + " AND TSP.CANCEL_DIV = '0' \n " + " WHERE TSH.CMP_CD = '{0}' \n " + " AND TSH.SALE_DT = '{1}' \n " + " AND TSH.STOR_CD = '{2}' \n " + " AND TSH.POS_NO = '{3}' \n " + " AND TSH.TRADE_NO = '{4}' \n " + " AND TSH.TRAIN_MODE_YN = '0' \n " + " AND TSH.TRADE_KINDPER IN ('00','20','21','42') \n " + " ) A \n " ; dtReturn = null; sQuery = string.Format(sSelQuery, sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); if (dtReturn != null && dtReturn.Rows.Count != 0) { DataRow dr = dtReturn.Rows[0]; // 결제 금액 전체를 현금영수증 승인했을 때는 생성하지 않도록 한다. if (CmUtil.GetDataRowStr(dr, "RESULT_AMT") != "0") { Hashtable ht_PAY_CASH = new Hashtable(); ht_PAY_CASH.Add(Pay_Cash.SLIP_FG, CmUtil.GetDataRowStr(dr, "SLIP_FG")); ht_PAY_CASH.Add(Pay_Cash.PROC_TYPE, CmUtil.GetDataRowStr(dr, "PROC_TYPE")); // 전체결제 금액 - 카드결제금액 - 현금영수증 승인금액 ht_PAY_CASH.Add(Pay_Cash.APPR_AMT, CmUtil.GetDataRowStr(dr, "RESULT_AMT")); ht_PAY_CASH.Add(Pay_Cash.APPR_NO, CmUtil.GetDataRowStr(dr, "APPR_NO")); ht_PAY_CASH.Add(Pay_Cash.APPR_DAY, CmUtil.GetDataRowStr(dr, "APPR_DAY")); ht_PAY_CASH.Add(Pay_Cash.APPR_TIME, CmUtil.GetDataRowStr(dr, "APPR_TIME")); ht_PAY_CASH.Add(Pay_Cash.VAN_CD, CmUtil.GetDataRowStr(dr, "VAN_CD")); al_Payment.Add(ht_PAY_CASH); ht_PAY_CASH = null; } } sQuery = ""; sSelQuery = ""; sSelQuery = "SELECT '02' AS SLIP_FG \n " + " , '00' AS PROC_TYPE \n " + " , ROUND ( CONVERT(VARCHAR, ISNULL(A.ETC_AMT, 0)) ,0) AS APPR_AMT \n " + " , A.OCCUR_ENTRY_02 AS APPR_NO \n " + " , '20' + A.OCCUR_ENTRY_03 AS APPR_DAY \n " + " , A.OCCUR_ENTRY_04 + '00' AS APPR_TIME \n " + " , '32' AS VAN_CD \n " + " , (CASE WHEN A.OCCUR_ENTRY_10 = '1' THEN '0' \n " + " ELSE CASE WHEN A.OCCUR_ENTRY_11 = '0' THEN '1' \n " + " ELSE '2' END \n " + " END) AS APPR_TYPE \n " + " FROM POSLOG..TR_SALE_ETC A \n " + " , POSLOG..TR_SALE_HEADER B \n " + " WHERE A.CMP_CD = '{0}' \n " + " AND A.SALE_DT = '{1}' \n " + " AND A.STOR_CD = '{2}' \n " + " AND A.POS_NO = '{3}' \n " + " AND A.TRADE_NO = '{4}' \n " + " AND A.ETC_WAY_CD = '80' \n " + " AND A.ETC_DTL_CD_01 = '00' \n " + " AND A.CMP_CD = B.CMP_CD \n " + " AND A.STOR_CD = B.STOR_CD \n " + " AND A.SALE_DT = B.SALE_DT \n " + " AND A.POS_NO = B.POS_NO \n " + " AND A.TRADE_NO = B.TRADE_NO \n " + " AND B.TRAIN_MODE_YN = '0' \n " + " AND B.TRADE_KINDPER IN ('00','20','21','42') \n "; dtReturn = null; sQuery = string.Format(sSelQuery, sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); if (dtReturn != null && dtReturn.Rows.Count != 0) { //foreach (DataRow dr in dtReturn.Rows) //{ DataRow dr = dtReturn.Rows[0]; Hashtable ht_PAY_CASH = new Hashtable(); ht_PAY_CASH.Add(Pay_Cash.SLIP_FG, CmUtil.GetDataRowStr(dr, "SLIP_FG")); //"00" : 현금, "01" : 상품권, "02" : 모바일쿠폰, "03" : 나이스선불카드, "04" : 마이탐 선불카드 ht_PAY_CASH.Add(Pay_Cash.PROC_TYPE, CmUtil.GetDataRowStr(dr, "PROC_TYPE")); ht_PAY_CASH.Add(Pay_Cash.APPR_AMT, CmUtil.GetDataRowStr(dr, "APPR_AMT")); ht_PAY_CASH.Add(Pay_Cash.APPR_NO, CmUtil.GetDataRowStr(dr, "APPR_NO")); ht_PAY_CASH.Add(Pay_Cash.APPR_DAY, CmUtil.GetDataRowStr(dr, "APPR_DAY")); ht_PAY_CASH.Add(Pay_Cash.APPR_TIME, CmUtil.GetDataRowStr(dr, "APPR_TIME")); ht_PAY_CASH.Add(Pay_Cash.VAN_CD, CmUtil.GetDataRowStr(dr, "VAN_CD")); al_Payment.Add(ht_PAY_CASH); ht_PAY_CASH = null; //} } #endregion 현금승인결제조회 AlSaleSPData = al_Payment; bRet = 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 (함수명)) "도로공사 Hi-쉼마루 SaleSP -> " + sQuery + " : " + ex.Message); bRet = false; } return bRet; } #endregion //#20180322 휴게소pos매출연동 end,phj //#20180322 휴게소pos매출연동 start,phj #region 상세조회 private bool MakeSaleDTData(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo, ref ArrayList AlSaleDTData) { bool bRet = false; string sQuery = string.Empty; string sSelQuery = string.Empty; DataTable dtReturn = new DataTable(); StringBuilder sb = new StringBuilder(); Column.RESTAREA_SALE_DT.DATA RESTAREA_SALE_DT = null; RESTAREA_SALE_DT = new Column.RESTAREA_SALE_DT.DATA(); ArrayList al_SaleDT = null; al_SaleDT = new ArrayList(); al_SaleDT.Clear(); try { #region SALE_DT sQuery = ""; sSelQuery = ""; //#20180406 도로공사 수정 start //LINE_NO : 1자리일 경우 앞에 0채워서 2자리로 생성 //기존 //sSelQuery = "SELECT CONVERT(VARCHAR, A.SEQ) AS LINE_NO \n " //변경 sSelQuery = "SELECT REPLICATE('0', 2 - LEN(CONVERT(VARCHAR, A.SEQ))) + CONVERT(VARCHAR, A.SEQ) AS LINE_NO \n " + //#20180406 도로공사 수정 end //" , A.STOR_CD AS SHOP_CD \n " + " ,'" + m_cPosStatus.RestAreaPos.RestAreaPosCd.PadLeft(7, '0').Trim() + "' AS SHOP_CD \n " + //" , CONVERT(VARCHAR, A.SEQ) AS PROD_SEQ \n " + " , A.ITEM_PLU_CD AS PROD_SEQ \n " + " , '' AS SOURCE_CD \n " + " , CONVERT(VARCHAR, ISNULL(A.SALE_QTY, 0)) AS PAN_QTY \n " + " , ROUND (CONVERT(VARCHAR, ISNULL(A.SALE_AMT, 0)) ,0) AS TOT_PAN_AMT \n " + " , '00' AS NOZZLE_NO \n " + " , CONVERT(VARCHAR, ISNULL(A.SALE_PRC, 0)) AS PAN_COST \n " + " , '0' AS FEE_COST \n " + " , '0' AS OIL_PROC_GB \n " + " , ROUND ('0' ,0) AS PRE_PAY_AMT \n " + " , ROUND ('0' ,0) AS FEE_AMT \n " + " , ROUND ('0' ,0) AS SC_AMT \n " + " , ROUND (CONVERT(VARCHAR, A.BILL_AMT) ,0) AS REAL_PAN_AMT \n " + " , ROUND (CONVERT(VARCHAR, A.APPLY_TAX_AMT) ,0) AS VAT_AMT \n " + " , ROUND (CONVERT(VARCHAR, ISNULL(A.BILL_AMT, 0) - ISNULL(A.APPLY_TAX_AMT, 0)) ,0) AS NET_PAN_AMT \n " + " , '0' AS NOZZLE_END_DTIME \n " + " , '0' AS DUTY_PAN_GB \n " + " , ROUND (CONVERT(VARCHAR, ISNULL(A.ITEM_DC_AMT, 0) + ISNULL(A.SUM_DC_AMT, 0) + \n " + " ISNULL(A.CPI_DC_AMT, 0) + ISNULL(A.COOP_CARD_DC_AMT, 0) + \n " + " ISNULL(A.POINT_DC_AMT, 0) + ISNULL(A.CPN_DC_AMT, 0) + \n " + " ISNULL(A.EMP_DC_AMT, 0) + ISNULL(A.SET_DC_AMT, 0) + \n " + " ISNULL(A.ETC_DC_AMT, 0) + ISNULL(A.EXCEP_DC_AMT, 0)) ,0) AS DC_AMT \n " + //" , ROUND ('0' ,0) AS NORM_DC_AMT \n " + " , ROUND (CONVERT(VARCHAR, ISNULL(A.ITEM_DC_AMT, 0) + ISNULL(A.SUM_DC_AMT, 0) + \n " + " ISNULL(A.CPI_DC_AMT, 0) + ISNULL(A.COOP_CARD_DC_AMT, 0) + \n " + " ISNULL(A.POINT_DC_AMT, 0) + ISNULL(A.CPN_DC_AMT, 0) + \n " + " ISNULL(A.EMP_DC_AMT, 0) + ISNULL(A.SET_DC_AMT, 0) + \n " + " ISNULL(A.ETC_DC_AMT, 0) + ISNULL(A.EXCEP_DC_AMT, 0)) ,0) AS NORM_DC_AMT \n " + " , ROUND ('0' ,0) AS BONUS_DC_AMT \n " + " , ROUND ('0' ,0) AS RAND_BONUS_DC_AMT \n " + " FROM POSLOG..TR_SALE_DETAIL A \n " + " , POSLOG..TR_SALE_HEADER B \n " + " WHERE A.CMP_CD = '{0}' \n " + " AND A.SALE_DT = '{1}' \n " + " AND A.STOR_CD = '{2}' \n " + " AND A.POS_NO = '{3}' \n " + " AND A.TRADE_NO = '{4}' \n " + " AND A.CMP_CD = B.CMP_CD \n " + " AND A.SALE_DT = B.SALE_DT \n " + " AND A.STOR_CD = B.STOR_CD \n " + " AND A.POS_NO = B.POS_NO \n " + " AND A.TRADE_NO = B.TRADE_NO \n " + " AND B.TRAIN_MODE_YN = '0' \n " + " AND B.TRADE_KINDPER IN ('00','20','21','42') \n " + " AND A.CANCEL_DIV = '0' \n " + // 판매단가가 0원이 아닌 것만 보냄. " AND A.SALE_PRC > 0 \n" + " ORDER BY A.SEQ \n "; dtReturn = null; sQuery = string.Format(sSelQuery, sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); if (dtReturn != null && dtReturn.Rows.Count != 0) { foreach (DataRow dr in dtReturn.Rows) { Hashtable tr_SaleDT = new Hashtable(); tr_SaleDT.Add(RESTAREA_SALE_DT.LINE_NO, CmUtil.GetDataRowStr(dr, "LINE_NO")); tr_SaleDT.Add(RESTAREA_SALE_DT.SHOP_CD, CmUtil.GetDataRowStr(dr, "SHOP_CD")); tr_SaleDT.Add(RESTAREA_SALE_DT.PROD_SEQ, CmUtil.GetDataRowStr(dr, "PROD_SEQ")); tr_SaleDT.Add(RESTAREA_SALE_DT.SOURCE_CD, CmUtil.GetDataRowStr(dr, "SOURCE_CD")); //cPluItem.ITEM_PLU_CD tr_SaleDT.Add(RESTAREA_SALE_DT.PAN_QTY, CmUtil.GetDataRowStr(dr, "PAN_QTY")); tr_SaleDT.Add(RESTAREA_SALE_DT.TOT_PAN_AMT, CmUtil.GetDataRowStr(dr, "TOT_PAN_AMT")); tr_SaleDT.Add(RESTAREA_SALE_DT.NOZZLE_NO, CmUtil.GetDataRowStr(dr, "NOZZLE_NO")); tr_SaleDT.Add(RESTAREA_SALE_DT.PAN_COST, CmUtil.GetDataRowStr(dr, "PAN_COST")); tr_SaleDT.Add(RESTAREA_SALE_DT.FEE_COST, CmUtil.GetDataRowStr(dr, "FEE_COST")); tr_SaleDT.Add(RESTAREA_SALE_DT.OIL_PROC_GB, CmUtil.GetDataRowStr(dr, "OIL_PROC_GB")); tr_SaleDT.Add(RESTAREA_SALE_DT.PRE_PAY_AMT, CmUtil.GetDataRowStr(dr, "PRE_PAY_AMT")); tr_SaleDT.Add(RESTAREA_SALE_DT.FEE_AMT, CmUtil.GetDataRowStr(dr, "FEE_AMT")); tr_SaleDT.Add(RESTAREA_SALE_DT.SC_AMT, CmUtil.GetDataRowStr(dr, "SC_AMT")); tr_SaleDT.Add(RESTAREA_SALE_DT.REAL_PAN_AMT, CmUtil.GetDataRowStr(dr, "REAL_PAN_AMT")); tr_SaleDT.Add(RESTAREA_SALE_DT.VAT_AMT, CmUtil.GetDataRowStr(dr, "VAT_AMT")); tr_SaleDT.Add(RESTAREA_SALE_DT.NET_PAN_AMT, CmUtil.GetDataRowStr(dr, "NET_PAN_AMT")); tr_SaleDT.Add(RESTAREA_SALE_DT.NOZZLE_END_DTIME, CmUtil.GetDataRowStr(dr, "NOZZLE_END_DTIME")); tr_SaleDT.Add(RESTAREA_SALE_DT.DUTY_PAN_GB, CmUtil.GetDataRowStr(dr, "DUTY_PAN_GB")); tr_SaleDT.Add(RESTAREA_SALE_DT.DC_AMT, CmUtil.GetDataRowStr(dr, "DC_AMT")); tr_SaleDT.Add(RESTAREA_SALE_DT.NORM_DC_AMT, CmUtil.GetDataRowStr(dr, "NORM_DC_AMT")); tr_SaleDT.Add(RESTAREA_SALE_DT.BONUS_DC_AMT, CmUtil.GetDataRowStr(dr, "BONUS_DC_AMT")); //RAND_BONUS_DC_AMT String 14 Y 1 임의등록 보너스카드 DC 금액(미사용) tr_SaleDT.Add(RESTAREA_SALE_DT.RAND_BONUS_DC_AMT, CmUtil.GetDataRowStr(dr, "RAND_BONUS_DC_AMT")); al_SaleDT.Add(tr_SaleDT); tr_SaleDT = null; } } #endregion SALE_DT AlSaleDTData = al_SaleDT; bRet = 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 (함수명)) "도로공사 Hi-쉼마루 SaleDT -> " + sQuery + " : " + ex.Message); bRet = false; } return bRet; } #endregion //#20180322 휴게소pos매출연동 end,phj //#20180322 휴게소pos매출연동 start,phj #region 헤더조회 private bool MakeSaleHDData(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo, ref Hashtable htSaleHDData) { bool bRet = false; string sQuery = string.Empty; string sSelQuery = string.Empty; DataTable dtReturn = new DataTable(); StringBuilder sb = new StringBuilder(); Column.RESTAREA_SALE_HD.DATA RESTAREA_SALE_HD = null; RESTAREA_SALE_HD = new Column.RESTAREA_SALE_HD.DATA(); Hashtable ht_SaleHD = null; ht_SaleHD = new Hashtable(); ht_SaleHD.Clear(); try { #region SALE_HD sQuery = ""; sSelQuery = ""; sSelQuery = "SELECT A.SALE_DT AS SALE_DAY \n " + //#20180406 도로공사 수정 start //BILL_NO : 앞에 0 채워서 8자리로 생성 //기존 //" , A.TRADE_NO AS BILL_NO \n " + //변경 " , REPLICATE('0', 8 - LEN(A.TRADE_NO)) + A.TRADE_NO AS BILL_NO \n " + //#20180406 도로공사 수정 end " , A.TRADE_DIV AS SALE_GB \n " + " , A.SYS_DT + A.PAY_TIME AS SYS_DTIME \n " + " , CONVERT(VARCHAR, C.TRDTL_CNT) AS DETAIL_CNT \n " + //#20180403 도로공사 현금전표 분기에 따른 총전표건수 계산식 변경 start //기존 //" , CONVERT(VARCHAR, (CASE WHEN ISNULL(B.CASH_AMT,0) > 0 THEN 1 ELSE 0 END) + B.TRCRD_CNT) AS SLIP_CNT \n " + //변경 // 1. 현금처리 금액이 있는지 체크 // 2. 현금처리 금액 - 현금 영수증 금액 빼서 0보다 크면 현금전표 2건 생성되고 아니면 1건 생성 // 3. 현금처리 금액이 없으면 현금전표 0건 생성 " , CONVERT(VARCHAR, (CASE WHEN ISNULL(B.CASH_AMT,0) = 0 THEN 0 \n " + " ELSE ( CASE WHEN D.TRCSH_CNT = '1' THEN (CASE WHEN ISNULL(B.CASH_AMT,0) - ISNULL(D.CASH_BILL_AMT,0) > 0 THEN 2 ELSE 1 END) \n " + " ELSE '1' \n " + " END) \n " + " END) + B.TRCRD_CNT) AS SLIP_CNT \n " + //#20180403 도로공사 현금전표 분기에 따른 총전표건수 계산식 변경 end " , ROUND (CONVERT(VARCHAR, ISNULL(A.TOTSALE_AMT, 0)),0) AS TOT_PAN_AMT \n " + " , ROUND (CONVERT(VARCHAR, B.CASH_AMT),0) AS CASH_AMT \n " + " , ROUND (CONVERT(VARCHAR, B.CRD_CARD_AMT),0) AS CARD_AMT \n " + " , ROUND ('0',0) AS GIFT_AMT \n " + " , ROUND ('0',0) AS SC_AMT \n " + " , ROUND ('0',0) AS PRE_PAY_AMT \n " + " , ROUND ('0',0) AS FEE_PROFIT_AMT \n " + " , ROUND (CONVERT(VARCHAR, ISNULL(A.NET_SALE_AMT, 0)),0) AS REAL_PAN_AMT \n " + " , ROUND (CONVERT(VARCHAR, ISNULL(A.TOT_VAT, 0)), 0) AS VAT_AMT \n " + " , ROUND (CONVERT(VARCHAR, ISNULL(A.NET_SALE_AMT, 0) - ISNULL(A.TOT_VAT, 0)),0) AS NET_PAN_AMT \n " + " , ROUND (CONVERT(VARCHAR, D.TRCSH_CNT),0) AS CASH_BILL_GB \n " + " , CASE WHEN TRADE_DIV = '1' THEN \n " + //#20180406 도로공사 수정 start //ORB_BILL_NO : 년도 YYYY형식으로 수정, 빌번호 8자리 //기존 //" (SUBSTRING(A.ORG_BILLDT,3,6) + \n " + //변경 " (A.ORG_BILLDT + \n " + //#20180406 도로공사 수정 end //" '000' + \n " + " '" + m_cPosStatus.RestAreaPos.RestAreaPosGroupCd.PadLeft(3, '0').Trim() + "' + \n " + //" SUBSTRING(A.STOR_CD, 2, 6) + \n " + 기존6자리에서 7자리로 늘임 //" SUBSTRING(A.STOR_CD, 1, 7) + \n " + " '" + m_cPosStatus.RestAreaPos.RestAreaPosCd.PadLeft(7, '0').Trim() + "' + \n " + //" '00' + \n " + " '" + m_cPosStatus.RestAreaPos.RestAreaPosPosGroupCd.PadLeft(2, '0').Trim() + "' + \n " + //" REPLICATE('0', 4 - LEN(A.ORG_BILL_POSNO)) + A.ORG_BILL_POSNO + \n " + " REPLICATE('0', 4 - LEN('" + m_cPosStatus.RestAreaPos.RestAreaPosPosNo.PadLeft(4, '0').Trim() + "')) + '" + m_cPosStatus.RestAreaPos.RestAreaPosPosNo.PadLeft(4, '0').Trim() + "' + \n " + " REPLICATE('0', 8 - LEN(A.ORG_BILL_NO)) + A.ORG_BILL_NO) \n " + " ELSE '' END AS ORG_BILL_NO \n " + " , '' AS EMP_ID \n " + " , '' AS OIL_PROC_CB \n " + " , ROUND ('0',0) AS BONUS_USE_AMT \n " + " , ROUND (CONVERT(VARCHAR, A.TOTDC_AMT),0) AS DC_AMT \n " + //" , ROUND ('0',0) AS NORM_DC_AMT \n " + " , ROUND (CONVERT(VARCHAR, A.TOTDC_AMT),0) AS NORM_DC_AMT \n " + " , ROUND ('0',0) AS BONUS_DC_AMT \n " + " , ROUND ('0',0) AS RAND_BONUS_DC_AMT \n " + " FROM POSLOG..TR_SALE_HEADER A \n " + " , ( \n " + //2018-04-03 카드기준 추가 //기존 //" SELECT ROUND (SUM(CASE WHEN TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 <> '0200' \n " + //" THEN ISNULL(TSP.AMT_ENTRY_01, 0) - ISNULL(TSP.AMT_ENTRY_02, 0) \n " + //" ELSE 0 \n " + //" END),0) AS CASH_AMT \n " + //" , ROUND (SUM(CASE WHEN TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 = '0200' \n " + //" THEN 1 \n " + //" ELSE 0 \n " + //" END),0) AS TRCRD_CNT \n " + //" , ROUND (SUM(CASE WHEN TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 = '0200' \n " + //" THEN ISNULL(TSP.AMT_ENTRY_01, 0) \n " + //" ELSE 0 \n " + //" END),0) AS CRD_CARD_AMT \n " + //변경 " SELECT ROUND (SUM(CASE WHEN TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 NOT IN ('0200','0402','0406','0407','0700','0701','0702','0703','0900','0901','1002') \n " + " THEN ISNULL(TSP.AMT_ENTRY_01, 0) - ISNULL(TSP.AMT_ENTRY_02, 0) \n " + " ELSE 0 \n " + " END),0) AS CASH_AMT \n " + //2018-04-03 카드기준 추가 //기존 //" , ROUND (SUM(CASE WHEN TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 = '0200' \n " + //" THEN 1 \n " + //" ELSE 0 \n " + //" END),0) AS TRCRD_CNT \n " + //변경 " , ROUND (SUM(CASE WHEN TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 IN ('0200','0402','0406','0407','0700','0701','0702','0703','0900','0901','1002') \n " + " THEN 1 \n " + " ELSE 0 \n " + " END),0) AS TRCRD_CNT \n " + //2018-04-03 카드기준 추가 //기존 //" , ROUND (SUM(CASE WHEN TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 = '0200' \n " + //" THEN ISNULL(TSP.AMT_ENTRY_01, 0) \n " + //" ELSE 0 \n " + //" END),0) AS CRD_CARD_AMT \n " + //변경 " , ROUND (SUM(CASE WHEN TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 IN ('0200','0402','0406','0407','0700','0701','0702','0703','0900','0901','1002') \n " + " THEN ISNULL(TSP.AMT_ENTRY_01, 0) \n " + " ELSE 0 \n " + " END),0) AS CRD_CARD_AMT \n " + " , ROUND (SUM(ISNULL(TSP.PAY_AMT, 0)),0) AS GST_PAY_AMT \n " + " , ROUND (SUM(ISNULL(TSP.AMT_ENTRY_02, 0)),0) AS RET_PAY_AMT \n " + " , ROUND (0,0) AS REPAY_CASH_AMT \n " + " FROM POSLOG..TR_SALE_HEADER TSH \n " + " LEFT JOIN POSLOG..TR_SALE_PAY TSP \n " + " ON TSH.CMP_CD = TSP.CMP_CD \n " + " AND TSH.SALE_DT = TSP.SALE_DT \n " + " AND TSH.STOR_CD = TSP.STOR_CD \n " + " AND TSH.POS_NO = TSP.POS_NO \n " + " AND TSH.TRADE_NO = TSP.TRADE_NO \n " + " AND TSP.PAY_DTL_CD_05 = '1' \n " + " AND TSP.CANCEL_DIV = '0' \n " + " WHERE TSH.CMP_CD = '{0}' \n " + " AND TSH.SALE_DT = '{1}' \n " + " AND TSH.STOR_CD = '{2}' \n " + " AND TSH.POS_NO = '{3}' \n " + " AND TSH.TRADE_NO = '{4}' \n " + " AND TSH.TRAIN_MODE_YN = '0' \n " + " AND TSH.TRADE_KINDPER IN ('00','20','21','42') \n " + " ) B \n " + " , ( \n " + " SELECT SUM(CASE WHEN ISNULL(TSD.SALE_AMT, 0) = 0 \n " + " THEN 0 \n " + " ELSE 1 \n " + " END) AS TRDTL_CNT \n " + " , ROUND (SUM(CASE WHEN ISNULL(TSD.APPLY_TAX_AMT, 0) = 0 \n " + " THEN 0 \n " + " ELSE ISNULL(TSD.BILL_AMT, 0) - ISNULL(TSD.APPLY_TAX_AMT, 0) \n " + " END),0) AS VAT_SALE_AMT \n " + " , ROUND (SUM(CASE WHEN ISNULL(TSD.APPLY_TAX_AMT, 0) = 0 \n " + " THEN ISNULL(TSD.SALE_AMT, 0) \n " + " ELSE 0 \n " + " END),0) AS NO_VAT_SALE_AMT \n " + " FROM POSLOG..TR_SALE_HEADER TSH \n " + " LEFT JOIN POSLOG..TR_SALE_DETAIL TSD \n " + " ON TSH.CMP_CD = TSD.CMP_CD \n " + " AND TSH.SALE_DT = TSD.SALE_DT \n " + " AND TSH.STOR_CD = TSD.STOR_CD \n " + " AND TSH.POS_NO = TSD.POS_NO \n " + " AND TSH.TRADE_NO = TSD.TRADE_NO \n " + " AND TSD.CANCEL_DIV = '0' \n " + " WHERE TSH.CMP_CD = '{0}' \n " + " AND TSH.SALE_DT = '{1}' \n " + " AND TSH.STOR_CD = '{2}' \n " + " AND TSH.POS_NO = '{3}' \n " + " AND TSH.TRADE_NO = '{4}' \n " + " AND TSH.TRAIN_MODE_YN = '0' \n " + " AND TSH.TRADE_KINDPER IN ('00','20','21','42') \n " + " ) C \n " + " , ( \n " + " SELECT SUM(CASE WHEN TSE.ETC_DTL_CD_01 = '00' \n " + " THEN 1 \n " + " ELSE 0 \n " + " END) AS TRCSH_CNT \n " + " , ISNULL(SUM(TSE.ETC_AMT), 0) AS CASH_BILL_AMT \n " + " FROM POSLOG..TR_SALE_HEADER TSH \n " + " LEFT JOIN POSLOG..TR_SALE_ETC TSE \n " + " ON TSH.CMP_CD = TSE.CMP_CD \n " + " AND TSH.SALE_DT = TSE.SALE_DT \n " + " AND TSH.STOR_CD = TSE.STOR_CD \n " + " AND TSH.POS_NO = TSE.POS_NO \n " + " AND TSH.TRADE_NO = TSE.TRADE_NO \n " + " AND TSE.ETC_WAY_CD = '80' \n " + " WHERE TSH.CMP_CD = '{0}' \n " + " AND TSH.SALE_DT = '{1}' \n " + " AND TSH.STOR_CD = '{2}' \n " + " AND TSH.POS_NO = '{3}' \n " + " AND TSH.TRADE_NO = '{4}' \n " + " AND TSH.TRAIN_MODE_YN = '0' \n " + " AND TSH.TRADE_KINDPER IN ('00','20','21','42') \n " + " ) D \n " + " WHERE A.CMP_CD = '{0}' \n " + " AND A.SALE_DT = '{1}' \n " + " AND A.STOR_CD = '{2}' \n " + " AND A.POS_NO = '{3}' \n " + " AND A.TRADE_NO = '{4}' \n " + " AND A.TRAIN_MODE_YN = '0' \n " + " AND A.TRADE_KINDPER IN ('00','20','21','42') \n "; dtReturn = null; sQuery = string.Format(sSelQuery, sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); if (dtReturn != null && dtReturn.Rows.Count != 0) { DataRow dr = dtReturn.Rows[0]; ht_SaleHD.Add(RESTAREA_SALE_HD.SALE_DAY, CmUtil.GetDataRowStr(dr, "SALE_DAY")); ht_SaleHD.Add(RESTAREA_SALE_HD.BILL_NO, CmUtil.GetDataRowStr(dr, "BILL_NO")); ht_SaleHD.Add(RESTAREA_SALE_HD.SALE_GB, CmUtil.GetDataRowStr(dr, "SALE_GB")); ht_SaleHD.Add(RESTAREA_SALE_HD.SYS_DTIME, CmUtil.GetDataRowStr(dr, "SYS_DTIME")); ht_SaleHD.Add(RESTAREA_SALE_HD.DETAIL_CNT, CmUtil.GetDataRowStr(dr, "DETAIL_CNT")); ht_SaleHD.Add(RESTAREA_SALE_HD.SLIP_CNT, CmUtil.GetDataRowStr(dr, "SLIP_CNT")); ht_SaleHD.Add(RESTAREA_SALE_HD.TOT_PAN_AMT, CmUtil.GetDataRowStr(dr, "TOT_PAN_AMT")); ht_SaleHD.Add(RESTAREA_SALE_HD.CASH_AMT, CmUtil.GetDataRowStr(dr, "CASH_AMT")); ht_SaleHD.Add(RESTAREA_SALE_HD.CARD_AMT, CmUtil.GetDataRowStr(dr, "CARD_AMT")); ht_SaleHD.Add(RESTAREA_SALE_HD.GIFT_AMT, CmUtil.GetDataRowStr(dr, "GIFT_AMT")); ht_SaleHD.Add(RESTAREA_SALE_HD.SC_AMT, CmUtil.GetDataRowStr(dr, "SC_AMT")); ht_SaleHD.Add(RESTAREA_SALE_HD.PRE_PAY_AMT, CmUtil.GetDataRowStr(dr, "PRE_PAY_AMT")); ht_SaleHD.Add(RESTAREA_SALE_HD.FEE_PROFIT_AMT, CmUtil.GetDataRowStr(dr, "FEE_PROFIT_AMT")); ht_SaleHD.Add(RESTAREA_SALE_HD.REAL_PAN_AMT, CmUtil.GetDataRowStr(dr, "REAL_PAN_AMT")); ht_SaleHD.Add(RESTAREA_SALE_HD.VAT_AMT, CmUtil.GetDataRowStr(dr, "VAT_AMT")); ht_SaleHD.Add(RESTAREA_SALE_HD.NET_PAN_AMT, CmUtil.GetDataRowStr(dr, "NET_PAN_AMT")); ht_SaleHD.Add(RESTAREA_SALE_HD.CASH_BILL_GB, CmUtil.GetDataRowStr(dr, "CASH_BILL_GB")); ht_SaleHD.Add(RESTAREA_SALE_HD.ORG_BILL_NO, CmUtil.GetDataRowStr(dr, "ORG_BILL_NO")); ht_SaleHD.Add(RESTAREA_SALE_HD.EMP_ID, CmUtil.GetDataRowStr(dr, "EMP_ID")); ht_SaleHD.Add(RESTAREA_SALE_HD.OIL_PROC_CB, CmUtil.GetDataRowStr(dr, "OIL_PROC_CB")); ht_SaleHD.Add(RESTAREA_SALE_HD.BONUS_USE_AMT, CmUtil.GetDataRowStr(dr, "BONUS_USE_AMT")); ht_SaleHD.Add(RESTAREA_SALE_HD.DC_AMT, CmUtil.GetDataRowStr(dr, "DC_AMT")); ht_SaleHD.Add(RESTAREA_SALE_HD.NORM_DC_AMT, CmUtil.GetDataRowStr(dr, "NORM_DC_AMT")); ht_SaleHD.Add(RESTAREA_SALE_HD.BONUS_DC_AMT, CmUtil.GetDataRowStr(dr, "BONUS_DC_AMT")); ht_SaleHD.Add(RESTAREA_SALE_HD.RAND_BONUS_DC_AMT, CmUtil.GetDataRowStr(dr, "RAND_BONUS_DC_AMT")); } #endregion SALE_HD htSaleHDData = ht_SaleHD; bRet = 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 (함수명)) "도로공사 Hi-쉼마루 SaleHD -> " + sQuery + " : " + ex.Message); bRet = false; } return bRet; } #endregion //#20180322 휴게소pos매출연동 end,phj //#15945 해피오더 자동주문 상세기능 start //해피오더 자동주문 로그 전송(HPO_AUTOORDER_LOG) public void HappyOrderAutoOrderLogSendProcess() { DataTable dtReturn = null; Hashtable htData = null; string sSendFlag = string.Empty; string sCmpCd = string.Empty; string sBrandCd = string.Empty; string sStorCd = string.Empty; string sSaleDt = string.Empty; string sPosNo = string.Empty; string sStatus = string.Empty; string sOrderNo = string.Empty; string sOrderType = string.Empty; try { // 전송할 HPO_AUTOORDER_LOG 데이터 생성 htData = GetHappyOrderAutoOrderLogData(ref dtReturn); if (dtReturn == null || dtReturn.Rows.Count == 0) { return; } else { iSendDataCnt += 1; } sCmpCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "CMP_CD"); sBrandCd = m_cPosStatus.Base.BrandCd; sSaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SALE_DT"); sStorCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STOR_CD"); sPosNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "POS_NO"); sOrderType = CmUtil.GetDataRowStr(dtReturn.Rows[0], "ORDER_TYPE"); sOrderNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "ORDER_NO"); sStatus = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STATUS"); string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, Convert.ToInt32(m_cPosStatus.Base.JrnlPort), 5000, new string[] { sCmpCd, sBrandCd, sStorCd, sSaleDt, sPosNo, "" }, ItemConst.COMM_MSG_TYPE.HPO_AUTOORDER_LOG, htData); if (sReturn == UserCom.RST_OK) { sSendFlag = "1"; // 정상 전송 m_cPosStatus.Sale.OnLineStatus = "1"; } else { sSendFlag = "9"; // 에러 m_cPosStatus.Sale.OnLineStatus = "0"; } } 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); sSendFlag = "9"; } finally { // Flag Update HappyOrderAutoOrderLogUpdate(sCmpCd, sSaleDt, sStorCd, sPosNo, sOrderNo, sStatus, sSendFlag); } } /// /// 데이터 조회 /// /// /// public Hashtable GetHappyOrderAutoOrderLogData(ref DataTable dtReturn) { Hashtable htReturn = null; string sQuery = string.Empty; DataTable dtTempReturn = null; try { ///////////////////////////////////////////////////////////////// /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! ///////////////////////////////////////////////////////////////// //00013523PCKR002 0000007 201808025400002201807301740181000{"ORDER_NO":"A100","STATUS":"5","PRE_STATUS":"4", "CLOUD_RES":"200", "GUBUN":"P", "CASHIER_ID":"0000007123", "REG_DATE":"201808031159"} sQuery += "SELECT TOP 1 "; sQuery += " CMP_CD,SALE_DT,STOR_CD,POS_NO,ORDER_NO,PRE_STATUS,STATUS,ORDER_TYPE,CLOUD_RES,GUBUN,CASHIER_ID,REG_DATE "; sQuery += " FROM POSLOG.dbo.TR_AUTOMATICSHIPMENT_LOG "; sQuery += " WHERE SEND_YN <> '1' "; sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; sQuery += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "' "; sQuery += " ORDER BY SEND_YN ASC "; if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) { if (dtTempReturn.Rows.Count == 1) { DataRow drTempReturn = dtTempReturn.Rows[0]; htReturn = MakeHappyOrderAutoOrderLogJsonData(drTempReturn); } } dtReturn = dtTempReturn; } 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 htReturn; } /// /// 전문 생성 /// /// /// private Hashtable MakeHappyOrderAutoOrderLogJsonData(DataRow drData) { Hashtable htData = new Hashtable(); try { ///////////////////////////////////////////////////////////////// /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! ///////////////////////////////////////////////////////////////// // 전문 생성 for (int iRow = 0; iRow < drData.Table.Columns.Count; iRow++) { if (drData.Table.Columns[iRow].ColumnName == "CMP_CD" || drData.Table.Columns[iRow].ColumnName == "SALE_DT" || drData.Table.Columns[iRow].ColumnName == "STOR_CD" || drData.Table.Columns[iRow].ColumnName == "POS_NO" || drData.Table.Columns[iRow].ColumnName == "ORDER_TYPE") continue; htData.Add(drData.Table.Columns[iRow].ColumnName, drData[iRow].ToString()); } } 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 htData; } /// /// 디비 업데이트 /// /// /// /// /// /// /// private int HappyOrderAutoOrderLogUpdate(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sOrderNo, string sStatus, string sSendFlag) { int iRet = UserCom.NG; string sQuery = string.Empty; try { if (sCmpCd.Trim() == "" || sSaleDt.Trim() == "" || sStorCd.Trim() == "" || sPosNo.Trim() == "" || sOrderNo.Trim() == "" || sStatus.Trim() == "") return iRet; sQuery += "UPDATE POSLOG.dbo.TR_AUTOMATICSHIPMENT_LOG "; sQuery += " SET SEND_YN = '" + sSendFlag + "' "; sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; sQuery += " AND SALE_DT = '" + sSaleDt + "' "; sQuery += " AND STOR_CD = '" + sStorCd + "' "; sQuery += " AND POS_NO = '" + sPosNo + "' "; sQuery += " AND ORDER_NO = '" + sOrderNo + "' "; sQuery += " AND STATUS = '" + sStatus + "' "; iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); } 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; } //#15945 해피오더 자동주문 상세기능 end } }