using ClientLib;
using ClientLib.CommonService;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using PublicLib;
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;

namespace HANMI_SALE
{
    public partial class CustAccountList : PublicLib.CommonMDI
    {
        public CustAccountList()
        {
            InitializeComponent();

       //     textEdit_SEARCH.ImeMode = System.Windows.Forms.ImeMode.Hangul;

            gridControl_Main.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat;
            gridControl_Main.LookAndFeel.UseDefaultLookAndFeel = false;
            gridView_Main.Appearance.HeaderPanel.BackColor = Color.FromArgb(170, 204, 255);

            textEdit_SEARCH.KeyPress += (sender, e) =>
            {
                if (e.KeyChar == '\r')
                {
                    searchProc();
                }
            };

            dateEdit_SDATE.DateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM") + "-01");
            dateEdit_FDATE.DateTime = DateTime.Now;


            this.Shown += (sender, e) =>
            {

            };
        }

        public override void searchProc()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                gridControl_Main.DataSource = null;

                SerializedSqlParam[] aParam = new SerializedSqlParam[] {
                    ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD),
                    ClientClass.CreateSqlParameter("SEARCH", SqlDbType.NVarChar, textEdit_SEARCH.Text)
                };
                ResultData resultData = ClientClass.GetData("GetCustAccountList", aParam);
                if (resultData.isError)
                {
                    throw new Exception(resultData.ResultValue);
                }

                gridControl_Main.DataSource = resultData.TableData;
                this.Cursor = Cursors.Arrow;
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Arrow;
                XtraMessageBox.Show(ex.Message);
            }
        }

        public override void excelProc()
        {
            this.ExportExcelGrid(gridControl_Main);
        }
    }
}