using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

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

namespace Cosmos.Win
{
    public partial class frmCustomerClaimInput : Form
    {
        #region 변수 선언
        private StateServer StateObject = (StateServer)StateServer.GetInstance();   // StateObject : StateServer Object (객체)
        private ICustomerService m_cCustomer = null;                                // 고객 클레임 처리 인터페이스
        private SManager sManager = new SManager();                                 // 이 객체를 통해 업무 Service 호출
        private PosStatus m_cPosStatus = new PosStatus();                           // 기본정보 참조

        // 고객 불만사항 등록 정보
        private string m_sSearchInfo = "";
        public string SearchInfo { set { m_sSearchInfo = value; } get { return m_sSearchInfo; } }

        // SEQ
        private string m_sSeqNo = "";
        // 수정을 위한 정보
        string m_sCMP_CD = "";
        string m_sSALE_DT = "";
        string m_sSTOR_CD = "";
        string m_sPOS_NO = "";
        #endregion 변수 선언

        #region 생성자 & 소멸자
        public frmCustomerClaimInput()
        {
            InitializeComponent();

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

            m_cPosStatus = (PosStatus)StateObject.POS;             // POS 기본정보
            m_cCustomer = (ICustomerService)sManager.InitServiceInstance(ServiceLists.BSV_ADMIN.DLL, ServiceLists.BSV_ADMIN.CUSTOMER_CLAIM);
        }

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

            if (m_sSearchInfo != "")
            {
                // 기존 등록된 정보를 수정
                ClaimDetail(m_sSearchInfo);
            }
            else
            {
                // 신규 등록
                m_sSeqNo = ClaimSeq();
            }
        }

        private void frmCustomerClaimInput_FormClosing(object sender, FormClosingEventArgs e)
        {
            UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", lblTitle.Text);
        }
        #endregion 생성자 & 소멸자

        #region 폼 컨트롤 초기화
        /// <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(this.lblTitle, 16, 1, 950, 50, 16);
                    FormManager.SetControlSize(this.btnExit, 965, 1, 58, 50);
                    FormManager.SetControlSize(this.label01, 16, 167, 656, 2);
                    FormManager.SetControlSize(this.lblAcceptNo, 16, 68, 122, 40);
                    FormManager.SetControlSize(this.txtAcceptNo, 154, 74, 501, 26);
                    FormManager.SetControlSize(this.txtCustomerNm, 154, 175, 373, 26);
                    FormManager.SetControlSize(this.label03, 16, 167, 992, 2);
                    FormManager.SetControlSize(this.lblCustomerNm, 16, 168, 122, 40);
                    FormManager.SetControlSize(this.txtCustomerTel, 810, 174, 185, 26);
                    FormManager.SetControlSize(this.lbCustomerTel, 669, 168, 122, 40);
                    FormManager.SetControlSize(this.txtPluNm, 154, 276, 501, 26);
                    FormManager.SetControlSize(this.label05, 16, 267, 992, 2);
                    FormManager.SetControlSize(this.lblPluNm, 16, 268, 122, 40);
                    FormManager.SetControlSize(this.label08, 16, 405, 656, 2);
                    FormManager.SetControlSize(this.lblExample, 670, 313, 274, 26);
                    FormManager.SetControlSize(this.txtCostAmt, 154, 452, 501, 26);
                    FormManager.SetControlSize(this.lblPrcsFlag, 16, 406, 122, 40);
                    FormManager.SetControlSize(this.lblCostAmt, 16, 445, 122, 40);
                    FormManager.SetControlSize(this.lblMemo, 16, 484, 122, 196);
                    FormManager.SetControlSize(this.lblCustomerInfo, 16, 148, 107, 18);
                    FormManager.SetControlSize(this.lblCustomerPrcs, 16, 386, 107, 18);
                    FormManager.SetControlSize(this.lblProductInfo, 16, 248, 107, 18);
                    FormManager.SetControlSize(this.lblPluCode1, 16, 307, 122, 20);
                    FormManager.SetControlSize(this.lblPluCode2, 16, 327, 122, 20);
                    FormManager.SetControlSize(this.txtPluCode, 154, 313, 501, 26);
                    FormManager.SetControlSize(this.rdoExchg, 90, 2, 86, 22);
                    FormManager.SetControlSize(this.rdoPay, 10, 2, 56, 22);
                    FormManager.SetControlSize(this.rdoIdem, 194, 2, 86, 22);
                    FormManager.SetControlSize(this.padInPut, 686, 430, 322, 250);
                    FormManager.SetControlSize(this.panel1, 532, 175, 123, 26);
                    FormManager.SetControlSize(this.rdoFemale, 65, 2, 56, 22);
                    FormManager.SetControlSize(this.rdoMale, 5, 2, 56, 22);
                    FormManager.SetControlSize(this.panel2, 154, 413, 286, 26);
                    FormManager.SetControlSize(this.btnInput, 806, 68, 100, 40);
                    FormManager.SetControlSize(this.btnPrint, 908, 68, 100, 40);
                    FormManager.SetControlSize(this.txtMemo, 156, 492, 499, 179);
                    FormManager.SetControlSize(this.btnBuyDate, 969, 274, 26, 26);
                    FormManager.SetControlSize(this.txtBuyDate, 810, 274, 157, 26);
                    FormManager.SetControlSize(this.lblBox6, 136, 406, 536, 40);
                    FormManager.SetControlSize(this.lblBox5, 137, 307, 871, 40);
                    FormManager.SetControlSize(this.lblBox4, 137, 268, 871, 40);
                    FormManager.SetControlSize(this.lblBox3, 790, 168, 218, 40);
                    FormManager.SetControlSize(this.lblBox2, 137, 168, 535, 40);
                    FormManager.SetControlSize(this.lblBox1, 137, 68, 535, 40);
                    FormManager.SetControlSize(this.lblBox8, 137, 484, 535, 197);
                    FormManager.SetControlSize(this.lblBox7, 136, 445, 536, 40);
                    FormManager.SetControlSize(this.label1, 17, 326, 120, 2);
                }
                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(this.lblTitle, 16, 1, 714, 50);
                    FormManager.SetControlSize(this.btnExit, 741, 1, 58, 50);
                    FormManager.SetControlSize(this.label01, 21, 67, 422, 2);
                    FormManager.SetControlSize(this.lblAcceptNo, 21, 68, 122, 40);
                    FormManager.SetControlSize(this.txtAcceptNo, 159, 74, 269, 26);
                    FormManager.SetControlSize(this.txtCustomerNm, 159, 141, 139, 26);
                    FormManager.SetControlSize(this.label03, 21, 133, 758, 2);
                    FormManager.SetControlSize(this.lblCustomerNm, 21, 134, 122, 40);
                    FormManager.SetControlSize(this.txtCustomerTel, 583, 140, 185, 26);
                    FormManager.SetControlSize(this.lbCustomerTel, 442, 134, 122, 40);
                    FormManager.SetControlSize(this.txtPluNm, 159, 208, 269, 26);
                    FormManager.SetControlSize(this.label05, 21, 199, 758, 2);
                    FormManager.SetControlSize(this.lblPluNm, 21, 200, 122, 40);
                    FormManager.SetControlSize(this.label08, 21, 304, 422, 2);
                    FormManager.SetControlSize(this.lblExample, 441, 245, 274, 26);
                    FormManager.SetControlSize(this.txtCostAmt, 159, 351, 269, 26);
                    FormManager.SetControlSize(this.lblPrcsFlag, 21, 305, 122, 40);
                    FormManager.SetControlSize(this.lblCostAmt, 21, 344, 122, 40);
                    FormManager.SetControlSize(this.lblMemo, 21, 383, 122, 196);
                    FormManager.SetControlSize(this.lblCustomerInfo, 21, 114, 107, 18);
                    FormManager.SetControlSize(this.lblCustomerPrcs, 21, 285, 107, 18);
                    FormManager.SetControlSize(this.lblProductInfo, 21, 180, 107, 18);
                    FormManager.SetControlSize(this.lblPluCode1, 21, 239, 122, 20);
                    FormManager.SetControlSize(this.lblPluCode2, 21, 259, 122, 20);
                    FormManager.SetControlSize(this.txtPluCode, 159, 245, 269, 26);
                    FormManager.SetControlSize(this.rdoExchg, 85, 2, 86, 22);
                    FormManager.SetControlSize(this.rdoPay, 15, 2, 56, 22);
                    FormManager.SetControlSize(this.rdoIdem, 179, 2, 86, 22);
                    FormManager.SetControlSize(this.padInPut, 457, 329, 322, 250);
                    FormManager.SetControlSize(this.panel1, 303, 141, 123, 26);
                    FormManager.SetControlSize(this.rdoFemale, 70, 2, 56, 22);
                    FormManager.SetControlSize(this.rdoMale, 10, 2, 56, 22);
                    FormManager.SetControlSize(this.panel2, 159, 312, 270, 26);
                    FormManager.SetControlSize(this.btnInput, 577, 68, 100, 40);
                    FormManager.SetControlSize(this.btnPrint, 679, 67, 100, 40);
                    FormManager.SetControlSize(this.txtMemo, 161, 391, 265, 179);
                    FormManager.SetControlSize(this.btnBuyDate, 742, 206, 26, 26);
                    FormManager.SetControlSize(this.txtBuyDate, 583, 206, 157, 26);
                    FormManager.SetControlSize(this.lblBox6, 142, 305, 301, 40);
                    FormManager.SetControlSize(this.lblBox5, 142, 239, 637, 40);
                    FormManager.SetControlSize(this.lblBox4, 142, 200, 637, 40);
                    FormManager.SetControlSize(this.lblBox3, 563, 134, 216, 40);
                    FormManager.SetControlSize(this.lblBox2, 142, 134, 301, 40);
                    FormManager.SetControlSize(this.lblBox1, 142, 68, 301, 40);
                    FormManager.SetControlSize(this.lblBox8, 142, 383, 301, 196);
                    FormManager.SetControlSize(this.lblBox7, 142, 344, 301, 40);
                    FormManager.SetControlSize(this.label1, 22, 258, 120, 2);
                }

                FormManager.SetFormAllControlFont(this, m_cPosStatus.Base.FONT);
                FormManager.SetTextBoxGlobalInfo(this, m_cPosStatus.Global.m_stCultureMaster.nGroupingDigits, m_cPosStatus.Global.m_stCultureMaster.strGroupingSymbol
                    , m_cPosStatus.Global.m_stCultureMaster.nDecimalDigits, m_cPosStatus.Global.m_stCultureMaster.strDecimalSymbol);
                FormManager.MovePopUpForm(this, false, m_cPosStatus.Sale.ScreenSizeUser);
                //picBack.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.POP_FULL_SIZE);

                //테마색상 적용!
                padInPut.ThemeColor = m_cPosStatus.ScnMst.ThemeColor;
                padInPut.ClearBtnText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0817);
                padInPut.SearchBtnText = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_1018);

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

                // 라벨 이름 설정
                lblTitle.Text        = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0662);

                lblCustomerInfo.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0663);
                lblProductInfo.Text  = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0664);
                lblCustomerPrcs.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0665);
                
                lblAcceptNo.Text     = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0666);
                lblCustomerNm.Text   = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0367);
                lbCustomerTel.Text   = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0192);
                lblPluNm.Text        = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0667);
                lblPluCode1.Text     = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0668);
                lblPluCode2.Text     = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0669);
                lblExample.Text      = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0670);
                lblPrcsFlag.Text     = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0671);
                lblCostAmt.Text      = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0411);
                lblMemo.Text         = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0413);

                rdoMale.Text   = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0099);
                rdoFemale.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0100);
                
                rdoPay.Text    = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0358);
                rdoExchg.Text  = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0672);
                rdoIdem.Text   = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0673);

                btnInput.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0225);
                btnPrint.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0257);

                txtAcceptNo.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0718);
                txtCustomerNm.Text = "";
                rdoMale.Checked = true;
                txtCustomerTel.Text = "";
                txtPluNm.Text = "";
                txtBuyDate.InputTypeFormat = m_cPosStatus.Global.m_stCultureMaster.strDatePattern;
                txtBuyDate.Text = m_cPosStatus.Global.DateToCulture(m_cPosStatus.Base.SaleDate);
                txtPluCode.Text = "";
                rdoPay.Checked = true;
                txtCostAmt.Text = "0";
                txtMemo.Text = "";

            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
        }
        #endregion 폼 컨트롤 초기화

        #region Control Event
        /// <summary>
        /// 종료
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        /// <summary>
        /// 저장
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnInput_Click(object sender, EventArgs e)
        {
            string sRet = UserCom.RST_ERR;
            string sClaimData = "";
            string sSexFlag = "";
            string sDoFlag = "";

            try
            {
                // 성별
                if (rdoMale.Checked == true)
                {
                    sSexFlag = "M";
                }
                else
                {
                    sSexFlag = "F";
                }

                // 처리구분
                if (rdoPay.Checked == true)
                {
                    sDoFlag = "0";
                }
                else if (rdoExchg.Checked == true)
                {
                    sDoFlag = "1";
                }
                else
                {
                    sDoFlag = "2";
                }

                sClaimData = txtAcceptNo.Text + "|" + m_sSeqNo + "|" + txtCustomerNm.Text.Trim() + "|" + sSexFlag + "|" + txtCustomerTel.Text.Trim() + "|"
                             + txtPluCode.Text.Trim() + "|" +
                             txtPluNm.Text.Trim() + "|" + m_cPosStatus.Global.CultureToDate(txtBuyDate.Text) + "|" + sDoFlag + "|" + txtCostAmt.Text.Trim().Replace(m_cPosStatus.Global.m_stCultureMaster.strGroupingSymbol, "") + "|" + txtMemo.Text.Trim();

                sRet = m_cCustomer.SetCustomerClaim(sClaimData);
                if (sRet == UserCom.RST_OK)
                {
                    WinManager.ConfirmMessage(POS_MESSAGE.ERROR.MSG_0180);
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    WinManager.ErrorMessage(sRet);
                }
            }
            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);
            }
        }

        /// <summary>
        /// 출력
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPrint_Click(object sender, EventArgs e)
        {
            string sRet = UserCom.RST_ERR;
            string sClaimData = "";
            string sSexFlag = "";
            string sDoFlag = "";

            try
            {
                // AS-IS 가 저장 후 출력하라고 메세지는 나오나 출력되기도 하여 동일하게 처리
                if (txtAcceptNo.Text == "")
                {
                    WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0181);
                    //return;
                }

                // 성별
                if (rdoMale.Checked == true)
                {
                    sSexFlag = rdoMale.Text;
                }
                else
                {
                    sSexFlag = rdoFemale.Text;
                }

                // 처리구분
                if (rdoMale.Checked == true)
                {
                    sDoFlag = rdoPay.Text;
                }
                else if (rdoMale.Checked == true)
                {
                    sDoFlag = rdoExchg.Text;
                }
                else
                {
                    sDoFlag = rdoIdem.Text;
                }

                sClaimData = txtAcceptNo.Text + "|" + txtAcceptNo.Text.Trim() + "|" + txtCustomerNm.Text.Trim() + "|" + sSexFlag + "|" + txtCustomerTel.Text.Trim() + "|"
                             + txtPluCode.Text.Trim() + "|" +
                             txtPluNm.Text.Trim() + "|" + m_cPosStatus.Global.CultureToDate(txtBuyDate.Text) + "|" + sDoFlag + "|" + txtCostAmt.Text.Trim() + "|" + txtMemo.Text.Trim();


                sRet = m_cCustomer.CustomerClaimPrt(sClaimData);
                if (sRet == UserCom.RST_OK)
                {
                    WinManager.ConfirmMessage(POS_MESSAGE.ERROR.MSG_0182);
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    WinManager.ErrorMessage(sRet);
                }
            }
            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);
            }
        }

        #region 텍스트박스 키 입력 이벤트 처리
        /// <summary>
        /// 텍스트박스 키 입력 이벤트 처리
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="sFuncValue"></param>
        private void txtEditBox_EditBoxKeyDownEvent(object sender, string sFuncValue)
        {
            try
            {
                string sTxtBoxName = ((Cosmos.UI.CsmPosEditBox)sender).Name;

                if (sFuncValue == PosKey.MENU_KEY.ENTER)
                {
                    if (((Cosmos.UI.CsmPosEditBox)sender) == txtCustomerNm)
                    {
                        txtCustomerTel.Focus();
                    }
                    else if (((Cosmos.UI.CsmPosEditBox)sender) == txtCustomerTel)
                    {
                        txtPluNm.Focus();
                    }
                    else if (((Cosmos.UI.CsmPosEditBox)sender) == txtPluNm)
                    {
                        txtPluCode.Focus();
                    }
                    else if (((Cosmos.UI.CsmPosEditBox)sender) == txtPluCode)
                    {
                        txtCostAmt.Focus();
                    }
                    else if (((Cosmos.UI.CsmPosEditBox)sender) == txtCostAmt)
                    {
                        txtMemo.Focus();
                    }
                }
                else if (sFuncValue == PosKey.MENU_KEY.CLEAR)
                {
                    // 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)
        {
            try
            {
                padInPut.SetActiveControl = (Control)sender;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
        }
        #endregion 텍스트박스 키 입력 이벤트 처리
        #endregion Control Event

        #region User Method
        /// <summary>
        /// 마지막 접수번호 확인
        /// </summary>
        /// <returns></returns>
        private string ClaimSeq()
        {
            DataTable dtData = new DataTable();

            try
            {
                dtData = m_cCustomer.GetClaimSeq();
                if (dtData != null && dtData.Rows.Count > 0)
                {
                    return CmUtil.GetDataRowStr(dtData.Rows[0], "SEQ");
                }
            }
            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 "1";
        }

        /// <summary>
        /// 고객불만사항 상세조회
        /// </summary>
        /// <param name="sData"></param>
        private void ClaimDetail(string sData)
        {
            DataTable dtData = new DataTable();
            string[] sInfo = null;

            try
            {
                if (sData == "")
                {
                    WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0302));
                }

                // 등록일자[0], SEQ[1]
                sInfo = sData.Split('|');

                dtData = m_cCustomer.SearchCustomerDetail(sInfo[0].Replace("-", ""), sInfo[1]);
                if (dtData != null && dtData.Rows.Count > 0)
                {
                    // 전체초기화
                    InitControl();

                    //접수번호 일자
                    string sSaleDt = CmUtil.GetDataRowStr(dtData.Rows[0], PosEtc.CUSTOMER_CLAIM_INFO.DATA.SALE_DT);

                    string sSaleYyyy = sSaleDt.Substring(0, 4);
                    string sSaleMm = sSaleDt.Substring(4, 2);
                    string sSaleDd = sSaleDt.Substring(6, 2);

                    m_sSeqNo = CmUtil.GetDataRowStr(dtData.Rows[0], PosEtc.CUSTOMER_CLAIM_INFO.DATA.SEQ);

                    // 접수번호
                    txtAcceptNo.Text = sSaleYyyy + "." + sSaleMm + "." + sSaleDd + "-" + CmUtil.GetDataRowStr(dtData.Rows[0], PosEtc.CUSTOMER_CLAIM_INFO.DATA.POS_NO) + "-" + CmUtil.GetDataRowStr(dtData.Rows[0], PosEtc.CUSTOMER_CLAIM_INFO.DATA.SEQ);
                    // 이름
                    txtCustomerNm.Text = CmUtil.GetDataRowStr(dtData.Rows[0], PosEtc.CUSTOMER_CLAIM_INFO.DATA.CUST_NM);
                    // 성별
                    if (CmUtil.GetDataRowStr(dtData.Rows[0], PosEtc.CUSTOMER_CLAIM_INFO.DATA.CUST_SEX) == "M")
                    {
                        rdoMale.Checked = true;
                    }
                    else if (CmUtil.GetDataRowStr(dtData.Rows[0], PosEtc.CUSTOMER_CLAIM_INFO.DATA.CUST_SEX) == "F")
                    {
                        rdoFemale.Checked = true;
                    }
                    // 연락처
                    txtCustomerTel.Text = CmUtil.GetDataRowStr(dtData.Rows[0], PosEtc.CUSTOMER_CLAIM_INFO.DATA.CUST_TEL);
                    // 대표제품명
                    txtPluNm.Text = CmUtil.GetDataRowStr(dtData.Rows[0], PosEtc.CUSTOMER_CLAIM_INFO.DATA.ITEM_SNM);
                    // 구매일자
                    txtBuyDate.Text = m_cPosStatus.Global.DateToCulture(CmUtil.GetDataRowStr(dtData.Rows[0], PosEtc.CUSTOMER_CLAIM_INFO.DATA.BUY_DT));
                    // 제품코드
                    txtPluCode.Text = CmUtil.GetDataRowStr(dtData.Rows[0], PosEtc.CUSTOMER_CLAIM_INFO.DATA.LOT_NO);
                    // 처리구분
                    if (CmUtil.GetDataRowStr(dtData.Rows[0], PosEtc.CUSTOMER_CLAIM_INFO.DATA.CLAIM_PRC_GB) == "0")
                    {
                        rdoPay.Checked = true;
                    }
                    else if (CmUtil.GetDataRowStr(dtData.Rows[0], PosEtc.CUSTOMER_CLAIM_INFO.DATA.CLAIM_PRC_GB) == "1")
                    {
                        rdoExchg.Checked = true;
                    }
                    else if (CmUtil.GetDataRowStr(dtData.Rows[0], PosEtc.CUSTOMER_CLAIM_INFO.DATA.CLAIM_PRC_GB) == "2")
                    {
                        rdoIdem.Checked = true;
                    }
                    // 처리비용
                    txtCostAmt.Text = CmUtil.TruncateDouble(CmUtil.GetDataRowDouble(dtData.Rows[0], PosEtc.CUSTOMER_CLAIM_INFO.DATA.CLAIM_PRC_COST)).ToString();
                    // 처리내용
                    txtMemo.Text = CmUtil.GetDataRowStr(dtData.Rows[0], PosEtc.CUSTOMER_CLAIM_INFO.DATA.CLAIM_PRC_MEMO);
                }
            }
            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 User Method

        private void btnDate_Click(object sender, EventArgs e)
        {
            try
            {
                string sDate = WinBasic.ShowForm(new string[] { FormManager.FORM_CALENDAR });
                if (sDate != "") txtBuyDate.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);
            }
        }
    }
}
