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

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

/*-----------------------------------------------------------------------------------------------*/
// 설      명 : PVC 상자재고
// 작  성  자 : 
// 변경  이력 : 
/*-----------------------------------------------------------------------------------------------*/
namespace Cosmos.Service
{
    class EtcPvc : IServiceUs
    {
        private SManager sManager = new SManager();                                 // 이 객체를 통해 업무 Service 호출
        private PosStatus m_cPosStatus = new PosStatus();                           //기본정보 참조
        private StateServer StateObject = (StateServer)StateServer.GetInstance();   // StateObject : StateServer Object (객체)

        protected IDataCommonUs m_cDataCommon = null;                               // 판매공통 모듈

        public EtcPvc()
        {
            m_cPosStatus = (PosStatus)StateObject.POS;                              // POS 기본정보
            m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON);

        }

        /// <summary>
        /// PVC 재고 등록
        /// </summary>
        /// <returns></returns>
        public string Execute(string[] aParam)
        {
            string sRet = UserCom.RST_ERR;

            try
            {
                Hashtable htSendData = new Hashtable();
                Hashtable htRecvData = new Hashtable();

                htSendData.Add(Column.IQ_PVCSTOCK_INQ_REQ.DATA.INQ_TYPE, ItemConst.IRT_INQ_TYPE.PVCSTOCK_INQ);
                htSendData.Add(Column.IQ_PVCSTOCK_INQ_REQ.DATA.STOR_CD, m_cPosStatus.Base.StoreNo);
                htSendData.Add(Column.IQ_PVCSTOCK_INQ_REQ.DATA.SALE_DT, m_cPosStatus.Base.SaleDate);
                htSendData.Add(Column.IQ_PVCSTOCK_INQ_REQ.DATA.PVC_L_QTY, aParam[0]);
                htSendData.Add(Column.IQ_PVCSTOCK_INQ_REQ.DATA.PVC_M_QTY, aParam[1]);
                htSendData.Add(Column.IQ_PVCSTOCK_INQ_REQ.DATA.PVC_S_QTY, aParam[2]);
                htSendData.Add(Column.IQ_PVCSTOCK_INQ_REQ.DATA.USER_ID, m_cPosStatus.Base.CashierNo);
                htSendData.Add(Column.IQ_PVCSTOCK_INQ_REQ.DATA.REG_YMDHMS, DateTime.Now.ToString("yyyyMMddHHmmss"));

                sRet = m_cDataCommon.ExecutePosIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.BizInqPort, 10000, htSendData, ref htRecvData);
                if (sRet != UserCom.RST_OK)
                {
                    return sRet;
                }

                if (htRecvData[Column.IQ_PVCSTOCK_INQ_RES.DATA.RES_CD].ToString() != "00")
                {
                    return sRet;
                }

                sRet = UserCom.RST_OK;

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