using System.IO;
using System.Net;
using System.Data;
using System.Net.NetworkInformation;

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

/*-----------------------------------------------------------------------------------------------*/
// 설      명 : 
// 작  성  자 : 
// 변경  이력 : 
/*-----------------------------------------------------------------------------------------------*/
namespace Cosmos.Service
{
    class NoticeCampaignInfo : IDataServiceUs
    {
        private SManager sManager = new SManager();                                 // 이 객체를 통해 업무 Service 호출
        private StateServer StateObject = (StateServer)StateServer.GetInstance();   // StateObject : StateServer Object (객체)
        private PosStatus m_cPosStatus;                                             // 기본정보 참조
        private TranStatus m_cTrnStatus;                                            // 거래정보 참조        
        private IMasterUs m_cMstService = null;                                     // 마스터 인터페이스

        public NoticeCampaignInfo()
        {
            m_cPosStatus = (PosStatus)StateObject.POS;              // POS 기본정보
            m_cTrnStatus = (TranStatus)StateObject.TRAN;            // POS 거래정보
            m_cMstService = (IMasterUs)sManager.InitServiceInstance(ServiceLists.ASV_MASTER.DLL, ServiceLists.ASV_MASTER.POS_MASTER);
        }


        /// <summary>
        /// 실행
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public string Execute(string[] aParam)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 데이터 저장
        /// </summary>
        /// <param name="oParam"></param>
        /// <returns></returns>
        public string SetData(object oParam)
        {
            string sReturn = UserCom.RST_ERR;

            //string sQuery = "";
            try
            {
                sReturn = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return sReturn;
        }

        /// <summary>
        /// 데이터 조회
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public object GetData(string[] aParam)
        {

            DataTable dt = null;

            string sQuery = "";
            try
            {

                if (aParam[0] == "NOTICE")
                {

                }
                else if (aParam[0] == PosMst.MST_CPI.TABLE_NAME)
                {
                    sQuery = " SELECT ROW_NUMBER() OVER( ORDER BY CPI_CD ASC) AS NO,CPI_CD,CPI_NM,CPI_EXPLN,CPI_INFO ";
                    sQuery += "  FROM POSMST.dbo.MST_CPI WITH(NOLOCK) ";
                    sQuery += " WHERE 1 = 1 ";
                    sQuery += "  AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'  ";
                    sQuery += "  AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' ";
                    sQuery += "  AND '" + m_cPosStatus.Base.SaleDate + "' BETWEEN STARTDAY AND FNSHDAY ";
                    sQuery += "  AND PRGRS_STATUS  = 'C'";
                    sQuery += "  AND USE_YN = '" + PosConst.MST_USE_YN.YES + "' ";
                }

                dt = m_cMstService.Select(new string[] { sQuery });
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return dt;
        }

    }


}
