using System;
using System.Drawing;
using System.Windows.Forms;

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

namespace Cosmos.Win
{
    public partial class frmCheck : frm_PayMainBack
    {

        #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 IDataProcessUs m_cDataService = null;
        private IPaymentUs m_cCash = null;
        private IDataCommonUs m_cDataCommon = null;                                 // POS 공통함수 인터페이스

        private Column.TR_PAYMENT.DATA m_cMultiCard = null;
        private DeviceStatus m_cDevStatus = new DeviceStatus();                     // 디바이스 관리
        private PosOLEDevice.DelegateOlePos delegatePos;

        private bool m_bApproval;
        
        private string m_sPosMenuKey;
        public string SetPosMenuKey { set { this.m_sPosMenuKey = value; } }         // POS 기능키

        #endregion

        #region 생성자 & 소멸자
        public frmCheck()
        {
            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_cCash = (IPaymentUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.CASH);
            m_cDataService = (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);

            delegatePos = new PosOLEDevice.DelegateOlePos(OnDeviceEvent);
            m_cDevStatus = (DeviceStatus)StateObject.DEVICE;
        }

        private void frmCheck_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();  
        }

        private void frmCheck_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (m_sPosMenuKey != PosKey.MENU_KEY.CHECK_CASH) FormManager.SetFormAllControlMove(this, 216, 123);

            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 frmCheck_Activated(object sender, EventArgs e)
        {
            PosOLEDevice.SetEventHandle(delegatePos);
        }
        private void frmCheck_Deactivate(object sender, EventArgs e)
        {
            PosOLEDevice.SetEventHandle(null);
        }

        #endregion 생성자 & 소멸자

        #region 폼 컨트롤 초기화
        /// <summary>
        /// 폼 컨트롤 초기화
        /// </summary>
        private void InitControl()
        {
            try
            {
                //picBack.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.POP_SIZE_S);
                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);

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

                if (m_sPosMenuKey == PosKey.MENU_KEY.CHECK_CASH)
                {
                    this.Location = new Point(0, 50);
                    this.Size = new Size(1024, 525);
                    picBack.Size = new Size(1024, 525);

                    //#20181015 결제창 엑박 관련 이미지 미사용 처리 start
                    //기존
                    //picBack.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.PAY_MAIN_BACKGROUND);
                    //#20181015 결제창 엑박 관련 이미지 미사용 처리 end

                    btnEnter.Visible = true;                    
                }
                else
                {
                    this.Size = new Size(788, 402);

                    //#20181015 결제창 엑박 관련 이미지 미사용 처리 start
                    //기존
                    //picBack.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.POP_SIZE_S);
                    //#20181015 결제창 엑박 관련 이미지 미사용 처리 end

                    FormManager.SetFormAllControlMove(this, -216, -123);
                    FormManager.MovePopUpForm(this, false, m_cPosStatus.Sale.ScreenSizeUser);

                    btnEnter.Visible = false;
                }

                lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0060);

                //lblPayAmt.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0061);
                //lblCheckNo.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0062);
                lblAccountNo.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0063);
                //lbIissueDate.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0064);

                lblNotice.Text = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0434);

                btnEnter.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0263);
                btnSearch.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0004);
                
                InitPayMainBack(m_cPosStatus, m_cDataCommon, m_sPosMenuKey, PosConst.MOT_MSG_TYPE.PAY_STEP_3, "");

                txtCheckNo.Text = "";
                txtPayAmt.Text = "";

                txtAccountNo.Text = "";
                txtissueDate.Text = "";


                txtPayAmt.Enabled = true;
                txtAccountNo.Enabled = true;
                txtissueDate.Enabled = true;

                btnSearch.Enabled = true;

                txtPayAmt.Text = "";
                txtPayAmt.Tag = "";

                lblStsMsg.Text = "";
                lblStsMsg.Tag = ""; //승인여부 체크!!

                SetCheckKind();

                //txtPayAmt.Select();
                btnCheckKind_Click(btnPay1, null);
            }
            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 SetCheckKind()
        {
            int nRow = 0;
            try
            {
                DataTable dtData = new DataTable();

                dtData = m_cDataCommon.SeletCommonCode(PosConst.COMMON_CODE_GROUP.Z0003, "");
                nRow = 0;
                if (dtData != null && dtData.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtData.Rows)
                    {
                        nRow++;
                        if (nRow == 1)
                        {
                            btnPay1.Text = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CD_NM);
                            btnPay1.Tag = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CHAR_VAL_TITLE_VAL_01);
                            btnPay1.Visible = true;
                        }
                        else if (nRow == 2)
                        {
                            btnPay2.Text = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CD_NM);
                            btnPay2.Tag = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CHAR_VAL_TITLE_VAL_01);
                            btnPay2.Visible = true;
                        }
                        else if (nRow == 3)
                        {
                            btnPay3.Text = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CD_NM);
                            btnPay3.Tag = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CHAR_VAL_TITLE_VAL_01);
                            btnPay3.Visible = true;
                        }
                        else if (nRow == 4)
                        {
                            btnPay4.Text = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CD_NM);
                            btnPay4.Tag = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CHAR_VAL_TITLE_VAL_01);
                            btnPay4.Visible = true;
                        }
                        else if (nRow == 5)
                        {
                            btnPay5.Text = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CD_NM);
                            btnPay5.Tag = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CHAR_VAL_TITLE_VAL_01);
                            btnPay5.Visible = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
        }

        #endregion

        #region Control Event

        #region 버튼 입력 처리
        /// <summary>
        /// 버튼 입력 처리
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnProc_Click(object sender, EventArgs e)
        {
            try
            {
                if (((Cosmos.UI.CsmButton)sender) == btnSearch) // 조회
                {
                    txtEditBox_EditBoxKeyDownEvent(null, PosKey.MENU_KEY.SEARCH);
                }
                else if (((Cosmos.UI.CsmButton)sender) == btnEnter) // 승인
                {
                    txtEditBox_EditBoxKeyDownEvent(null, PosKey.MENU_KEY.APPROVAL);
                }
                padInPut.SetActiveFocus();
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
        }

        /// <summary>
        /// 권종 처리
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCheckKind_Click(object sender, EventArgs e)
        {
            try
            {

                SetSelectColor(((UI.CsmButton)sender).Name.ToString());

                string sTmp = ((UI.CsmButton)sender).Tag.ToString();

                txtPayAmt.Tag = CmUtil.MidH(sTmp, 0, 2);

                lblStsMsg.Text = "";

                if (CmUtil.MidH(sTmp, 3, 1) == "")
                {
                    lblStsMsg.Tag = "";
                    txtPayAmt.Value = "";
                    txtPayAmt.Focus();
                }
                else
                {
                    txtPayAmt.Value = ((UI.CsmButton)sender).Tag.ToString().Substring(2);
                    txtEditBox_EditBoxKeyDownEvent(txtPayAmt, PosKey.MENU_KEY.ENTER);
                }


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

        }

        /// <summary>
        /// 버튼 선택 색상 변경
        /// </summary>
        /// <param name="sBtnName"></param>
        private void SetSelectColor(string sBtnName)
        {
            try
            {

                foreach (Control c in this.Controls)
                {
                    if (c is Cosmos.UI.CsmButton)
                    {

                        if (c.Name.StartsWith("btnPay"))
                        {
                            if (c.Name == sBtnName)
                            {
                                c.BackColor = Color.FromArgb(70, 86, 98);
                                c.ForeColor = Color.White;
                            }
                            else
                            {
                                c.BackColor = Color.White;
                                c.ForeColor = Color.FromArgb(70, 86, 98);
                            }
                        }
                    }
                }

            }
            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>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtEditBox_EnterEvent(object sender, EventArgs e)
        {
            try
            {
                padInPut.SetActiveControl = (Control)sender;
            }
            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>
        /// <param name="sender"></param>
        /// <param name="sFuncValue"></param>
        private void txtEditBox_EditBoxKeyDownEvent(object sender, string sFuncValue)
        {
            try
            {
                if (sFuncValue != PosKey.MENU_KEY.APPROVAL)
                {
                    lblStsMsg.Tag = ""; //등록이 아니면 초기화
                    lblStsMsg.Text = "";
                }

                if (sFuncValue == PosKey.MENU_KEY.ENTER)
                {

                    if (((Cosmos.UI.CsmPosEditBox)sender) == txtPayAmt)
                    {
                        if (CheckTxtInPut(txtPayAmt) == false) return;
                        txtCheckNo.Focus();
                    }
                    else if (((Cosmos.UI.CsmPosEditBox)sender) == txtCheckNo)
                    {
                        if (CheckTxtInPut(txtCheckNo) == false) return;
                        txtissueDate.Focus();
                    }
                    else if (((Cosmos.UI.CsmPosEditBox)sender) == txtissueDate)
                    {
                        if (CheckTxtInPut(txtissueDate) == false) return;
                        txtAccountNo.Focus();
                    }
                    else if (((Cosmos.UI.CsmPosEditBox)sender) == txtAccountNo)
                    {
                        if (CheckTxtInPut(txtAccountNo) == false) return;
                    }

                }
                else if (sFuncValue == PosKey.MENU_KEY.CLEAR)
                {
                    if (((Cosmos.UI.CsmPosEditBox)sender).ReadOnly == false) ((Cosmos.UI.CsmPosEditBox)sender).Text = "";
                }
                else if (sFuncValue == PosKey.MENU_KEY.ESC_PREVIOUS)
                {
                    this.DialogResult = DialogResult.Cancel;
                    this.Close();
                }
                else if (sFuncValue == PosKey.MENU_KEY.APPROVAL)
                {
                    if (CheckTxtInPut(null) == false) return;
                    CompleteTxtInPut(2);
                }
                else if (sFuncValue == PosKey.MENU_KEY.SEARCH)
                {
                    if (CheckTxtInPut(null) == false) return;
                    CompleteTxtInPut(1);
                }
            }
            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>
        /// <param name="sender"></param>
        /// <returns></returns>
        private bool CheckTxtInPut(object sender)
        {
            try
            {

                // 수표금액 체크
                if (sender == null || ((Cosmos.UI.CsmPosEditBox)sender) == txtPayAmt)
                {

                    if (m_cDataService.DoubleParse(txtPayAmt.Value) == 0)
                    {
                        WinManager.ConfirmMessage(POS_MESSAGE.ERROR.MSG_0045);
                        txtPayAmt.Focus();
                        return false;
                    }
                }

                // 수표번호 체크
                if (sender == null || ((Cosmos.UI.CsmPosEditBox)sender) == txtCheckNo)
                {
                    if (txtCheckNo.Value.Length != 14)
                    {
                        //msg : 수표번호를 확인 하세요.
                        WinManager.ConfirmMessage(POS_MESSAGE.ERROR.MSG_0046);
                        txtCheckNo.Focus();
                        return false;
                    }

                }

                // 발행일자 체크
                if (sender == null || ((Cosmos.UI.CsmPosEditBox)sender) == txtissueDate)
                {

                    if (txtissueDate.Value.Length < 8)
                    {
                        WinManager.ConfirmMessage(POS_MESSAGE.ERROR.MSG_0047);
                        txtissueDate.Focus();
                        return false;
                    }

                }

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

        #region 텍스트박스 입력 완료 처리
        /// <summary>
        /// 텍스트박스 입력 완료 처리
        /// </summary>
        /// <param name="nFlowMode"></param>
        /// <returns></returns>
        private bool CompleteTxtInPut(int nFlowMode)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                if (nFlowMode == 1) // 조회
                {
                    // 중복 승인 방지 체크
                    if (m_bApproval == true) return false;
                    m_bApproval = true;
                    CheckSearch();
                    m_bApproval = false;

                    padInPut.SetActiveFocus();

                }
                else
                {
                    if (lblStsMsg.Tag.ToString().StartsWith("0") == false)
                    {

                        if (WinManager.QuestionMessage(POS_MESSAGE.ERROR.MSG_0044) == false)
                            return false;

                    }

                    //결제 등록
                    if (SetCheckPay() == true)
                    {
                        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);
                return false;
            }
            return true;
        }
        #endregion


        #endregion

        #region User Method

        #region 수표 조회
        /// <summary>
        /// 수표조회
        /// </summary>
        /// <returns></returns>
        private bool CheckSearch()
        {
            try
            {
                //조회 필요시 처리
                string sRet = UserCom.RST_ERR;
                string[] aTmp = new string[3];

                InDataKindCheck();  //권종코드 다시 셋팅!

                // 수표조회 발행일 부분 수정(2017.07.21)
                //sRet = m_cCash.SearchPayment(new string[] { txtCheckNo.Value, txtPayAmt.Tag.ToString(), m_cDataService.DoubleParse(txtPayAmt.Value).ToString(), txtissueDate.Value, txtAccountNo.Value }, ref aTmp);
                sRet = m_cCash.SearchPayment(new string[] { txtCheckNo.Value, txtPayAmt.Tag.ToString(), m_cDataService.DoubleParse(txtPayAmt.Value).ToString(), txtissueDate.Value.Substring(2), txtAccountNo.Value }, ref aTmp);


                lblStsMsg.Tag = (aTmp[0] == "O" ? 0 : 9) + aTmp[1];      //승인구분(1) + 거래일시(10)
                lblStsMsg.Text = aTmp[2];     //메세지(48) 

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

        #region 수표 결제 등록
        /// <summary>
        /// 수표 결제 등록
        /// </summary>
        /// <returns></returns>
        private bool SetCheckPay()
        {

            string sRet = UserCom.RST_ERR;
            try
            {

                string sAppDate = CmUtil.MidH(lblStsMsg.Tag.ToString(), 1, 6);    //승인일자
                string sAppTime = CmUtil.MidH(lblStsMsg.Tag.ToString(), 7, 4);    //승인시간
                string sAppDiv = CmUtil.MidH(lblStsMsg.Tag.ToString(), 0, 1);    //승인구분 x

                sRet = m_cCash.SetPayment(new string[] { m_cDataService.DoubleParse(txtPayAmt.Value).ToString(), PosKey.MENU_KEY.CHECK_CASH, txtCheckNo.Value, sAppDate, sAppTime, sAppDiv, txtissueDate.Value, txtPayAmt.Tag.ToString() });
                if (sRet != UserCom.RST_OK)
                {
                    WinManager.CosmosMessageBox(PosConst.MSG_BOX_TYPE.ERROR, sRet);
                    return false;
                }

                return true;


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

        }
        #endregion


        private void InDataKindCheck()
        {

            try
            {
                DataTable dtData = m_cDataCommon.SeletCommonCode(PosConst.COMMON_CODE_GROUP.Z0003, "");

                bool bRet = false;

                if (dtData != null && dtData.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtData.Rows)
                    {

                        string sTmpData = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CHAR_VAL_TITLE_VAL_01);

                        string sKind = CmUtil.MidH(sTmpData, 0, 2);
                        string sAmt = CmUtil.MidH(sTmpData, 2, sTmpData.Length).Trim();

                        if (txtPayAmt.Value == sAmt)
                        {
                            txtPayAmt.Tag = sKind;
                            bRet = true;
                            break;
                        }
                    }

                    if (bRet == false)
                    {
                        txtPayAmt.Tag = "19";
                    }

                }
            }
            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 DeviceEvent 관련
        /// <summary>
        /// DeviceEvent 관련
        /// </summary>
        /// <param name="sDevice"></param>
        /// <param name="sData1"></param>
        /// <param name="sData2"></param>
        /// <param name="sData3"></param>
        public void OnDeviceEvent(string sDevice, string sData1, string sData2, string sData3)
        {
            try
            {
                switch (sDevice)
                {
                    case PosConst.OPOS_DEVICE.MSR:
                        this.Invoke(new EventHandler(OnMSREvent));
                        break;
                }
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
        }

        #region MSR Event
        /// <summary>
        /// MSR Event
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        private void OnMSREvent(object source, EventArgs e)
        {
            try
            {

            }
            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 MSR Event


        private void btnExit_Click(object sender, EventArgs e)
        {
            try
            {
                txtEditBox_EditBoxKeyDownEvent(null, PosKey.MENU_KEY.ESC_PREVIOUS);
            }
            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 DeviceEvent 관련

        /// <summary>
        /// 개발 테스트 용
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void csmLabel1_MouseDown(object sender, MouseEventArgs e)
        {
            //if (e.Button == System.Windows.Forms.MouseButtons.Right)
            //{

            //    btnCheckKind_Click(btnPay1, null);
            //    txtCheckNo.Value = "12345678901234";
            //    txtEditBox_EditBoxKeyDownEvent(txtAccountNo, PosKey.MENU_KEY.ENTER);
            //    txtissueDate.Value = "20160607";
            //}
        }


    }
}
