//#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 start
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data;

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

/*-----------------------------------------------------------------------------------------------*/
// 설      명 : 쿠폰 전송
// 작  성  자 : 
// 변경  이력 : 
/*-----------------------------------------------------------------------------------------------*/
namespace Cosmos.Win
{
    public partial class frmCpnSend : Form
    {
        #region Variable

        private SManager sManager = new SManager();                                 // 이 객체를 통해 업무 Service 호출
        private StateServer StateObject = (StateServer)StateServer.GetInstance();   // StateObject : StateServer Object (객체)
        private PosStatus m_cPosStatus = new PosStatus();                           // 기본정보 참조
        private TranStatus m_cTrnStatus = new TranStatus();                         // 거래정보 참조
        private PosOLEDevice.DelegateOlePos delegatePos;

        private string m_sInPutType;
        private string m_sInMaskData;
        private string m_sInEncData;
        private string m_sInServiceCode;
        private string m_sInAppCardNo;

        public string SetInPutType { set { this.m_sInPutType = value; } }
        public string SetInMaskData { set { this.m_sInMaskData = value; } }
        public string SetInEncData { set { this.m_sInEncData = value; } }
        public string SetInServiceCode { set { this.m_sInServiceCode = value; } }
        public string SetInAppCardNo { set { this.m_sInAppCardNo = value; } }

        private IDataProcessUs m_cDataSrv = null;
        private IDataCommonUs m_cDataCommon = null;                                 // POS 공통함수 인터페이스
        private ISvr2Tran m_cSvr2Tran = null;
        private IPaymentUs m_cHappyPoint = null;

        /// <summary>
        /// 마스터 인터페이스
        /// </summary>
        protected IMasterUs m_cMstService = null;

        //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 start, 20180510
        //쿠폰 표시 그리드 형태로 변경
        /// <summary>
        /// 쿠폰 리스트
        /// </summary>
        private DataTable m_dtSearchList;
        //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 end, 20180510
        
        //오퍼ID
        string sOPPRID = "";


        #endregion
        
        #region 생성자 & 소멸자
        /// <summary>
        /// 생성자
        /// </summary>
        public frmCpnSend()
        {
            InitializeComponent();

            base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true);
            //this.UpdateStyles();

            m_cPosStatus = (PosStatus)StateObject.POS;      // POS 기본정보
            m_cTrnStatus = (TranStatus)StateObject.TRAN;    // POS 거래정보
            
            m_cDataSrv = (IDataProcessUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_SERVICE);
            m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON);
            m_cSvr2Tran = (ISvr2Tran)sManager.InitServiceInstance(ServiceLists.BSV_SALE.DLL, ServiceLists.BSV_SALE.SVR2TRAN);
            m_cHappyPoint = (IPaymentUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.CPN_SEND);
            m_cMstService = (IMasterUs)sManager.InitServiceInstance(ServiceLists.ASV_MASTER.DLL, ServiceLists.ASV_MASTER.POS_MASTER);
        }

        #endregion 생성자 & 소멸자
        
        #region 폼 컨트롤 초기화
        /// <summary>
        /// 폼 컨트롤 초기화
        /// </summary>
        private void InitControl()
        {
            try
            {
                // 이미지 로딩 처리
                //picBack.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.SCH_MESSAGE_BOX);

                FormManager.SetFormAllControlFont(this, m_cPosStatus.Base.FONT);
                FormManager.SetTextBoxGlobalInfo(this, m_cPosStatus.Global.m_stCultureMaster.nGroupingDigits, m_cPosStatus.Global.m_stCultureMaster.strGroupingSymbol
                    , m_cPosStatus.Global.m_stCultureMaster.nDecimalDigits, m_cPosStatus.Global.m_stCultureMaster.strDecimalSymbol);
                FormManager.MovePopUpForm(this, false, m_cPosStatus.Sale.ScreenSizeUser);

                btnExit.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.BTN_CLOSE);
                if (btnExit.Image != null) btnExit.Text = "";

                // 메시지 처리
                lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_1122);
                csmLabel5.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_1120);
                csmLabel1.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_1121);
                btnSend.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_1119);
                btnCancel.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0010);

                //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 start, 20180510
                //기존 소스 주석 미사용
                /*
                CpnBtnIni("0");

                CpnGubunSearch();
                */
                //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 end, 20180510

                //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 start, 20180510
                //쿠폰 표시 그리드 형태로 변경


                btnUp2.Image = CmUtil.LoadImage(BaseCom.NxImgPath + ImageManager.NAVIBTN_14X9_UP2_BASIC);
                btnDw2.Image = CmUtil.LoadImage(BaseCom.NxImgPath + ImageManager.NAVIBTN_14X9_DOWN2_BASIC);
                
                //그리드 초기화 테이블
                InitializeGrid();
                // 쿠폰 리스트 조회
                CpnSearch();
                
                //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 end, 20180510
            }
            catch (Exception ex)
            {
               WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
        }         
        #endregion

        //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 start, 20180510
        //쿠폰 표시 그리드 형태로 변경
        #region 그리드 초기화
        /// <summary>
        /// 그리드 초기화
        /// </summary>
        private void InitializeGrid()
        {
            try
            {
                grdSearchList.CsmGridColumnHeadersVisible = false;           //DataGridView 자체의 컬럼 헤더 Visible 여부

                grdSearchList.CsmGridColumnHeadersFont = new Font(m_cPosStatus.Base.FONT, 12);

                grdSearchList.CsmGridColumnHeadersHeight = 36;              //DataGridView 자체의 컬럼 헤더 높이
                grdSearchList.CsmGridRowsHeight = 47;
                grdSearchList.CsmGridColumnCount = 5;                      //그리드의 컬럼수
                grdSearchList.CsmGridShowPageRowsCount = 5;                //그리드의 한 화면에 보이는 로우수
                grdSearchList.CsmGridSetHeaderBackColor(236, 238, 239);                             //그리드 헤더 배경색
                grdSearchList.CsmGridDefaultRowBackColor = Color.FromArgb(255, 255, 255);           //그리드 홀수(Default)행의 배경색 지정
                grdSearchList.CsmGridAlternateRowBackColor = Color.FromArgb(251, 253, 255);         //그리드 짝수(Alternate)행의 배경색 지정
                grdSearchList.CsmGridBackGroundColor = Color.FromArgb(251, 253, 255);               //기본 백그라운드 컬러
                grdSearchList.CsmGridHighlightColor = Color.FromArgb(255, 251, 211);                //그리드 선택 백 컬러
                grdSearchList.CsmGridHighlightTextColor = Color.Black;                              //그리드 선택 글자 컬러
                grdSearchList.CsmGridSetColumnWidth(new int[] { 0, 400, 0, 0, 0 });   //컬럼넓이 지정
                grdSearchList.CsmGridAlignment(new int[] { 1, 1, 2, 2, 1 });               //컬럼 정렬 0:왼쪽, 1:가운데, 2:오른쪽

                //각 컬럼별 이름 지정(유형, 할인률, 최소승인금액, 최대승인금액)
                grdSearchList.CsmGridColumnName(0, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_1120));
                grdSearchList.CsmGridColumnName(1, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_1121));


                //그리드 초기화 테이블
                m_dtSearchList = new DataTable("CPN_INIT");
                m_dtSearchList.Columns.Add(new DataColumn("GUBUN", typeof(string)));
                m_dtSearchList.Columns.Add(new DataColumn("DCRATE", typeof(string)));
                m_dtSearchList.Columns.Add(new DataColumn("MINDCAMT", typeof(string)));
                m_dtSearchList.Columns.Add(new DataColumn("MAXDCAMT", typeof(string)));
                m_dtSearchList.Columns.Add(new DataColumn("OPPERID", typeof(string)));

                m_dtSearchList.Clear();

            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
        }
        #endregion
        //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 end, 20180510

        #region 버튼 입력 처리
        private void btnCpnSend_Click(object sender, EventArgs e)
        {
            try
            {
                if (((Cosmos.UI.CsmButton)sender) == btnSend)   // 발송
                {
                    //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 start, 20180510
                    //쿠폰 표시 그리드 형태로 변경
                    if (grdSearchList.CsmGridRowsCount == 0)
                    {
                        // 쿠폰을 선택 해주세요
                        WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0782);
                        return;
                    }

                    int nRow = grdSearchList.CsmGridSelectedRowIndex;
                    if (nRow < 0)
                    {
                        // 쿠폰을 선택 해주세요
                        WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0782);
                        return;
                    }

                    // 오퍼ID
                    string sOPPRID = grdSearchList.CsmGridGetCell(nRow, 4);
                    //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 end, 20180510

                    // 오퍼ID
                    //string sOPPRID = "";

                    if (sOPPRID == "")
                    {
                        // 쿠폰을 선택 해주세요
                        WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0782);
                        return;
                    }

                    // 쿠폰 발송
                    //string[] saRecvdData = null;

                    string sRet = m_cHappyPoint.SetPayment(new string[] { m_sInPutType, m_sInMaskData, m_sInEncData, "13", m_sInAppCardNo, sOPPRID });
                    if (sRet == UserCom.RST_OK)
                    {
                        //쿠폰발송이 완료되었습니다.
                        WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0784);
                        //MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0783);

                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                }
                else if (((Cosmos.UI.CsmButton)sender) == btnCancel)     // 취소
                {
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }

                //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 start, 20180510
                //쿠폰 표시 그리드 형태로 변경
                else if (((Cosmos.UI.CsmButton)sender) == btnUp2)
                {
                    grdSearchList.CsmGridScroll("PAGE UP");
                }
                else if (((Cosmos.UI.CsmButton)sender) == btnDw2)
                {
                    grdSearchList.CsmGridScroll("PAGE DOWN");
                }
                //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 end, 20180510

                //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 start, 20180510
                //기존 소스 주석 미사용
                /*
                else if ((((Cosmos.UI.CsmButton)sender).Name.Substring(0,7)) == "btnCpnG")     // 유형
                {
                    CpnBtnIni("1");
                    CpnBtnIni("2");
                    ((Cosmos.UI.CsmButton)sender).BackColor = System.Drawing.Color.Gold;
                    CpnRateSearch(((Cosmos.UI.CsmButton)sender).Tag.ToString());
                }
                else if ((((Cosmos.UI.CsmButton)sender).Name.Substring(0, 7)) == "btnCpnR")     // 할인율
                {
                    CpnBtnIni("2");
                    ((Cosmos.UI.CsmButton)sender).BackColor = System.Drawing.Color.Gold;
                    sOPPRID = ((Cosmos.UI.CsmButton)sender).Tag.ToString();
                }
                */
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            try
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
                this.Close();
            }
        }
        #endregion

        private void frmCpnSend_FormClosing(object sender, FormClosingEventArgs e)
        {
            UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", lblTitle.Text);
        }

        private void frmCpnSend_Load(object sender, EventArgs e)
        {
            UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "");
            InitControl();
        }

        //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 start, 20180510
        //쿠폰 표시 그리드 형태로 변경
        #region 쿠폰 조회
        /// <summary>
        /// 쿠폰 조회
        /// </summary>   
        private void CpnSearch()
        {
            string sQuery = "";
            
            try
            {
                //그리드 초기화 테이블
                m_dtSearchList.Clear();

                // 쿠폰 리스트 조회
                sQuery += " SELECT B.CMM_CD, B.ENTRY_NM, B.CHAR_VAL_TITLE_VAL_02 ";
                sQuery += "   FROM STR_SEND_CPN_DTL A INNER JOIN ";
                sQuery += "        ( ";
                sQuery += "        SELECT CMP_CD, CMM_GRP_CD, CMM_CD, ENTRY_NM, DISP_SEQ, CHAR_VAL_TITLE_VAL_02 ";
                sQuery += "          FROM MST_CMM ";
                sQuery += "         WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "           AND CMM_GRP_CD = 'T0037' ";
                //#15525 고객구매이력 수정 요청 start
                //발송가능한 쿠폰을 브랜드별로 관리
                sQuery += "           AND SALES_ORG_CD = '" + m_cPosStatus.Base.BrandCd + "'";
                //#15525 고객구매이력 수정 요청 end
                sQuery += "           AND USE_YN = '" + PosConst.MST_USE_YN.YES + "' ";
                sQuery += "        ) AS B ";
                sQuery += "     ON A.CMP_CD = B.CMP_CD AND A.CODE = B.CMM_CD ";
                sQuery += "  WHERE A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "    AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'";
                sQuery += "    AND A.USE_YN = '" + PosConst.MST_USE_YN.YES + "' ";
                sQuery += "  ORDER BY B.DISP_SEQ ";

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

                if (dtMstCpi != null && dtMstCpi.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtMstCpi.Rows)
                    {
                        DataRow drNewRow = m_dtSearchList.NewRow();
                        drNewRow["GUBUN"] = CmUtil.GetDataRowStr(dr, "CMM_CD");
                        drNewRow["DCRATE"] = CmUtil.GetDataRowStr(dr, "ENTRY_NM");
                        drNewRow["MINDCAMT"] = "";
                        drNewRow["MAXDCAMT"] = "";
                        drNewRow["OPPERID"] = CmUtil.GetDataRowStr(dr, "CHAR_VAL_TITLE_VAL_02");

                        m_dtSearchList.Rows.Add(drNewRow);
                    }
                }
                else
                {
                    WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0302));
                }

                // 그리드 적용
                grdSearchList.CsmGridDataSource = m_dtSearchList;

                grdSearchList.CsmGridSelectRow(0);
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
        }
        #endregion
        //#20180418 고객 구매이력 정보 표시 및 해피쿠폰 발송 end, 20180510

        #region 쿠폰 유형 조회
        /// <summary>
        /// 쿠폰 유형 조회
        /// </summary>       
        private void CpnGubunSearch()
        {
            string sQuery = "";

            try
            {
                // 쿠폰 리스트 조회
                sQuery += " SELECT TOP 5 * FROM POSMST..MST_CMM ";
                sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "   AND CMM_GRP_CD = 'T0036'";
                sQuery += "   AND LANG_TYPE = '" + m_cPosStatus.Base.Country + "'";
                sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                sQuery += " ORDER BY CMM_GRP_CD, DISP_SEQ, CMM_CD ";
                
                DataTable dtMstCpi =  m_cMstService.Select(new string[] { sQuery });
                int seq = 1;
                if (dtMstCpi != null && dtMstCpi.Rows.Count > 0)
                {

                    foreach (DataRow dr in dtMstCpi.Rows)
                    {

                        foreach (Control control in this.Controls)
                        {
                            if (control is UI.CsmButton)
                            {
                                if (control.Name == "btnCpnGubun" + seq.ToString())
                                {
                                    
                                    control.Text = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CD_NM);
                                    control.Tag = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CMM_CD);
                                }
                            }

                        }

                        seq++;
                    }
                }
                else
                {
                    //WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0302));
                }

                /*
                DataTable dtData = m_cDataCommon.SeletCommonCode("T0036", "");
                if (dtData != null && dtData.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtData.Rows)
                    {
                        foreach (Control control in this.Controls)
                        {
                            if (control is UI.CsmButton)
                            {
                                if (control.Name.Substring(0, 7) == "btnCpnG" || control.Name.Substring(0, 7) == "btnCpnR")
                                {
                                    control.Text = "";
                                    control.Tag = "";
                                    //control.Visible = true;
                                }
                            }

                        }
                        DataRow drNewRow = m_dtSearchList.NewRow();
                        drNewRow["COUPONTYPE"]      = CmUtil.GetDataRowStr(dr, "ENTRY_NM");
                        drNewRow["CouponOPPERID"]   = CmUtil.GetDataRowStr(dr, "CHAR_VAL_TITLE_VAL_01");

                        m_dtSearchList.Rows.Add(drNewRow);
                    }
                }
                else
                {
                    WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0302));
                }
                */

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

        #region 쿠폰 할인율 조회
        /// <summary>
        /// 쿠폰 할인율 조회
        /// </summary>       
        private void CpnRateSearch(string sCpnGbCd)
        {
            string sQuery = "";

            try
            {
                //CHAR_VAL_TITLE_VAL_01 : 쿠폰 유형 코드
                //CHAR_VAL_TITLE_VAL_02 : 오퍼ID
                sQuery += " SELECT TOP 5 * FROM POSMST..MST_CMM ";
                sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'";
                sQuery += "   AND CMM_GRP_CD = 'T0037'";
                sQuery += "   AND CHAR_VAL_TITLE_VAL_01 = '" + sCpnGbCd + "'";
                sQuery += "   AND LANG_TYPE = '" + m_cPosStatus.Base.Country + "'";
                sQuery += "   AND USE_YN  = '" + PosConst.MST_USE_YN.YES + "'";
                sQuery += " ORDER BY CMM_GRP_CD, DISP_SEQ, CMM_CD ";

                DataTable dtMstCpi = m_cMstService.Select(new string[] { sQuery });
                int seq = 1;
                if (dtMstCpi != null && dtMstCpi.Rows.Count > 0)
                {

                    foreach (DataRow dr in dtMstCpi.Rows)
                    {

                        foreach (Control control in this.Controls)
                        {
                            if (control is UI.CsmButton)
                            {
                                if (control.Name == "btnCpnRate" + seq.ToString())
                                {

                                    control.Text = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CD_NM);
                                    control.Tag = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CHAR_VAL_TITLE_VAL_02);
                                }
                            }

                        }

                        seq++;
                    }
                }
                else
                {
                    //WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0302));
                }
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
        }
        #endregion

        #region 버튼 초기화
        /// <summary>
        /// 버튼 초기화
        /// <param name="sGB"></param>
        /// </summary>
        private void CpnBtnIni(string sGB) // sGB(0: 전체 초기화, 1: 유형 초기화, 2: 할인 초기화)
        {
            try
            {
                //버튼 변경시 오퍼ID 초기화
                sOPPRID = "";

                foreach (Control control in this.Controls)
                {
                    if (control is UI.CsmButton)
                    {
                        if (sGB == "0")
                        {
                            if (control.Name.Substring(0, 7) == "btnCpnG" || control.Name.Substring(0, 7) == "btnCpnR")
                            {
                                control.Text = "";
                                control.Tag = "";
                                control.BackColor = System.Drawing.Color.White;
                            }
                        }
                        else if (sGB == "1")
                        {
                            if (control.Name.Substring(0, 7) == "btnCpnG")
                            {
                                //control.Text = "";
                                //control.Tag = "";
                                control.BackColor = System.Drawing.Color.White;
                            }
                        }
                        else if (sGB == "2")
                        {
                            if (control.Name.Substring(0, 7) == "btnCpnR")
                            {
                                //control.Text = "";
                                //control.Tag = "";
                                control.BackColor = System.Drawing.Color.White;
                            }
                        } 
                    }

                }


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