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.Data;

namespace Cosmos.Win
{
    public partial class frmHoldDeal : 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 IDataProcessUs m_cDataService = null;
        private ISalePluItemUs m_cPluService = null;                                //판매 등록 관리
        private IDataCommonUs m_cDataCommon = null;                                 // POS 공통함수 인터페이스
        private IHoldDeal m_cHoldDeal = null;
        private ISaleCompleteUs m_cRecService = null;

        private DeviceStatus m_cDevStatus = new DeviceStatus();                     // 디바이스 관리
        private PosOLEDevice.DelegateOlePos delegatePos;

        private string[,] aStr = new string[10,2];                                  //조건값

        private DataTable m_dtItemInit;                                             // 조회 상품 리스트

        private string m_sPosMenuKeyOut;
        public string PosMenuKeyOut { set { m_sPosMenuKeyOut = value; } get { return m_sPosMenuKeyOut; } }

        #endregion
        
        #region 생성자 & 소멸자
        public frmHoldDeal()
        {
            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_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);
            m_cPluService = (ISalePluItemUs)sManager.InitServiceInstance(ServiceLists.BSV_SALE.DLL, ServiceLists.BSV_SALE.SALE_PLU_ITEM);

            m_cHoldDeal = (IHoldDeal)sManager.InitServiceInstance(ServiceLists.BSV_SALE.DLL, ServiceLists.BSV_SALE.HOLD_DEAL);
            m_cRecService = (ISaleCompleteUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.SALE_COMPLETE);

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

            GetBtnImg();

        }
        /// <summary>
        /// 폼로드
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmHoldDeal_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();
        }
        /// <summary>
        /// 폼클로즈
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmHoldDeal_FormClosing(object sender, FormClosingEventArgs e)
        {
            vScrollbar.Attach(null);
            UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", lblTitle.Text);
        }
        /// <summary>
        /// 폼엑티브
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmHoldDeal_Activated(object sender, EventArgs e)
        {
            PosOLEDevice.SetEventHandle(delegatePos);
        }
        /// <summary>
        /// 폼디엑티브
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmHoldDeal_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_800X600);
                this.Size = new Size(800, 600);
                //this.Location = new Point(170, 173);

                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);

                txtPrtData.Font = new Font(m_cPosStatus.Base.FONT_FIX, txtPrtData.Font.Size, txtPrtData.Font.Style);

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

                lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0091);
                lblHoldDay.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0254);


                btnLoad.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0255);
                btnDel.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0021);
                BtnPrt.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0257);

                txtDate.InputTypeFormat = m_cPosStatus.Global.m_stCultureMaster.strDatePattern;
                txtDate.Text = m_cPosStatus.Global.DateToCulture(m_cPosStatus.Base.SaleDate);

                InitializeGrid();
                
                HoldDealSearch();

                m_sPosMenuKeyOut = "";

                txtDate.Enabled = false;
                btnDate.Enabled = false;

                vScrollbar.Attach(txtPrtData);
            }
            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>
        private void InitializeGrid()
        {
            try
            {
                // 상품권 등록정보 표시 그리드
                grdSearchItem.CsmGridColumnHeadersVisible = true;                                   //DataGridView 자체의 컬럼 헤더 Visible 여부
                grdSearchItem.CsmGridColumnHeadersHeight = 44;                                      //DataGridView 자체의 컬럼 헤더 높이
                grdSearchItem.CsmGridColumnHeadersFont = new Font(m_cPosStatus.Base.FONT, 12, FontStyle.Bold);  //DataGridView 자체의 컬럼 헤더 폰트
                grdSearchItem.CsmGridRowsHeight = 38;
                grdSearchItem.CsmGridColumnCount = 8;                                               //그리드의 컬럼수
                grdSearchItem.CsmGridShowPageRowsCount = 11;                                         //그리드의 한 화면에 보이는 로우수
                grdSearchItem.CsmGridSetHeaderBackColor(236, 238, 239);                             //그리드 헤더 배경색
                grdSearchItem.CsmGridDefaultRowBackColor = Color.FromArgb(255, 255, 255);           //그리드 홀수(Default)행의 배경색 지정
                grdSearchItem.CsmGridAlternateRowBackColor = Color.FromArgb(251, 253, 255);         //그리드 짝수(Alternate)행의 배경색 지정
                grdSearchItem.CsmGridBackGroundColor = Color.FromArgb(251, 253, 255);               //기본 백그라운드 컬러
                grdSearchItem.CsmGridHighlightColor = Color.FromArgb(255, 251, 211);                //그리드 선택 백 컬러
                grdSearchItem.CsmGridHighlightTextColor = Color.Black;                              //그리드 선택 글자 컬러
                grdSearchItem.CsmGridSetColumnWidth(new int[] { 40, 110, 162, 105, 0, 0, 0, 0 });   //컬럼넓이 지정(417)
                grdSearchItem.CsmGridAlignment(new int[] { 2, 1, 0, 2, 1, 1, 1, 1 });               //컬럼 정렬 0:왼쪽, 1:가운데, 2:오른쪽
                //grdSearchItem.CsmGridSetBorderStyle(UI.CsmGrid.CsmGridBorderStyle.Single);

                

                //각 컬럼별 이름 지정
                grdSearchItem.CsmGridColumnName(0, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0014));
                grdSearchItem.CsmGridColumnName(1, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0256));
                grdSearchItem.CsmGridColumnName(2, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0015));
                grdSearchItem.CsmGridColumnName(3, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0231));
                grdSearchItem.CsmGridColumnName(4, "SALE_QTY");
                grdSearchItem.CsmGridColumnName(5, "SALE_DT");
                grdSearchItem.CsmGridColumnName(6, "POS_NO");
                grdSearchItem.CsmGridColumnName(7, "REG_NO");
                                
                //그리드 초기화 테이블
                m_dtItemInit = new DataTable("INIT");
                m_dtItemInit.Columns.Add(new DataColumn("NO", typeof(string)));
                m_dtItemInit.Columns.Add(new DataColumn("SYS_DT", typeof(string)));
                m_dtItemInit.Columns.Add(new DataColumn("ITEM_NM", typeof(string)));
                m_dtItemInit.Columns.Add(new DataColumn("SALE_AMT", typeof(string)));
                m_dtItemInit.Columns.Add(new DataColumn("SALE_QTY", typeof(string)));
                m_dtItemInit.Columns.Add(new DataColumn("SALE_DT", typeof(string)));
                m_dtItemInit.Columns.Add(new DataColumn("POS_NO", typeof(string)));
                m_dtItemInit.Columns.Add(new DataColumn("REG_NO", typeof(string)));
                
                m_dtItemInit.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);
            }
        }


        /// <summary>
        /// 이미지로드
        /// </summary>
        private void GetBtnImg()
        {
            try
            {
                //승인 종류 버튼 테마색상 적용!
                if (m_cPosStatus.ScnMst.ThemeColor.Length == 9)
                {
                   btnDel.BackColor = CmUtil.GetColorToString(m_cPosStatus.ScnMst.ThemeColor);
                }

                //네이게이션 버튼 이미지 적용!
                btnUp.DefaultImage = CmUtil.LoadImage(BaseCom.NxImgPath + ImageManager.NAVIBTN_105X48_UP1_BASIC);
                btnUp.ClickImage = CmUtil.LoadImage(BaseCom.NxImgPath + ImageManager.NAVIBTN_105X48_UP1_PRESS);
                btnUp2.DefaultImage = CmUtil.LoadImage(BaseCom.NxImgPath + ImageManager.NAVIBTN_105X48_UP2_BASIC);
                btnUp2.ClickImage = CmUtil.LoadImage(BaseCom.NxImgPath + ImageManager.NAVIBTN_105X48_UP2_PRESS);

                btnDw.DefaultImage = CmUtil.LoadImage(BaseCom.NxImgPath + ImageManager.NAVIBTN_105X48_DOWN1_BASIC);
                btnDw.ClickImage = CmUtil.LoadImage(BaseCom.NxImgPath + ImageManager.NAVIBTN_105X48_DOWN1_PRESS);
                btnDw2.DefaultImage = CmUtil.LoadImage(BaseCom.NxImgPath + ImageManager.NAVIBTN_105X48_DOWN2_BASIC);
                btnDw2.ClickImage = CmUtil.LoadImage(BaseCom.NxImgPath + ImageManager.NAVIBTN_105X48_DOWN2_PRESS);

            }
            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) == btnLoad) // 불러오기
                {
                    if(LoadHoldDeal() == true)
                    {
                        //정상 종료 확인
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                }
                else if (((Cosmos.UI.CsmButton)sender) == btnDel) // 삭제
                {
                    DeleteHoldDeal("2");
                }
                else if (((Cosmos.UI.CsmButton)sender) == BtnPrt) // 프린트
                {
                    PrintHoldDeal();
                }
                
            }
            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
                
        /// <summary>
        /// 조회 그리드 업/다운 클릭 이벤트
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSelProc_Click(object sender, EventArgs e)
        {
            try
            {
                if ((UI.CsmButton)sender == btnUp2)
                {
                    grdSearchItem.CsmGridScroll("PAGE UP");
                }
                else if ((UI.CsmButton)sender == btnUp)
                {
                    grdSearchItem.CsmGridScroll("UP");
                }
                else if ((UI.CsmButton)sender == btnDw)
                {
                    grdSearchItem.CsmGridScroll("DOWN");
                }
                else if ((UI.CsmButton)sender == btnDw2)
                {
                    grdSearchItem.CsmGridScroll("PAGE DOWN");
                }
            }

            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="rowIndex"></param>
        private void grdSearchItem_GridClickEvent(object sender, string rowIndex)
        {
            try
            {

                string sSaleData = string.Empty;
                string sPosNo = string.Empty;
                string sRegNo = string.Empty;
                string sJnlData = string.Empty;

                DataTable dt = null;


                if (grdSearchItem.CsmGridRowsCount == 0)
                {
                    return;
                }

                sSaleData = grdSearchItem.CsmGridGetCell(grdSearchItem.CsmGridSelectedRowIndex, 5);
                sPosNo = grdSearchItem.CsmGridGetCell(grdSearchItem.CsmGridSelectedRowIndex, 6);
                sRegNo = grdSearchItem.CsmGridGetCell(grdSearchItem.CsmGridSelectedRowIndex, 7);


                dt = m_cHoldDeal.SearchHoldDealPrint(sSaleData, sPosNo, sRegNo);

                if (dt == null || dt.Rows.Count == 0)
                {
                    txtPrtData.Text = "";
                    txtPrtData.Tag = "";
                }
                else
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        sJnlData = dr[0].ToString();
                        txtPrtData.Text = PrintDispCuting(sJnlData);
                        txtPrtData.Tag = sJnlData;
                        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);
            }
        }
        
        #endregion

        #region User Method
        /// <summary>
        /// 보류 데이터 조회
        /// </summary>
        private void HoldDealSearch()
        {
            try
            {
                DataTable dt = null;

                //보류 조회
                dt = m_cHoldDeal.SearchHoldDealList(m_cPosStatus.Global.CultureToDate(txtDate.Text));

                if(dt == null || dt.Rows.Count == 0)
                {
                    //데이터 없음!
                    grdSearchItem.CsmGridDataSource = m_dtItemInit;
                    txtPrtData.Text = "";
                    txtPrtData.Tag = "";
                }
                else
                {


                    string sData = "";
                    string sTime = "";

                    foreach (DataRow dr in dt.Rows)
                    {
                        sData = m_cPosStatus.Global.DateToCulture(CmUtil.MidH(dr["SYS_DT"].ToString(), 0, 8));
                        sTime = CmUtil.StrToTime(CmUtil.MidH(dr["SYS_DT"].ToString(), 8, 6));

                        dr["SYS_DT"] = string.Format("{0} \n{1}", sData, sTime);

                        dr["NET_SALE_AMT"] = m_cPosStatus.Global.NumericTOCurrency(m_cDataService.DoubleParse(dr["NET_SALE_AMT"].ToString()));
                        dr["SALE_QTY"] = m_cPosStatus.Global.NumericTOCurrency(m_cDataService.LongParse(dr["SALE_QTY"].ToString()));
                    }
                    



                    //그리드 적용!
                    grdSearchItem.CsmGridDataSource = dt;

                    grdSearchItem.CsmGridSelectRow(0);
                    
                    grdSearchItem_GridClickEvent(null, 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);
            }


        }
        /// <summary>
        /// 저널 데이터 컷팅
        /// </summary>
        /// <param name="sPrtData"></param>
        /// <returns></returns>
        private string PrintDispCuting(string sPrtData)
        {
            string sRecvData = string.Empty;
            int iDataLen = 0;

            try
            {
                while(iDataLen <= sPrtData.Length)
                {
                    sRecvData += CmUtil.MidH(sPrtData, iDataLen + 5, 42) + Convert.ToChar(13).ToString() + Convert.ToChar(10).ToString();

                    iDataLen += 47;

                }

            }
            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 sRecvData;

        }
        /// <summary>
        /// 보류영수증 불러오기
        /// </summary>
        /// <returns></returns>
        private bool LoadHoldDeal()
        {

            bool bRet = false;

            try
            {

                if (grdSearchItem.CsmGridRowsCount == 0 || grdSearchItem.CsmGridSelectedRowIndex < 0)
                {
                    return bRet;
                }

                string sSaleData = grdSearchItem.CsmGridGetCell(grdSearchItem.CsmGridSelectedRowIndex, 5);
                string sPosNo = grdSearchItem.CsmGridGetCell(grdSearchItem.CsmGridSelectedRowIndex, 6);
                string sRegNo = grdSearchItem.CsmGridGetCell(grdSearchItem.CsmGridSelectedRowIndex, 7);

                //매출 데이터 조회
                if (m_cHoldDeal.LoadLocalTranPlu(sSaleData, sPosNo, sRegNo) == true)
                {

                    m_cHoldDeal.UpdateHoldDeal(sSaleData, sPosNo, sRegNo, "1", 0, 0);

                    m_cTrnStatus.Head.HoldOrgRegNo = sRegNo;
                    m_cTrnStatus.Head.HoldStat = ItemConst.HOLD_STAT_CD.LOAD;

                    bRet = 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 bRet;
        }

        /// <summary>
        /// 보류 영수증 삭제
        /// </summary>
        /// <param name="sStat"></param>
        /// <returns></returns>
        private bool DeleteHoldDeal(string sStat)
        {

            bool bRet = false;

            try
            {

                if (grdSearchItem.CsmGridRowsCount == 0 || grdSearchItem.CsmGridSelectedRowIndex < 0)
                {
                    return bRet;
                }

                if (WinManager.QuestionMessage(POS_MESSAGE.ERROR.MSG_0455) == false) return false;
                
                string sSaleData = grdSearchItem.CsmGridGetCell(grdSearchItem.CsmGridSelectedRowIndex, 5);
                string sPosNo = grdSearchItem.CsmGridGetCell(grdSearchItem.CsmGridSelectedRowIndex, 6);
                string sRegNo = grdSearchItem.CsmGridGetCell(grdSearchItem.CsmGridSelectedRowIndex, 7);

                string sSaleAmt = grdSearchItem.CsmGridGetCell(grdSearchItem.CsmGridSelectedRowIndex, 3); //금액
                string sQty = grdSearchItem.CsmGridGetCell(grdSearchItem.CsmGridSelectedRowIndex, 4); //수량


                int iRet = m_cHoldDeal.UpdateHoldDeal(sSaleData, sPosNo, sRegNo, sStat, m_cDataService.DoubleParse(sQty), m_cDataService.DoubleParse(sSaleAmt));

                HoldDealSearch();

                bRet = 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 bRet;
        }

        /// <summary>
        /// 보류 영수증 출력
        /// </summary>
        /// <returns></returns>
        private bool PrintHoldDeal()
        {

            bool bRet = false;

            try
            {

                if (txtPrtData.Tag.ToString().Trim() == "")
                {
                    return bRet;
                }

                bRet = m_cHoldDeal.PrintHoldDeal(txtPrtData.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);
            }

            return bRet;
        }

       

        #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
            {
                m_sPosMenuKeyOut = "";
                this.DialogResult = DialogResult.Cancel;
                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);
                
            }

            
        }
        
        #endregion DeviceEvent 관련

        private void btnDate_Click(object sender, EventArgs e)
        {
            try
            {
                string sDate = WinBasic.ShowForm(new string[] { FormManager.FORM_CALENDAR });
                if (sDate != "") txtDate.Text = m_cPosStatus.Global.DateToCulture(sDate);
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
        }

    }
}
