using System;
using System.Text;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.Collections;

using Cosmos.Win;
using Cosmos.BaseFrame;
using Cosmos.UserFrame;
using Cosmos.ServiceProvider;
using Cosmos.Common;
using Cosmos.CommonManager;
using Cosmos.UI;

//************************************************************************************************
// 변경  이력 : 담당자별 매출 조회 화면에서 상품명 자릿수 넓힘
//------------------------------------------------------------------------------------------------
// - 작 업 자 : 서광원B
// - 작업일자 : 2017.11.02
// - 작업분류 : 2017.10.20 CS팀 판매 담당자별매출조회
// - 요청사항 : 판매프로그램>조회>담당자별매출조회>전체에서 볼때 상품명이 잘려보여서 어떤 제품인지 구분하기 힘듬.
//              한글14자리까지 자리 표시
// - 작업내용 : 기존의 20자리였던 상품명을 -> 24자리로 넓히고,
//              기존의 11자리였던 수량을 -> 7자리로 줄임
//              cf) 타입 'm_sIRTType'의 의미는 잘 모르겠으므로, \
//                  상품명을 표현하던 20자리를 -> 24로, 
//                  수량을 표시하던 11자리를 -> 7로 모두 수정함
//************************************************************************************************
namespace Cosmos.Win
{
    public partial class frmDataSearch : Form
    {

        #region 변수 선언

        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 DeviceStatus m_cDevStatus = new DeviceStatus();                     // 디바이스 관리

        private IDataCommonUs m_cDataCommon = null;                                 // POS 공통함수 인터페이스
        private IDataProcessUs m_cDataService = null;
        private IDataSearch m_cDataSearch = null;
        private ISaleCompleteUs m_cSaleComplete = null;
        private ISaleRefundUs m_cSaleRefund = null;                                 // 반품처리
        private ArrayList m_sPrintData;

        private bool bNotDoubleClik = false;                                        // 더블 클릭 방지용

        private string m_sPosMenuKey;                                               // 입력코드
        /// <summary>
        /// 할인 구분
        /// </summary>
        public string SetPosMenuKey { set { this.m_sPosMenuKey = value; } }

        /// <summary>
        /// 조회구분 (1:자료조회, 2:매출조회, 3:영수증메모조회)
        /// </summary>
        private string m_sSearchType;                                              

        /// <summary>
        /// 영수증 리스트
        /// </summary>
        private DataTable m_dtSearchList;
        
        /// <summary>
        /// 입력구분
        /// </summary>
        private string m_sInPutType = "";
        /// <summary>
        /// 입력데이터
        /// </summary>
        private string m_sInPutData = "";
        /// <summary>
        /// 카드데이터
        /// </summary>
        private string m_sInEncData = "";
        private string m_sIRTType = "";

        #endregion 변수 선언

        #region 생성자 & 소멸자 & 폼초기화
        public frmDataSearch()
        {
            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_cDataSearch = (IDataSearch)sManager.InitServiceInstance(ServiceLists.BSV_ADMIN.DLL, ServiceLists.BSV_ADMIN.DATASEARCH);
            m_cSaleComplete = (ISaleCompleteUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.SALE_COMPLETE);
            m_cSaleRefund = (ISaleRefundUs)sManager.InitServiceInstance(ServiceLists.BSV_SALE.DLL, ServiceLists.BSV_SALE.SALE_REFUND);
        }

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

        private void frmDataSearch_Activated(object sender, EventArgs e)
        {
            //#20181026 #17412 PAS 대왕암공원 - 매출자료조회 frmADMT 오류창 팝업 start
            UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                 System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +
                                 System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                 "");
            //#20181026 #17412 PAS 대왕암공원 - 매출자료조회 frmADMT 오류창 팝업 end
        }

        private void frmDataSearch_Deactivate(object sender, EventArgs e)
        {
            //#20181026 #17412 PAS 대왕암공원 - 매출자료조회 frmADMT 오류창 팝업 start
            UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                 System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +
                                 System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                 "");

            //기존소스 
            //불필요하므로 주석처리. PosOLEDevice 짝꿍이없음.
            //PosOLEDevice.SetEventHandle(null);

            //#20181026 #17412 PAS 대왕암공원 - 매출자료조회 frmADMT 오류창 팝업 end
        }

        /// <summary>
        /// 폼 컨트롤 초기화
        /// </summary>
        private void InitControl()
        {
            try
            {
                if (m_cPosStatus.Sale.ScreenSizeUser == 1024)
                {
                    // 이미지 로딩 처리
                    picBack.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.POP_FULL_SIZE);
                    //this.Size = new Size(1024, 696);
                    //this.Location = new Point(0, 50);
                    FormManager.SetControlSize(picBack, 0, 0, 1024, 696);
                    FormManager.SetControlSize(this, 0, 50, picBack.Size.Width, picBack.Size.Height);

                    FormManager.SetControlSize(lblTitle, 16, 1, 950, 50, 16);
                    FormManager.SetControlSize(btnExit, 965, 1, 58, 50, 20);
                    FormManager.SetControlSize(label2, 16, 68, 654, 2);
                    FormManager.SetControlSize(lblSaleDate, 18, 68, 120, 40, 12);
                    FormManager.SetControlSize(txtDateFrom, 156, 75, 123, 28, 12);
                    FormManager.SetControlSize(btnFromDate, 281, 75, 30, 28);
                    FormManager.SetControlSize(lblLabel, 317, 78, 21, 21, 14);
                    FormManager.SetControlSize(txtDateTo, 344, 75, 123, 28, 12);
                    FormManager.SetControlSize(btnDateTo, 469, 75, 30, 28);
                    FormManager.SetControlSize(label1, 16, 108, 575, 1);
                    FormManager.SetControlSize(label4, 16, 108, 654, 1);
                    FormManager.SetControlSize(lblChasu, 18, 109, 120, 40, 12);
                    FormManager.SetControlSize(cbChasu, 156, 115, 140, 26, 12);
                    FormManager.SetControlSize(lbliTemType, 315, 109, 150, 40, 12);
                    FormManager.SetControlSize(ckbSimple, 378, 118, 87, 22, 12);
                    FormManager.SetControlSize(cbiTemGroup, 480, 115, 176, 26, 12);
                    FormManager.SetControlSize(label3, 16, 149, 654, 1);
                    FormManager.SetControlSize(btnSearch, 803, 110, 100, 40, 14);
                    FormManager.SetControlSize(btnPrint, 908, 110, 100, 40, 14);

                    FormManager.SetControlSize(label5, 16, 163, 653, 2);
                    FormManager.SetControlSize(grdSearchList, 16, 164, 653, 468);
                    FormManager.SetControlSize(txtPrtData, 674, 163, 322, 516, 10);
                    FormManager.SetControlSize(vScrollbar, 973, 163, 35, 516);

                    FormManager.SetControlSize(btnUp2, 16, 631, 164, 48);
                    FormManager.SetControlSize(btnUp, 179, 631, 164, 48);
                    FormManager.SetControlSize(btnDw, 342, 631, 164, 48);
                    FormManager.SetControlSize(btnDw2, 505, 631, 164, 48);
                }
                else
                {
                    // 이미지 로딩 처리
                    picBack.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.POP_SIZE_800X600);
                    FormManager.SetControlSize(picBack, 0, 0, 800, 600);
                    FormManager.SetControlSize(this, 0, 0, picBack.Size.Width, picBack.Size.Height);

                    FormManager.SetControlSize(lblTitle, 16, 1, 728, 50, 16);
                    FormManager.SetControlSize(btnExit, 742, 1, 58, 50, 20);
                    FormManager.SetControlSize(label2, 16, 62, 525, 2);
                    FormManager.SetControlSize(lblSaleDate, 16, 64, 100, 40, 12);
                    FormManager.SetControlSize(txtDateFrom, 128, 71, 110, 26, 12);
                    FormManager.SetControlSize(btnFromDate, 241, 71, 30, 26);
                    FormManager.SetControlSize(lblLabel, 279, 75, 18, 18, 12);
                    FormManager.SetControlSize(txtDateTo, 303, 71, 110, 26, 12);
                    FormManager.SetControlSize(btnDateTo, 416, 71, 30, 26);
                    FormManager.SetControlSize(label1, 16, 104, 265, 1);
                    FormManager.SetControlSize(label4, 16, 104, 533, 1);
                    FormManager.SetControlSize(lblChasu, 16, 105, 100, 40, 12);
                    FormManager.SetControlSize(cbChasu, 128, 113, 121, 25, 11);
                    FormManager.SetControlSize(lbliTemType, 258, 105, 151, 40, 12);
                    FormManager.SetControlSize(ckbSimple, 317, 114, 83, 21, 11);
                    FormManager.SetControlSize(cbiTemGroup, 419, 113, 121, 25, 11);
                    FormManager.SetControlSize(label3, 16, 145, 533, 1);
                    FormManager.SetControlSize(btnSearch, 569, 105, 104, 40, 14);
                    FormManager.SetControlSize(btnPrint, 680, 105, 104, 40, 14);

                    FormManager.SetControlSize(label5, 16, 161, 428, 2);
                    FormManager.SetControlSize(grdSearchList, 16, 161, 428, 380);
                    FormManager.SetControlSize(txtPrtData, 450, 161, 322, 422, 10);
                    FormManager.SetControlSize(vScrollbar, 749, 161, 35, 422);

                    FormManager.SetControlSize(btnUp2, 16, 535, 108, 48);
                    FormManager.SetControlSize(btnUp, 123, 535, 108, 48);
                    FormManager.SetControlSize(btnDw, 230, 535, 108, 48);
                    FormManager.SetControlSize(btnDw2, 336, 535, 108, 48);
                }

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

                vScrollbar.Attach(txtPrtData);
                txtPrtData.Font = new Font(m_cPosStatus.Base.FONT_FIX, txtPrtData.Font.Size, txtPrtData.Font.Style);
                txtPrtData.Update();
                ckbSimple.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 = "";
                btnFromDate.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.ICON_DATE_BASIC);
                if (btnFromDate.Image != null) btnFromDate.Text = "";
                btnDateTo.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.ICON_DATE_BASIC);
                if (btnDateTo.Image != null) btnDateTo.Text = "";

                if (m_sPosMenuKey == PosKey.MENU_KEY.DATA_SEARCH)
                {
                    lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0323);
                    m_sSearchType = ItemConst.SALE_SEARCH_TYPE.DATA;
                }
                else if (m_sPosMenuKey == PosKey.MENU_KEY.SALES_REPORT)
                {
                    lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0322);
                    m_sSearchType = ItemConst.SALE_SEARCH_TYPE.SALE;
                }
                else if (m_sPosMenuKey == PosKey.MENU_KEY.SALE_EMP_SEARCH)
                {
                    lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0534);
                    m_sSearchType = ItemConst.SALE_SEARCH_TYPE.EMP;
                }                

                lblSaleDate.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0354);                      // 조회기간
                lblChasu.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0519);                         // 차수
                lbliTemType.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0520);                      // 제품군

                btnSearch.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0004);                        // 조회
                btnPrint.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0257);                         // 출력

                //lblTitle1.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0521);                        // 조회목록
                //lblTitle2.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0514);                        // 상세내역

                m_sPrintData = new ArrayList();
                InitializeGrid();                                                                                       // 그리드 초기화      

                txtDateFrom.InputTypeFormat = m_cPosStatus.Global.m_stCultureMaster.strDatePattern;
                //txtDateFrom.Text = m_cPosStatus.Global.DateToCulture(System.DateTime.Now.ToString("yyyyMMdd"));
                //MoonSeokWoo 2017.10.30 판매일자로 초기 셋팅 되도록 수정.
                txtDateFrom.Text = m_cPosStatus.Global.DateToCulture(m_cPosStatus.Base.SaleDate);
                txtDateTo.InputTypeFormat = m_cPosStatus.Global.m_stCultureMaster.strDatePattern;
                txtDateTo.Text = m_cPosStatus.Global.DateToCulture(System.DateTime.Now.ToString("yyyyMMdd"));

                btnUp.DefaultImage = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.NAVIBTN_164X48_UP1_BASIC);
                btnUp.ClickImage = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.NAVIBTN_164X48_UP1_PRESS);
                btnUp2.DefaultImage = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.NAVIBTN_164X48_UP2_BASIC);
                btnUp2.ClickImage = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.NAVIBTN_164X48_UP2_PRESS);

                btnDw.DefaultImage = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.NAVIBTN_164X48_DOWN1_BASIC);
                btnDw.ClickImage = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.NAVIBTN_164X48_DOWN1_PRESS);
                btnDw2.DefaultImage = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.NAVIBTN_164X48_DOWN2_BASIC);
                btnDw2.ClickImage = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.NAVIBTN_164X48_DOWN2_PRESS);


                txtPrtData.Text = "";
                lblLabel.Visible = false;
                lblChasu.Visible = false;
                cbChasu.Visible = false;
                label3.Visible = false;
                //label2.Width = 335;
                //label1.Width = 335;
                label2.Width = m_cPosStatus.Sale.ScreenSizeUser == 1024 ? 335 : 265;
                label1.Width = m_cPosStatus.Sale.ScreenSizeUser == 1024 ? 335 : 265;
                label4.Visible = false;

                txtDateTo.Visible = false;
                btnDateTo.Visible = false;

                lbliTemType.Visible = false;
                cbiTemGroup.Visible = false;
                ckbSimple.Visible = false;

                cbChasu.Items.Clear();
                cbiTemGroup.Items.Clear();

                bNotDoubleClik = false;

                DataGridSetting(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

        #region 버튼 입력 처리
        /// <summary>
        /// 버튼 입력 처리
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnProc_Click(object sender, EventArgs e)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                //#20181026 #17412 PAS 대왕암공원 - 매출자료조회 frmADMT 오류창 팝업 start
                UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +
                                     System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                     "버튼입력처리 :" + ((UI.CsmButton)sender).Name);
                //#20181026 #17412 PAS 대왕암공원 - 매출자료조회 frmADMT 오류창 팝업 end

                if (bNotDoubleClik) return;
                bNotDoubleClik = true;

                if ((UI.CsmButton)sender == btnUp2)
                {
                    grdSearchList.CsmGridScroll("PAGE UP");
                }
                else if ((UI.CsmButton)sender == btnUp)
                {
                    grdSearchList.CsmGridScroll("UP");
                }
                else if ((UI.CsmButton)sender == btnDw)
                {
                    grdSearchList.CsmGridScroll("DOWN");
                }
                else if ((UI.CsmButton)sender == btnDw2)
                {
                    grdSearchList.CsmGridScroll("PAGE DOWN");
                }
                else if (((Cosmos.UI.CsmButton)sender) == btnSearch )          // 조회
                {
                    sRet = ExSelect();

                    bNotDoubleClik = false;

                    if (sRet != UserCom.RST_OK) return;
                }
                else if (((Cosmos.UI.CsmButton)sender) == btnPrint)          // 출력
                {
                    sRet = ExPrint();

                    bNotDoubleClik = false;
                    
                    if (sRet != UserCom.RST_OK) return;
                }
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
                bNotDoubleClik = false;
            }

            bNotDoubleClik = false;
        }

        /// <summary>
        /// 닫기
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        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
           
        #region 텍스트박스 키 입력 이벤트 처리
        /// <summary>
        /// 텍스트박스 키 입력 이벤트 처리
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="sFuncValue"></param>
        private void txtEditBox_EditBoxKeyDownEvent(object sender, string sFuncValue)
        {
            try
            {
                //#20181026 #17412 PAS 대왕암공원 - 매출자료조회 frmADMT 오류창 팝업 start
                UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +
                                     System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
                                     "텍스트박스 입력 이벤트 처리 : " + sFuncValue);
                //#20181026 #17412 PAS 대왕암공원 - 매출자료조회 frmADMT 오류창 팝업 end

                if (sFuncValue == PosKey.MENU_KEY.ENTER)
                {
                    
                }
                else if (sFuncValue == PosKey.MENU_KEY.CLEAR)
                {
                     
                }
                else if (sFuncValue == PosKey.MENU_KEY.ESC_PREVIOUS)
                {
                    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);
            }
        }

        /// <summary>
        /// 텍스트박스 활성화 처리
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtEditBox_EnterEvent(object sender, EventArgs e)
        {

        }
        #endregion 

        #region 텍스트박스 입력 유효성 체크
        /// <summary>
        /// 텍스트박스 입력 유효성 체크
        /// </summary>
        /// <param name="sender"></param>
        /// <returns></returns>
        private bool CheckTxtInPut(object sender)
        {
            try
            {
                //if (sender == null || ((Cosmos.UI.CsmPosEditBox)sender) == txtCardNo)
                //{
                //    WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0189);
                //    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>
        /// <returns></returns>
        private string ExSelect()
        {
            string sRet = UserCom.RST_ERR; 
            try
            {
                if (txtDateFrom.Visible == true &&  txtDateFrom.Value.Length != 8)
                {
                    WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0536));
                    txtDateFrom.Select();
                    txtDateFrom.SelectText();
                    return sRet;
                }
                if (txtDateTo.Visible == true && txtDateTo.Value.Length != 8)
                {
                    WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0536));
                    txtDateTo.Select();
                    txtDateTo.SelectText();
                    return sRet;
                }

                if (grdSearchList.CsmGridRowsCount == 0) return sRet;

                int nRow = grdSearchList.CsmGridSelectedRowIndex;
                if (nRow < 0) return sRet;

                m_sIRTType = grdSearchList.CsmGridGetCell(nRow, 0);

                string sDateFrom = m_cPosStatus.Global.CultureToDate(txtDateFrom.Text);
                string sDateTo = m_cPosStatus.Global.CultureToDate(txtDateFrom.Text);
                if (txtDateTo.Visible == true) sDateTo = m_cPosStatus.Global.CultureToDate(txtDateTo.Text);
                string siTemGroup = CmUtil.MidH(cbiTemGroup.Text, 0, 2);
                if (siTemGroup.Trim() == "") siTemGroup = "00";
                
                string sChasu = "0";
                string sPosNo = "";
                if (m_sPosMenuKey == PosKey.MENU_KEY.DATA_SEARCH)
                    sChasu = CmUtil.MidH(cbChasu.Text, 0, 1);
                if (m_sPosMenuKey == PosKey.MENU_KEY.SALES_REPORT)
                {
                    sPosNo = CmUtil.MidH(cbChasu.Text, 0, 2);
                    sChasu = (ckbSimple.Checked == true) ? "Y" : "N";
                }
                if (sPosNo.Trim() == "") sPosNo = m_cPosStatus.Base.PosNo;

                bool bSubTitle = false;

                string[] aRecvdData = null;
                string[] sTitleNm = new string[] { grdSearchList.CsmGridGetCell(nRow, 1) };
                string[] sSubTitle = null;

                m_sPrintData = new ArrayList();
                txtPrtData.Text = "";

                // 조회 요청
                if (m_sPosMenuKey == PosKey.MENU_KEY.SALE_EMP_SEARCH)
                {
                    #region 담당자별 매출 조회

                    string sCashierID = grdSearchList.CsmGridGetCell(nRow, 0);
                    DataTable dtData = null;
                    DataTable dtData2 = null;
                    //#20171113 담당자별 매출 조회 분류별 제품 나오도록 수정 start,phj
                    DataTable dtData3 = null;
                    //#20171113 담당자별 매출 조회 분류별 제품 나오도록 수정 end,phj

                    this.Refresh();

                    if (sCashierID == "00")
                    {
                        // 정산 점검지 생성
                        WinManager.ShowSearchMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0361), this);
                        sRet = m_cDataSearch.MakeAccADMTCheck(sDateFrom, ref dtData, (ckbSimple.Checked == true ? "1" : "0"));
                        WinManager.HideSearchMessage(this);
                        if (sRet != UserCom.RST_OK) return sRet;

                        //dtData = m_cDataSearch.SelectAccADMTCheck(new string[] { sDateFrom });
                        //if (sRet != UserCom.RST_OK) return sRet;

                        aRecvdData = new string[dtData.Rows.Count];
                    }
                    else
                    {
                        WinManager.ShowSearchMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0361), this);
                        // 품목별 정산 내역 조회
                        dtData = m_cDataSearch.SelectCashier_iTem(new string[] { "1", sDateFrom, sCashierID });
                        // 결제 내역 조회
                        dtData2 = m_cDataSearch.SelectCashier_iTem(new string[] { "2", sDateFrom, sCashierID });
                        //#20171113 담당자별 매출 조회 분류별 제품 나오도록 수정 start,phj
                        dtData3 = m_cDataSearch.SelectCashier_iTem(new string[] { "3", sDateFrom, sCashierID });
                        //#20171113 담당자별 매출 조회 분류별 제품 나오도록 수정 end,phj

                        WinManager.HideSearchMessage(this);

                        if (dtData == null) return sRet;
                        if (dtData2 == null) return sRet;
                        //#20171113 담당자별 매출 조회 분류별 제품 나오도록 수정 start,phj
                        if (dtData3 == null) return sRet;
                        //#20171113 담당자별 매출 조회 분류별 제품 나오도록 수정 end,phj

                        //#20171113 담당자별 매출 조회 분류별 제품 나오도록 수정 start,phj
                        //기존
                        //if (dtData.Rows.Count + dtData2.Rows.Count <= 0) return sRet;
                        //aRecvdData = new string[dtData.Rows.Count + dtData2.Rows.Count + 8];
                        //변경
                        if (dtData.Rows.Count + dtData2.Rows.Count + dtData3.Rows.Count <= 0) return sRet;
                        aRecvdData = new string[dtData.Rows.Count + dtData2.Rows.Count + (dtData3.Rows.Count * 5) + 8];
                        //#20171113 담당자별 매출 조회 분류별 제품 나오도록 수정 end,phj
                    }

                    // 품목별 정산 내역
                    int iLoop = 0;
                    long nQty = 0;
                    double nAmount = 0;
                    if (sCashierID == "00")
                    {
                        // 일마감-점검지내역

                        // 정산 수량이 없는 경우 그룹별 '내용없음' 표시로 변경 20170830 goblin6
                        int[] aDataPrint = new int[10];
                        string sPrevCd = "";
                        foreach (DataRow dr in dtData.Rows)
                        {
                            if (sPrevCd == "" || sPrevCd != CmUtil.LeftH(CmUtil.GetDataRowStr(dr, "SEQ_NO"), 1))
                            {
                                sPrevCd = CmUtil.LeftH(CmUtil.GetDataRowStr(dr, "SEQ_NO"), 1);
                            }
                            aDataPrint[CmUtil.IntParse(sPrevCd)] += CmUtil.GetDataRowInt(dr, "QTY");
                        }
                        // 정산 수량이 없는 경우 그룹별 '내용없음' 표시로 변경 20170830 goblin6

                        foreach (DataRow dr in dtData.Rows)
                        {
                            string sBillType = dr["BILL_TYPE_TAG"].ToString().Replace("<CODE>", "");

                            if (sBillType == "<CLASS>"
                                || sBillType == "<ITEM>"
                                || sBillType == "<TENDER>"
                                || sBillType == "<CASHREFUND>") continue;                                      // 현금반품 내역 추가 20170830 goblin6

                            if (dr["MSG"].ToString().Trim() == "")
                                aRecvdData[iLoop++] = dr["BILL_TYPE_TAG"].ToString().Replace("<CODE>", "");
                            else
                            {
                                // 정산 수량이 없는 경우 그룹별 '내용없음' 표시로 변경 20170830 goblin6
                                string sSeq = CmUtil.GetDataRowStr(dr, "SEQ_NO");                                                      // 정산지 수량이 있는 경우만 출력 추가 20170830 goblin6
                                if ((CmUtil.IntParse(sSeq) >= 2100 && CmUtil.IntParse(sSeq) < 6100
                                    || CmUtil.IntParse(sSeq) >= 8701 && CmUtil.IntParse(sSeq) <= 8704)
                                    && CmUtil.IntParse(sSeq) != 3800 && CmUtil.IntParse(sSeq) != 3801
                                    && CmUtil.IntParse(sSeq) != 4300 && CmUtil.IntParse(sSeq) != 4301
                                    )

                                {
                                    if (CmUtil.IntParse(m_cPosStatus.Global.NumericTOCurrency(CmUtil.GetDataRowDouble(dr, "QTY"))) > 0)
                                    {
                                        aRecvdData[iLoop++] = dr["MSG"].ToString() + "|" + m_cPosStatus.Global.NumericToQuantity(CmUtil.LongParse(dr["QTY"].ToString())) + "|" + m_cPosStatus.Global.NumericTOCurrency(m_cDataService.DoubleParse(dr["AMT"].ToString()));
                                    }
                                    else
                                    {
                                        sPrevCd = CmUtil.LeftH(CmUtil.GetDataRowStr(dr, "SEQ_NO"), 1);
                                        if (aDataPrint[CmUtil.IntParse(sPrevCd)] == 0)
                                        {
                                            aDataPrint[CmUtil.IntParse(sPrevCd)] = 1;
                                            aRecvdData[iLoop++] = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0570);
                                        }
                                    }
                                }
                                else
                                {
                                    aRecvdData[iLoop++] = dr["MSG"].ToString() + "|" + m_cPosStatus.Global.NumericToQuantity(CmUtil.LongParse(dr["QTY"].ToString())) + "|" + m_cPosStatus.Global.NumericTOCurrency(m_cDataService.DoubleParse(dr["AMT"].ToString()));
                                }
                                // 정산 수량이 없는 경우 그룹별 '내용없음' 표시로 변경 20170830 goblin6

                                //aRecvdData[iLoop++] = dr["MSG"].ToString() + "|" + m_cPosStatus.Global.NumericToQuantity(CmUtil.LongParse(dr["QTY"].ToString())) + "|" + m_cPosStatus.Global.NumericTOCurrency(m_cDataService.DoubleParse(dr["AMT"].ToString()));
                            }
                            nQty += m_cDataService.LongParse(dr["QTY"].ToString());
                            nAmount = CmUtil.DoubleAdd(nAmount, m_cDataService.DoubleParse(dr["AMT"].ToString()));
                        }
                    }
                    else
                    {
                        if (dtData != null && dtData.Rows.Count != 0)
                        {
                            aRecvdData[iLoop++] = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0536);
                            foreach (DataRow dr in dtData.Rows)
                            {
                                string Temp1 = dr["ITEM_NM"].ToString();
                                string Temp2 = m_cPosStatus.Global.NumericToQuantity(CmUtil.LongParse(dr["SALE_QTY"].ToString()));
                                string Temp3 = m_cPosStatus.Global.NumericTOCurrency(m_cDataService.DoubleParse(dr["SALE_AMT"].ToString()));                           

                                aRecvdData[iLoop++] = dr["ITEM_NM"].ToString() + "|" + m_cPosStatus.Global.NumericToQuantity(CmUtil.LongParse(dr["SALE_QTY"].ToString())) + "|" + m_cPosStatus.Global.NumericTOCurrency(m_cDataService.DoubleParse(dr["SALE_AMT"].ToString()));                           
                                nQty =+ m_cDataService.LongParse(dr["SALE_QTY"].ToString());
                                nAmount = CmUtil.DoubleAdd(nAmount, m_cDataService.DoubleParse(dr["SALE_AMT"].ToString()));
                            }
                            // 합계

                            aRecvdData[iLoop++] = "-";
                            aRecvdData[iLoop++] = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0501) + "|" + m_cPosStatus.Global.NumericToQuantity(nQty) + "|" + m_cPosStatus.Global.NumericTOCurrency(nAmount);
                            aRecvdData[iLoop++] = "-";
                        }

                        // 결제 내역
                        nQty = 0;
                        nAmount = 0;
                        if (dtData2 != null && dtData2.Rows.Count != 0)
                        {
                            aRecvdData[iLoop++] = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0537);
                            foreach (DataRow dr in dtData2.Rows)
                            {
                                aRecvdData[iLoop++] = dr["ITEM_NM"].ToString() + "|" + m_cPosStatus.Global.NumericToQuantity(CmUtil.LongParse(dr["SALE_QTY"].ToString())) + "|" + m_cPosStatus.Global.NumericTOCurrency(m_cDataService.DoubleParse(dr["SALE_AMT"].ToString()));
                                nQty += m_cDataService.LongParse(dr["SALE_QTY"].ToString());
                                nAmount = CmUtil.DoubleAdd(nAmount, m_cDataService.DoubleParse(dr["SALE_AMT"].ToString()));
                            }
                            // 합계
                            aRecvdData[iLoop++] = "-";
                            aRecvdData[iLoop++] = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0501) + "|" + m_cPosStatus.Global.NumericToQuantity(nQty) + "|" + m_cPosStatus.Global.NumericTOCurrency(nAmount);
                            

                            //#20171113 담당자별 매출 조회 분류별 제품 나오도록 수정 start,phj
                            //기존
                            //aRecvdData[iLoop++] = "-";
                            //변경
                            aRecvdData[iLoop++] = "-";
                            //#20171113 담당자별 매출 조회 분류별 제품 나오도록 수정 end,phj
                        }


                        //#20171113 담당자별 매출 조회 분류별 제품 나오도록 수정 start,phj
                        if (dtData3 != null && dtData3.Rows.Count != 0)
                        {
                            string ITEM_CLSS_CD = string.Empty;
                            string ITEM_CLSS_NM = string.Empty;
                            string ITEM_NM = string.Empty;
                            string sub_title = string.Empty;

                            aRecvdData[iLoop++] = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_1076);

                            foreach (DataRow dr in dtData3.Rows)
                            {
                                // 제품 분류 표시 
                                if (sub_title == "" && ITEM_CLSS_CD != dr["ITEM_CLSS_CD"].ToString() && (dr["ITEM_CLSS_CD"].ToString() != ""))
                                {
                                    sub_title = "* " + dr["ITEM_CLSS_NM"].ToString() + " *" + "|" + "" + "|" + "C";

                                    //aRecvdData[iLoop++] = "-";
                                    aRecvdData[iLoop++] = sub_title;
                                    aRecvdData[iLoop++] = "-";
                                }

                                // 제품 
                                if (dr["LEVEL_GB"].ToString() == "0")
                                {
                                    ITEM_CLSS_CD = dr["ITEM_CLSS_CD"].ToString();

                                    aRecvdData[iLoop++] = dr["ITEM_NM"].ToString() + "|" + m_cPosStatus.Global.NumericToQuantity(CmUtil.LongParse(dr["SALE_QTY"].ToString())) + "|" + m_cPosStatus.Global.NumericTOCurrency(m_cDataService.DoubleParse(dr["SALE_AMT"].ToString()));
                                }
                                // 제품 분류 소계 
                                else if (dr["LEVEL_GB"].ToString() == "3")
                                {
                                    aRecvdData[iLoop++] = "-";
                                    aRecvdData[iLoop++] = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_1075) + "|" + m_cPosStatus.Global.NumericToQuantity(CmUtil.LongParse(dr["SALE_QTY"].ToString())) + "|" + m_cPosStatus.Global.NumericTOCurrency(m_cDataService.DoubleParse(dr["SALE_AMT"].ToString()));
                                    aRecvdData[iLoop++] = "-";

                                    sub_title = string.Empty;
                                }
                                // 총 합계
                                else if (dr["LEVEL_GB"].ToString() == "4")
                                {
                                    //aRecvdData[iLoop++] = "-";
                                    aRecvdData[iLoop++] = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0501) + "|" + m_cPosStatus.Global.NumericToQuantity(CmUtil.LongParse(dr["SALE_QTY"].ToString())) + "|" + m_cPosStatus.Global.NumericTOCurrency(m_cDataService.DoubleParse(dr["SALE_AMT"].ToString()));
                                }
                            }
                        }
                        //#20171113 담당자별 매출 조회 분류별 제품 나오도록 수정 end,phj
                    }
                    sRet = UserCom.RST_OK;

                    #endregion // 담당자별 매출 조회
                }
                else
                {
                    // 자료 조회
                    
                    sRet = m_cDataSearch.ExecuteHostIrt(m_sIRTType, sPosNo, sDateFrom, sDateTo, sChasu, siTemGroup, ref aRecvdData);
                    this.Refresh();
                }
                if (sRet != UserCom.RST_OK) { return sRet; }

                #region 자료 조회
                
                // grayber@20180117 [BR]자료조회 주문내역 조회 출력 start - 합계계산 변수 추가
                int iQty = 0;           // 합계수량 
                double dTax = 0;        // 부가세액
                double dAmount = 0;     // 합계
                // grayber@20180117 [BR]자료조회 주문내역 조회 출력 end

                // 분해 
                for (int iLoop = 0; iLoop < aRecvdData.Length; iLoop++)
                {
                    if (aRecvdData[iLoop] == null) { continue; }
                    if (aRecvdData[iLoop].Trim().Length <= 0) { continue; }

                    aRecvdData[iLoop] = aRecvdData[iLoop].ToUpper().Replace("NULL", "");
                    string[] aRecvData = aRecvdData[iLoop].Trim().Split(new string[] { "|" }, StringSplitOptions.None);

                    // 상단부 
                    if (iLoop == 0 && CmUtil.LenH(sTitleNm[0]) <= 42)
                    {
                        // 타이틀 표시
                        AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, new string[] { "*" }, ref m_sPrintData);
                        AddPrintData(PosConst.PRT_HDR.PRT_VER, PosConst.PRT_FMT.F103, sTitleNm, ref m_sPrintData);
                        AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, new string[] { "*" }, ref m_sPrintData);

                        if( m_sIRTType.Trim().Equals("27") == true &&  m_cPosStatus.Mst.CorpDiv.Equals(ItemConst.CORP_DIV.BR) == true )    // [BRKR] 주문내역 조회
                        {
                            #region [BR/DD]상단정보
                            AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, new string[] { " " }, ref m_sPrintData);
                            
                            // 상단 정보 표시
                            AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, new string[] { "[ 배송일자 ] " + txtDateFrom.Text.Replace('-','.') }, ref m_sPrintData);
                            AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, new string[] { "[ 주문차수 ] [" + CmUtil.MidH(cbChasu.Text, 0, 1) + "]  " + CmUtil.MidH(cbChasu.Text, 2, cbChasu.Text.Length) }, ref m_sPrintData);
                            AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, new string[] { "[ 제 품 군 ] [" + CmUtil.MidH(cbiTemGroup.Text, 0, 2) + "] " + CmUtil.MidH(cbiTemGroup.Text, cbiTemGroup.Text.IndexOf(' ') + 1, cbiTemGroup.Text.Length + 1) }, ref m_sPrintData);
                            AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, new string[] { "=" }, ref m_sPrintData);
                            #endregion
                        }
                    }

                    // grayber@20180117 [BR]자료조회 주문내역 조회 출력 start - 컬럼명 출력
                    if( m_sIRTType.Trim().Equals("27") == true &&  m_cPosStatus.Mst.CorpDiv.Equals(ItemConst.CORP_DIV.BR) == true )
                    {
                        
                        #region [BR] 배송기사
                        if (aRecvData[0].Trim().Equals("*") == true) // 배송기사
                        {    
                            AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, new string[] { "[ 배송기사 ] " + aRecvData[1] }, ref m_sPrintData);
                            AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, new string[] { "[ 연 락 처 ] " + aRecvData[2] }, ref m_sPrintData);
                            AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, new string[] { "=" }, ref m_sPrintData);
                            continue;
                        }
                        #endregion
                        
                        #region [BR/DD]컬럼명 Check
                        if (aRecvData[0].Trim().Equals("구분") == true)   // 컬럼명
                        {
                            AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F301, aRecvData, ref m_sPrintData);
                            AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, new string[] { "=" }, ref m_sPrintData);
                            continue;
                        }
                        #endregion
                    }
                    // grayber@20180117 [BR]자료조회 주문내역 조회 출력 end
                    
                    // 데이터
                    if (aRecvData.Length == 1 && aRecvdData[iLoop].Trim() != "-")
                    {
                        if (aRecvData[0].ToString() == MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0570))
                        {
                            AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F103, aRecvData, ref m_sPrintData);
                            //AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, new string[] { " " }, ref m_sPrintData);
                        }
                        else
                        {
                            //AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, new string[] { " " }, ref m_sPrintData);
                            AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, new string[] { "=" }, ref m_sPrintData);
                            AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F103, aRecvData, ref m_sPrintData);
                            AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, new string[] { "=" }, ref m_sPrintData);
                        }
                        bSubTitle = false;
                    }
                    else if (aRecvData[0] == "-")
                    {
                        AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, new string[] { "-" }, ref m_sPrintData);
                    }
                    else
                    {
                        //#20171113 담당자별 매출 조회 분류별 제품 나오도록 수정 end,phj
                        //기존
                        //AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F301, aRecvData, ref m_sPrintData);

                        //3번째 자리에 C가 오면, 제품분류명칭이라 판단하고 가운데 정렬로 수정
                        //변경
                        if (aRecvData[2] == "C")
                        {
                            AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F103, aRecvData, ref m_sPrintData);
                        }
                        else
                        {
                            AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F301, aRecvData, ref m_sPrintData);

                            // grayber@20180117 [BR]자료조회 주문내역 조회 출력 start - 합계 계산
                            #region [BR]합계 누적 계산
                            if (m_sIRTType.Trim().Equals("27") == true && m_cPosStatus.Base.BrandDiv.Equals("BR") == true )
                            {
                                
                                if ( m_cPosStatus.Base.BrandDiv.Equals("BR") == true )
                                {
                                    iQty += CmUtil.IntParse(aRecvData[3]);                                     // 합계수량
                                    dAmount = CmUtil.DoubleAdd(dAmount, CmUtil.DoubleParse(aRecvData[4]));     // 합계
                                    dTax = CmUtil.DoubleAdd(dTax, CmUtil.DoubleParse(aRecvData[5]));           // 부가세액
                                }

                            }
                            #endregion
                            // grayber@20180117 [BR]자료조회 주문내역 조회 출력 end

                        }
                        //#20171113 담당자별 매출 조회 분류별 제품 나오도록 수정 end,phj

                        if (iLoop == 0) AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, new string[] { "-" }, ref m_sPrintData);
                    }
                }

                // grayber@20180117 [BR]자료조회 주문내역 조회 출력 start - 합계 출력
                if ( m_sIRTType.Trim().Equals("27") == true && m_cPosStatus.Mst.CorpDiv.Equals(ItemConst.CORP_DIV.BR ) )
                {
                    if ( m_cPosStatus.Base.BrandDiv.Equals("BR") == true) // [BR] 처리
                    {
                        #region [BR]합계부
                        var dUnitCost = CmUtil.DoubleSubtraction(dAmount, dTax);
                        AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, new string[] { "=" }, ref m_sPrintData);

                        AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F200, new string[] { "합계수량 : ", m_cPosStatus.Global.NumericToQuantity(CmUtil.LongParse(iQty.ToString())) }, ref m_sPrintData);
                        AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F200, new string[] { "공급가액 : ", m_cPosStatus.Global.NumericToQuantity(CmUtil.LongParse(dUnitCost.ToString())) }, ref m_sPrintData);
                        AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F200, new string[] { "부가세액 : ", m_cPosStatus.Global.NumericToQuantity(CmUtil.LongParse(dTax.ToString())) }, ref m_sPrintData);
                        AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F200, new string[] { "합    계 : ", m_cPosStatus.Global.NumericToQuantity(CmUtil.LongParse(dAmount.ToString())) }, ref m_sPrintData);

                        AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, new string[] { "=" }, ref m_sPrintData);
                        #endregion // [BR]합계부
                    }
                    #region [BR/DD]조회 일시
                    AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F103, new string[] { "** 조회일시 : " + DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss") + " **" }, ref m_sPrintData);
                    #endregion // 조회 일시
                }
                // grayber@20180117 [BR]자료조회 주문내역 조회 출력 end

                #endregion  // 자료 조회
                
                AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, new string[] { "-" }, ref m_sPrintData);
                //AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, new string[] { " " }, ref m_sPrintData); 
                //AddPrintData(PosConst.PRT_HDR.PRT_CUT, PosConst.PRT_FMT.F100, new string[] { " " }, ref m_sPrintData);

                // 화면에 표시
                string sData = "";
                for (int nLoop = 0; nLoop < m_sPrintData.Count; nLoop++)
                {
                    if (m_sPrintData[nLoop].ToString().Trim() != "")
                    {
                        sData += m_sPrintData[nLoop].ToString().Substring(5).TrimEnd() + PosConst.CRLF;
                        //sData += CmUtil.MidH(m_sPrintData[nLoop].ToString(), 5, CmUtil.LenH(m_sPrintData[nLoop].ToString())-5).ToString() + PosConst.CRLF;
                    }
                }
                txtPrtData.Text = sData;

                vScrollbar.Attach(txtPrtData);

                sRet = 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 sRet;
        }
        #endregion
        
        #region 출력 처리
        /// <summary>
        /// 출력 처리
        /// </summary>
        /// <returns></returns>
        private string ExPrint()
        {
            string sRet = UserCom.RST_ERR;

            try
            {
                ArrayList aPrintData = new ArrayList();

                // 상단 이미지 출력
                if (PosMstManager.GetPosOption(POS_OPTION.OPT409) != "0")
                    AddPrintData(PosConst.PRT_HDR.PRT_TBM, PosConst.PRT_FMT.F100, new string[] { "" }, ref aPrintData);

                // 상단 문구 출력
                AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, new string[] { MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0160) + m_cPosStatus.Mst.StorName }, ref aPrintData);
                AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, new string[] { MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0161) + m_cPosStatus.Mst.StorAddr }, ref aPrintData);
                AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, new string[] { MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0162) + m_cPosStatus.Mst.StorOwnName }, ref aPrintData);
                AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, new string[] { MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0163) + m_cPosStatus.Mst.StorBizPsnNo + "  (" + m_cPosStatus.Mst.StorTelNo + ")" }, ref aPrintData);
                AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, new string[] { MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0164) + CmUtil.MidH(m_cPosStatus.Base.CashierName, 0, 12) + " POS NO :" + m_cPosStatus.Base.PosNo }, ref aPrintData);
                AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, new string[] { MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0165) + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") }, ref aPrintData);
                // grayber@20180117 [BR]자료조회 주문내역 조회 출력 start - [BR/DD] 상단부 추가 분기 추가
                if(m_cPosStatus.Mst.CorpDiv.Trim().Equals(ItemConst.CORP_DIV.BR) == true)
                    AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F100, new string[] { " " }, ref aPrintData);
                else
                    AddPrintData(PosConst.PRT_HDR.PRT_NOR, PosConst.PRT_FMT.F101, new string[] { "-" }, ref aPrintData);
                // grayber@20180117 [BR]자료조회 주문내역 조회 출력 end

                // 공지사항 출력
                aPrintData.AddRange(m_sPrintData);

                // 하단 이미지 출력
                if (PosMstManager.GetPosOption(POS_OPTION.OPT410) != "0")
                    AddPrintData(PosConst.PRT_HDR.PRT_BBM, PosConst.PRT_FMT.F100, new string[] { "" }, ref aPrintData);

                // cut
                AddPrintData(PosConst.PRT_HDR.PRT_CUT, PosConst.PRT_FMT.F100, new string[] { " " }, ref aPrintData);

                if (aPrintData.Count == 0) return sRet;
                bool bReturn = m_cDataSearch.PosDataPrint(aPrintData);
                if (bReturn == true) sRet = 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 sRet;
        }
        #endregion

        #region 영수증 출력데이터 생성
        /// <summary>
        /// 영수증 출력데이터 생성
        /// </summary>
        /// <param name="sPrtHead">출력형태</param>
        /// <param name="sPrtFmt">출력포맷</param>
        /// <param name="sData">Data</param>
        private void AddPrintData(string sPrtHead, string sPrtFmt, string[] aData, ref ArrayList aPrintData)
        {
            string sDate = "";
            string sDate2 = ""; 
            try
            {
                string sPrtData = "";

                if (sPrtFmt == PosConst.PRT_FMT.F100)               // 선귿기
                {
                    //if (sPrtFmt == PosConst.PRT_FMT.F100 && (aData[0] == "-" || aData[0] == "="))    // 선귿기
                    //{
                    //    if (sPrtHead == PosConst.PRT_HDR.PRT_BLD)
                    //        for (int i = 1; i <= 21; i++) sPrtData += "━";
                    //    else
                    //        for (int i = 1; i <= 21; i++) sPrtData += "─";
                    //}
                    //else
                    //{
                        for (int i = 1; i <= 42; i++) sPrtData += aData[0];
                    //}
                }

                else if (sPrtFmt == PosConst.PRT_FMT.F101)          // 왼쪽정렬
                {
                    sPrtData = aData[0]; 
                }
                else if (sPrtFmt == PosConst.PRT_FMT.F102)          // 오른쪽 정렬
                {
                    sPrtData = CmUtil.LPadH(aData[0], 42); 
                }
                else if (sPrtFmt == PosConst.PRT_FMT.F103)          // 중앙정렬
                {
                    if (sPrtHead == PosConst.PRT_HDR.PRT_HOR || sPrtHead == PosConst.PRT_HDR.PRT_BIG)
                    {
                        if (CmUtil.LenH(aData[0]) <= 21) sPrtData = CmUtil.LPadH("", 10 - (CmUtil.LenH(aData[0]) / 2)) + aData[0];
                    }
                    else
                    {
                        if (CmUtil.LenH(aData[0]) <= 42) sPrtData = CmUtil.LPadH("", 21 - (CmUtil.LenH(aData[0]) / 2)) + aData[0];
                    }
                }
                else
                {
                    int iCol = 0;

                    for (int iLoop = 0; iLoop < aData.Length; iLoop += aData.Length)
                    { 
                        switch (aData.Length)
                        {
                            //case 5:
                            //    sPrtData = LF_CheckPrintData(aData[iLoop + iCol].ToString(), 10) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 12) + CmUtil.LPadH(aData[iLoop + iCol + 2].ToString(), 6) + CmUtil.LPadH(aData[iLoop + iCol + 3].ToString(), 10) + CmUtil.LPadH(aData[iLoop + iCol + 4].ToString(), 4);
                            //    break;
                            //case 4:
                                //sPrtData = CmUtil.RPadH(aData[iLoop + iCol].ToString(), 12) + CmUtil.LPadH(aData[iLoop + iCol + 1].ToString(), 12) + CmUtil.LPadH(aData[iLoop + iCol + 2].ToString(), 7) + CmUtil.LPadH(aData[iLoop + iCol + 3].ToString(), 11);
                                //break;
                            case 3:
                                if (m_sIRTType == "")
                                {
                                    //***************************************************************************************************************
                                    // (2017.11.02) 담당자별 매출 조회 화면에서 상품명 자릿수 넓힘
                                    //---------------------------------------------------------------------------------------------------------------
                                    // - 작 업 자 : 서광원B
                                    // - 작업일자 : 2017.11.02
                                    // - 작업분류 : 2017.10.20 CS팀 판매 담당자별매출조회
                                    // - 요청사항 : 판매프로그램>조회>담당자별매출조회>전체에서 볼때 상품명이 잘려보여서 어떤 제품인지 구분하기 힘듬.
                                    //              한글14자리까지 자리 표시
                                    //***************************************************************************************************************
                                    // (원본) sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 20) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 11) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 11);
                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 24) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 7) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 11);
                                    // 이하 아래부분 모두 동일
                                    //***************************************************************************************************************
                                }
                                else if (m_sIRTType == "00")
                                {
                                    // (원본) sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 20) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 11) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 11);
                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 24) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 7) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 11);
                                }
                                else if (m_sIRTType == "01")
                                {
                                    // (원본) sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 20) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 11) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 11);
                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 24) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 7) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 11);
                                }
                                else if (m_sIRTType == "02")
                                {
                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 10) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 20) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 11);
                                }
                                else if (m_sIRTType == "10")
                                {
                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 10) + CmUtil.RPadH(aData[iLoop + iCol + 1].ToString(), 20) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 11);
                                }
                                else if (m_sIRTType == "12")
                                {
                                    sDate = aData[iLoop + iCol + 2].ToString();
                                    if (CmUtil.IsNumber(sDate) == true && iLoop == 0)
                                        sDate = m_cPosStatus.Global.DateToCulture(aData[iLoop + iCol + 2].ToString());

                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 18) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 12) + CmUtil.LPadH(sDate.ToString(), 12);
                                }
                                else if (m_sIRTType == "14")
                                {
                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 23) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 7) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 11);
                                }
                                else if (m_sIRTType == "18")
                                {
                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 23) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 7) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 11);
                                }
                                else if (m_sIRTType == "22")
                                {
                                    sDate = aData[iLoop + iCol].ToString();
                                    if (CmUtil.IsNumber(sDate) == true && iLoop == 0)
                                        sDate = m_cPosStatus.Global.DateToCulture(aData[iLoop + iCol].ToString());

                                    sPrtData += CmUtil.RPadH(sDate, 12) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 18) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 11);
                                }
                                else if (m_sIRTType == "24")
                                {
                                    sDate = aData[iLoop + iCol].ToString();
                                    if (CmUtil.IsNumber(sDate) == true && iLoop == 0)
                                        sDate = m_cPosStatus.Global.DateToCulture(aData[iLoop + iCol].ToString());

                                    sPrtData += CmUtil.RPadH(sDate, 12) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 18) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 11);
                                }
                                else if (m_sIRTType == "34")
                                {
                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 23) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 7) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 11);
                                }
                                else if (m_sIRTType == "36")
                                {
                                    sDate = aData[iLoop + iCol].ToString();
                                    if (CmUtil.IsNumber(sDate) == true && iLoop == 0)
                                        sDate = m_cPosStatus.Global.DateToCulture(aData[iLoop + iCol].ToString());

                                    sPrtData += CmUtil.RPadH(sDate, 12) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 18) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 11);
                                }
                                // grayber@20180117 [BR]자료조회 주문내역 조회 출력 start - 출력 구분 처리 (aData.Length == 3)
                                else if (m_sIRTType.Trim().Equals("27") == true && m_cPosStatus.Mst.CorpDiv.Equals(ItemConst.CORP_DIV.BR) == true)
                                {
                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 20) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 4) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 4);
                                    sPrtData += LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 4) + LF_CheckPrintData(aData[iLoop + iCol + 4].ToString(), 10);
                                }
                                // grayber@20180117 [BR]자료조회 주문내역 조회 출력 end
                                else if (m_sIRTType == "03" || m_sIRTType == "06")
                                {
                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 25) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 6) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 11);
                                }
                                else
                                {
                                    // (원본) sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 20) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 11) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 11);
                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 24) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 7) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 11);
                                }
                                break;
                            case 2:
                                if (m_sIRTType == "39")
                                {
                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 16) + CmUtil.RPadH(aData[iLoop + iCol + 1].ToString(), 24);
                                }
                                // grayber@20180117 [BR]자료조회 주문내역 조회 출력 start - 출력 구분 처리 추가 (aData.Length == 2)
                                else if (m_sIRTType.Trim().Equals("27") == true && m_cPosStatus.Mst.CorpDiv.Equals(ItemConst.CORP_DIV.BR) == true)
                                {
                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 23) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 18);
                                }
                                // grayber@20180117 [BR]자료조회 주문내역 조회 출력 end
                                else 
                                {
                                    sPrtData += LF_CheckPrintData(aData[iLoop + iCol].ToString(), 23) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 18);
                                }
                                break;
                            case 1:
                                sPrtData += LF_CheckPrintData(aData[iLoop + iCol].ToString(), 42);
                                break;
                            default:
                                if (m_sIRTType == "03")
                                {
                                    if (m_cPosStatus.Mst.CorpDiv == ItemConst.CORP_DIV.BR)
                                    {
                                        sDate = aData[iLoop + iCol].ToString();
                                        sPrtData += CmUtil.RPadH(sDate, 9) + CmUtil.RPadH(aData[iLoop + iCol + 1].ToString(), 16) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 6) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 11);
                                    }
                                    else
                                    {
                                        //#20170925 상품별 매출 실적 asis와 동일하게 표시 start
                                        // 상품코드(7) + 상품명(19) + 수량(6) + 금액(10)
                                        //기존
                                        //sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 12) + CmUtil.RPadH(aData[iLoop + iCol + 1].ToString(), 15) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 15);
                                        //sPrtData += LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 12) + LF_CheckPrintData(aData[iLoop + iCol + 4].ToString(), 15) + LF_CheckPrintData(aData[iLoop + iCol + 5].ToString(), 15);
                                        //변경
                                        
                                        if (aData.Length == 4)
                                        {
                                            sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 7);            // 상품코드
                                            sPrtData += CmUtil.RPadH(aData[iLoop + iCol + 1].ToString(), 19);       // 상품명
                                            sPrtData += LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 6);   // 수량
                                            sPrtData += LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 10);  // 금액
                                        }
                                        else
                                        {
                                            sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 12) + CmUtil.RPadH(aData[iLoop + iCol + 1].ToString(), 15) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 15);
                                            sPrtData += LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 12) + LF_CheckPrintData(aData[iLoop + iCol + 4].ToString(), 15) + LF_CheckPrintData(aData[iLoop + iCol + 5].ToString(), 15);
                                        }
                                        
                                        //#20170925 상품별 매출 실적 asis와 동일하게 표시 end
                                    }
                                }
                                else if (m_sIRTType == "04")
                                {
                                    sDate = aData[iLoop + iCol].ToString();
                                    if (CmUtil.IsNumber(sDate) == true && iLoop == 0)
                                        sDate = m_cPosStatus.Global.DateToCulture(aData[iLoop + iCol].ToString());

                                    sPrtData += CmUtil.RPadH(sDate, 12) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 15) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 15);
                                    sPrtData += CmUtil.RPadH("", 12) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 30);
                                }
                                else if (m_sIRTType == "05")
                                {
                                    sDate = aData[iLoop + iCol].ToString();
                                    if (CmUtil.IsNumber(sDate) == true && iLoop == 0)
                                        sDate = m_cPosStatus.Global.DateToCulture(aData[iLoop + iCol].ToString());

                                    sPrtData += CmUtil.RPadH(sDate, 12) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 10) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 10) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 10);
                                }
                                else if (m_sIRTType == "06")
                                {
                                    sDate = aData[iLoop + iCol].ToString();
                                    sPrtData += CmUtil.RPadH(sDate, 8) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 9) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 12) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 13);
                                }
                                else if (m_sIRTType == "07")
                                {
                                    sDate = aData[iLoop + iCol].ToString();
                                    if (CmUtil.IsNumber(sDate) == true && iLoop == 0)
                                        sDate = m_cPosStatus.Global.DateToCulture(aData[iLoop + iCol].ToString());

                                    sPrtData += CmUtil.RPadH(sDate, 11) + CmUtil.RPadH(aData[iLoop + iCol + 1].ToString(), 9) + CmUtil.LPadH(aData[iLoop + iCol + 2].ToString(), 12) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 10);
                                }
                                else if (m_sIRTType == "08")
                                {
                                    sDate = aData[iLoop + iCol].ToString();
                                    if (CmUtil.IsNumber(sDate) == true && iLoop == 0)
                                        sDate = string.Format("{0:00/00}", CmUtil.LongParse(aData[iLoop + iCol].ToString()));

                                    //#20180221 해피포인트 일자별 실적 포맷수정 start,phj
                                    //기존
                                    //sPrtData += CmUtil.RPadH(sDate, 12) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 10) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 10) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 10);
                                    //변경
                                    sPrtData += CmUtil.RPadH(sDate, 10) +
                                                LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 8) +
                                                LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 8) +
                                                LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 8) +
                                                LF_CheckPrintData(aData[iLoop + iCol + 4].ToString(), 8);
                                    //#20180221 해피포인트 일자별 실적 포맷수정 end,phj
                                }
                                else if (m_sIRTType == "13")
                                {
                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 10) + CmUtil.RPadH(aData[iLoop + iCol + 1].ToString(), 5) + CmUtil.RPadH(aData[iLoop + iCol + 2].ToString(), 19) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 8);
                                }
                                else if (m_sIRTType == "15")
                                {
                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 6) + CmUtil.RPadH(aData[iLoop + iCol + 1].ToString(), 20) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 6) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 10);
                                }
                                else if (m_sIRTType == "16")
                                {
                                    sDate = aData[iLoop + iCol + 3].ToString();
                                    if (CmUtil.IsNumber(sDate) == true && iLoop == 0)
                                        sDate = m_cPosStatus.Global.DateToCulture(aData[iLoop + iCol + 3].ToString());

                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 8) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 15) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 10) + CmUtil.LPadH(sDate, 9);
                                }
                                else if (m_sIRTType == "17")
                                {
                                    sDate = aData[iLoop + iCol].ToString();
                                    if (CmUtil.IsNumber(sDate) == true && iLoop == 0)
                                        sDate = m_cPosStatus.Global.DateToCulture(aData[iLoop + iCol].ToString());

                                    sPrtData += CmUtil.RPadH(sDate, 12) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 15) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 15);
                                    sPrtData += CmUtil.RPadH("", 12) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 30);
                                }
                                else if (m_sIRTType == "19")
                                {
                                    sDate = aData[iLoop + iCol].ToString();
                                    if (CmUtil.IsNumber(sDate) == true && iLoop == 0)
                                        sDate = m_cPosStatus.Global.DateToCulture(aData[iLoop + iCol].ToString());

                                    sPrtData += CmUtil.RPadH(sDate, 12) + CmUtil.RPadH(aData[iLoop + iCol + 1].ToString(), 10) + CmUtil.RPadH(aData[iLoop + iCol + 2].ToString(), 10) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 8);
                                }
                                else if (m_sIRTType == "20")
                                {
                                    sDate = aData[iLoop + iCol].ToString();
                                    if (CmUtil.IsNumber(sDate) == true && iLoop == 0)
                                        sDate = m_cPosStatus.Global.DateToCulture(aData[iLoop + iCol].ToString());

                                    sPrtData += CmUtil.RPadH(sDate, 12) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 10) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 10) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 10);
                                }
                                else if (m_sIRTType == "21")
                                {
                                    sDate = aData[iLoop + iCol].ToString();
                                    if (CmUtil.IsNumber(sDate) == true && iLoop == 0)
                                        sDate = m_cPosStatus.Global.DateToCulture(aData[iLoop + iCol].ToString());
                                    sDate2 = aData[iLoop + iCol + 1].ToString();
                                    if (CmUtil.IsNumber(sDate2) == true && iLoop == 0)
                                        sDate2 = m_cPosStatus.Global.DateToCulture(aData[iLoop + iCol + 1].ToString());

                                    sPrtData += CmUtil.RPadH(sDate, 12) + CmUtil.RPadH(sDate2, 12) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 18);
                                    sPrtData += CmUtil.RPadH("", 12) + CmUtil.RPadH("", 12) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 18);

                                }
                                else if (m_sIRTType == "23")
                                {
                                    sDate = aData[iLoop + iCol].ToString();
                                    if (CmUtil.IsNumber(sDate) == true && iLoop == 0)
                                        sDate = m_cPosStatus.Global.DateToCulture(aData[iLoop + iCol].ToString());

                                    sPrtData += CmUtil.RPadH(sDate, 12) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 20) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 10);
                                    sPrtData += CmUtil.RPadH("", 12) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 15) + LF_CheckPrintData(aData[iLoop + iCol + 4].ToString(), 15);
                                }
                                else if (m_sIRTType == "26")
                                {
                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 8) + CmUtil.RPadH(aData[iLoop + iCol + 1].ToString(), 14) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 8) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 8) + LF_CheckPrintData(aData[iLoop + iCol + 4].ToString(), 4);
                                }
                                else if (m_sIRTType == "27")    // 주문내역
                                {
                                    // grayber@20180117 [BR]자료조회 주문내역 조회 출력 start - 출력 구분 처리 추가 ( 길이에 따라 2줄 혹은 1줄 출력 ) 
                                    if (m_cPosStatus.Mst.CorpDiv.Equals(ItemConst.CORP_DIV.BR) == true)
                                    {
                                        if (CmUtil.LenH(aData[iLoop + iCol + 2].ToString()) >= 24)
                                        {
                                            // 두줄
                                            sPrtData += CmUtil.RPadH(aData[iLoop + iCol + 2].ToString(), 42) + PosConst.CRLF;
                                            sPrtData += CmUtil.RPadH(" ", 24) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 7) + LF_CheckPrintData(aData[iLoop + iCol + 4].ToString(), 10);
                                        }
                                        else
                                        {
                                            // 한줄
                                            sPrtData += CmUtil.RPadH(aData[iLoop + iCol + 2].ToString(), 24) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 7) + LF_CheckPrintData(aData[iLoop + iCol + 4].ToString(), 10);
                                        }
                                    }
                                    else
                                    // grayber@20180117 [BR]자료조회 주문내역 조회 출력 end
                                    {
                                        //#20171205 주문내역조회 포맷 변경 start
                                        //기존
                                        /*
                                        sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 7) + CmUtil.RPadH(aData[iLoop + iCol + 1].ToString(), 15) + CmUtil.RPadH(aData[iLoop + iCol + 2].ToString(), 20);
                                        sPrtData += CmUtil.RPadH(aData[iLoop + iCol + 3].ToString(), 8) + LF_CheckPrintData(aData[iLoop + iCol + 4].ToString(), 20) +LF_CheckPrintData(aData[iLoop + iCol + 5].ToString(), 14);
                                        */
                                        //변경
                                        sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 20) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 4) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 4);
                                        sPrtData += LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 4) + LF_CheckPrintData(aData[iLoop + iCol + 4].ToString(), 10);// +LF_CheckPrintData(aData[iLoop + iCol + 5].ToString(), 14);
                                        //#20171205 주문내역조회 포맷 변경 end
                                    }
                                    // grayber@20180117 [BR] 주문내역 출력 처리 end
                                }
                                else if (m_sIRTType == "28")
                                {
                                    sDate = aData[iLoop + iCol].ToString();
                                    sPrtData += CmUtil.RPadH(sDate, 10) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 10) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 10) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 12);
                                }
                                else if (m_sIRTType == "29")
                                {
                                    sDate = aData[iLoop + iCol].ToString();
                                    if (CmUtil.IsNumber(sDate) == true && iLoop == 0)
                                        sDate = m_cPosStatus.Global.DateToCulture(aData[iLoop + iCol].ToString());

                                    sPrtData += CmUtil.RPadH(sDate, 12) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 15) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 15);
                                    sPrtData += LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 12) + LF_CheckPrintData(aData[iLoop + iCol + 4].ToString(), 15) + LF_CheckPrintData(aData[iLoop + iCol + 5].ToString(), 15);
                                }
                                else if (m_sIRTType == "31")
                                {
                                    sPrtData += CmUtil.RPadH(aData[iLoop + iCol].ToString(), 6) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 9) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 9) + CmUtil.RPadH(aData[iLoop + iCol + 3].ToString(), 18);
                                    sPrtData += LF_CheckPrintData(aData[iLoop + iCol + 4].ToString(), 12) + LF_CheckPrintData(aData[iLoop + iCol + 5].ToString(), 10) + LF_CheckPrintData(aData[iLoop + iCol + 6].ToString(), 10) + LF_CheckPrintData(aData[iLoop + iCol + 7].ToString(), 10);
                                }
                                else if (m_sIRTType == "32")
                                {
                                    sDate = aData[iLoop + iCol].ToString();
                                    if (CmUtil.IsNumber(sDate) == true && iLoop == 0)
                                        sDate = m_cPosStatus.Global.DateToCulture(aData[iLoop + iCol].ToString());

                                    sPrtData += CmUtil.RPadH(sDate, 12) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 15) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 15);
                                    sPrtData += CmUtil.RPadH("", 12) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 15) + LF_CheckPrintData(aData[iLoop + iCol + 4].ToString(), 15);
                                }
                                else if (m_sIRTType == "33")
                                {
                                    sDate = aData[iLoop + iCol].ToString();
                                    if (CmUtil.IsNumber(sDate) == true && iLoop == 0)
                                        sDate = m_cPosStatus.Global.DateToCulture(aData[iLoop + iCol].ToString());

                                    sPrtData += CmUtil.RPadH(sDate, 12) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 15) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 15);
                                    sPrtData += CmUtil.RPadH("", 12) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 15) + LF_CheckPrintData(aData[iLoop + iCol + 4].ToString(), 15);
                                }
                                else
                                {
                                    sDate = aData[iLoop + iCol].ToString();
                                    sPrtData += CmUtil.RPadH(sDate, 12) + LF_CheckPrintData(aData[iLoop + iCol + 1].ToString(), 10) + LF_CheckPrintData(aData[iLoop + iCol + 2].ToString(), 10) + LF_CheckPrintData(aData[iLoop + iCol + 3].ToString(), 10);
                                }
                                //sPrtData = CmUtil.RPadH(aData[iLoop + iCol].ToString(), 10) + CmUtil.RPadH(aData[iLoop + iCol + 1].ToString(), 12) + CmUtil.LPadH(aData[iLoop + iCol + 2].ToString(), 6) + CmUtil.LPadH(aData[iLoop + iCol + 3].ToString(), 10) + CmUtil.LPadH(aData[iLoop + iCol + 4].ToString(), 4);
                                break;
                        }
                        iCol += 3;

                    }
                }
                aPrintData.Add(sPrtHead + sPrtData);
            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.LOG_ERROR,
                                     System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                     System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                     ex.Message);
            }
        }
        #endregion 

        #region 문자열 출력타입체크
        private string LF_CheckPrintData(string sData, int iMaxlen)
        {
            string sResult = "";
            try
            {
                if (sData.ToUpper() == "NULL") sData = "";

                if (CmUtil.IsNumber(sData.Trim()) == true)
                {
                    // 숫자인 경우 오른쪽 정렬 
                    sResult = CmUtil.LPadH(m_cPosStatus.Global.NumericTOCurrency(m_cDataService.DoubleParse(sData.Trim().ToString())), iMaxlen);
                }
                else
                {
                    // 문자열인 경우 왼쪽 정렬
                    sResult = CmUtil.LPadH(sData.ToString().Trim(), iMaxlen);
                }
            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.LOG_ERROR,
                                     System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                     System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                     ex.Message);
            }
            return sResult;
        }
        #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;
                    case PosConst.OPOS_DEVICE.SCANNER:
                        this.Invoke(new EventHandler(OnScannerEvent));
                        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);
            }
        }

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

        }
        /// <summary>
        /// 스캐너 이벤트 처리
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        private void OnScannerEvent(object source, EventArgs e)
        {
            string sScanData = m_cDevStatus.Scanner.DataLabel;
            if (sScanData.Length > 0 && m_sInPutData == "")
            {
                m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_BARCODE;
                m_sInPutData = sScanData;

                //txtCardNo.Text = m_sInPutData;

///                if (m_cTrnStatus.Head.TradeDiv == ItemConst.TRAN_DIV.NORMAL) SearchTxtInPut();
            }

        }

        /// <summary>
        /// 카드 번호 암호화
        /// </summary>
        /// <param name="sInData"></param>
        /// <param name="sCardData"></param>
        /// <param name="sCardNo"></param>
        /// <returns></returns>
        private string EncryptedCardNo(string sInData, ref string sCardData, ref string sCardNo)
        {
            string sEncData = sInData;

            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);
            }
            return sEncData;
        }

        /// <summary>
        /// IC 카드 정보 입력 처리
        /// </summary>
        /// <returns></returns>
        private bool GetIcCardData()
        {
            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);
            }
            return false;
        }
        #endregion

        #region 그리드 초기화
        /// <summary>
        /// 그리드 초기화
        /// </summary>
        private void InitializeGrid()
        {
            try
            {
                if (m_cPosStatus.Sale.ScreenSizeUser == 1024)
                {
                    grdSearchList.CsmGridColumnHeadersVisible = true;                               //DataGridView 자체의 컬럼 헤더 Visible 여부
                    grdSearchList.CsmGridColumnHeadersFont = new Font(m_cPosStatus.Base.FONT, 14, FontStyle.Bold);
                    grdSearchList.CsmGridColumnHeadersHeight = 37;                                  //DataGridView 자체의 컬럼 헤더 높이
                    grdSearchList.CsmGridRowsHeight = 39;
                    grdSearchList.CsmGridColumnCount = 7;                                           //그리드의 컬럼수
                    grdSearchList.CsmGridShowPageRowsCount = 11;                                    //그리드의 한 화면에 보이는 로우수
                    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, 653, 0, 0, 0, 0, 0 });       //컬럼넓이 지정
                    grdSearchList.CsmGridAlignment(new int[] { 1, 0, 0, 0, 0, 0, 0 });              //컬럼 정렬 0:왼쪽, 1:가운데, 2:오른쪽
                    grdSearchList.CsmGridSetSortMode(new int[] { 0, 1, 0, 0, 0, 0, 0 });
                }
                else
                {
                    grdSearchList.CsmGridColumnHeadersVisible = true;                               //DataGridView 자체의 컬럼 헤더 Visible 여부
                    grdSearchList.CsmGridColumnHeadersFont = new Font(m_cPosStatus.Base.FONT, 12, FontStyle.Bold);
                    grdSearchList.CsmGridColumnHeadersHeight = 35;                                  //DataGridView 자체의 컬럼 헤더 높이
                    grdSearchList.CsmGridRowsHeight = 34;
                    grdSearchList.CsmGridColumnCount = 7;                                           //그리드의 컬럼수
                    grdSearchList.CsmGridShowPageRowsCount = 10;                                    //그리드의 한 화면에 보이는 로우수
                    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, 428, 0, 0, 0, 0, 0 });       //컬럼넓이 지정
                    grdSearchList.CsmGridAlignment(new int[] { 1, 0, 0, 0, 0, 0, 0 });              //컬럼 정렬 0:왼쪽, 1:가운데, 2:오른쪽
                    grdSearchList.CsmGridSetSortMode(new int[] { 0, 1, 0, 0, 0, 0, 0 });
                }


                //각 컬럼별 이름 지정(영업일자,POS번호,판매금액,거래번호,거래시간,거래구분,)
                grdSearchList.CsmGridColumnName(0, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0522));
                grdSearchList.CsmGridColumnName(1, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0523));

                //그리드 초기화 테이블
                m_dtSearchList = new DataTable("INIT");
                m_dtSearchList.Columns.Add(new DataColumn("CMM_CD", typeof(string)));
                m_dtSearchList.Columns.Add(new DataColumn("ENTRY_NM", typeof(string)));
                m_dtSearchList.Columns.Add(new DataColumn("TODATE_USE", typeof(string)));
                m_dtSearchList.Columns.Add(new DataColumn("SUB_CMM_CD1", typeof(string)));
                m_dtSearchList.Columns.Add(new DataColumn("SUB_CMM_CD2", typeof(string)));
                m_dtSearchList.Columns.Add(new DataColumn("POSNO_USE", typeof(string)));
                m_dtSearchList.Columns.Add(new DataColumn("SIMPLE_USE", 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
        
        #region 그리드 설정 및 사용
        private double DataGridSetting(int iWorkMode)
        {
            DataTable dtData = null;
            try
            {
                m_dtSearchList.Clear();

                if (m_sPosMenuKey == PosKey.MENU_KEY.SALE_EMP_SEARCH)
                {
                    // 담당자별 매출 조회                     
                    string sDateFrom = m_cPosStatus.Global.CultureToDate(txtDateFrom.Text);
                    dtData = m_cDataSearch.SelectTranCashier(new string[] { sDateFrom });
                }
                else
                {
                    // 자료 조회
                    dtData = m_cDataSearch.SelectGroupList(new string[] { PosConst.COMMON_CODE_GROUP.Z0009, m_sSearchType });
                }
                if (dtData != null && dtData.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtData.Rows)
                    {
                        DataRow drNewRow = m_dtSearchList.NewRow();
                        drNewRow["CMM_CD"] = CmUtil.GetDataRowStr(dr, "CMM_CD");
                        drNewRow["ENTRY_NM"] = CmUtil.GetDataRowStr(dr, "ENTRY_NM");
                        drNewRow["TODATE_USE"] = CmUtil.GetDataRowStr(dr, "TODATE_USE");
                        drNewRow["SUB_CMM_CD1"] = CmUtil.GetDataRowStr(dr, "SUB_CMM_CD1");
                        drNewRow["SUB_CMM_CD2"] = CmUtil.GetDataRowStr(dr, "SUB_CMM_CD2");
                        drNewRow["POSNO_USE"] = CmUtil.GetDataRowStr(dr, "POSNO_USE");
                        drNewRow["SIMPLE_USE"] = CmUtil.GetDataRowStr(dr, "SIMPLE_USE");

                        m_dtSearchList.Rows.Add(drNewRow);
                    }
                }
                
                //그리드 적용
                grdSearchList.CsmGridDataSource = m_dtSearchList;

                grdSearchList.CsmGridIndicateForeColor = Color.Red;

                //grdSearchItem_GridClickEvent(null, "0");
                //grdSearchList.CsmGridSelectRow(0);
                grdSearchList.Select();
            }
            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 0;
        }

        #endregion

        #region 그리드 클릭 이벤트
        /// <summary>
        /// 그리드 클릭 이벤트
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="rowIndex"></param>
        private void grdSearchItem_GridClickEvent(object sender, string rowIndex)
        {
            DataTable dtData = new DataTable();
            string sVisibleCheck = "";
            try
            {
                txtPrtData.Text = "";
                txtPrtData.Tag = "";

                if (grdSearchList.CsmGridRowsCount == 0) return;

                int nRow = grdSearchList.CsmGridSelectedRowIndex;
                if (nRow < 0) return;

                // 종료일자 활성화 체크
                sVisibleCheck = grdSearchList.CsmGridGetCell(nRow, 2);
                if (sVisibleCheck.Trim().ToString() != "")
                {
                    // 표시
                    lblLabel.Visible = true;
                    txtDateTo.Visible = true;
                    btnDateTo.Visible = true;

                    //label2.Width = 575;
                    //label1.Width = 575;
                    label2.Width = m_cPosStatus.Sale.ScreenSizeUser == 1024 ? 575 : 533;
                    label1.Width = m_cPosStatus.Sale.ScreenSizeUser == 1024 ? 575 : 533;
                }
                else
                {
                    // 미표시
                    lblLabel.Visible = false;
                    txtDateTo.Visible = false;
                    btnDateTo.Visible = false;

                    //label2.Width = 335;
                    //label1.Width = 335;
                    label2.Width = m_cPosStatus.Sale.ScreenSizeUser == 1024 ? 335 : 265;
                    label1.Width = m_cPosStatus.Sale.ScreenSizeUser == 1024 ? 335 : 265;
                }

                label3.Visible = false;
                label4.Visible = false;

                // 차수 활성화 체크
                cbChasu.Items.Clear();
                sVisibleCheck = grdSearchList.CsmGridGetCell(nRow, 3);
                if (sVisibleCheck.Trim().ToString() != "")
                {
                    // 표시
                    lblChasu.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0519);                         // 차수

                    lblChasu.Visible = true;
                    cbChasu.Visible = true;

                    cbChasu.Items.Clear();
                    dtData = m_cDataCommon.SeletCommonCode(sVisibleCheck, "");
                    if (dtData != null && dtData.Rows.Count != 0)
                    {
                        foreach (DataRow dr in dtData.Rows)
                        {
                            cbChasu.Items.Add(dr[PosMst.MST_COMMON.DATA.CMM_CD].ToString() + " " + dr[PosMst.MST_COMMON.DATA.CD_NM].ToString());
                        }
                        cbChasu.SelectedIndex = 0;
                    }
                    label3.Visible = true;
                    label4.Visible = true;
                }
                else
                {
                    // 미표시
                    lblChasu.Visible = false;
                    cbChasu.Visible = false;
                }

                // 제품군 활성화 체크
                cbiTemGroup.Items.Clear();
                sVisibleCheck = grdSearchList.CsmGridGetCell(nRow, 4);
                if (sVisibleCheck.Trim().ToString() != "" )
                {
                    // 표시
                    lbliTemType.Visible = true;
                    cbiTemGroup.Visible = true;

                    cbiTemGroup.Items.Clear();
                    dtData = m_cDataCommon.SeletCommonCode(sVisibleCheck, "");
                    if (dtData != null && dtData.Rows.Count != 0)
                    {
                        foreach (DataRow dr in dtData.Rows)
                        {
                            cbiTemGroup.Items.Add(dr[PosMst.MST_COMMON.DATA.CMM_CD].ToString() + " " + dr[PosMst.MST_COMMON.DATA.CD_NM].ToString());
                        }
                        cbiTemGroup.SelectedIndex = 0;
                    }

                    label3.Visible = true;
                    label4.Visible = true;
                }
                else
                {
                    // 미표시
                    lbliTemType.Visible = false;
                    cbiTemGroup.Visible = false;
                }

                // pos번호 활성화 체크 - 차수 대체
                sVisibleCheck = grdSearchList.CsmGridGetCell(nRow, 5);
                if (sVisibleCheck.Trim().ToString() != "")
                {
                    // 표시
                    lblChasu.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0370);                         // posno

                    lblChasu.Visible = true;
                    cbChasu.Visible = true;

                    cbChasu.Items.Clear();
                    dtData = m_cDataSearch.SelectPosNo(new string[] { "" });

                    int iPosIndex = 0;
                    int iLoop = 0;
                    if (dtData != null && dtData.Rows.Count != 0)
                    {
                        foreach (DataRow dr in dtData.Rows)
                        {
                            cbChasu.Items.Add(dr[PosMst.MST_COMMON.DATA.CMM_CD].ToString() + " " + dr[PosMst.MST_COMMON.DATA.CD_NM].ToString());

                            if (dr[PosMst.MST_COMMON.DATA.CMM_CD].ToString()  == m_cPosStatus.Base.PosNo)
                            {
                                iPosIndex = iLoop;
                            }
                            iLoop++;
                        }
                        cbChasu.SelectedIndex = iPosIndex;
                    }
                    label3.Visible = true;
                    label4.Visible = true;
                }


                // 간편조회 활성화 체크
                ckbSimple.Checked = false;
                sVisibleCheck = grdSearchList.CsmGridGetCell(nRow, 6);
                if (sVisibleCheck.Trim().ToString() != "")
                {
                    // #Rhee, 20170921 간편조회 번역 누락 추가 start
                    ckbSimple.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_1035);
                    // #Rhee, 20170921 간편조회 번역 누락 추가 end

                    // 표시
                    ckbSimple.Visible = true;
                    ckbSimple.Checked = true;
                }
                else
                {
                    // 미표시
                    ckbSimple.Visible = false;
                }

                // 조회
                btnProc_Click(btnSearch, 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);
            }
        }
        #endregion 

        #region 달력 클릭
        /// <summary>
        /// 달력 클릭
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnFromDate_Click(object sender, EventArgs e)
        {
            try
            {
                string sDate = WinBasic.ShowForm(new string[] { FormManager.FORM_CALENDAR });

                if (sDate.Trim() == "") return;

                DateTime dtFromDate = Convert.ToDateTime(m_cPosStatus.Global.DateToCulture(sDate));
                DateTime dtToDate = Convert.ToDateTime(txtDateTo.Text);
                TimeSpan dateDiff = dtToDate - dtFromDate;
                if (dateDiff.Days < 0 || dateDiff.Days > 50)
                {
                    WinManager.ErrorMessage(string.Format(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0619), 50));

                    return;
                }
                
                if (sDate != "") txtDateFrom.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);
            }
        }

        private void btnDateTo_Click(object sender, EventArgs e)
        {
            try
            {
                string sDate = WinBasic.ShowForm(new string[] { FormManager.FORM_CALENDAR });

                if (sDate.Trim() == "") return;

                DateTime dtFromDate = Convert.ToDateTime(txtDateFrom.Text);
                DateTime dtToDate = Convert.ToDateTime(m_cPosStatus.Global.DateToCulture(sDate));
                TimeSpan dateDiff = dtToDate - dtFromDate;
                if (dateDiff.Days < 0 || dateDiff.Days > 50  )
                {
                    WinManager.ErrorMessage(string.Format(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0619), 50));

                    return;
                }

                if (sDate != "") txtDateTo.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);
            }
        }
        #endregion

        private void txtDateFrom_EditBoxTextChangedEvnet(object sender, EventArgs e)
        {
            if (m_sPosMenuKey == PosKey.MENU_KEY.SALE_EMP_SEARCH)
                DataGridSetting(0);

        }
         
    }

}
