yoonlee
yoonlee
Reputation Top 1%
yoonlee
8 Snippets  (106th place)
Published
2 Channels
Created
1 Channel
Following
236 points  (129th place)
Reputation
Junior Code Generator
Serious Code Generator
Junior Publisher
Serious Publisher
Junior Topic Creator
Junior Trend Maker
Junior Popular Coder
Serious Popular Coder
Junior Autobiographer
Serious Autobiographer
Serious Famous Coder

Recent Snippets See all snippets by yoonlee

public by yoonlee  1760  3  6  0

[CodingRule] HMS01

HMS 프로젝트 코딩 룰 01
public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        protected override void OnLoad(EventArgs e)
        {
            // 00 Inlitialize는 OnLoad 함수에서 처리
            base.OnLoad(e);

            try
            {
                //00. Event 등록 전, 컨트롤 초기화
                InitializeControl();

                //00. Evnet 등록은 코드로 처리
                InitializeEvent();

                //01. if문 조건문에 ! 대신에 false로 처리하기
                //02. 비교대상 문자열을 앞에 위치, Equals  함수 사용하기
                CodingRule1();

                //03. loop문 사용시 조건 확장메서드 사용하기
                CodingRule2();

                //04. validation 처리
                CodingRule3(new DataTable());
            }
            catch (Exception)
            {
                throw;
            }
        }

        #region Initialize
        private void InitializeControl()
        {
            try
            {

            }
            catch (Exception)
            {

                throw;
            }
        }

        private void InitializeEvent()
        {
            try
            {
                this.DoubleClick += new EventHandler(Form1_DoubleClick);
                this.button1.Click += new EventHandler(button1_Click);
            }
            catch (Exception)
            {

                throw;
            }
        }

        #endregion

        #region Event

        void Form1_DoubleClick(object sender, EventArgs e)
        {
            //01. Depth Level이 0인 함수는 꼭 Try Catch 문 처리할 것 
            try
            {
                testc();
            }
            catch (Exception)
            {
                
                throw;
            }
        }

        private void testc()
        {
            //DETPTH 1

        }

        void button1_Click(object sender, EventArgs e)
        {
            try
            {
                 //01. sender를 형 변환해서 사용해야 재샤용성이 높아짐
                if (sender is Button)
                {
                    //02. as 로 캐스팅할 경우 캐스팅 실패시 null을 리턴함
                    //(Button) 식으로 캐스팅 할 경우 실패시 Exception 발생
                    Button btn = sender as Button;

                    string str = btn.Name;
                }
            }
            catch (Exception)
            {
                
                throw;
            }
        }

        #endregion

        #region Method
        private void CodingRule1()
        {
            string tempStr = null;

            //tempStr의 값이 null일 경우에 false 값을 리턴함
            //tempStr.Equals("Y") 처리했을 경우 Exceptiono 발생
            if ("Y".Equals(tempStr) == false)
            {
                
            }
        }


        private void CodingRule2()
        {
            DataTable dt = new DataTable();

            //불필요한 loop  제거
            //람다식을 사용할 경우 디버그 모드에서 문제가 수정이 불하가하니 Select 함수 권장
            foreach (DataRow row in dt.Select("ISUSABLE = 'Usable'"))
            {
                
            }
        }


        private void CodingRule3(DataTable dataTable)
        {
            // 분기문으로 Validation 처리하는 경우 조건을 부정문으로 작성하여 
            // 괄호로 감싸지 말고 Line 한줄로 처리할 것 (중복된 괄호처리로 인해 가독성이 낮아지는 현상 방지)
            if (dataTable == null || dataTable.Rows.Count <= 0) return;
        }

        #endregion

    }
;

public by yoonlee  1683  0  6  0

[Lamda] DataType 지정없이 Value 가져오기

람다식 DataType 지정없이 데이터 가져오기 예제 'x.Filed' 형식으로 DataType 지정해서 가져오는 경우 Casting Exception 발생을 방지하기 위함
private static decimal GetSumSqaremeter(DataView dvInfo)
        {
            try
            {
                if (dvInfo == null || dvInfo.Table == null) return 0;
                if (dvInfo.Table.Columns.Contains(CIM_LOT.SQAREMETER) == false) return 0;
                
                int colIndex = dvInfo.Table.Columns[CIM_LOT.SQAREMETER].Ordinal;

                var sumInfo = dvInfo.Table.AsEnumerable().Sum(r => Convert.ToDecimal(r.ItemArray[colIndex]));
                
                return sumInfo;
            }
            catch (Exception)
            {
                return 0;
            }
        }                        
;

public by yoonlee  2223  2  5  1

[CustomUtil]CommonUtil.cs

CommonUtl파일, ver.gds
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using DevExpress.Utils;
using CIM.UI.MessageConverter.Constants;
using System.Data;
using System.Data.OleDb;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using CIM.UI.MessageConverter.Services;
using CIM.UI.CustomControl.Control;
using CIM.UI.CustomControl.Constants;
using CIM.UI.Infrastructure.Interface.Constants;
using Microsoft.Practices.CompositeUI;
using CIM.UI.CustomControl.Capture;
using System.Drawing;
using System.Drawing.Imaging;
using DevExpress.XtraGrid;
using CIM.UI.Infrastructure.Interface.Services;

namespace CIM.UI.CustomControl
{
    public class CommonUtil
    {
        #region Variable

        public static string DATE_FORMAT = "yyyy-MM-dd";
        public static string DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
        public static string TIME_FORMAT = "HH:mm:ss";
        public static string SPCDATETIME_FORMAT = "yyyyMMdd-HHmmss";

        public const string DASH = "-";

        public static string PRINTER_NAME = "";

        #endregion

        #region WaitForm

        /// <summary>
        /// 메시지 처리 대기창
        /// </summary>
        /// <returns></returns>
        public static void WaitProcessShow()
        {
            try
            {
                WaitForm.Show(MessageNames.processingMessage);
            }
            catch (Exception ex)
            {
                MesMessageBox.ShowDialog(ex);
            }
        }

        /// <summary>
        /// 메시지 처리 대기창
        /// </summary>
        /// <returns></returns>
        public static void WaitProcessShow(string nlsId, string[] processParam, string tid)
        {
            string[] para = new string[] { };

            if (ConfirmShow(string.Format(NLSService.GetNLSMessage(nlsId), (processParam == null ? para : processParam)), tid) != DialogResult.OK)
            {
                Exception ex = new Exception();
                ex.Data["OIRESPONSE"] = null;
                throw ex;
            }

            WaitForm.Show(MessageNames.MESOI_Message_Process, null, tid);
        }

        /// <summary>
        /// 메시지 처리 대기창
        /// </summary>
        /// <returns></returns>
        public static void WaitProcessShow(string nlsId, string[] processParam, string tid, bool insertcancelmessage)
        {
            string[] para = new string[] { };

            if (ConfirmShow(string.Format(NLSService.GetNLSMessage(nlsId), (processParam == null ? para : processParam)), tid) != DialogResult.OK)
            {
                Exception ex = new Exception("취소 되었습니다.");
                ex.Data["OIRESPONSE"] = null;
                throw ex;
            }

            WaitForm.Show(MessageNames.MESOI_Message_Process, null, tid);
        }

        /// <summary>
        /// 조회 대기창
        /// </summary>
        /// <returns></returns>
        public static void WaitSearchShow()
        {
            try
            {
                WaitForm.Show(MessageNames.MESOI_Message_Search);
            }
            catch (Exception ex)
            {
                //MesMessageBox.ShowDialog(ex);
            }
        }

        /// <summary>
        /// 조회 결과창 ( 조회된 데이터가 없습니다. )
        /// </summary>
        /// <returns></returns>
        public static void CheckNotFoundData(TabbedGridControl grd)
        {
            if (grd.RowCount() < 1)
            {
                AlertMessage(MessageNames.MESOI_Data_NotFound);
            }
        }

        /// <summary>
        /// 조회 결과창 ( 조회된 데이터가 없습니다. )
        /// </summary>
        /// <returns></returns>
        public static void CheckNotFoundData(CGridControl grd)
        {
            if (grd.RowCount() < 1)
            {
                AlertMessage(MessageNames.MESOI_Data_NotFound);
            }
        }

        /// <summary>
        /// 조회 결과창 ( 데이터가 없습니다. )
        /// </summary>
        /// <returns></returns>
        public static void CheckNotFoundData(CheckedTabbedGridControl grd)
        {
            if (grd.RowCount() < 1)
            {
                AlertMessage(MessageNames.MESOI_Message_NotFound);
            }
        }

        /// <summary>
        /// 조회 결과창 ( 데이터가 없습니다. )
        /// </summary>
        /// <returns></returns>
        public static void CheckNotFoundData(CheckedTabbedGridPanel grd)
        {
            if (grd.CheckedTabbedGridControl.RowCount() < 1)
            {
                AlertMessage(MessageNames.MESOI_Message_NotFound);
            }
        }

        /// <summary>
        /// Check Grid column
        /// </summary>
        /// <param name="grd"></param>
        public static bool CheckGrid_Validation(CheckedTabbedGridControl grd)
        {
            if (grd.GetCheckedIndex().Length < 1)
            {
                AlertMessage("CheckGrid_Validation");
                return false;
            }
            return true;
        }

        #endregion

        #region Confirm Box

        /// <summary>
        /// ConfirmShow OKCancel 
        /// </summary>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static DialogResult ConfirmShow(string nlsName, string title)
        {
            string text = NLSService.GetNLSMessage(nlsName);

            if (string.IsNullOrEmpty(text))
            {
                return XtraMessageBox.Show(nlsName, title, MessageBoxButtons.OKCancel);
            }
            else
            {
                return XtraMessageBox.Show(text, title, MessageBoxButtons.OKCancel);
            }

        }

        /// <summary>
        /// ConfirmShow OKCancel 
        /// </summary>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static DialogResult ConfirmShow(string nlsName, string[] parameter, string title)
        {
            string text = string.Empty;
            string sTitle = string.Format(NLSService.GetNLSLabel(title));

            if (parameter == null)
            {
                text = string.Format(NLSService.GetNLSMessage(nlsName));
            }
            else
            {
                text = string.Format(NLSService.GetNLSMessage(nlsName), parameter);
            }

            return XtraMessageBox.Show(text, sTitle, MessageBoxButtons.OKCancel);
        }

        /// <summary>
        /// ConfirmShow Dynamic
        /// </summary>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static DialogResult ConfirmShow(string nlsName, string title, MessageBoxButtons btn)
        {
            string text = NLSService.GetNLSMessage(nlsName);
            return XtraMessageBox.Show(text, title, btn);
        }

        /// <summary>
        /// ConfirmShow Dynamic
        /// </summary>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static DialogResult ConfirmShow(string nlsName, string[] parameter, string title, MessageBoxButtons btn)
        {
            string text = string.Format(NLSService.GetNLSMessage(nlsName), parameter);
            return XtraMessageBox.Show(text, title, btn);
        }

        /// <summary>
        /// Null or Contain Value Check
        /// DataTable or DataRow or DataRow[] or int[] or string
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="nlsName"></param>
        /// <param name="parameter"></param>
        public static bool ValidationNull(object obj, string nlsName, string[] parameter)
        {
            bool bRtn = false;

            try
            {
                if (obj is DataTable)
                {
                    DataTable dt = obj as DataTable;

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        bRtn = true;
                    }
                }
                else if (obj is DataRow)
                {
                    DataRow dr = obj as DataRow;

                    if (dr != null)
                    {
                        bRtn = true;
                    }
                }
                else if (obj is DataRow[])
                {
                    DataRow[] drArry = obj as DataRow[];

                    if (drArry != null && drArry.Length > 0)
                    {
                        bRtn = true;
                    }
                }
                else if (obj is int[])
                {
                    int[] iArry = obj as int[];

                    if (iArry != null && iArry.Length > 0)
                    {
                        bRtn = true;
                    }
                }
                else if (obj is string)
                {
                    string data = obj as string;
                    if (string.IsNullOrEmpty(data) == true)
                    {

                    }
                    else
                    {
                        bRtn = true;
                    }
                }

                if (bRtn == false)
                {
                    if (parameter != null && parameter.Length > 0)
                    {
                        AlertMessage(nlsName, parameter);
                    }
                    else
                    {
                        AlertMessage(nlsName);
                    }

                    return bRtn;
                }
            }
            catch (Exception ex)
            {
                MesMessageBox.ShowDialog(ex);
            }

            return bRtn;
        }

        /// <summary>
        /// Null or Contain Value Check
        /// DataTable or DataRow or DataRow[] or int[]
        /// </summary>
        /// <param name="obj"></param>
        public static bool ValidationNull(object obj, string nlsName)
        {
            return ValidationNull(obj, nlsName, new string[] { });
        }

        #endregion

        #region AlertMessage

        /// <summary>
        /// ConfirmShow Dynamic
        /// </summary>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static void AlertMessage(string nlsName)
        {
            MesMessageBox.ShowDialog(NLSService.GetNLSMessage(nlsName), MappingMessageType(nlsName.Substring(0, 3)), true);
        }

        /// <summary>
        /// ConfirmShow Dynamic
        /// </summary>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static void AlertMessage(string nlsName, string[] parameter)
        {
            string message = string.Format(NLSService.GetNLSMessage(nlsName), parameter);
            MesMessageBox.ShowDialog(message, MappingMessageType(nlsName.Substring(0, 3)), true);
        }

        /// <summary>
        /// ConfirmShow Dynamic
        /// </summary>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static void AlertMessage(string nlsName, string[] parameter, Exception ex)
        {
            string message = string.Format(NLSService.GetNLSMessage(nlsName), parameter) + "\r\n" + ex.Message;
            MesMessageBox.ShowDialog(message, MappingMessageType(nlsName.Substring(0, 3)), true);
        }

        /// <summary>
        /// ConfirmShow Dynamic
        /// </summary>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static string GetAlertMessage(string nlsName, string returnmsg)
        {
            returnmsg = NLSService.GetNLSMessage(nlsName);

            return returnmsg;
        }
        /// <summary>
        /// ConfirmShow Dynamic
        /// </summary>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static string GetAlertMessage(string nlsName, string returnmsg, string[] parameter)
        {
            returnmsg = string.Format(NLSService.GetNLSMessage(nlsName), parameter);

            return returnmsg;
        }
        /// <summary>
        /// Mapping message type
        /// </summary>
        /// <param name="messageType"></param>
        /// <returns></returns>
        private static Constants.UIMessageType MappingMessageType(string messageType)
        {
            Constants.UIMessageType uIMessageType = UIMessageType.Information;

            switch (messageType)
            {
                case MessageType.ERR:
                    uIMessageType = UIMessageType.Error;
                    break;
                case MessageType.INF:
                    uIMessageType = UIMessageType.Information;
                    break;
                case MessageType.WAN:
                    uIMessageType = UIMessageType.Warning;
                    break;
                case MessageType.QUS:
                    uIMessageType = UIMessageType.Question;
                    break;
                default:
                    uIMessageType = UIMessageType.Information;
                    break;
            }

            return uIMessageType;
        }

        #endregion

        #region MandatoryShow

        /// <summary>
        /// 필수 입력값을 확인하세요. MessageBox 표시.
        /// </summary>
        /// <returns></returns>
        public static bool MandatoryShow()
        {
            MesMessageBox.ShowDialog(MessageNames.MESOI_Mandatory_Field, Constants.UIMessageType.Information, true);
            return false;
        }


        #endregion

        #region DataTable Copy
        /// <summary>
        /// 동일한 dataTable 생성
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static DataTable CopyDataTable(DataTable dt)
        {
            DataTable tmp = dt.Clone();

            foreach (DataRow dr in dt.Rows)
            {
                tmp.ImportRow(dr);
            }
            return tmp;
        }
        /// <summary>
        /// 동일한 dataTable 생성 후 조회조건 결과 반영
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        public static DataTable CopyDataTable(DataTable dt, string condition)
        {
            DataTable tmp = dt.Clone();

            foreach (DataRow dr in dt.Select(condition))
            {
                tmp.ImportRow(dr);
            }
            return tmp;
        }

        /// <summary>
        /// DataTable 의 Column 을 조회하여 RowCount 에 해당하는 Row 가 없다면 만든다.
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="columnName"></param>
        /// <param name="rowCount"></param>
        /// <returns></returns>
        public static DataTable MakeDataTableByColumn(DataTable dt, string columnName, int rowCount)
        {
            return MakeDataTableByColumn(dt, columnName, rowCount, false);
        }

        /// <summary>
        /// Carrier할당이 처음일 때.
        /// 할당이 안된 lot을 처음으로 할당하려고 할 때에는 
        /// Slot NO가 없는 상태이기때문에
        /// index를 처음 새로 부여해야한다~~~
        /// by shlee
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="columnName"></param>
        /// <param name="rowCount"></param>
        /// <param name="isfirst"></param>
        /// <returns></returns>
        public static DataTable MakeDataTableByColumn(DataTable dt, string columnName, int rowCount, bool isfirst)
        {
            //만들려는 Row Count 보다 원본 Count 가 크다면 안됨..
            if (dt == null || dt.Rows.Count > rowCount) return dt;

            DataTable tmp = dt.Clone();

            int idx = 0;
            Dictionary<int, DataRow> dicRow = new Dictionary<int, DataRow>();

            if (isfirst == true)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    idx++;
                    dr[columnName] = idx.ToString();
                    dicRow[idx] = dr;
                }
            }
            else
            {
                foreach (DataRow dr in dt.Rows)
                {
                    idx = Convert.ToInt16(dr[columnName].ToString());
                    dicRow[idx] = dr;
                }
            }

            //Slot 거꾸로 보여야함.
            for (int i = rowCount; i >= 1; i--)
            {
                if (dicRow.ContainsKey(i))
                {
                    tmp.ImportRow(dicRow[i]);
                }
                else
                {
                    DataRow row = tmp.NewRow();
                    row[columnName] = (i).ToString();
                    tmp.Rows.Add(row);
                }
            }

            return tmp;
        }

        /// <summary>
        /// Insert 할 Data 를 ChildOriginal Data 에 ChildEmptyRow 에 해당하는 ColumnName 위치에 넣는다.
        /// ChildEmptyRow 는 ChildOriginal 에서 가져온 Data 여야만 하고, Insert DataTable 과 ChildOriginal DataTable 은 같아야 한다.
        /// </summary>
        /// <param name="insertData"></param>
        /// <param name="toDataTable"></param>
        /// <param name="toEmptyRow"></param>
        /// <param name="columnName"></param>
        /// <returns></returns>
        public static DataTable MakeCheckDataTable(DataTable insertData, DataTable toDataTable, DataRow[] toEmptyRow, string columnName)
        {
            //만들려는 Row Count 보다 원본 Count 가 크다면 안됨..
            if (insertData == null || toEmptyRow == null || insertData.Rows.Count > toEmptyRow.Length) return toDataTable;

            DataTable tmp = toDataTable.Clone();

            List<int> idxList = new List<int>();
            foreach (DataRow dr in toEmptyRow)
            {
                int idx = Int32.Parse(dr[columnName].ToString());

                idxList.Add(idx);
            }

            int insertIdx = 0;
            foreach (DataRow row in toDataTable.Rows)
            {
                //포함이 되어 있으면 InserData 를 넣어 주자.
                int fieldValue = Int32.Parse(row[columnName].ToString());
                if (idxList.Contains(fieldValue))
                {
                    if (insertIdx < insertData.Rows.Count)
                    {
                        DataRow iRow = insertData.Rows[insertIdx];
                        iRow[columnName] = Int32.Parse(row[columnName].ToString());
                        tmp.ImportRow(iRow);
                        insertIdx++;
                    }
                    else
                    {
                        tmp.ImportRow(row);
                    }
                }
                else
                {
                    tmp.ImportRow(row);
                }
            }
            return tmp;
        }

        /// <summary>
        /// Insert 할 Data 를 ChildOriginal Data 에 변경 될 ColumnName 위치에 ValueColumn 으로 넣는다.
        /// Insert DataTable 과 ChildOriginal DataTable 은 같아야 한다.
        /// </summary>
        /// <param name="insertData"></param>
        /// <param name="toDataTable"></param>
        /// <param name="chgColumnName"></param>
        /// <param name="valueColumn"></param>
        /// <returns></returns>
        public static DataTable MakeChangeDataTable(DataTable insertData, DataTable toDataTable, string chgColumnName, string valueColumn)
        {
            //만들려는 Row Count 보다 원본 Count 가 크다면 안됨..
            if (insertData == null) return toDataTable;

            foreach (DataRow insertRow in insertData.Rows)
            {
                int val = Int32.Parse(insertRow[valueColumn].ToString());

                DataRow row = toDataTable.Rows[toDataTable.Rows.Count - val];

                row.ItemArray = insertRow.ItemArray;

                row[chgColumnName] = insertRow[valueColumn];
            }

            return toDataTable;
        }

        /// <summary>
        /// DataTable 에 ColumnName 을 만들고, Value 를 넣어 준다.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="ColumnName"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static DataTable SetColumnValue(DataTable data, string columnName, string value)
        {
            if (data == null) return data;

            DataColumn col = new DataColumn(columnName);
            if (data.Columns.Contains(col.Caption) != true)
            {
                data.Columns.Add(col);

                foreach (DataRow row in data.Rows)
                {
                    row[columnName] = value;
                }
            }

            return data;
        }

        /// <summary>
        /// DataTable 에 ColumnName 을 만들고, Value 를 ValueColumn 에 있는 값을 넣어 준다.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="columnName"></param>
        /// <param name="valueColumn"></param>
        /// <returns></returns>
        public static DataTable SetColumnValueColumn(DataTable data, string columnName, string valueColumn)
        {
            if (data == null) return data;

            DataColumn col = new DataColumn(columnName);
            if (data.Columns.Contains(col.Caption) != true && data.Columns.Contains(valueColumn) == true)
            {
                data.Columns.Add(col);

                foreach (DataRow row in data.Rows)
                {
                    row[columnName] = row[valueColumn];
                }
            }

            return data;
        }

        /// <summary>
        /// DataTable 에서 Index Arr 에서 아래에서 부터 지운다... 
        /// </summary>
        /// <param name="table"></param>
        /// <param name="intArr"></param>
        public static void RemoveDataRowByIndex(DataTable table, int[] idxArr)
        {
            if (table == null || table.Rows.Count == 0 || idxArr == null || idxArr.Length == 0) return;
            for (int i = idxArr.Length - 1; i >= 0; i--)
            {
                int idx = idxArr[i];
                table.Rows.RemoveAt(idx);
            }
        }


        /// <summary>
        /// Row[] 의 Row 내의 해당 Fleld 값을 이용해 Query 를 만든다.
        /// 'AAA','BBB','CCC' 형으로 Return 함
        /// </summary>
        /// <param name="rows"></param>
        /// <param name="fieldName"></param>
        /// <param name="splitChar"></param>
        /// <returns></returns>
        public static string GetQueryInParam(DataRow[] rows, string fieldName, string splitChar)
        {
            StringBuilder sb = new StringBuilder();

            foreach (DataRow dr in rows)
            {
                sb.Append("'");
                sb.Append(dr[fieldName].ToString());
                sb.Append("'");
                sb.Append(splitChar);
            }

            return sb.ToString().Remove(sb.Length - 1);
        }

        /// <summary>
        /// Query 사용시 
        /// DataTable 에서 해당하는 fieldName 의 값을 splitChar 로 재 작성.
        /// AAA,BBB,CCC
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="fieldName"></param>
        /// <param name="splitChar"></param>
        /// <returns></returns>
        public static string GetQueryInParam(DataTable dt, string fieldName, string splitChar)
        {
            StringBuilder sb = new StringBuilder();

            foreach (DataRow dr in dt.Rows)
            {
                sb.Append(dr[fieldName].ToString());
                sb.Append(splitChar);
            }

            return sb.ToString().Remove(sb.Length - 1);
        }

        /// <summary>
        /// Query 사용시 
        /// DataTable 에서 해당하는 fieldName 의 값을 splitChar 로 재 작성.
        /// AAA,BBB,CCC
        /// </summary>
        /// <param name="list"></param>
        /// <param name="splitChar"></param>
        /// <returns></returns>
        public static string GetQueryInParam(List<string> list, string splitChar)
        {
            StringBuilder sb = new StringBuilder();

            foreach (string sr in list)
            {
                sb.Append(sr);
                sb.Append(splitChar);
            }

            return sb.ToString().Remove(sb.Length - 1);
        }
        #endregion

        #region UserException
        /// <summary>
        /// 사용자 에러 메시지
        /// </summary>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static void UserException(string nlsName)
        {
            Exception ex = new Exception();
            ex.Data["INFOMATION"] = nlsName;
            if (ex.Data.Count < 1) ex.Data["ERROR"] = nlsName;
            throw ex;
        }
        /// <summary>
        /// 사용자 에러 메시지
        /// </summary>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static void UserException(string nlsName, string[] parameters)
        {
            Exception ex = new Exception();
            ex.Data["INFOMATION"] = nlsName;
            ex.Data["PARAMETERS"] = parameters;
            throw ex;
        }
        /// <summary>
        /// 사용자 에러 메시지
        /// </summary>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static void UserException(string nlsName, Constants.UIMessageType messageType)
        {
            Exception ex = new Exception();
            if (messageType == Constants.UIMessageType.Warning)
            {
                ex.Data["WARNING"] = nlsName;
            }
            if (messageType == Constants.UIMessageType.Information)
            {
                ex.Data["INFOMATION"] = nlsName;
            }
            if (messageType == Constants.UIMessageType.Question)
            {
                ex.Data["QUESTION"] = nlsName;
            }
            if (ex.Data.Count < 1) ex.Data["ERROR"] = nlsName;
            throw ex;
        }
        /// <summary>
        /// 사용자 에러 메시지
        /// </summary>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static void UserException(string nlsName, string[] parameters, Constants.UIMessageType messageType)
        {
            Exception ex = new Exception();
            if (messageType == Constants.UIMessageType.Warning)
            {
                ex.Data["WARNING"] = nlsName;
            }
            if (messageType == Constants.UIMessageType.Information)
            {
                ex.Data["INFOMATION"] = nlsName;
            }
            if (messageType == Constants.UIMessageType.Question)
            {
                ex.Data["QUESTION"] = nlsName;
            }
            if (ex.Data.Count < 1) ex.Data["ERROR"] = nlsName;
            ex.Data["PARAMETERS"] = parameters;
            throw ex;
        }
        #endregion

        #region 일자 비교
        /// <summary>
        /// 시작일자 종료일자 체킁
        /// </summary>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        public static bool IsDateTimeCondition(DateTime startDate, DateTime endDate)
        {
            TimeSpan Days = endDate - startDate;
            if (Days.Days < 0)
            {
                //시작 일자와 종료 일자를 확인하십시요
                CommonUtil.AlertMessage("PLN_Date_Validation_Message");
                // 2014.03.05  사용자 오류 메시지 정리- By JJG
                //MesMessageBox.ShowDialog("PLN_Date_Validation_Message", UIMessageType.Information, true);
                return false;
            }
            return true;
        }

        #endregion

        #region 일자 변경
        /// <summary>
        /// 일자
        /// </summary>
        /// <param name="datetime"></param>
        /// <returns></returns>
        public static string GetDateFormatToDate(DateTime datetime)
        {
            return datetime.ToString(DATE_FORMAT);
        }
        /// <summary>
        /// 일자 시간
        /// </summary>
        /// <param name="datetime"></param>
        /// <returns></returns>
        public static string GetDateFormatToDateTime(DateTime datetime)
        {
            return datetime.ToString(DATETIME_FORMAT);
        }
        /// <summary>
        /// 일자 시간
        /// </summary>
        /// <param name="datetime"></param>
        /// <returns></returns>
        public static string GetDateFormatToTime(DateTime datetime)
        {
            return datetime.ToString(TIME_FORMAT);
        }


        #endregion

        #region 조회 결과 데이터가 없습니다.

        /// <summary>
        /// 조회 결과 데이터가 없습니다.
        /// </summary>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static void NotFoundData()
        {
            MesMessageBox.ShowDialog(NLSService.GetNLSMessage(NLSNames.NoData), Constants.UIMessageType.Information, true);
        }

        #endregion

        #region Lot 검색
        /// <summary>
        /// 최소한 하나의 정보를 입력하세요.  심플넘버 : {0} 랏넘버 : {1} 케리어 : {2}
        /// </summary>
        public static void InvalidSearchLot(string simpleNo, string lotId, string carrier)
        {

            if (string.IsNullOrEmpty(simpleNo) && string.IsNullOrEmpty(lotId) && string.IsNullOrEmpty(carrier))
            {
                // 최소한 하나의 정보를 입력하세요.
                CommonUtil.UserException("LOT_InvalidSearchLot");
                return;
            }
        }

        /// <summary>
        /// Active상태인 랏만 사용가능합니다. 랏상태를 확인하세요. 랏넘버: {0} 랏상태: {1}
        /// </summary>
        public static void InvalidTrackingLot(DataTable dt)
        {
            foreach (DataRow dr in dt.Rows)
            {
                if (!LotState.Active.Equals(dr[CIM_LOT.STATE].ToString()))
                {
                    CommonUtil.UserException("InvalidTrackingLot", new string[] { dr[CIM_LOT.LOTID].ToString(), dr[CIM_LOT.STATE].ToString() });
                    return;
                }
            }
        }

        #endregion

        #region Text util

        /// <summary>
        /// obj의 Trim 된 String 값을 반환한다.
        /// obj.ToString().Trim()
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static string GetTrimString(object obj)
        {
            if (obj == null)
                return String.Empty;

            return String.IsNullOrWhiteSpace(obj.ToString()) ? String.Empty : obj.ToString().Trim();
        }

        public static string GetFullTrimString(object obj)
        {
            if (obj == null)
                return string.Empty;

            return string.IsNullOrWhiteSpace(obj.ToString()) ? string.Empty : obj.ToString().Replace(" ", string.Empty);
        }
        public static string GetString(object obj)
        {
            if (obj == null)
                return String.Empty;

            return String.IsNullOrWhiteSpace(obj.ToString()) ? String.Empty : obj.ToString();
        }
        public static string GetString(object obj)
        {
            if (obj == null)
                return String.Empty;

            return String.IsNullOrWhiteSpace(obj.ToString()) ? String.Empty : obj.ToString();
        }

        public static string AddXmlCDATA(string data)
        {
            return string.Format("<![CDATA[{0}]]>", data);
        }

        public static DateTime GetStringDateFormat(string strDate)
        {
            strDate = strDate.Replace("-", "");

            return DateTime.ParseExact(strDate, "yyyyMMdd", null);
        }

        public static bool CheckInnerType(IMessageService Service, string siteID, string LotID, string businessUnitID, string ProcessSegmentID)
        {
            if (businessUnitID.Equals(BusinessUnit.MLB))
            {
                // 내층작업 완료 UI 의 대상 LOT은 MLB(HDI) 이면서 Layer가 1층이 아니면 대상
                if (GetFistLayOut(Service, siteID, LotID, ProcessSegmentID) && ExistCCL(Service, siteID, LotID) && CheckCCLTrackOutProcessSegment(ProcessSegmentID))
                {
                    return true;
                }

                //if (GetFistLayOut(Service, siteID, LotID, ProcessSegmentID) && ExistCCL(Service, siteID, LotID) && CheckCCLTrackOutProcessSegment(ProcessSegmentID))
                //{
                //    return true;
                //}
            }
            return false;
        }

        public static string getLotID(string lotName)
        {
            string lotid = GetTrimString(lotName);

            if (lotid.Contains(DASH) == false)
                return lotid;

            if (lotid.Length < 7)
                return lotid;

            int idxDash = -1;

            if (lotid.Length >= 7 && lotid.Contains(DASH))
                idxDash = GetFullTrimString(lotid).IndexOf(DASH, 0, 10);

            if (idxDash < 0)
                return lotid;

            return lotid.Remove(idxDash, 1);
        }

        public static string getLotID(string lotName, string lotType = LotType.MAIN)
        {
            string lotid = GetTrimString(lotName);

            int idxDash = -1;

            if (lotid.Length >= 7)
                idxDash = GetFullTrimString(lotid).IndexOf(DASH, 0, 10);

            if (idxDash < 0)
                return lotid;

            if (lotType.ToUpper().Equals(LotType.CCL.ToUpper()))
                return lotid.Remove(idxDash, 1);
            else
                return getReplacedString(lotid);
        }

        public static string getLotName(string lotID)
        {
            string lotName = GetFullTrimString(lotID);

            if (lotName.Length < 7)
                return lotName;

            return GetFullTrimString(lotID).Insert(7, DASH);
        }

        public static string getReplacedString(object obj, string token = DASH)
        {
            return GetFullTrimString(obj).Replace(token, String.Empty);
        }

        public static bool GetFistLayOut(IMessageService Service, string siteID, string lotID, string processSegmentID)
        {
            Dictionary<string, string> dicParam = new Dictionary<string, string>();
            dicParam.Add("SITEID", UIConstants.SiteId);
            dicParam.Add("LOTID", GetFullTrimString(lotID));
            dicParam.Add("PROCESSSEGMENT", processSegmentID);

            DataTable resultData = FactoryService.GetQueryList(Service, "CheckInnerProcessSegment", "4", dicParam, false);

            bool judge = false;
            if (resultData != null && resultData.Rows.Count > 0)
            {
                int process = GetInteger(resultData.Rows[0]["PROCESSSEGMENTID"], 0);
                int proseq = GetInteger(resultData.Rows[0]["PROCSEQ"], 0);

                judge = process > proseq ? false : true;
            }
            return judge;
        }

        public static bool ExistCCL(IMessageService Service, string siteID, string lotID)
        {
            Dictionary<string, string> dicParam = new Dictionary<string, string>();
            dicParam.Add("SITEID", UIConstants.SiteId);
            dicParam.Add("LOTID", GetFullTrimString(lotID));

            DataTable resultData = FactoryService.GetQueryList(Service, "ExistCCLMaterial", "1", dicParam, false);

            if (resultData.Rows.Count <= 0)
            {
                return false;
            }
            return true;
        }

        public static bool CheckCCLTrackOutProcessSegment(string processSegmentID)
        {
            if (processSegmentID.Equals("R0040") || processSegmentID.Equals("R0050") || processSegmentID.Equals("R0060")
                || processSegmentID.Equals("R0070") || processSegmentID.Equals("R0080") || processSegmentID.Equals("R0100"))
            {
                return true;
            }
            return false;
        }

        /// <summary>
        /// obj 값을 Boolean 타입으로 변환을 시도하고, 실패할 경우 defaultValue를 반환한다.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public static bool GetBoolean(object obj, bool defaultValue)
        {
            bool value = true;

            try
            {
                if (GetFullTrimString(obj).ToUpper().Equals("Y"))
                {
                    return true;
                }
                else if (GetFullTrimString(obj).ToUpper().Equals("N"))
                {
                    return false;
                }

                value = Convert.ToBoolean(obj);

                if (obj == null)
                {
                    value = defaultValue;
                }
            }
            catch { value = defaultValue; }

            return value;
        }

        /// <summary>
        /// obj 값을 Double 타입으로 변환을 시도하고, 실패할 경우 defaultValue를 반환한다.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public static double GetDouble(object obj, double defaultValue)
        {
            double value = 0;

            try
            {
                if (string.IsNullOrEmpty(GetFullTrimString(obj)))
                {
                    value = defaultValue;
                }
                else
                {
                    value = Convert.ToDouble(GetFullTrimString(obj));
                }
            }
            catch
            {
                value = defaultValue;
            }

            return value;
        }
        //Decimal

        /// <summary>
        /// obj 값을 Decimal 타입으로 변환을 시도하고, 실패할 경우 defaultValue를 반환한다.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public static Decimal GetDecimal(object obj, Decimal defaultValue)
        {
            Decimal value = 0;

            try
            {
                if (string.IsNullOrEmpty(GetFullTrimString(obj)))
                {
                    value = defaultValue;
                }
                else
                {
                    value = Convert.ToDecimal(GetFullTrimString(obj));
                }
            }
            catch
            {
                value = defaultValue;
            }

            return value;
        }
        /// <summary>
        /// obj 값을 Integer 타입으로 변환을 시도하고, 실패할 경우 defaultValue를 반환한다.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public static int GetInteger(object obj, int defaultValue)
        {
            int value = 0;

            try { value = Convert.ToInt32(GetFullTrimString(obj)); }
            catch { value = defaultValue; }

            return value;
        }

        /// <summary>
        /// 문자열의 오른쪽 문자 들을 가져온다.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string GetRight(object obj, int value)
        {
            // 2014.09.17 이승현
            string str = string.Empty;
            if (obj != null)
            {
                str = GetFullTrimString(obj);
                int len = str.Length;
                str = str.Substring(len - value, value);
            }
            return str;
        }

        /// <summary>
        /// 문자열의 왼쪽 문자 들을 가져온다.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string GetLeft(object obj, int value)
        {
            // 2014.09.17 이승현
            string str = string.Empty;
            if (obj != null)
            {
                str = GetFullTrimString(obj);
                str = str.Substring(0, value);
            }
            return str;
        }

        #endregion

        #region RequestDocument

        /// <summary>
        /// Request document
        /// </summary>
        /// <param name="workItem"></param>
        /// <param name="processSegment"></param>
        public static void RequestDocument(WorkItem workItem, string processSegment)
        {
            PopupRequestDocument.ShowDialog(workItem, processSegment);
        }

        #endregion

        #region ScreenShot

        /// <summary>
        /// Screen capture
        /// </summary>
        /// <param name="frm"></param>
        public static void ScreenShot(IntPtr handle)
        {
            try
            {
                ScreenCapture screenCapture = new ScreenCapture();
                Image image = screenCapture.CaptureScreen();

                string fileName = string.Format(@"{0}\ScreenShot\{1}{2}.gif", new string[]
                {
                    Application.StartupPath, UIConstants.UserID, DateTime.Now.ToString("yyyyMMddHHmmss")
                });

                screenCapture.CaptureWindowToFile(handle, fileName, ImageFormat.Gif);
                AlertMessage(NLSNames.ScreenShotSuccess, new string[] { fileName, "" });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// Screen capture
        /// </summary>
        /// <param name="frm"></param>
        public static void ScreenShot(IntPtr handle, IntPtr handle2)
        {
            try
            {
                ScreenCapture screenCapture = new ScreenCapture();
                Image image = screenCapture.CaptureScreen();

                string fileName = string.Format(@"{0}\ScreenShot\{1}{2}_1.gif", new string[]
                {
                    Application.StartupPath, UIConstants.UserID, DateTime.Now.ToString("yyyyMMddHHmmss")
                });

                string fileName2 = string.Format(@"{0}\ScreenShot\{1}{2}_2.gif", new string[]
                {
                    Application.StartupPath, UIConstants.UserID, DateTime.Now.ToString("yyyyMMddHHmmss")
                });

                screenCapture.CaptureWindowToFile(handle, fileName, ImageFormat.Gif);
                screenCapture.CaptureWindowToFile(handle2, fileName2, ImageFormat.Gif);

                AlertMessage(NLSNames.ScreenShotSuccess, new string[] { fileName, fileName2 });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        #endregion

        public static void CheckNotFoundData(DataTable dtMaterialInfoList)
        {
            throw new NotImplementedException();
        }

        public static DataTable ChangDataType(string[] _Colums, Type Datatype, DataTable orgDT)
        {
            //2014-09-01 이승현
            //format 적용을 위하여 datatable 의 data type 를 변경 한다. - 기본 적으로 string 로 넘어옴
            DataTable dt = orgDT.Clone();
            for (int i = 0; i < _Colums.Length; i++)
            {
                try
                {
                    string test = _Colums[i].ToString();
                    dt.Columns[_Colums[i].ToString()].DataType = Datatype;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("[CommonUtill.ChangDataType] \r\n   " + _Colums[i].ToString() + " " + ex.Message + "\r\n   컬럼명을 확인 하세요.");
                }
            }
            try
            {
                foreach (DataRow dr in orgDT.Rows)
                {
                    DataRow dr2 = dt.NewRow();
                    int i = 0;
                    foreach (DataColumn dc in orgDT.Columns)
                    {
                        //if (_Colums.Contains(dc.ColumnName))
                        //{

                        //    switch (Datatype.Name)
                        //    {
                        //        case "Double":
                        //            dr2[i] = GetDouble(GetFullTrimString(dr[i]), 0);
                        //            break;
                        //        case "Decimal":
                        //            dr2[i] = GetDecimal(GetFullTrimString(dr[i]),0);
                        //            break;
                        //        case "Int16":
                        //            dr2[i] = GetInteger(GetFullTrimString(dr[i]), 0);
                        //            break;
                        //        case "Int32":
                        //            dr2[i] = GetInteger(GetFullTrimString(dr[i]), 0);
                        //            break;
                        //        case "Int64":
                        //            dr2[i] = GetInteger(GetFullTrimString(dr[i]), 0);
                        //            break;
                        //        default:
                        //            dr2[i] = dr[i];
                        //            break;
                        //    }
                        //}
                        //else
                        //{
                        if (!string.IsNullOrEmpty(GetFullTrimString(dr[i])))
                        {
                            dr2[i] = dr[i];
                        }
                        //}

                        i++;
                    }
                    dt.Rows.Add(dr2);
                }
            }
            catch (Exception ex)
            {
                MesMessageBox.ShowDialog(ex);
            }
            return dt;
        }

        public DataTable ChangDataType(int[] _ColumIndex, Type Datatype, DataTable orgDT)
        {
            //2014-09-01 이승현
            //format 적용을 위하여 datatable 의 data type 를 변경 한다. - 기본 적으로 string 로 넘어옴
            DataTable dt = orgDT.Clone();
            for (int i = 0; i < _ColumIndex.Length; i++)
            {
                dt.Columns[_ColumIndex[i]].DataType = Datatype;
            }
            try
            {
                foreach (DataRow dr in orgDT.Rows)
                {
                    DataRow dr2 = dt.NewRow();
                    int i = 0;
                    foreach (DataColumn dc in orgDT.Columns)
                    {
                        dr2[i] = dr[i];
                        i++;
                    }
                    dt.Rows.Add(dr2);
                }
            }
            catch (Exception ex)
            {
                MesMessageBox.ShowDialog(ex);
            }
            return dt;
        }

        public static DataTable AddColumn(DataTable Table, string ColumnName, Type DataType)
        {
            string Name = GetFullTrimString(ColumnName);
            Table.Columns.Add(Name, DataType);
            return Table;
        }
        // 엑셀 문서 DataTable 로 Import 2014.09.16 이승현
        public object OpenExcelFile(string FilePath, string SheetName)
        {

            DataTable dt = new DataTable();
            //var fullFileName = string.Format("{0}\\{1}", Directory.GetCurrentDirectory(), FileName);
            if (!File.Exists(FilePath))
            {
                System.Windows.Forms.MessageBox.Show("File not found");
                return null;
            }
            try
            {
                var connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8.0;", FilePath);
                var adapter = new OleDbDataAdapter("select * from [" + SheetName + "$]", connectionString);
                var ds = new DataSet();
                string tableName = "excelData";
                adapter.Fill(ds, tableName);
                dt = ds.Tables[tableName];

            }
            catch (Exception ex)
            {
                MesMessageBox.ShowDialog(ex);
            }
            return dt;
        }

        public static DataTable DataTableCopy(DataTable DataSource)
        {
            DataTable copyTable = null;

            try
            {

                System.IO.MemoryStream stream = new System.IO.MemoryStream();

                System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

                formatter.Serialize(stream, DataSource);

                stream.Position = 0;

                copyTable = (DataTable)formatter.Deserialize(stream);
            }
            catch { }

            return copyTable;
        }

        public static DataTable GetSysdate(IMessageService messageService)
        {
            DataTable dtSysdate = new DataTable();

            try
            {
                Dictionary<string, string> bindSet = new Dictionary<string, string>();

                dtSysdate = FactoryService.GetQueryList(messageService, "GetSysdate", "3", bindSet, false);

            }
            catch { }

            return dtSysdate;
        }

        public static string GetSysdate(IMessageService messageService, string dateFormat)
        {
            DataTable dtSysdate = GetSysdate(messageService);

            DateTime dtNow = Convert.ToDateTime(dtSysdate.Rows[0]["SYSDATE"]);

            switch (dateFormat)
            {
                case "NOW":
                    return GetFullTrimString(dtSysdate.Rows[0]["SYSDATE"]);
                case "YYYYMMDD":
                    return GetFullTrimString(dtSysdate.Rows[0]["YYYYMMDD"]);
                case "YYYY_MM_DD":
                    return GetFullTrimString(dtSysdate.Rows[0]["YYYY-MM-DD"]);
                default:
                    return GetFullTrimString(dtSysdate.Rows[0]["SYSDATE"]);
            }
        }

        #region ftpFileUpload - 이미지 저장 - 전자 mes service 에서 카피
        //  이승현 ftp 서버가 현재 없는 상태 local ftp 설정 - 전자 mes service 에서 카피
        // FTP FILE UPLOAD
        public static void ftpFileUpload(byte[] bFile, string sPath, string sFileName)
        {
            //ms.Position = 0;
            List<string> sPathList = sPath.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries).ToList();

            string sFtpAddr = "ftp://dddms:2000"; // 서버 주소
            //string sFtpAddr = "ftp://127.0.0.1"; // 로컬 FTP

            if (sFtpAddr == null || sFtpAddr.Length == 0)
            {
                // 서버 정보 없음 2014.08.11
            }
            else
            {
                string sDirPath = sPath;
                sDirPath = sFtpAddr;
                for (int i = 0; i < sPathList.Count; i++)
                {
                    if (!FtpDirectoryExists(sDirPath, sPathList[i]))
                    {
                        makeFtpDir(sDirPath + "/" + sPathList[i]);
                    }
                    sDirPath += "/" + sPathList[i];
                }
                FtpWebRequest ftp = GetFtpRequest(sFtpAddr + "/" + sPath + "/" + sFileName);

                ftp.Method = WebRequestMethods.Ftp.UploadFile;

                byte[] buffer = new byte[2048];
                Stream stream = ftp.GetRequestStream();
                //int offSet = 0;
                try
                {
                    stream.Write(bFile, 0, bFile.Count());

                    //offSet = ms.Read(buffer, 0, 2048);
                    //while (offSet != 0)
                    //{
                    //    stream.Write(buffer, 0, offSet);
                    //    offSet = ms.Read(buffer, 0, 2048);
                    //}

                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    stream.Close();
                    //ms.Close();
                }
            }
        }

      
        public static FtpWebRequest GetFtpRequest(string URI)
        {
            FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(URI);
            request.Credentials = new NetworkCredential("Rw_DDG_Mes", "Mes2DDG");// null;//new NetworkCredential(Constant.FTP_SERVER_ID, Constant.FTP_SERVER_PW);
            request.UsePassive = true;
            request.UseBinary = true;
            request.KeepAlive = false;

            return request;
        }

        // 이승현  전자 mes service 에서 카피
        public static bool FtpDirectoryExists(string sParentPath, string sDir)
        {
            List<string> sDirList = new List<string>();

            bool IsExists = false;
            try
            {
                FtpWebRequest request = GetFtpRequest(sParentPath);
                request.Timeout = 5000;
                request.Method = WebRequestMethods.Ftp.ListDirectory;
                FtpWebResponse response = (FtpWebResponse)request.GetResponse();
                StreamReader reader = new StreamReader(response.GetResponseStream());

                string line = reader.ReadLine();
                while (line != null)
                {
                    sDirList.Add(line);
                    line = reader.ReadLine();


                }

                if (sDirList.Contains(sDir))
                {
                    IsExists = true;
                }
                reader.Close();
                response.Close();
            }
            catch
            {
                IsExists = false;
            }
            return IsExists;
        }

        // 디렉토리 자동 생성
        public static void makeFtpDir(string sUri)
        {
            FtpWebRequest ftpMakeDir = GetFtpRequest(sUri);
            ftpMakeDir.Timeout = 5000;

            ftpMakeDir.Method = System.Net.WebRequestMethods.Ftp.MakeDirectory;

            try
            {
                FtpWebResponse response = (FtpWebResponse)ftpMakeDir.GetResponse();
                response.Close();

            }
            catch (Exception ex)
            {
                throw ex;
            }

        }
        #endregion

        #region 채번
        // 채번을 하게 되면 번호가 증가 함. 조회 에 달게 되면 조회 할때마다 증가 하게됨.
        // 이승현 2014.10.20
        public static DataTable GetPettenID(IMessageService Service, string Pattern)
        {
            DataTable dt = new DataTable();
            try
            {
                CIM.UI.MessageConverter.Entities.OIMessage oMessageUP = FactoryService.GetBaseOIMessage();
                oMessageUP.MessageName = MessageNames.GetPatternid;
                CIM.UI.MessageConverter.Entities.MessageItem Patternid = new CIM.UI.MessageConverter.Entities.MessageItem("Patternid");

                Dictionary<string, string> bind = new Dictionary<string, string>();
                bind.Add("Patternid", Pattern);

                Patternid = MessageServiceHelper.MakeSubMessageItem(Patternid, bind);
                oMessageUP.SetMessageItem(Patternid);
                CIM.UI.MessageConverter.Entities.OIResponse responseMaster = FactoryService.SendOIMessage(Service, oMessageUP);

                dt = responseMaster.GetReplyDataTable("DATALIST");

            }
            catch (Exception ex)
            {

            }
            return dt;
        }
        #endregion

        #region EquipmentID 채번
        public static DataTable GetEquipmentPettenID(IMessageService Service, string Pattern, string IdindexName)
        {
            DataTable dt = new DataTable();
            try
            {
                CIM.UI.MessageConverter.Entities.OIMessage oMessageUP = FactoryService.GetBaseOIMessage();
                oMessageUP.MessageName = MessageNames.GetEquipmentPatternid;
                CIM.UI.MessageConverter.Entities.MessageItem Patternid = new CIM.UI.MessageConverter.Entities.MessageItem("Patternid");

                Dictionary<string, string> bind = new Dictionary<string, string>();
                bind.Add("Patternid", Pattern);
                bind.Add("idindexname", IdindexName);

                Patternid = MessageServiceHelper.MakeSubMessageItem(Patternid, bind);
                oMessageUP.SetMessageItem(Patternid);
                CIM.UI.MessageConverter.Entities.OIResponse responseMaster = FactoryService.SendOIMessage(Service, oMessageUP);

                dt = responseMaster.GetReplyDataTable("DATALIST");

            }
            catch (Exception ex)
            {

            }
            return dt;
        }
        #endregion


        /// <summary>
        /// Get user info
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static DataTable GetUserInfo(IMessageService Service, string userId)
        {
            try
            {
                DataTable dtUser = new DataTable();
                Dictionary<string, string> bindSet = new Dictionary<string, string>();
                bindSet.Add(CIM_USER.SITEID, UIConstants.SiteId);
                bindSet.Add(CIM_USER.USERID, userId);
                bindSet.Add(CIM_USER.USERTYPE, string.Empty);

                return FactoryService.GetQueryList(Service, "GetUserInfo", "4", bindSet);
            }
            catch (Exception ex)
            {
                MesMessageBox.ShowDialog(ex);
                return null;
            }
        }

        /// <summary>
        /// Check Combobox의 SelectedData를 Query IN Parameter 형식으로 변환해서 리턴
        /// 'ㅁㅁㅁㅁ','ㅁㅁㅁㅁ','ㅁㅁㅁ' 형식
        /// </summary>
        /// <param name="dtSelectedData"></param>
        /// <param name="sColumn"></param>
        /// <returns></returns>
        public static string GetSelectedDatalikeinParam(DataTable dtSelectedData, string sColumn)
        {
            string sCombineText = string.Empty;

            if (dtSelectedData == null) return null;
            if (dtSelectedData.Rows.Count == 0) return null;

            foreach (DataRow drSelectedRow in dtSelectedData.Rows)
            {
                string sGetText = drSelectedRow[sColumn].ToString();
                sCombineText += ",'" + sGetText + "'";
            }
            //제일앞의 , 제거
            sCombineText = sCombineText.Remove(0, 1);
            return sCombineText;
        }

        #region A By B Qty

        /// <summary>
        /// GetQtyValueType 쿼리로 PanelQty, StripQty, PcsQty, SquareMeterQty
        /// </summary>
        /// <param name="Service"></param>
        /// <param name="LotID"></param>
        /// <returns></returns>
        public static DataTable GetQtyValueType(IMessageService Service, string LotID)
        {
            Dictionary<string, string> dicParam = new Dictionary<string, string>();
            dicParam.Add("SITEID", UIConstants.SiteId);
            dicParam.Add("LOTID", GetFullTrimString(LotID));

            Dictionary<string, object> dic = new Dictionary<string, object>();

            DataTable dtResult = FactoryService.GetQueryList(Service, "GetQtyValueType", "1", dicParam, false);

            return dtResult;
        }

        public static double PieceToStrip(string LotID, double PcsQty, IMessageService Service)
        {
            double stripQty = 0;
            try
            {
                DataTable dtResult = GetQtyValueType(Service, LotID);

                if (dtResult.Rows.Count <= 0)
                {
                    return stripQty;
                }
                double strip = CommonUtil.GetDouble(dtResult.Rows[0]["UPNR"], 0);

                stripQty = Math.Round((PcsQty / strip), 2);
            }
            catch { }
            return stripQty;
        }

        public static double PieceToStrip(DataTable lotData, double PcsQty)
        {
            double stripQty = 0;
            double strip = CommonUtil.GetDouble(lotData.Rows[0]["UPNR"], 0);

            if (strip == 0)
            {
                return stripQty;
            }

            stripQty = Math.Round((PcsQty / strip), 2);

            return stripQty;
        }

        public static double StripToPiece(string LotID, double StripQty, IMessageService Service)
        {
            double pieceQty = 0;
            try
            {
                Dictionary<string, string> dicParam = new Dictionary<string, string>();
                dicParam.Add("SITEID", UIConstants.SiteId);
                dicParam.Add("LOTID", GetFullTrimString(LotID));

                Dictionary<string, object> dic = new Dictionary<string, object>();

                DataTable dtResult = FactoryService.GetQueryList(Service, "GetQtyValueType", "1", dicParam, false);

                if (dtResult.Rows.Count <= 0)
                {
                    return pieceQty;
                }
                double strip = CommonUtil.GetDouble(dtResult.Rows[0]["UPNR"], 0);

                pieceQty = Math.Round((StripQty * strip), 2);
                return pieceQty;
            }
            catch
            {
                return pieceQty;
            }

        }

        public static double StripToPiece(DataTable lotData, double StripQty)
        {
            double pieceQty = 0;
            double strip = CommonUtil.GetDouble(lotData.Rows[0]["UPNR"], 0);

            if (strip == 0)
            {
                return pieceQty;
            }

            pieceQty = Math.Round((StripQty * strip), 2);

            return pieceQty;
        }

        public static double StripToPiece(double stripQty, double stripUnitQty)
        {
            return stripQty * stripUnitQty;
        }

        public static double PieceToPannel(string LotID, double PcsQty, IMessageService Service)
        {
            double pannelQty = 0;
            try
            {
                DataTable dtResult = GetQtyValueType(Service, LotID);

                if (dtResult.Rows.Count <= 0)
                {
                    return pannelQty;
                }
                double panel = CommonUtil.GetDouble(dtResult.Rows[0]["PCPPANEL"], 0);

                pannelQty = Math.Round((PcsQty / panel), 2);
            }
            catch { }
            return pannelQty;
        }

        public static double PieceToPannel(DataTable lotData, double PcsQty)
        {
            double pannelQty = 0;
            double panel = CommonUtil.GetDouble(lotData.Rows[0]["PCPPANEL"], 0);

            if (panel == 0)
            {
                return pannelQty;
            }

            pannelQty = Math.Round((PcsQty / panel), 2);
            return pannelQty;
        }

        public static double PieceToSquaremeter(string LotID, double PcsQty, IMessageService Service)
        {
            double squareMeter = 0;
            try
            {
                DataTable dtResult = GetQtyValueType(Service, LotID);

                if (dtResult.Rows.Count <= 0)
                {
                    return squareMeter;
                }
                double sqareMeter = CommonUtil.GetDouble(dtResult.Rows[0]["ARM2NR"], 0);

                squareMeter = Math.Round((PcsQty / Math.Round(sqareMeter, 2)), 3);
            }
            catch { }

            return squareMeter;
        }

        public static double PieceToSquaremeter(double pcsQty, double sqmtUnitQty)
        {
            return Math.Round((pcsQty / Math.Round(sqmtUnitQty, 2)), 3);
        }

        public static double PieceToSquaremeter(DataTable lotData, double PcsQty)
        {
            double squareMeter = 0;
            double squareMeterQty = CommonUtil.GetDouble(lotData.Rows[0]["ARM2NR"], 0);

            if (squareMeterQty == 0)
            {
                return squareMeter;
            }
            squareMeter = Math.Round((PcsQty / Math.Round(squareMeterQty, 2)), 3);

            return squareMeter;
        }

        public static double PannelToPiece(string LotID, double PnlQty, IMessageService Service)
        {
            double pieceQty = 0;
            try
            {
                DataTable dtResult = GetQtyValueType(Service, LotID);

                if (dtResult.Rows.Count <= 0)
                {
                    return pieceQty;
                }
                double panel = CommonUtil.GetDouble(dtResult.Rows[0]["PCPPANEL"], 0);

                pieceQty = Math.Round((PnlQty * panel), 2);
                return pieceQty;
            }
            catch
            {
                return pieceQty;
            }

        }

        public static double PannelToPiece(DataTable lotData, double PnlQty)
        {
            double pieceQty = 0;
            double panel = CommonUtil.GetDouble(lotData.Rows[0]["PCPPANEL"], 0);
            if (panel == 0)
            {
                return pieceQty;
            }
            pieceQty = PnlQty * panel;

            return pieceQty;
        }

        public static double PannelToPiece(double panelQty, double panelUnitQty)
        {
           return panelQty * panelUnitQty;
        }
        
        public static double pannelToStrip(string LotID, double PnlQty, IMessageService Service)
        {
            double stripQty = 0;
            try
            {
                DataTable dtResult = GetQtyValueType(Service, LotID);

                if (dtResult.Rows.Count <= 0)
                {
                    return stripQty;
                }
                double strip = CommonUtil.GetDouble(dtResult.Rows[0]["UPNR"], 0);
                double panel = CommonUtil.GetDouble(dtResult.Rows[0]["PCPPANEL"], 0);

                stripQty = Math.Round(((PnlQty * panel) / strip), 2);
            }
            catch { }
            return stripQty;
        }

        public static double pannelToStrip(double panelQty, double panelUnitQty, double stripUnitQty)
        {
            return Math.Round(((panelQty * panelUnitQty) / stripUnitQty), 2);
        }

        public static double pannelToStrip(DataTable lotData, double PnlQty)
        {
            double stripQty = 0;

            double strip = CommonUtil.GetDouble(lotData.Rows[0]["UPNR"], 0);
            double panel = CommonUtil.GetDouble(lotData.Rows[0]["PCPPANEL"], 0);

            if (strip == 0 || panel == 0)
            {
                return stripQty;
            }
            stripQty = Math.Round(((PnlQty * panel) / strip), 2);

            return stripQty;
        }

        #endregion

        #region # CTextEdit KeyPress Events with only numeric & alphabetic
        public static void KeyPressIsLetterOrDigit(KeyPressEventArgs e)
        {
            if (char.IsLetterOrDigit(e.KeyChar) || char.IsControl(e.KeyChar)) e.Handled = false;
            else e.Handled = true;


        }
        #endregion

        /// <summary>
        /// CIM_STATE 정보 조회
        /// </summary>
        /// <returns></returns>
        public static DataTable GetStateCode(IMessageService Service)
        {
            DataTable dt = new DataTable();
            Dictionary<string, string> bindSet = new Dictionary<string, string>();

            bindSet.Add(CIM_MULTILANGUAGE.LANGUAGE, UIConstants.Language);
            bindSet.Add(CIM_STATE.SITEID, UIConstants.SiteId);
            bindSet.Add(CIM_STATE.STATEMODELID, CustomFields.EQUIPMENTSTATE);

            dt = FactoryService.GetQueryList(Service, "GetStateData", "1", bindSet, false);

            if (dt == null)
                return null;
            else
                return dt;

        }

        public static DataTable GetCimCodeList(IMessageService Service, string siteid, string CodeClassid)
        {
            DataTable dt = new DataTable();
            Dictionary<string, string> bindSet = new Dictionary<string, string>();

            bindSet.Add(CIM_MULTILANGUAGE.LANGUAGE, UIConstants.Language);
            bindSet.Add(CIM_CODE.SITEID, siteid);
            bindSet.Add(CIM_CODE.CODECLASSID, CodeClassid);

            dt = FactoryService.GetQueryList(Service, "GetCodeList", "8", bindSet, false);

            if (dt == null)
                return null;
            else
                return dt;

        }

        public static void GetPieceQtyPerStripPanel(IMessageService messageService ,string lotid, string siteId, out int pieceQtyPerStrip, out int pieceQtyPerPanel)
        {
            try
            {
                pieceQtyPerStrip = 0;
                pieceQtyPerPanel = 0;

                Dictionary<string, string> param = new System.Collections.Generic.Dictionary<string, string>();
                param.Add(CIM_LOT.LOTID, lotid);
                param.Add(CIM_LOT.SITEID, siteId);

                DataTable dtResult = FactoryService.GetQueryList(messageService, "GetQtyValueType", "1", param);

                if (dtResult != null && dtResult.Rows.Count > 0)
                {
                    pieceQtyPerStrip = CommonUtil.GetInteger(dtResult.Rows[0]["UPNR"], 0);
                    pieceQtyPerPanel = CommonUtil.GetInteger(dtResult.Rows[0]["PCPPANEL"], 0);
                }
            }
            catch (Exception ex)
            {
                MesMessageBox.ShowDialog(ex);
                pieceQtyPerStrip = 0;
                pieceQtyPerPanel = 0;
            }
        }

        public enum QTYType
        {
            PIECE,
            STRIP,
            PANEL
        }

        public static void SetFlagComboControl(ref CLookUpCombo cboAoiInpectResult, string columnCaption, string[] flags)
        {
            try
            {
                //cboIsFixedDefect Value set
                DataTable dt = new DataTable();
                dt.Columns.Add(columnCaption);

                for (int i = 0; i < flags.Length; i++)
                {
                    DataRow dr = dt.NewRow();
                    dr[columnCaption] = flags[i].ToString();
                    dt.Rows.Add(dr);
                }

                cboAoiInpectResult.Properties.DisplayMember = columnCaption;
                cboAoiInpectResult.Bind(dt);
            }
            catch (Exception ex)
            {
                MesMessageBox.ShowDialog(ex.ToString(), UIMessageType.Error);
            }
        }

        public static void SetLookUpComboControl(ref CLookUpCombo cboControl, string columnCaption, string valueName, DataTable dt)
        {
            try
            {
                cboControl.Properties.DisplayMember = columnCaption;
                cboControl.Properties.ValueMember = valueName;
                cboControl.Bind(dt);
            }
            catch (Exception ex)
            {
                MesMessageBox.ShowDialog(ex);
            }
        }

        public static bool ValidateIsCut(IMessageService service, string lotId, string siteId)
        {
            try
            {
                Dictionary<string, string> bindSet = new Dictionary<string, string>();

                bindSet.Add(CIM_LOT.SITEID, siteId);
                bindSet.Add(CIM_LOT.LOTID, lotId);

                DataTable dt = FactoryService.GetQueryList(service, "ValidateIsCut", "1", bindSet, false);

                if (dt != null && dt.Rows.Count > 0)
                {
                    if (CommonUtil.GetString(dt.Rows[0]["ISCUT"]).Equals("Y"))
                        return true;
                }
            }
            catch (Exception ex)
            {
                MesMessageBox.ShowDialog(ex.ToString(), UIMessageType.Error);
            }

            return false;
        }

        #region 일반 파일을 Byte[]로 변환
        /// <summary>
        /// 일반 파일을 Byte[]로 변환하는 함수.
        /// </summary>
        /// <param name="fileName">A File name includes full path.</param>
        /// <returns></returns>
        public byte[] FileToByteArray(string fileName)
        {
            return File.ReadAllBytes(fileName);
        }
        #endregion

        public static int Devide(int molecule, int denominator)
        {
            int retInt = 0;
            try
            {
                retInt = molecule / denominator;
            }
            catch (Exception)
            {
                return 0;
            }

            return retInt;
        }

        public static double Devide(double molecule, double denominator)
        {
            double retInt = 0;
            try
            {
                retInt = molecule / denominator;
            }
            catch (Exception)
            {
                return 0;
            }

            return retInt;
        }
        /// <summary>
        /// 10005(삼성전자(주))의 경우 은광(500431) 업체만 DC_LABELFILEREL 의 고객코드를 그대로 사용
        /// 다른 포장업체는 30075(삼성전자㈜-VD(사) TV [P105])의 고객코드를 활용하여 10005 라벨 양식으로 사용한다.
        /// </summary>
        /// <param name="customerId"></param>
        /// <param name="companyId"></param>
        /// <returns></returns>
        public static string getLabelCustomer(string customerId)
        {
            string ret = customerId;
            if ("10005".Equals(customerId))
            {
                if (!UIConstants.CompanyId.Equals("500431"))
                {
                    ret = "30075";
                }
            }

            return ret;
        }


        public static DateTime GetSystemTime(IMessageService iMessageService)
        {
            try
            {
                DataTable dt = FactoryService.GetQueryList(iMessageService, "GetCurrentDateTime", "00001");
                return Convert.ToDateTime(dt.Rows[0][0].ToString());
            }
            catch (Exception)
            {
                return DateTime.Now;
            }
            
        }
    }
}

                        
;

public by yoonlee  2490  1  7  0

[string] Validation (null, WhiteSpace)

문자열 Null, " ", 체크 - string.empty로 리턴
public static string GetString(object obj)
        {
            if (obj == null)
                return String.Empty;

            return String.IsNullOrWhiteSpace(obj.ToString()) ? String.Empty : obj.ToString();
        }                        
;

public by yoonlee  3845  3  6  0

[UserControl][GDS] CGridControl

커스텀 그리드컨트롤 ver.GDS
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using CIM.UI.CustomControl.Constants;
using CIM.UI.Infrastructure.Interface.Constants;
using CIM.UI.LabelManagement;
using CIM.UI.MessageConverter.Services;
using DevExpress.Data;
using DevExpress.Utils;
using DevExpress.Utils.Menu;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using DevExpress.XtraEditors;


namespace CIM.UI.CustomControl.Control
{
    [ToolboxItem(true)]
    public partial class CGridControl : UserControl
    {
        #region Variable

        private string defaultDateFormat = "yyyy-MM-dd HH:mm:ss";
        private string defaultNumericFormat = "n0";
        private bool isEnterKeyEvent = true;

        private string ClipboardData
        {
            get
            {
                IDataObject iData = Clipboard.GetDataObject();
                if (iData == null) return "";

                if (iData.GetDataPresent(DataFormats.Text))
                    return (string)iData.GetData(DataFormats.Text);
                return "";
            }
            set { Clipboard.SetDataObject(value); }
        }

        private Dictionary<string, string> allChecked = new Dictionary<string, string>();

        private FocusedRowChangedEventHandler focusedRowChanged;
        private RowCellAlignmentEventHandler rowCellDefaultAlignment;
        private CustomColumnDataEventHandler customColumnData;
        private GridCheckMarksSelection selection = null;
        private ColumnHeaderCustomDrawEventHandler columnHeaderCustomDraw;
        private CellValueChangedEventHandler cellValueChanged;
        private RowCellStyleEventHandler rowCellStyle;
        private RowClickEventHandler rowClick;
        private EventHandler rowCellDoubleClick;
        private CellMergeEventHandler cellMerge;
        private GridRowStateHelper rowStateHelper = null;
        private RowStyleEventHandler rowStyle = null;
        private CustomColumnDisplayTextEventHandler customColumnDisplayText;
        private RowFilterEventArgs customRowFilter;
        private PopupMenuShowingEventHandler popupMenuShowing;
        private RowCellCustomDrawEventHandler customDrawCell;

        public GridHitInfo GridHitInfo = null;

        public delegate void dgGridButtonClicked(object sender, int row, ButtonPressedEventArgs e);
        public event dgGridButtonClicked GridButtonClicked;

        //사용자 정의 메뉴 추가 구성용
        public Collection<DXMenuItem> CustomMenuItems;

        public delegate void AllRowCheckedEventHandler(object sender, string checkedState);
        public event AllRowCheckedEventHandler AllRowCheckedChangeEvent;

        public delegate void grdShowingEditor(object sender, CancelEventArgs e);
        public event grdShowingEditor ShowingEditor;

        public event EventHandler CheckedChanged;

        public delegate void grdGotFocus(object sender, EventArgs e);
        public event grdGotFocus GotFocus1;

        public delegate void grdRowCellClick(object sender, RowCellClickEventArgs e);

        public event grdRowCellClick RowCellClick;

        //public delegate void ValidateRowEventHandler(object sender, ValidateRowEventArgs e);
        private ValidateRowEventHandler validateRow;

        private CustomSummaryEventHandler customSummaryCalculate;

        public List<MergedColumnInfo> MergedColumnInfos;
        public bool AllCheckUserble = true;

        #region Getter/Setter
        public bool IsBlockDelete { get; set; }
        #endregion

        #endregion Variable

        #region Constructor

        public CGridControl()
        {
            MergedColumnInfos = new List<MergedColumnInfo>();

            InitializeComponent();
            InitializeGrid();
            this.DoubleBuffered = true;
        }

        #endregion Constructor

        #region Event

        #region Clipboad Data Copy Code
        private void gridControl1_ProcessGridKey(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.Control && e.KeyCode == Keys.V)
                {
                    string[] data = ClipboardData.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    if (data.Length < 1) return;
                    int startRow = gridView1.FocusedRowHandle;
                    foreach (string row in data)
                    {
                        AddRow(row, startRow++);
                        if (!gridView1.IsValidRowHandle(startRow)) break;
                    }
                    e.SuppressKeyPress = true;
                    e.Handled = true;
                }
            }
            catch { }
        }

        private void AddRow(string data, int rowHandle)
        {
            if (data == string.Empty) return;
            string[] rowData = data.Split('\t');
            int column = gridView1.FocusedColumn.VisibleIndex;
            for (int i = 0; i < rowData.Length; i++)
            {
                if (i >= gridView1.VisibleColumns.Count) break;
                gridView1.SetRowCellValue(rowHandle, gridView1.VisibleColumns[column + i], rowData[i]);
            }
        }
        #endregion

        /// <summary>
        /// GridView popup menu showing
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e)
        {
            if (e.Menu == null) return;

            DXMenuItem dXMenuItem = new DevExpress.Utils.Menu.DXMenuItem(NLSService.GetNLSValue(NLSType.Grid, "EXPORT_EXCEL"), new EventHandler(this.exportExcelMenu_Click));
            e.Menu.Items.Add(dXMenuItem);

            dXMenuItem = new DevExpress.Utils.Menu.DXMenuItem(NLSService.GetNLSValue(NLSType.Grid, "COPY_CELL"), new EventHandler(this.copyCellMenu_Click));
            dXMenuItem.BeginGroup = true;
            e.Menu.Items.Add(dXMenuItem);

            dXMenuItem = new DevExpress.Utils.Menu.DXMenuItem(NLSService.GetNLSValue(NLSType.Grid, "COPY_ROW"), new EventHandler(this.copyRowMenu_Click));
            e.Menu.Items.Add(dXMenuItem);

            dXMenuItem = new DevExpress.Utils.Menu.DXMenuItem(NLSService.GetNLSValue(NLSType.Grid, "GRIDCLEAR"), new EventHandler(this.clearGridData_Click));
            e.Menu.Items.Add(dXMenuItem);

            if (gridView1.Columns.ColumnByFieldName(CustomFields.CHK) != null || gridView1.Columns.ColumnByFieldName(CustomFields.CHK) != null)
            {
                dXMenuItem = new DevExpress.Utils.Menu.DXMenuItem(NLSService.GetNLSValue(NLSType.Grid, "CHECK_SELECTED_ROW"), new EventHandler(this.RowCheckMenu_Click));
                dXMenuItem.BeginGroup = true;
                e.Menu.Items.Add(dXMenuItem);

                dXMenuItem = new DevExpress.Utils.Menu.DXMenuItem(NLSService.GetNLSValue(NLSType.Grid, "UNCHECK_SELECTED_ROW"), new EventHandler(this.RowUnCheckMenu_Click));
                e.Menu.Items.Add(dXMenuItem);
            }

            if (CustomMenuItems != null)
            {
                int iCnt = 0;

                foreach (DXMenuItem menuItem in CustomMenuItems)
                {
                    if (iCnt == 0) menuItem.BeginGroup = true;
                    e.Menu.Items.Add(menuItem);
                    iCnt++;
                }
            }
        }

        /// <summary>
        /// Export excel menu click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void exportExcelMenu_Click(object sender, EventArgs e)
        {
            ExportExcel();
        }

        /// <summary>
        /// Copy cell menu click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void copyCellMenu_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(gridView1.FocusedValue.ToString())) return;

                Clipboard.SetText(gridView1.FocusedValue.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

        /// <summary>
        /// GridClear
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void clearGridData_Click(object sender, EventArgs e)
        {
            try
            {
                Clear();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        /// <summary>
        /// Copy row menu click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void copyRowMenu_Click(object sender, EventArgs e)
        {
            int rowIndex = gridView1.FocusedRowHandle;
            string text = string.Empty;

            for (int i = 0; i < gridView1.Columns.Count; i++)
            {
                text += gridView1.GetRowCellDisplayText(rowIndex, gridView1.Columns[i]) + "\t";
            }

            text = text.TrimEnd(' ');
            Clipboard.SetText(text);
        }

        /// <summary>
        /// Row check menu click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RowCheckMenu_Click(object sender, EventArgs e)
        {
            int[] selectRowIndexArray = gridView1.GetSelectedRows();

            foreach (int index in selectRowIndexArray)
            {
                if (gridView1.Columns.ColumnByFieldName(CustomFields.CHK) != null)
                {
                    gridView1.SetRowCellValue(index, CustomFields.CHK, CheckBoxValue.ONE);
                }
                else
                {
                    gridView1.SetRowCellValue(index, CustomFields.CHK, CheckBoxValue.ONE);
                }
            }
        }

        /// <summary>
        /// Row uncheck menu click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RowUnCheckMenu_Click(object sender, EventArgs e)
        {
            int[] selectRowIndexArray = gridView1.GetSelectedRows();

            foreach (int index in selectRowIndexArray)
            {
                if (gridView1.Columns.ColumnByFieldName(CustomFields.CHK) != null)
                {
                    gridView1.SetRowCellValue(index, CustomFields.CHK, CheckBoxValue.ZERO);
                }
                else
                {
                    gridView1.SetRowCellValue(index, CustomFields.CHK, CheckBoxValue.ZERO);
                }
            }
        }

        /// <summary>
        /// Label print click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LabelPrint_Click(object sender, EventArgs e)
        {
            try
            {
                PrintBarcode();
            }
            catch (Exception)
            {
                return;
            }
        }

        /// <summary>
        /// GridView click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_Click(object sender, EventArgs e)
        {
            try
            {
                if (AllCheckUserble)
                {
                    Point point = MousePosition;
                    GridView gridView = (GridView)sender;
                    GridHitInfo gridHitInfo = gridView.CalcHitInfo(gridView.GridControl.PointToClient(point));
                    GridHitInfo = gridHitInfo;
                    if (gridHitInfo.InColumnPanel)
                    {
                        if ((gridView.Columns[gridHitInfo.Column.FieldName].ColumnEdit != null) && (gridView.Columns[gridHitInfo.Column.FieldName].ColumnEdit.EditorTypeName == "CheckEdit"))
                        {
                            try
                            {
                                RepositoryItemCheckEdit repositoryItemCheckEdit = ((RepositoryItemCheckEdit)(gridView.Columns[gridHitInfo.Column.FieldName].ColumnEdit));
                                setCheckAllRows(gridHitInfo.Column.FieldName, repositoryItemCheckEdit.DisplayValueChecked, repositoryItemCheckEdit.DisplayValueUnchecked, e);
                            }
                            catch
                            {
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }

        /// <summary>
        /// GridView cell merge
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_CellMerge(object sender, CellMergeEventArgs e)
        {
            if (this.cellMerge != null) this.cellMerge(sender, e);
        }

        /// <summary>
        /// GridView row style
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_RowStyle(object sender, RowStyleEventArgs e)
        {
            if (this.rowStyle != null) this.rowStyle(sender, e);
        }

        /// <summary>
        /// GridView Custom column display text
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_CustomColumnDisplayText(object sender, CustomColumnDisplayTextEventArgs e)
        {
            if (this.customColumnDisplayText != null) this.customColumnDisplayText(sender, e);
        }

        /// <summary>
        /// GridView custom draw column header
        /// 2014-08-13 김정민 추가 - setMergedColumnInfo에서 사용함. 중첩 헤더 추가
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_CustomDrawColumnHeader(object sender, DevExpress.XtraGrid.Views.Grid.ColumnHeaderCustomDrawEventArgs e)
        {
            try
            {
                if (e.Column != null)
                {
                    for (int i = 0; i < MergedColumnInfos.Count; i++)
                    {
                        e.DefaultDraw();

                        int lastStrMergedColumnIndex = MergedColumnInfos[i].strbeMergedColumns.Length;
                        if ((e.Column.FieldName) == (MergedColumnInfos[i].strbeMergedColumns[lastStrMergedColumnIndex -1].ToString()))
                        {
                            //최 좌측 시작점 (픽스트 컬럼 끝점) 구하기
                            int endPointOfFixedColumns = this.Location.X + 19; //rowheadersize : 19
                            int startBandLocationX = 19;
                            string viewtext = NLSService.GetNLSValue(NLSType.Grid, MergedColumnInfos[i].MergedHeaderColumnText);

                            foreach (DevExpress.XtraGrid.Columns.GridColumn gridcolumn in gridView1.Columns)
                            {
                                if (gridcolumn.Fixed == FixedStyle.Left)
                                {
                                    endPointOfFixedColumns = endPointOfFixedColumns + gridcolumn.VisibleWidth;
                                }
                            }

                            //사이즈 : width
                            int sizeX = 0; //merge된 visiblecolumn들의 width 합계 (fixed col에 가려진 컬럼 제외)
                            int fullsizeX = 0; //merge된 column들의 width 합계 (fixed col에 가려진 컬럼 포함)
                            for (int j = 0; j < MergedColumnInfos[i].strbeMergedColumns.Length; j++)
                            {
                                sizeX = sizeX + gridView1.Columns[MergedColumnInfos[i].strbeMergedColumns[j]].VisibleWidth;
                                fullsizeX = fullsizeX + gridView1.Columns[MergedColumnInfos[i].strbeMergedColumns[j]].Width;
                            }

                            Rectangle r;
                            if (e.Bounds.Location.X - sizeX + e.Bounds.Width > endPointOfFixedColumns)
                            {
                                startBandLocationX = e.Bounds.Location.X - sizeX + e.Bounds.Width;
                            }
                            else
                            {
                                startBandLocationX = endPointOfFixedColumns;
                            }

                            //사각형 그리기
                            r = new Rectangle(startBandLocationX
                                , e.Bounds.Location.Y
                                , sizeX
                                , e.Bounds.Height / 2);
                            DevExpress.XtraGrid.Skins.GridSkinElementsPainter Painter = new DevExpress.XtraGrid.Skins.GridSkinElementsPainter(this.gridView1);
                            DevExpress.Utils.Drawing.HeaderObjectInfoArgs Args = new DevExpress.Utils.Drawing.HeaderObjectInfoArgs();
                            Args.Assign(new DevExpress.Utils.Drawing.ObjectInfoArgs(e.Cache, r, DevExpress.Utils.Drawing.ObjectState.Normal));
                            Args.Graphics = e.Graphics;
                            Painter.Column.DrawObject(Args);

                            //텍스트 그리기
                            AppearanceObject ao = new AppearanceObject(e.Appearance);
                            ao.TextOptions.VAlignment = VertAlignment.Center;
                            ao.TextOptions.HAlignment = HorzAlignment.Center;

                            //표시될 글자의 pixel 길이
                            int stringWidth = Convert.ToInt32(e.Graphics.MeasureString(MergedColumnInfos[i].MergedHeaderColumnText, e.Appearance.Font).Width) * 2;

                            //글자가 들어갈 사각형 맨 오른쪽 점부터~ mergedcolumn의 끝까지의 길이
                            int backposition = (e.Bounds.Location.X + e.Bounds.Width) - ((fullsizeX - stringWidth) / 2);
                            Rectangle textRec;

                            //글자가 새겨질 사각형의 시작 위치가 fixed column의 오른쪽 끝보다 왼쪽에 있다면
                            if (backposition - stringWidth < endPointOfFixedColumns)
                            {
                                while (backposition - stringWidth < endPointOfFixedColumns)
                                {
                                    //한글자씩 삭제함
                                    if (viewtext.Length == 1)
                                    {
                                        viewtext = "";
                                        stringWidth = 0;
                                        break;
                                    }
                                    else
                                    {
                                        viewtext = viewtext.Substring(1);
                                        stringWidth = Convert.ToInt16(e.Graphics.MeasureString(viewtext, e.Appearance.Font).Width);
                                    }
                                }
                                textRec = new Rectangle(endPointOfFixedColumns, r.Location.Y, stringWidth, r.Height);
                            }
                            else
                            {
                                textRec = new Rectangle(backposition - stringWidth, r.Location.Y, stringWidth, r.Height);
                            }

                            ao.DrawString(e.Cache, viewtext, textRec);
                            e.Appearance.TextOptions.VAlignment = VertAlignment.Bottom;
                            e.Appearance.TextOptions.HAlignment = HorzAlignment.Center;

                            //e.Appearance.DrawString(e.Cache, MergedColumnInfos[i].MergedHeaderColumnText, r);
                            e.Handled = true;
                        }
                    }

                }
            }
            catch
            {
            }
            if (this.columnHeaderCustomDraw != null) this.columnHeaderCustomDraw(sender, e);
        }

        /// <summary>
        /// GridView custom row filter
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_CustomRowFilter(object sender, RowFilterEventArgs e)
        {
            if (this.customRowFilter != null) this.gridView1_CustomRowFilter(sender, e);
        }

        /// <summary>
        /// GridView showing editor
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void gridView1_ShowingEditor(object sender, CancelEventArgs e)
        {
            if (ShowingEditor == null) return;
            ShowingEditor(sender, e);
        }

        /// <summary>
        /// GridView got focus
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void gridView1_GotFocus(object sender, EventArgs e)
        {
            if (GotFocus1 == null) return;
            GotFocus1(sender, e);
        }

        /// <summary>
        /// GridView row cell click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_RowCellClick(object sender, RowCellClickEventArgs e)
        {
            try
            {
                // 3번 클릭해야 CheckBox가 체크되는 것 수정 (from 내부인수 대기 View)
                GridView view = sender as GridView;
                if (e.Button == System.Windows.Forms.MouseButtons.Left)
                {
                    DataRow dr = view.GetFocusedDataRow();

                    if (dr != null)
                    {
                        // 포커스 된 로우가 존재하지 않는 경우(조회 후 컬럼헤더의 간격을 바로 조정하는 상태)에 발생하는 문제 처리하기 위한 로직
                        if (view.FocusedColumn == null) return;

                        // 선택한 칼럼이 "CHK"인 조건 추가
                        string focusedFieldName = view.FocusedColumn.FieldName;
                        if (focusedFieldName == CustomFields.CHK)
                        {
                            if (dr[CustomFields.CHK].ToString() == CheckBoxValue.ZERO)
                            {
                                view.SetRowCellValue(view.FocusedRowHandle, CustomFields.CHK, CheckBoxValue.ONE);

                                // 체크 박스 클릭시 체크박스 이벤트 수행 하지 않고 그리드 클릭 이벤트로 값만 변경 하기 때문에 체크 체인지 이벤트 미수행으로 인하여 추가 
                                if (this.CheckedChanged != null)
                                {
                                    CheckEdit chkedit = new CheckEdit();
                                    chkedit.Checked = true;
                                    this.CheckedChanged(chkedit, e);
                                }
                            }
                            else
                            {
                                view.SetRowCellValue(view.FocusedRowHandle, CustomFields.CHK, CheckBoxValue.ZERO);

                                if (this.CheckedChanged != null)
                                {
                                    CheckEdit chkedit = new CheckEdit();
                                    chkedit.Checked = false;
                                    this.CheckedChanged(chkedit, e);
                                }
                            }
                        }
                        else if (focusedFieldName == CustomFields.CHK1)
                        {
                            if (dr[CustomFields.CHK1].ToString() == CheckBoxValue.ZERO)
                            {
                                view.SetRowCellValue(view.FocusedRowHandle, CustomFields.CHK1, CheckBoxValue.ONE);

                                // 체크 박스 클릭시 체크박스 이벤트 수행 하지 않고 그리드 클릭 이벤트로 값만 변경 하기 때문에 체크 체인지 이벤트 미수행으로 인하여 추가 
                                if (this.CheckedChanged != null)
                                {
                                    CheckEdit chkedit = new CheckEdit();
                                    chkedit.Checked = true;
                                    this.CheckedChanged(chkedit, e);
                                }
                            }
                            else
                            {
                                view.SetRowCellValue(view.FocusedRowHandle, CustomFields.CHK1, CheckBoxValue.ZERO);

                                if (this.CheckedChanged != null)
                                {
                                    CheckEdit chkedit = new CheckEdit();
                                    chkedit.Checked = false;
                                    this.CheckedChanged(chkedit, e);
                                }
                            }
                        }
                        else if (focusedFieldName == CustomFields.ISSTARTNODE)
                        {
                            if (dr[CustomFields.ISSTARTNODE].ToString() == CheckBoxValue.ZERO)
                            {
                                view.SetRowCellValue(view.FocusedRowHandle, CustomFields.ISSTARTNODE, CheckBoxValue.ONE);

                                // 체크 박스 클릭시 체크박스 이벤트 수행 하지 않고 그리드 클릭 이벤트로 값만 변경 하기 때문에 체크 체인지 이벤트 미수행으로 인하여 추가 
                                if (this.CheckedChanged != null)
                                {
                                    CheckEdit chkedit = new CheckEdit();
                                    chkedit.Checked = true;
                                    this.CheckedChanged(chkedit, e);
                                }
                            }
                            else
                            {
                                view.SetRowCellValue(view.FocusedRowHandle, CustomFields.ISSTARTNODE, CheckBoxValue.ZERO);

                                if (this.CheckedChanged != null)
                                {
                                    CheckEdit chkedit = new CheckEdit();
                                    chkedit.Checked = false;
                                    this.CheckedChanged(chkedit, e);
                                }
                            }
                        }
                        else if (focusedFieldName == CustomFields.ISENDNODE)
                        {
                            if (dr[CustomFields.ISENDNODE].ToString() == CheckBoxValue.ZERO)
                            {
                                view.SetRowCellValue(view.FocusedRowHandle, CustomFields.ISENDNODE, CheckBoxValue.ONE);

                                // 체크 박스 클릭시 체크박스 이벤트 수행 하지 않고 그리드 클릭 이벤트로 값만 변경 하기 때문에 체크 체인지 이벤트 미수행으로 인하여 추가 
                                if (this.CheckedChanged != null)
                                {
                                    CheckEdit chkedit = new CheckEdit();
                                    chkedit.Checked = true;
                                    this.CheckedChanged(chkedit, e);
                                }
                            }
                            else
                            {
                                view.SetRowCellValue(view.FocusedRowHandle, CustomFields.ISENDNODE, CheckBoxValue.ZERO);

                                if (this.CheckedChanged != null)
                                {
                                    CheckEdit chkedit = new CheckEdit();
                                    chkedit.Checked = false;
                                    this.CheckedChanged(chkedit, e);
                                }
                            }
                        }
                        else if (focusedFieldName == CustomFields.CONFIRM)
                        {
                            if (dr[CustomFields.CONFIRM].ToString() == CheckBoxValue.ZERO)
                            {
                                view.SetRowCellValue(view.FocusedRowHandle, CustomFields.CONFIRM, CheckBoxValue.ONE);

                                // 체크 박스 클릭시 체크박스 이벤트 수행 하지 않고 그리드 클릭 이벤트로 값만 변경 하기 때문에 체크 체인지 이벤트 미수행으로 인하여 추가 
                                if (this.CheckedChanged != null)
                                {
                                    CheckEdit chkedit = new CheckEdit();
                                    chkedit.Checked = true;
                                    this.CheckedChanged(chkedit, e);
                                }
                            }
                            else
                            {
                                view.SetRowCellValue(view.FocusedRowHandle, CustomFields.CONFIRM, CheckBoxValue.ZERO);

                                if (this.CheckedChanged != null)
                                {
                                    CheckEdit chkedit = new CheckEdit();
                                    chkedit.Checked = false;
                                    this.CheckedChanged(chkedit, e);
                                }
                            }
                        }
                    }
                }

                if (RowCellClick == null) return;
                RowCellClick(sender, e);
            }
            catch (Exception ex)
            {
                MesMessageBox.ShowDialog(ex);
            }
        }

        /// <summary>
        /// GridView row cell style
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_RowCellStyle(object sender, RowCellStyleEventArgs e)
        {
            if (this.rowCellStyle != null) this.rowCellStyle(sender, e);
        }

        /// <summary>
        /// GridView Custom Draw Cell
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e)
        {
            if (this.customDrawCell != null) this.customDrawCell(sender, e);
        }

        /// <summary>
        /// GridView rowcell default alignment
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_RowCellDefaultAlignment(object sender, RowCellAlignmentEventArgs e)
        {
            if (this.rowCellDefaultAlignment != null) this.rowCellDefaultAlignment(sender, e);
        }

        /// <summary>
        /// GridView focused row changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            if (this.focusedRowChanged != null) this.focusedRowChanged(sender, e);
        }

        /// <summary>
        /// GridView custom unbound column data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e)
        {
            if (this.customColumnData != null) this.customColumnData(sender, e);
        }

        /// <summary>
        /// GridView cell value changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_CellValueChanged(object sender, CellValueChangedEventArgs e)
        {
            if (this.cellValueChanged != null) this.cellValueChanged(sender, e);
        }

        /// <summary>
        /// GridView row click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_RowClick(object sender, RowClickEventArgs e)
        {
            if (this.rowClick != null) this.rowClick(sender, e);
        }

        /// <summary>
        /// GridView double click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_DoubleClick(object sender, EventArgs e)
        {
            Point point = MousePosition;

            GridView gridView = (GridView)sender;
            GridView view = (GridView)sender;
            GridHitInfo hitInfo = view.CalcHitInfo(view.GridControl.PointToClient(point));

            if (!hitInfo.InRow || gridView.IsGroupRow(hitInfo.RowHandle)) return;

            if (this.rowCellDoubleClick != null) this.rowCellDoubleClick(sender, e);
        }

        /// <summary>
        /// GridView key down
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete && IsBlockDelete)
            {
                try
                {
                    GridCell[] cellList = gridView1.GetSelectedCells();

                    if (cellList != null && cellList.Length > 0)
                    {
                        gridView1.BeginDataUpdate();

                        foreach (GridCell cell in cellList)
                        {
                            try
                            {
                                if (cell.Column.ColumnType == typeof(object)
                                    || cell.Column.ColumnType == typeof(string))
                                    gridView1.SetRowCellValue(cell.RowHandle, cell.Column, "");
                                else
                                    gridView1.SetRowCellValue(cell.RowHandle, cell.Column, 0);
                            }
                            catch { }
                        }

                        gridView1.EndDataUpdate();
                    }
                }
                catch { }
            }
            //else if (e.KeyCode != System.Windows.Forms.Keys.Enter) return;

            //if (isEnterKeyEvent)
            //{
            //    if (this.rowCellDoubleClick != null) this.rowCellDoubleClick(sender, e);
            //}
        }

        /// <summary>
        /// Validated Row Events (Grid Row별 입력항목 필수체크 적용을 위한 Event)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_ValidateRow(object sender, ValidateRowEventArgs e)
        {
            if (this.validateRow != null) this.validateRow(sender, e);
        }

        private void gridView1_CustomSummaryCalculate(object sender, CustomSummaryEventArgs e)
        {
            if (this.customSummaryCalculate != null) this.customSummaryCalculate(sender, e);
        }

        /// <summary>
        /// Include grid button click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            if (GridButtonClicked == null) return;
            GridButtonClicked(this, gridView1.SourceRowHandle, e);
        }

        [Category("RowCellAlignment"), Description("Enable to content alignment (Override Event)")]
        public event RowCellAlignmentEventHandler RowCellAlignment
        {
            add
            {
                this.rowCellDefaultAlignment += value;
            }
            remove
            {
                this.rowCellDefaultAlignment -= value;
            }
        }

        [Category("FocusedRowChanged"), Description("Fire when changed focused row (Override Event)")]
        public event FocusedRowChangedEventHandler FocusedRowChanged
        {
            add
            {
                this.focusedRowChanged += value;
            }
            remove
            {
                this.focusedRowChanged -= value;
            }
        }

        [Category("CustomUnboundColumnData"), Description("Fire when unbound data is binded (Override Event)")]
        public event CustomColumnDataEventHandler CustomUnboundColumnData
        {
            add
            {
                this.customColumnData += value;
            }
            remove
            {
                this.customColumnData -= value;
            }
        }

        [Category("ColumnHeaderCustomDraw"), Description("Fire when draw column header string (Override Event)")]
        public event ColumnHeaderCustomDrawEventHandler ColumnHeaderCustomDraw
        {
            add
            {
                this.columnHeaderCustomDraw += value;
            }
            remove
            {
                this.columnHeaderCustomDraw -= value;
            }
        }

        [Category("CellValueChanged"), Description("Fire when cellvalue changed (Override Event)")]
        public event CellValueChangedEventHandler CellValueChanged
        {
            add
            {
                this.cellValueChanged += value;
            }
            remove
            {
                this.cellValueChanged -= value;
            }
        }

        [Category("RowCellStyle"), Description("Fire when change rowcell style (Override Event)")]
        public event RowCellStyleEventHandler RowCellStyle
        {
            add
            {
                this.rowCellStyle += value;
            }
            remove
            {
                this.rowCellStyle -= value;
            }
        }

        [Category("CustomDrawCell"), Description("GridViewCustomDrawCell (Override Event)")]
        public event RowCellCustomDrawEventHandler CustomDrawCell
        {
            add
            {
                this.customDrawCell += value;
            }
            remove
            {
                this.customDrawCell -= value;
            }
        }

        [Category("RowClick"), Description("Fire when click a row cell (Override Event)")]
        public event RowClickEventHandler RowClick
        {
            add
            {
                this.rowClick += value;
            }
            remove
            {
                this.rowClick -= value;
            }
        }

        [Category("CellMerge"), Description("Fire cell merge (Override Event)")]
        public event CellMergeEventHandler CellMerge
        {
            add
            {
                this.cellMerge += value;
            }
            remove
            {
                this.cellMerge -= value;
            }
        }

        [Category("RowStyle"), Description("change row style (Override Event)")]
        public event RowStyleEventHandler RowStyle
        {
            add
            {
                this.rowStyle += value;
            }
            remove
            {
                this.rowStyle -= value;
            }
        }

        [Category("CustomColumnDisplayText"), Description("change display text.(Override Event)")]
        public event CustomColumnDisplayTextEventHandler CustomColumnDisplayText
        {
            add
            {
                this.customColumnDisplayText += value;
            }
            remove
            {
                this.customColumnDisplayText -= value;
            }
        }

        [Category("PopupMenuShowing"), Description("change display text.(Override Event)")]
        public event PopupMenuShowingEventHandler PopupMenuShowing
        {
            add
            {
                this.popupMenuShowing += value;
            }
            remove
            {
                this.popupMenuShowing -= value;
            }
        }

        [Category("RowCellDoubleClick"), Description("Fire when cell double click (Custom Event)")]
        public event EventHandler RowCellDoubleClick
        {
            add
            {
                this.rowCellDoubleClick += value;
            }
            remove
            {
                this.rowCellDoubleClick -= value;
            }
        }

        [Category("ValidateRow"), Description("Validate row (Override Event)")]
        public event ValidateRowEventHandler ValidateRow
        {
            add
            {
                this.validateRow += value;
            }
            remove
            {
                this.validateRow -= value;
            }
        }

        [Category("CustomSummaryCalculate"), Description("customSummaryEvent (Override Event)")]
        public event CustomSummaryEventHandler CustomSummaryCalculate
        {
            add
            {
                this.customSummaryCalculate += value;
            }
            remove
            {
                this.customSummaryCalculate -= value;
            }
        }

        #endregion Event

        #region Method

        /// <summary>
        /// Initialize grid
        /// </summary>
        public void InitializeGrid()
        {
            Guard.ArgumentNotNull(this.gridControl1, "GridControl");

            GridView gridView = (GridView)gridControl1.Views[0];
            gridView.OptionsView.EnableAppearanceEvenRow = true;
            gridView.OptionsView.ShowGroupPanel = false;
            gridView.OptionsBehavior.AllowAddRows = DefaultBoolean.False;
            gridView.OptionsBehavior.AllowDeleteRows = DefaultBoolean.False;
            gridView.OptionsBehavior.Editable = false;
            gridView.OptionsView.ColumnAutoWidth = false;
            gridControl1.TabStop = false;
            rowStateHelper = new GridRowStateHelper(gridView);

            gridView1.PopupMenuShowing += new PopupMenuShowingEventHandler(gridView1_PopupMenuShowing);

            //Added by jclee. Clipboard Data Paste to Grid
            gridView1.OptionsSelection.MultiSelect = true;
            gridView1.OptionsSelection.MultiSelectMode = GridMultiSelectMode.CellSelect;
            gridView1.OptionsBehavior.CopyToClipboardWithColumnHeaders = false;

            gridView1.KeyDown += new KeyEventHandler(gridView1_KeyDown);

            gridControl1.ProcessGridKey += new KeyEventHandler(gridControl1_ProcessGridKey);

        }

        /// <summary>
        /// Set check all rows
        /// </summary>
        /// <param name="fieldname"></param>
        /// <param name="checkedState"></param>
        /// <param name="unCheckedState"></param>
        private void setCheckAllRows(string fieldname, string checkedState, string unCheckedState, EventArgs e)
        {
            string nextCheckedstate = string.Empty;

            if (allChecked.ContainsKey(fieldname))
            {
                if (allChecked[fieldname].ToString() == checkedState)
                {
                    nextCheckedstate = unCheckedState;
                    allChecked[fieldname] = unCheckedState;
                }
                else
                {
                    nextCheckedstate = checkedState;
                    allChecked[fieldname] = checkedState;
                }
            }
            else
            {
                allChecked.Add(fieldname, checkedState);
                nextCheckedstate = checkedState;
            }

            DataTable dt = gridControl1.DataSource as DataTable;

            if (dt != null && dt.Rows.Count > 0)
            {
                for (int rowindex = 0; rowindex < dt.Rows.Count; rowindex++)
                {
                    dt.Rows[rowindex][fieldname] = nextCheckedstate;
                    //if (dt.Rows[rowindex]["EXECUTION"].ToString() != "INSERT")
                    //{
                    //    dt.Rows[rowindex]["EXECUTION"] = "UPDATE";
                    //    dt.Rows[rowindex]["EXECUTIONTIME"] = string.Format("{0:yyyyMMddHHmmssfff}", DateTime.Now);
                    //}
                }
            }

            gridView1.RefreshData();

            if (this.AllRowCheckedChangeEvent != null)
                this.AllRowCheckedChangeEvent(gridControl1, nextCheckedstate);
        }

        /// <summary>
        /// allow edit in field name array. other fields not allow edit.
        /// </summary>
        /// <param name="fieldNames"></param>
        public void AllowEdit(params string[] fieldNames)
        {
            if (gridView1.RowCount == 0) return;

            gridView1.OptionsBehavior.Editable = true;

            System.Drawing.Color forecolor = gridView1.Columns[0].AppearanceCell.ForeColor;

            for (int i = 0; i < gridView1.Columns.Count; i++)
            {
                //gridView1.Columns[i].AppearanceHeader.ForeColor = Color.Black;

                gridView1.Columns[i].OptionsColumn.AllowEdit = false;
                gridView1.Columns[i].OptionsColumn.ReadOnly = true;
                // gridView1.Columns[i].AppearanceCell.ForeColor = System.Drawing.Color.Gray;
            }

            for (int i = 0; i < fieldNames.Length; i++)
            {
                if (fieldNames[i].ToString() == "CHK" || fieldNames[i].ToString() == "CHECK")
                {
                    gridView1.Columns[fieldNames[i]].OptionsColumn.AllowEdit = true;
                    gridView1.Columns[fieldNames[i]].OptionsColumn.ReadOnly = false;
                    gridView1.Columns[fieldNames[i]].AppearanceCell.ForeColor = forecolor;
                }
                else
                {
                    gridView1.Columns[fieldNames[i]].AppearanceHeader.ForeColor = Color.Red;

                    gridView1.Columns[fieldNames[i]].OptionsColumn.AllowEdit = true;
                    gridView1.Columns[fieldNames[i]].OptionsColumn.ReadOnly = false;
                    gridView1.Columns[fieldNames[i]].AppearanceCell.ForeColor = forecolor;
                }
            }
        }

        /// <summary>
        /// allow edit in field name array. other fields not allow edit.
        /// </summary>
        /// <param name="ColorChang"></param>
        /// <param name="fieldNames"></param>
        public void AllowEdit(bool ColorChang, params string[] fieldNames)
        {
            if (gridView1.RowCount == 0) return;

            gridView1.OptionsBehavior.Editable = true;

            System.Drawing.Color forecolor = gridView1.Columns[0].AppearanceCell.ForeColor;

            for (int i = 0; i < gridView1.Columns.Count; i++)
            {
                gridView1.Columns[i].AppearanceHeader.ForeColor = Color.Black;

                gridView1.Columns[i].OptionsColumn.AllowEdit = false;
                gridView1.Columns[i].OptionsColumn.ReadOnly = true;
                // gridView1.Columns[i].AppearanceCell.ForeColor = System.Drawing.Color.Gray;
            }

            for (int i = 0; i < fieldNames.Length; i++)
            {
                if (fieldNames[i].ToString() == "CHK" || fieldNames[i].ToString() == "CHECK")
                {
                    gridView1.Columns[fieldNames[i]].OptionsColumn.AllowEdit = true;
                    gridView1.Columns[fieldNames[i]].OptionsColumn.ReadOnly = false;
                    gridView1.Columns[fieldNames[i]].AppearanceCell.ForeColor = forecolor;
                }
                else
                {
                    if (ColorChang == true)
                    {
                        gridView1.Columns[fieldNames[i]].AppearanceHeader.ForeColor = Color.Red;
                    }
                    gridView1.Columns[fieldNames[i]].OptionsColumn.AllowEdit = true;
                    gridView1.Columns[fieldNames[i]].OptionsColumn.ReadOnly = false;
                    gridView1.Columns[fieldNames[i]].AppearanceCell.ForeColor = forecolor;
                }
            }
        }

        /// <summary>
        /// Add rows
        /// </summary>
        /// <param name="dataRowList"></param>
        public void AddRows(List<DataRow> dataRowList)
        {
            DataTable dt = gridControl1.DataSource as DataTable;

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dataRowList)
                {
                    DataRow newDr = dt.NewRow();

                    for (int columnindex = 0; columnindex < dt.Columns.Count; columnindex++)
                    {
                        for (int listcolumnsindex = 0; listcolumnsindex < dt.Columns.Count; listcolumnsindex++)
                        {
                            if (dt.Columns[columnindex].ColumnName == dr.Table.Columns[listcolumnsindex].ColumnName)
                            {
                                try
                                {
                                    newDr[dt.Columns[columnindex]] = dr[listcolumnsindex].ToString();
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                        }
                    }

                    dt.Rows.Add(newDr);
                }
            }
        }

        /// <summary>
        /// Add rows
        /// </summary>
        /// <param name="dataRowList"></param>
        /// <param name="setdata"></param>
        public void AddRows(List<DataRow> dataRowList, Dictionary<string, string> setdata)
        {
            DataTable dt = gridControl1.DataSource as DataTable;

            foreach (DataRow dr in dataRowList)
            {
                DataRow newDr = dt.NewRow();

                for (int columnindex = 0; columnindex < dt.Columns.Count; columnindex++)
                {
                    for (int listcolumnsindex = 0; listcolumnsindex < dt.Columns.Count; listcolumnsindex++)
                    {
                        if (dt.Columns[columnindex].ColumnName == dr.Table.Columns[listcolumnsindex].ColumnName)
                        {
                            try
                            {
                                newDr[dt.Columns[columnindex]] = dr[listcolumnsindex].ToString();
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }

                    for (int listcolumnsindex = 0; listcolumnsindex < setdata.Count; listcolumnsindex++)
                    {
                        if (setdata.ContainsKey(dt.Columns[columnindex].ColumnName.ToString()))
                        {
                            try
                            {
                                newDr[dt.Columns[columnindex]] = setdata[dt.Columns[columnindex].ColumnName.ToString()];
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }
                }

                dt.Rows.Add(newDr);
            }
        }

        /// <summary>
        /// Add rows
        /// </summary>
        /// <param name="dataRowList"></param>
        /// <param name="setdata"></param>
        /// <param name="bindAgain"></param>
        public void AddRows(List<DataRow> dataRowList, Dictionary<string, string> setdata, bool bindAgain)
        {
            DataTable dt = gridControl1.DataSource as DataTable;

            foreach (DataRow dr in dataRowList)
            {
                DataRow newDr = dt.NewRow();

                for (int columnindex = 0; columnindex < dt.Columns.Count; columnindex++)
                {
                    for (int listcolumnsindex = 0; listcolumnsindex < dt.Columns.Count; listcolumnsindex++)
                    {
                        if (dt.Columns[columnindex].ColumnName == dr.Table.Columns[listcolumnsindex].ColumnName)
                        {
                            try
                            {
                                newDr[dt.Columns[columnindex]] = dr[listcolumnsindex].ToString();
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }

                    for (int listcolumnsindex = 0; listcolumnsindex < setdata.Count; listcolumnsindex++)
                    {
                        if (setdata.ContainsKey(dt.Columns[columnindex].ColumnName.ToString()))
                        {
                            try
                            {
                                newDr[dt.Columns[columnindex]] = setdata[dt.Columns[columnindex].ColumnName.ToString()];
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }
                }

                dt.Rows.Add(newDr);
            }

            if (bindAgain)
            {
                this.BindNLS(dt, false);
            }
        }

        /// <summary>
        /// Un select all
        /// </summary>
        public void UnselectAll()
        {
            for (int i = 0; i < gridView1.RowCount; i++)
            {
                gridView1.UnselectRow(i);
            }
        }

        /// <summary>
        /// Get grid control
        /// </summary>
        /// <returns></returns>
        public GridControl GetGridControl()
        {
            return this.gridControl1;
        }

        /// <summary>
        /// Get grid view
        /// </summary>
        /// <returns></returns>
        public GridView GetGridView()
        {
            return this.gridView1;
        }

        /// <summary>
        /// Get source DataTable
        /// </summary>
        /// <returns></returns>
        public DataTable GetSourceDataTable()
        {
            return gridControl1.DataSource as DataTable;
        }

        /// <summary>
        /// if checkbox column is exist, return checked Rows dataTable
        /// </summary>
        /// <returns></returns>
        public DataTable GetCheckedDataTable()
        {
            DataTable dtClone = null;

            try
            {
                DataTable dt = gridControl1.DataSource as DataTable;

                if (dt != null && dt.Rows.Count > 0)
                {
                    dt.AcceptChanges();
                    dtClone = dt.Clone();

                    foreach (DataRow dr in dt.Rows)
                    {
                        if (dr[CustomFields.CHK] != DBNull.Value && dr[CustomFields.CHK].ToString() == CheckBoxValue.ONE)
                        {
                            dtClone.ImportRow(dr);
                        }
                    }

                    dtClone.TableName = string.IsNullOrEmpty(dt.TableName) ? "NoTableName" : dt.TableName;
                    dtClone.AcceptChanges();
                }
            }
            catch (Exception ex)
            {
            }

            return dtClone;
        }


        /// <summary>
        /// if checkbox column is exist, return checked Rows 
        /// </summary>
        /// <returns></returns>
        public DataRow[] GetCheckedDataRows()
        {

            DataTable dt = gridControl1.DataSource as DataTable;
            List<DataRow> lst = new List<DataRow>();

            foreach (DataRow dr in dt.Rows)
            {
                if (dr[CustomFields.CHK] != DBNull.Value && dr[CustomFields.CHK].ToString() == CheckBoxValue.ONE)
                {
                    lst.Add(dr);
                }
            }

            return lst.ToArray();
        }

        /// <summary>
        /// Print barcode
        /// </summary>
        private void PrintBarcode()
        {
            try
            {
                DataRow dataRow = this.gridView1.GetFocusedDataRow() as DataRow;

                DataTable dt = gridControl1.DataSource as DataTable;
                DataTable tmp = dt.Clone();
                tmp.ImportRow(dataRow);

                int count = tmp.Rows.Count;

                LabelManager.PrintLabelTest(tmp, count);
            }
            catch (Exception ex)
            {
                MesMessageBox.ShowDialog(ex);
            }
        }

        /// <summary>
        /// Bind NLS
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="checkFlag"></param>
        public void BindNLS(DataTable dt, bool checkFlag)
        {
            if (dt == null)
            {
                gridControl1.DataSource = null;
                return;
            }

            Guard.ArgumentNotNull(gridControl1, "GridControl");
            Guard.ArgumentNotNull(dt, "DataTable");

            try
            {
                if (gridView1.Columns.Count < 1)
                {
                    if (checkFlag)
                    {
                        GridCheckMarksSelection selection = new GridCheckMarksSelection(gridView1, true);

                        CheckMarkSelection = selection;
                        selection.CheckMarkColumn.VisibleIndex = 0;
                    }

                    foreach (DataColumn col in dt.Columns)
                    {
                        GridColumn gridColumn = new GridColumn();

                        gridColumn.FieldName = col.ColumnName;
                        gridColumn.Caption = NLSService.GetNLSValue(NLSType.Grid, col.ColumnName);
                        gridColumn.Visible = true;
                        gridColumn.VisibleIndex = dt.Columns.IndexOf(col);
                        gridColumn.OptionsColumn.AllowGroup = DefaultBoolean.True;

                        if (col.DataType == typeof(DateTime))
                        {
                            gridColumn.DisplayFormat.FormatString = defaultDateFormat;
                        }

                        if (col.DataType == typeof(Double) || col.DataType == typeof(int))
                        {
                            gridColumn.DisplayFormat.FormatString = defaultNumericFormat;
                            gridColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom;
                        }
                        gridColumn.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
                        gridView1.Columns.Add(gridColumn);
                    }
                }

                if (dt != null)
                {
                    gridControl1.DataSource = dt;

                    if (checkFlag) AllowEdit(CheckMarkSelection.CheckMarkColumn.FieldName);

                    gridView1.BestFitColumns();
                    gridView1.OptionsBehavior.Editable = false;
                    gridView1.OptionsSelection.MultiSelect = true;
                    gridView1.OptionsCustomization.AllowSort = true;

                    gridView1.Appearance.HeaderPanel.TextOptions.HAlignment = HorzAlignment.Center;
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }

        /// <summary>
        /// Bind DataTable data to grid. (초기 DataTable의 ColumnName기준으로 NLS의 컬럼명을 가져온다.)
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="dt"></param>
        public void BindNLS(DataTable dt, bool checkFlag, CTextComboEdit combo)
        {
            if (dt == null)
            {
                gridControl1.DataSource = null;
                return;
            }

            Guard.ArgumentNotNull(gridControl1, "GridControl");
            Guard.ArgumentNotNull(dt, "DataTable");

            gridView1.Columns.Clear();

            if (gridView1.Columns.Count < 1)
            {
                foreach (DataColumn col in dt.Columns)
                {
                    GridColumn gridColumn = new GridColumn();
                    gridColumn.FieldName = col.ColumnName;
                    gridColumn.Caption = NLSService.GetNLSValue(NLSType.Grid, col.ColumnName);
                    gridColumn.Visible = true;
                    gridColumn.VisibleIndex = dt.Columns.IndexOf(col);

                    if (col.DataType == typeof(DateTime))
                    {
                        gridColumn.DisplayFormat.FormatString = defaultDateFormat;
                    }

                    if (col.DataType == typeof(Double) || col.DataType == typeof(int))
                    {
                        gridColumn.DisplayFormat.FormatString = defaultNumericFormat;
                        gridColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom;
                    }

                    gridColumn.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
                    gridView1.Columns.Add(gridColumn);
                }

                if (checkFlag)
                {
                    GridCheckMarksSelection selection = new GridCheckMarksSelection(gridView1, true, combo);
                    CheckMarkSelection = selection;
                    selection.CheckMarkColumn.VisibleIndex = 0;

                    gridView1.OptionsBehavior.Editable = true;
                    gridView1.OptionsSelection.MultiSelect = true;
                }
            }

            if (dt != null)
            {
                gridControl1.DataSource = dt;
                gridView1.OptionsCustomization.AllowSort = true;

                if (checkFlag) AllowEdit(CheckMarkSelection.CheckMarkColumn.FieldName);

                gridView1.BestFitColumns();
                gridView1.Appearance.HeaderPanel.TextOptions.HAlignment = HorzAlignment.Center;
            }
        }

        /// <summary>
        /// Bind datatable with CheckBoxEdit.
        /// </summary>
        /// <param name="dt"></param>
        public void BindWithCheck(DataTable dt)
        {
            BindWithCheck(dt, true);
        }

        /// <summary>
        ///  Bind datatable and hide check all header with CheckBoxEdit.
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="visibleGridHeader"></param>
        public void BindWithCheck(DataTable dt, bool visibleGridHeader)
        {
            Guard.ArgumentNotNull(gridControl1, "GridControl");
            Guard.ArgumentNotNull(dt, "DataTable");

            gridControl1.DataSource = null;
            rowStateHelper.Clear();

            if (dt.Columns.Count > 0)
            {
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();

                GridCheckMarksSelection selection = new GridCheckMarksSelection(gridView1, visibleGridHeader);
                CheckMarkSelection = selection;
                selection.CheckMarkColumn.VisibleIndex = 0;

                gridView1.OptionsBehavior.Editable = true;
                gridView1.OptionsSelection.MultiSelect = true;
            }
        }

        /// <summary>
        /// Bind datatable, hide check all header with CheckBoxEdit and checked counting to CTextComboEdit
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="visibleGridHeader"></param>
        /// <param name="combo"></param>
        public void BindWithCheck(DataTable dt, bool visibleGridHeader, CTextComboEdit combo)
        {
            Guard.ArgumentNotNull(gridControl1, "GridControl");
            Guard.ArgumentNotNull(dt, "DataTable");

            gridControl1.DataSource = null;

            if (dt.Columns.Count > 0)
            {
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();

                GridCheckMarksSelection selection = new GridCheckMarksSelection(gridView1, visibleGridHeader, combo);
                CheckMarkSelection = selection;
                selection.CheckMarkColumn.VisibleIndex = 0;

                gridView1.OptionsBehavior.Editable = true;
                gridView1.OptionsSelection.MultiSelect = true;
            }
        }

        /// <summary>
        /// Bind datatable, hide check all header with CheckBoxEdit and checked counting to CTextComboEdit
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="visibleGridHeader"></param>
        /// <param name="combo"></param>
        public void BindWithCheck(DataTable dt, bool visibleGridHeader, CTextComboEdit combo, string columnName)
        {
            Guard.ArgumentNotNull(gridControl1, "GridControl");

            Guard.ArgumentNotNull(dt, "DataTable");

            gridControl1.DataSource = null;

            if (dt.Columns.Count > 0)
            {
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();

                GridCheckMarksSelection selection = new GridCheckMarksSelection(gridView1, visibleGridHeader, combo, columnName);
                CheckMarkSelection = selection;
                selection.CheckMarkColumn.VisibleIndex = 0;

                gridView1.OptionsBehavior.Editable = true;
                gridView1.OptionsSelection.MultiSelect = true;
            }
        }

        /// <summary>
        /// Clear gridView
        /// </summary>
        public void Clear()
        {
            this.gridView1.Columns.Clear();
            this.gridControl1.DataSource = null;
        }

        /// <summary>
        /// Create columns from column array.
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="columnNames"></param>
        public void CreateColumns(string[] fieldNames)
        {
            CreateColumns(fieldNames, null);
        }

        /// <summary>
        /// Create columns from column array.
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="columnNames"></param>
        public void CreateColumns(string[] fieldNames, string[] captions)
        {
            if (captions != null)
            {
                if (fieldNames.Length != captions.Length)
                {
                    throw new ArgumentOutOfRangeException("FieldNames,CaptionNames", "Two arrays mismatch length");
                }
            }

            GridView gridView = (GridView)gridControl1.Views[0];

            for (int i = 0; i < fieldNames.Length; i++)
            {
                GridColumn gridColumn = gridView.Columns.AddField(fieldNames[i]);
                gridColumn.VisibleIndex = gridView.Columns.Count;

                if (captions != null) gridColumn.Caption = captions[i];
                //gridColumn.Caption = NLSService.GetNLSValue(NLSType.Grid, (captions != null ? captions[i] : fieldNames[i]));
                gridColumn.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            }
        }

        /// <summary>
        /// Create button column
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="caption"></param>
        public void CreateButtonColumn(string fieldName, string caption)
        {
            if (string.IsNullOrEmpty(fieldName)) throw new ArgumentNullException("FieldName");

            GridColumn gridColumn = gridView1.Columns.ColumnByFieldName(fieldName);
            if (gridColumn == null)
            {
                GridColumn newGridColumn = new GridColumn();
                newGridColumn.FieldName = fieldName;
                gridView1.Columns.Add(newGridColumn);
            }

            gridView1.OptionsBehavior.Editable = true;

            RepositoryItemButtonEdit repositoryItemButtonEdit = new RepositoryItemButtonEdit();
            repositoryItemButtonEdit.TextEditStyle = TextEditStyles.HideTextEditor;
            repositoryItemButtonEdit.Buttons[0].Caption = NLSService.GetNLSValue(NLSType.Grid, caption); // 다국어 처리
            repositoryItemButtonEdit.Buttons[0].Tag = fieldName;
            repositoryItemButtonEdit.Buttons[0].Kind = ButtonPredefines.Glyph;

            repositoryItemButtonEdit.ButtonClick += new ButtonPressedEventHandler(btn_ButtonClick);
            gridView1.Columns[fieldName].ColumnEdit = repositoryItemButtonEdit;
        }

        /// <summary>
        /// Set comboBox in grid. use this method after binding data
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="comboData"></param>
        public void CreateComboColumn(string fieldName, string[] comboData)
        {
            if (string.IsNullOrEmpty(fieldName)) throw new ArgumentNullException("FieldName");
            if (comboData == null) throw new ArgumentNullException("ComboBox Data");

            GridColumn gridColumn = gridView1.Columns.ColumnByFieldName(fieldName);

            if (gridColumn == null)
            {
                GridColumn newGrodColumn = new GridColumn();
                newGrodColumn.FieldName = fieldName;

                gridView1.Columns.Add(newGrodColumn);
            }

            gridView1.OptionsBehavior.Editable = true;

            RepositoryItemComboBox comboBox = new RepositoryItemComboBox();
            comboBox.Items.AddRange(comboData);
            gridView1.Columns[fieldName].ColumnEdit = comboBox;
        }

        /// <summary>
        /// Set lookupEdit in grid. display only displayMember.
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="fieldName"></param>
        /// <param name="displayValueMember"></param>
        public void CreateLookUpEdit(DataTable dt, string fieldName, string displayValueMember)
        {
            CreateLookUpEdit(dt, fieldName, displayValueMember, null);
        }

        /// <summary>
        /// Set lookupEdit in grid.
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="fieldName"></param>
        /// <param name="displayMember"></param>
        /// <param name="valueMember"></param>
        public void CreateLookUpEdit(DataTable dt, string fieldName, string displayMember, string valueMember)
        {
            if (dt == null) return;

            RepositoryItemLookUpEdit repositoryItemLookUpEdit = new RepositoryItemLookUpEdit();
            repositoryItemLookUpEdit.DataSource = dt;
            repositoryItemLookUpEdit.DisplayMember = displayMember;
            repositoryItemLookUpEdit.NullText = string.Empty;
            repositoryItemLookUpEdit.AllowNullInput = DefaultBoolean.True;

            if (valueMember != null) repositoryItemLookUpEdit.ValueMember = valueMember;
            else repositoryItemLookUpEdit.ValueMember = displayMember;

            gridView1.Columns[fieldName].ColumnEdit = repositoryItemLookUpEdit;
            LookUpColumnInfoCollection collection = repositoryItemLookUpEdit.Columns;
            collection.Clear();

            collection.Add(new LookUpColumnInfo(displayMember));
            if (valueMember != null) collection.Add(new LookUpColumnInfo(valueMember));
        }

        /// <summary>
        /// Set Number column in grid. use this method after binding data
        /// </summary>
        /// <param name="visualIndex"></param>
        public void CreateNumberColumn(int visibleIndex)
        {
            GridColumn unbColumn = gridView1.Columns.AddField(CustomFields.NO);
            unbColumn.VisibleIndex = visibleIndex;
            unbColumn.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
            unbColumn.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;
            unbColumn.Width = 30;
            unbColumn.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
            unbColumn.OptionsColumn.AllowEdit = false;
        }

        /// <summary>
        /// Display summary field to grid footer
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="summaryItemList"></param>
        public void DisplaySummary(Dictionary<int, SummaryItemType> summaryItemList)
        {
            Guard.ArgumentNotNull(gridControl1, "GridControl");

            GridView gridView = (GridView)gridControl1.Views[0];
            gridView.OptionsView.ShowFooter = true;

            foreach (KeyValuePair<int, SummaryItemType> item in summaryItemList)
            {
                gridView.Columns[item.Key].DisplayFormat.FormatType = FormatType.Numeric;
                gridView.Columns[item.Key].DisplayFormat.FormatString = "n0";
                gridView.Columns[item.Key].SummaryItem.SummaryType = item.Value;
                gridView.Columns[item.Key].SummaryItem.DisplayFormat = item.Value.ToString().ToUpper() + "={0:n0}";
            }
        }

        /// <summary>
        /// Display Numeric format(ex. ###,###)
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="columnIndexs"></param>
        public void DisplayNumericFormat(int[] columnIndexs)
        {
            Guard.ArgumentNotNull(gridControl1, "GridControl");
            GridView gridView = (GridView)gridControl1.Views[0];

            foreach (int columnIndex in columnIndexs)
            {
                gridView.Columns[columnIndex].DisplayFormat.FormatType = FormatType.Numeric;
                gridView.Columns[columnIndex].DisplayFormat.FormatString = "n0";
            }
        }

        /// <summary>
        /// show find panel and set property.
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="filterColumn"></param>
        public void DisplayFindPanel(string filterColumn)
        {
            Guard.ArgumentNotNull(gridControl1, "GridControl");
            GridView gridView = (GridView)gridControl1.Views[0];

            gridView.OptionsFind.AllowFindPanel = true;
            gridView.OptionsFind.ShowCloseButton = false;
            gridView.OptionsFind.HighlightFindResults = true;
            gridView.OptionsFind.AlwaysVisible = true;

            if (string.IsNullOrEmpty(filterColumn)) filterColumn = "*";

            gridView.OptionsFind.FindFilterColumns = filterColumn;
            gridView.OptionsFind.FindMode = DevExpress.XtraEditors.FindMode.FindClick;
            gridView.OptionsFind.ClearFindOnClose = false;
        }

        /// <summary>
        /// Get check rows to list
        /// </summary>
        /// <param name="checkeditcolumnname"></param>
        /// <param name="checkedState"></param>
        /// <returns></returns>
        public List<DataRow> GetCheckRowsToList(string checkeditcolumnname, string checkedState)
        {
            DataTable dt = gridControl1.DataSource as DataTable;
            List<DataRow> dataRowList = new List<DataRow>();
            DataRow[] drs = dt.Select(checkeditcolumnname + "='" + checkedState + "'");

            foreach (DataRow dr in drs)
            {
                dataRowList.Add(dr);
            }

            return dataRowList;
        }

        /// <summary>
        /// 선택된 datarow 가져오기
        /// </summary>
        /// <returns></returns>
        public DataRow[] GetSelectedDataRows()
        {
            if (gridControl1.DataSource == null) return null;

            if (gridView1.GetSelectedRows().Length < 1) return null;

            DataTable dt = gridControl1.DataSource as DataTable;
            List<DataRow> lst = new List<DataRow>();

            foreach (int row in gridView1.GetSelectedRows())
            {
                lst.Add(dt.Rows[row]);
            }

            return lst.ToArray();
        }

        /// <summary>
        /// 선택된 특정Row 정보 가져오기
        /// </summary>
        /// <param name="row"></param>
        /// <returns></returns>
        public DataRow GetSelectedDataRow(int row)
        {
            if (gridControl1.DataSource == null) return null;

            if (gridView1.GetSelectedRows().Length < 1) return null;

            DataTable dt = gridControl1.DataSource as DataTable;
            return dt.Rows[gridView1.GetSelectedRows()[row]];
        }

        /// <summary>
        /// Focused 된 Cell Value Return;
        /// </summary>
        /// <returns></returns>
        public object GetFocusedValue()
        {
            return this.gridView1.GetFocusedValue();
        }

        /// <summary>
        /// 지정한 Cell Value Return
        /// </summary>
        /// <param name="rowHandle"></param>
        /// <param name="columnname"></param>
        /// <returns></returns>
        public object GetCellValue(int rowHandle, string columnname)
        {
            return this.GetCellValue(rowHandle, this.gridView1.Columns[columnname]);
        }
        public object GetCellValue(int rowHandle, GridColumn column)
        {
            return this.gridView1.GetRowCellValue(rowHandle, column);
        }

        /// <summary>
        /// 지정한 Cell Value Setting
        /// </summary>
        /// <param name="rowHandle"></param>
        /// <param name="columnname"></param>
        /// <param name="setValue"></param>
        public void SetCellValue(int rowHandle, string columnname, object setValue)
        {
            this.SetCellValue(rowHandle, this.gridView1.Columns[columnname], setValue);
        }
        public void SetCellValue(int rowHandle, GridColumn columnname, object setValue)
        {
            this.gridView1.SetRowCellValue(rowHandle, columnname, setValue);
        }

        /// <summary>
        /// 선택된 정보중 처음 정보만 가져오기
        /// </summary>
        /// <param name="row"></param>
        /// <returns></returns>
        public DataRow GetSelectedDataRow()
        {
            if (gridControl1.DataSource == null) return null;

            if (gridView1.GetSelectedRows().Length < 1) return null;

            DataTable dt = gridControl1.DataSource as DataTable;
            return dt.Rows[gridView1.GetSelectedRows()[0]];
        }

        /// <summary>
        /// if checkbox column is exist, return checked index array.
        /// </summary>
        /// <returns></returns>
        public int[] GetCheckedIndex()
        {
            if (this.CheckMarkSelection == null) return null;

            List<int> intList = new List<int>();

            for (int i = 0; i < gridView1.RowCount; i++)
            {
                bool check = this.CheckMarkSelection.IsRowSelected(i);
                if (check) intList.Add(i);
            }

            if (intList.Count == 0) return null;

            return intList.ToArray();
        }

        /// <summary>
        /// Export excel
        /// </summary>
        public void ExportExcel()
        {
            try
            {
                this.gridView1.OptionsPrint.AutoWidth = false;
                this.gridView1.OptionsPrint.PrintHeader = true;
                this.gridView1.OptionsPrint.PrintSelectedRowsOnly = false;
                this.gridView1.OptionsPrint.ExpandAllDetails = true;
                this.gridView1.OptionsPrint.ExpandAllGroups = true;
                this.gridView1.OptionsPrint.PrintDetails = true;
                this.gridView1.OptionsPrint.UsePrintStyles = true;

                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = "Excel File(*.xlsx)|*.xlsx|All Files(*.*)|*.*";
                saveFileDialog.Title = "Save the Grid to Excel";

                if ((saveFileDialog.ShowDialog()) == DialogResult.OK)
                {
                    string filePath = saveFileDialog.FileName.ToString();
                    gridView1.ExportToXlsx(filePath);
                }
            }
            catch (Exception ex)
            {
                MesMessageBox.ShowDialog(ex.Message, UIMessageType.Error);
            }
        }

        /// <summary>
        /// Get Row Count
        /// </summary>
        /// <returns></returns>
        public int RowCount()
        {
            return this.gridView1.RowCount;
        }

        /// <summary>
        /// Remove check row
        /// </summary>
        /// <param name="checkedcolumnname"></param>
        public void RemoveCheckRow(string checkedcolumnname)
        {
            try
            {
                DataTable dt = gridControl1.DataSource as DataTable;
                if (dt == null) return;
                if (dt.Rows.Count == 0) return;

                for (int rowindex = dt.Rows.Count - 1; rowindex >= 0; rowindex--)
                {
                    if (Convert.ToBoolean(Convert.ToInt16(gridView1.GetRowCellValue(rowindex, checkedcolumnname))))
                    {
                        dt.Rows.RemoveAt(rowindex);
                    }
                }
            }
            catch
            {
            }
        }

        /// <summary>
        /// Remove check row
        /// </summary>
        /// <param name="checkedcolumnname"></param>
        /// <param name="checkedstate"></param>
        public void RemoveCheckRow(string checkedcolumnname, string checkedstate)
        {
            try
            {
                DataTable dt = gridControl1.DataSource as DataTable;
                if (dt == null) return;
                if (dt.Rows.Count == 0) return;

                for (int rowindex = dt.Rows.Count - 1; rowindex >= 0; rowindex--)
                {
                    if (gridView1.GetRowCellValue(rowindex, checkedcolumnname).ToString() == checkedstate)
                    {
                        dt.Rows.RemoveAt(rowindex);
                    }
                }
            }
            catch
            {
            }
        }

        /// <summary>
        /// Sort by column
        /// </summary>
        /// <param name="columnName"></param>
        public void Sort(string columnName)
        {
            gridView1.BeginSort();

            try
            {
                gridView1.ClearSorting();
                gridView1.Columns[columnName].SortOrder = ColumnSortOrder.Ascending;
            }
            finally
            {
                gridView1.EndSort();
            }
        }

        /// <summary>
        /// Sort by multi-column
        /// </summary>
        /// <param name="columnNames"></param>
        public void Sort(string[] columnNames)
        {
            gridView1.BeginSort();

            try
            {
                gridView1.ClearSorting();

                for (int i = 0; i < columnNames.Length; i++)
                {
                    gridView1.Columns[columnNames[i]].SortOrder = ColumnSortOrder.Ascending;
                }
            }
            finally
            {
                gridView1.EndSort();
            }
        }

        /// <summary>
        /// set all column width with the same width.
        /// </summary>
        /// <param name="width"></param>
        public void SetWidthAllColumns(int width)
        {
            GridView gridView = (GridView)gridControl1.Views[0];

            for (int i = 0; i < gridView.Columns.Count; i++)
            {
                gridView.Columns[i].Width = width;
            }
        }

        /// <summary>
        /// aliign all column header text
        /// </summary>
        /// <param name="horzAlignment"></param>
        public void SetAlignmenttAllColumn(HorzAlignment horzAlignment)
        {
            GridView gridView = (GridView)gridControl1.Views[0];

            for (int i = 0; i < gridView.Columns.Count; i++)
            {
                gridView.Columns[i].AppearanceHeader.TextOptions.HAlignment = horzAlignment;
            }
        }

        /// <summary>
        /// aliign Fields column Alignment text
        /// </summary>
        /// <param name="horzAlignment"></param>
        public void SetAlignmentColumns(string[] fieldNames, HorzAlignment horzAlignment)
        {
            foreach (string fieldName in fieldNames)
            {
                gridView1.Columns[fieldName].AppearanceCell.TextOptions.HAlignment = horzAlignment;
            }
        }

        /// <summary>
        /// Set Column to CheckEdit in Grid
        /// 20140704 김정민 추가
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="comboData"></param>
        public void SetColumnToCheckEdit(string fieldName, string checkedData, string grayedData, string unCheckedData)
        {
            if (string.IsNullOrEmpty(fieldName)) throw new ArgumentNullException("FieldName");
            if (checkedData == "") throw new ArgumentNullException("CheckEdit Data");
            if (unCheckedData == "") throw new ArgumentNullException("CheckEdit Data");

            GridColumn gridColumn = gridView1.Columns.ColumnByFieldName(fieldName);
            if (gridColumn == null)
            {
                GridColumn newGridColumn = new GridColumn();
                newGridColumn.FieldName = fieldName;
                gridView1.Columns.Add(newGridColumn);
            }

            gridView1.OptionsBehavior.Editable = true;
            gridView1.Columns[fieldName].OptionsColumn.AllowEdit = true;
            gridView1.Columns[fieldName].OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;

            RepositoryItemCheckEdit repositoryItemCheckEdit = new RepositoryItemCheckEdit();
            repositoryItemCheckEdit.CheckStyle = DevExpress.XtraEditors.Controls.CheckStyles.Standard;
            repositoryItemCheckEdit.DisplayValueChecked = checkedData;
            repositoryItemCheckEdit.DisplayValueGrayed = grayedData;
            repositoryItemCheckEdit.DisplayValueUnchecked = unCheckedData;
            repositoryItemCheckEdit.ValueChecked = checkedData;
            repositoryItemCheckEdit.ValueGrayed = grayedData;
            repositoryItemCheckEdit.ValueUnchecked = unCheckedData;
            repositoryItemCheckEdit.CheckStateChanged += new EventHandler(repositoryItemCheckEdit_CheckStateChanged);
            this.gridView1.Columns[gridColumn.AbsoluteIndex].ColumnEdit = repositoryItemCheckEdit;
        }

        private void repositoryItemCheckEdit_CheckStateChanged(object sender, EventArgs e)
        {
            if (this.CheckedChanged != null) this.CheckedChanged(sender, e);
        }

        /// <summary>
        /// Set column to check edit
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="checkedData"></param>
        /// <param name="grayedData"></param>
        /// <param name="unCheckedData"></param>
        /// <param name="Editable"></param>
        public void SetColumnToCheckEdit(string fieldName, string checkedData, string grayedData, string unCheckedData, bool Editable)
        {
            if (string.IsNullOrEmpty(fieldName)) throw new ArgumentNullException("FieldName");
            if (checkedData == "") throw new ArgumentNullException("CheckEdit Data");
            if (unCheckedData == "") throw new ArgumentNullException("CheckEdit Data");

            GridColumn gridColumn = gridView1.Columns.ColumnByFieldName(fieldName);
            if (gridColumn == null)
            {
                GridColumn newGridColumn = new GridColumn();
                newGridColumn.FieldName = fieldName;
                gridView1.Columns.Add(newGridColumn);
            }

            gridView1.OptionsBehavior.Editable = Editable;
            gridView1.Columns[fieldName].OptionsColumn.AllowEdit = Editable;
            gridView1.Columns[fieldName].OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;

            RepositoryItemCheckEdit repositoryItemCheckEdit = new RepositoryItemCheckEdit();
            repositoryItemCheckEdit.CheckStyle = DevExpress.XtraEditors.Controls.CheckStyles.Standard;
            repositoryItemCheckEdit.DisplayValueChecked = checkedData;
            repositoryItemCheckEdit.DisplayValueGrayed = grayedData;
            repositoryItemCheckEdit.DisplayValueUnchecked = unCheckedData;
            repositoryItemCheckEdit.ValueChecked = checkedData;
            repositoryItemCheckEdit.ValueGrayed = grayedData;
            repositoryItemCheckEdit.ValueUnchecked = unCheckedData;
            repositoryItemCheckEdit.ReadOnly = !Editable;
            this.gridView1.Columns[gridColumn.AbsoluteIndex].ColumnEdit = repositoryItemCheckEdit;
        }

        /// <summary>
        /// Set column to check edit
        /// </summary>
        /// <param name="fieldNames"></param>
        /// <param name="checkedData"></param>
        /// <param name="grayedData"></param>
        /// <param name="unCheckedData"></param>
        public void SetColumnToCheckEdit(string[] fieldNames, string checkedData, string grayedData, string unCheckedData)
        {
            if (fieldNames.Length == 0) throw new ArgumentNullException("FieldName");
            if (checkedData == "") throw new ArgumentNullException("CheckEdit Data");

            foreach (string fieldName in fieldNames)
            {
                GridColumn gridColumn = gridView1.Columns.ColumnByFieldName(fieldName);
                if (gridColumn == null)
                {
                    GridColumn newColumn = new GridColumn();
                    newColumn.FieldName = fieldName;
                    gridView1.Columns.Add(newColumn);
                }

                gridView1.OptionsBehavior.Editable = true;
                gridView1.Columns[fieldName].OptionsColumn.AllowEdit = true;
                gridView1.Columns[fieldName].OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;

                RepositoryItemCheckEdit repositoryItemCheckEdit = new RepositoryItemCheckEdit();
                repositoryItemCheckEdit.CheckStyle = DevExpress.XtraEditors.Controls.CheckStyles.Standard;
                repositoryItemCheckEdit.DisplayValueChecked = checkedData;
                repositoryItemCheckEdit.DisplayValueGrayed = grayedData;
                repositoryItemCheckEdit.DisplayValueUnchecked = unCheckedData;
                repositoryItemCheckEdit.ValueChecked = checkedData;
                repositoryItemCheckEdit.ValueGrayed = grayedData;
                repositoryItemCheckEdit.ValueUnchecked = unCheckedData;
                this.gridView1.Columns[gridColumn.AbsoluteIndex].ColumnEdit = repositoryItemCheckEdit;
            }
        }

        /// <summary>
        /// Set Column to LookUpCombo in Grid
        /// 20140704 김정민 추가
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="comboData"></param>
        public void SetColumnToComboBox(string fieldName, DataTable Dt, String displaymember, String valuemember)
        {
            if (string.IsNullOrEmpty(fieldName)) throw new ArgumentNullException("FieldName");

            GridColumn gridColumn = gridView1.Columns.ColumnByFieldName(fieldName);
            if (gridColumn == null) return;

            gridView1.OptionsBehavior.Editable = true;
            gridView1.Columns[fieldName].OptionsColumn.AllowEdit = true;

            RepositoryItemGridLookUpEdit repositoryItemGridLookUpEdit = new RepositoryItemGridLookUpEdit();

            repositoryItemGridLookUpEdit.View.FocusRectStyle = DrawFocusRectStyle.RowFocus;
            repositoryItemGridLookUpEdit.View.OptionsBehavior.AllowPixelScrolling = DevExpress.Utils.DefaultBoolean.True;
            repositoryItemGridLookUpEdit.View.OptionsView.AutoCalcPreviewLineCount = true;
            repositoryItemGridLookUpEdit.View.OptionsView.ColumnAutoWidth = true;
            repositoryItemGridLookUpEdit.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;

            this.gridView1.Columns[gridColumn.AbsoluteIndex].ColumnEdit = repositoryItemGridLookUpEdit;
            repositoryItemGridLookUpEdit.DataSource = Dt;
            repositoryItemGridLookUpEdit.ValueMember = valuemember;
            repositoryItemGridLookUpEdit.DisplayMember = displaymember;
            repositoryItemGridLookUpEdit.NullText = string.Empty;
        }

        /// <summary>
        /// DevExpress GridView Set Column Control DateEdit
        /// </summary>
        /// <param name="fieldNames"></param>
        /// <param name="sDisplayFormatString"></param>
        public void SetColumnToDateEdit(string[] fieldNames)
        {
            this.SetColumnToDateEdit(fieldNames, defaultDateFormat, false, false, true);
        }
        public void SetColumnToDateEdit(string[] fieldNames, string sDisplayFormatString, bool bIsReadOnly = false, bool bIsShowClear = false, bool bIsShowToDay = true)
        {
            if (fieldNames.Length == 0) throw new ArgumentNullException("FieldName");
            if (string.IsNullOrEmpty(sDisplayFormatString)) sDisplayFormatString = defaultDateFormat;

            foreach (string fieldName in fieldNames)
            {
                GridColumn gridColumn = gridView1.Columns.ColumnByFieldName(fieldName);
                if (gridColumn == null)
                {
                    GridColumn newColumn = new GridColumn();
                    newColumn.FieldName = fieldName;
                    gridView1.Columns.Add(newColumn);
                }

                gridView1.OptionsBehavior.Editable = true;
                gridView1.Columns[fieldName].OptionsColumn.AllowEdit = true;
                gridView1.Columns[fieldName].OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;
                gridView1.Columns[fieldName].DisplayFormat.FormatType = FormatType.DateTime;
                gridView1.Columns[fieldName].DisplayFormat.FormatString = sDisplayFormatString;

                RepositoryItemDateEdit repositoryItemDateEdit = new RepositoryItemDateEdit();
                repositoryItemDateEdit.NullDate = DateTime.Now;
                repositoryItemDateEdit.DisplayFormat.FormatType = FormatType.DateTime;
                repositoryItemDateEdit.DisplayFormat.FormatString = sDisplayFormatString;
                repositoryItemDateEdit.EditFormat.FormatType = FormatType.DateTime;
                repositoryItemDateEdit.EditFormat.FormatString = sDisplayFormatString;
                repositoryItemDateEdit.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime;
                repositoryItemDateEdit.Mask.EditMask = sDisplayFormatString;
                //repositoryItemDateEdit.Mask.UseMaskAsDisplayFormat = true;

                repositoryItemDateEdit.VistaEditTime = DefaultBoolean.True;
                repositoryItemDateEdit.VistaTimeProperties.TimeEditStyle = TimeEditStyle.SpinButtons;
                repositoryItemDateEdit.VistaTimeProperties.EditFormat.FormatType = FormatType.DateTime;
                repositoryItemDateEdit.VistaTimeProperties.EditFormat.FormatString = "HH:mm";
                repositoryItemDateEdit.VistaTimeProperties.DisplayFormat.FormatType = FormatType.DateTime;
                repositoryItemDateEdit.VistaTimeProperties.DisplayFormat.FormatString = "HH:mm";
                repositoryItemDateEdit.VistaTimeProperties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime;
                repositoryItemDateEdit.VistaTimeProperties.Mask.EditMask = "HH:mm";
                repositoryItemDateEdit.VistaTimeProperties.Mask.UseMaskAsDisplayFormat = true;

                repositoryItemDateEdit.ReadOnly = bIsReadOnly;
                repositoryItemDateEdit.ShowToday = bIsShowToDay;
                repositoryItemDateEdit.ShowClear = bIsShowClear;

                //repositoryItemDateEdit.VistaTimeProperties.
                this.gridView1.Columns[gridColumn.AbsoluteIndex].ColumnEdit = repositoryItemDateEdit;
            }
        }

        public void SetColumnToDateTimeEdit(string[] fieldNames, string sDisplayFormatString, bool bIsReadOnly = false, bool bIsShowClear = false, bool bIsShowToDay = true)
        {
            if (fieldNames.Length == 0) throw new ArgumentNullException("FieldName");
            if (string.IsNullOrEmpty(sDisplayFormatString)) sDisplayFormatString = defaultDateFormat;

            foreach (string fieldName in fieldNames)
            {
                GridColumn gridColumn = gridView1.Columns.ColumnByFieldName(fieldName);
                if (gridColumn == null)
                {
                    GridColumn newColumn = new GridColumn();
                    newColumn.FieldName = fieldName;
                    gridView1.Columns.Add(newColumn);
                }

                gridView1.OptionsBehavior.Editable = true;
                gridView1.Columns[fieldName].OptionsColumn.AllowEdit = true;
                gridView1.Columns[fieldName].OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;

                RepositoryItemDateEdit repositoryItemDateEdit = new RepositoryItemDateEdit();
                //repositoryItemDateEdit.NullDate = DateTime.Now;
                //repositoryItemDateEdit.DisplayFormat.FormatType = FormatType.DateTime;
                //repositoryItemDateEdit.DisplayFormat.FormatString = sDisplayFormatString;
                //repositoryItemDateEdit.EditFormat.FormatType = FormatType.DateTime;
                //repositoryItemDateEdit.EditFormat.FormatString = sDisplayFormatString;
                //repositoryItemDateEdit.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime;
                //repositoryItemDateEdit.Mask.EditMask = sDisplayFormatString;
                ////repositoryItemDateEdit.Mask.UseMaskAsDisplayFormat = true;


                //repositoryItemDateEdit.VistaEditTime = DefaultBoolean.True;
                //repositoryItemDateEdit.VistaTimeProperties.TimeEditStyle = TimeEditStyle.SpinButtons;
                //repositoryItemDateEdit.VistaTimeProperties.EditFormat.FormatType = FormatType.DateTime;
                //repositoryItemDateEdit.VistaTimeProperties.EditFormat.FormatString = "HH:mm:ss";
                //repositoryItemDateEdit.VistaTimeProperties.DisplayFormat.FormatType = FormatType.DateTime;
                //repositoryItemDateEdit.VistaTimeProperties.DisplayFormat.FormatString = "HH:mm:ss";
                //repositoryItemDateEdit.VistaTimeProperties.Mask.UseMaskAsDisplayFormat = true;
                //repositoryItemDateEdit.VistaTimeProperties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime;
                //repositoryItemDateEdit.VistaTimeProperties.Mask.EditMask = "HH:mm:ss";

                //repositoryItemDateEdit.DisplayFormat.FormatString = "d";
                //repositoryItemDateEdit.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom;
                repositoryItemDateEdit.Mask.EditMask = "yyyy-MM-dd HH:mm:ss";
                repositoryItemDateEdit.Name = "repositoryItemDateEdit1";

                //repositoryItemDateEdit.ReadOnly = bIsReadOnly;
                //repositoryItemDateEdit.ShowToday = bIsShowToDay;
                //repositoryItemDateEdit.ShowClear = bIsShowClear;

                //repositoryItemDateEdit.VistaTimeProperties.
                this.gridView1.Columns[gridColumn.AbsoluteIndex].ColumnEdit = repositoryItemDateEdit;
            }
        }

        /// <summary>
        /// Set row checked.
        /// </summary>
        /// <param name="indexs"></param>
        public void SetCheckRow(params int[] indexs)
        {
            if (this.CheckMarkSelection == null) return;

            for (int i = 0; i < indexs.Length; i++)
            {
                this.CheckMarkSelection.SelectRow(indexs[i], true);
            }
        }

        /// <summary>
        /// Set visible property for columns
        /// </summary>
        /// <param name="fieldNames"></param>
        public void VisibleColumns(string[] fieldNames)
        {
            VisibleColumns(fieldNames, null, null);
        }

        /// <summary>
        /// Set visible,caption property for columns
        /// </summary>
        /// <param name="fieldNames"></param>
        /// <param name="captions"></param>
        public void VisibleColumns(string[] fieldNames, string[] captions)
        {
            VisibleColumns(fieldNames, captions, null);
        }

        /// <summary>
        /// Set visible,caption,width property for columns
        /// </summary>
        /// <param name="fieldNames"></param>
        /// <param name="captions"></param>
        /// <param name="widths"></param>
        public void VisibleColumns(string[] fieldNames, string[] captions, int[] widths)
        {
            GridView gridView = (GridView)gridControl1.Views[0];

            if (captions != null)
            {
                if (fieldNames.Length != captions.Length)
                {
                    throw new ArgumentOutOfRangeException("FieldNames,CaptionNames", "Two arrays mismatch length");
                }
            }

            if (widths != null)
            {
                if (fieldNames.Length != widths.Length)
                {
                    throw new ArgumentOutOfRangeException("FieldNames,Widths", "Two arrays mismatch length");
                }
            }

            if (gridView.Columns.Count == 0) return;

            for (int i = 0; i < gridView.Columns.Count; i++)
            {
                gridView.Columns[i].Visible = false;
            }

            for (int j = 0; j < fieldNames.Length; j++)
            {
                try
                {
                    gridView.Columns[fieldNames[j].ToUpper()].Visible = true;
                    gridView.Columns[fieldNames[j].ToUpper()].VisibleIndex = j + 100;
                    if (captions != null) gridView.Columns[fieldNames[j].ToUpper()].Caption = captions[j];
                    if (widths != null) gridView.Columns[fieldNames[j].ToUpper()].Width = widths[j];
                }
                catch
                {
                }
            }
        }

        /// <summary>
        /// Set inVisible Columns
        /// </summary>
        /// <param name="fieldNames"></param>
        public void inVisibleColumns(string[] fieldNames)
        {
            GridView gridView = (GridView)gridControl1.Views[0];

            if (gridView.Columns.Count == 0) return;

            for (int j = 0; j < fieldNames.Length; j++)
            {
                try
                {
                    gridView.Columns[fieldNames[j].ToUpper()].Visible = false;
                    //gridView.Columns[fieldNames[j].ToUpper()].VisibleIndex = j + 100;
                }
                catch
                {
                }
            }
        }

        /// <summary>
        /// Set merged column info
        /// </summary>
        /// <param name="_beMergedColumns"></param>
        /// <param name="_MergedHeaderColumnText"></param>
        public void setMergedColumnInfo(string[] _beMergedColumns, string _MergedHeaderColumnText)
        {
            //2014-08-13 김정민 추가
            //중첩헤더를 추가한다. (_beMergedColumns : 중첩된 헤더를 붙일 컬럼들 // _MergedHeaderColumnText : 중첩헤더의 caption
            try
            {
                this.MergedColumnInfos.Add(new MergedColumnInfo(_beMergedColumns, _MergedHeaderColumnText, gridView1));
                this.Refresh();

                foreach (DevExpress.XtraGrid.Columns.GridColumn column in gridView1.Columns)
                {
                    for (int i = 0; i < _beMergedColumns.Length; i++)
                    {
                        if (column.FieldName == _beMergedColumns[i].ToString())
                        {
                            column.AppearanceHeader.Options.UseTextOptions = true;
                            column.AppearanceHeader.TextOptions.VAlignment = VertAlignment.Bottom;
                            column.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
                        }
                    }
                }
            }
            catch
            {
            }
        }

        /// <summary>
        /// 중첩 헤더 설정
        /// </summary>
        /// <param name="_beMergedColumns">중첩될 컬럼들</param>
        /// <param name="_MergedHeaderColumnText">중첩헤더의 caption</param>
        /// <param name="Alignment">헤더 정렬</param>
        public void setMergedColumnInfo(string[] _beMergedColumns, string _MergedHeaderColumnText, DevExpress.Utils.HorzAlignment Alignment)
        {
            setMergedColumnInfo(_beMergedColumns, _MergedHeaderColumnText);

            foreach (string column in _beMergedColumns)
            {
                gridView1.Columns[column].AppearanceHeader.TextOptions.HAlignment = Alignment;
            }
        }

        #endregion Method

        #region Property

        public string DefaultNumericFormat
        {
            get
            {
                return defaultNumericFormat;
            }
            set
            {
                defaultNumericFormat = value;
            }
        }

        public string DefaultDateFormat
        {
            get
            {
                return defaultDateFormat;
            }
            set
            {
                defaultDateFormat = value;
            }
        }

        public bool IsEnterKeyEvent
        {
            get
            {
                return isEnterKeyEvent;
            }
            set
            {
                isEnterKeyEvent = value;
            }
        }

        //[Category("DisplayText"), Description("Display tabpage text")]
        //public String DisplayText
        //{
        //    get
        //    {
        //        return text;
        //    }
        //    set
        //    {
        //        //this.xtraTabPage1.Text = value;
        //        //text = value;

        //        text = value;

        //        string temp = value;
        //        string nlsName = Regex.Replace(temp, @"\s", "");
        //        nlsName = NLSService.GetNLSTab(nlsName);
        //        if (!string.IsNullOrEmpty(nlsName)) temp = nlsName;
        //        this.xtraTabPage1.Text = temp;

        //    }
        //}

        //[Description("show/hide tabpage header")]
        //[DefaultValue(DefaultBoolean.Default)]
        //public DefaultBoolean ShowTabHeader
        //{
        //    get
        //    {
        //        return isShowHeader;
        //    }
        //    set
        //    {
        //        isShowHeader = value;
        //        xtraTabControl1.ShowTabHeader = isShowHeader;
        //    }
        //}

        public GridCheckMarksSelection CheckMarkSelection
        {
            get
            {
                return selection;
            }
            set
            {
                selection = value;
            }
        }

        public GridRowStateHelper RowStateHelper
        {
            get
            {
                return rowStateHelper;
            }
        }

        #endregion Property

        /// <summary>
        /// Set column Property
        /// </summary>
        /// <param name="column"></param>
        /// <param name="Format"></param>
        /// <param name="Alignment"></param>
        public void SetColumn(string column, string Format, HorzAlignment Alignment)
        {   // 그리드 컬럼 속성 수정 포멧,가로 정렬2014.09.01 이승현
            this.GetGridView().Columns[column].DisplayFormat.FormatType = FormatType.Custom;
            this.GetGridView().Columns[column].DisplayFormat.FormatString = Format;
            this.GetGridView().Columns[column].AppearanceCell.TextOptions.HAlignment = Alignment;
        }

        /// <summary>
        /// Set Column Property
        /// </summary>
        /// <param name="column"></param>
        /// <param name="Format"></param>
        /// <param name="Alignment"></param>
        /// <param name="Width"></param>
        public void SetColumn(string column, string Format, HorzAlignment Alignment, int Width)
        {   // 그리드 컬럼 속성 수정 포멧,가로 정렬2014.09.01 이승현
            this.GetGridView().Columns[column].DisplayFormat.FormatType = FormatType.Custom;
            this.GetGridView().Columns[column].DisplayFormat.FormatString = Format;
            this.GetGridView().Columns[column].AppearanceCell.TextOptions.HAlignment = Alignment;
            this.GetGridView().Columns[column].Width = Width;
        }

        /// <summary>
        /// Set Columns Property
        /// </summary>
        /// <param name="columns"></param>
        /// <param name="Format"></param>
        /// <param name="Alignment"></param>
        /// <param name="Width"></param>
        public void SetColumn(string[] columns, string Format, HorzAlignment Alignment, int Width)
        {   // 그리드 컬럼 속성 수정 포멧,가로 정렬2014.09.26 이승현
            foreach (string column in columns)
            {
                this.GetGridView().Columns[column].DisplayFormat.FormatType = FormatType.Custom;
                this.GetGridView().Columns[column].DisplayFormat.FormatString = Format;
                this.GetGridView().Columns[column].AppearanceCell.TextOptions.HAlignment = Alignment;
                this.GetGridView().Columns[column].Width = Width;
            }
        }

        /// <summary>
        /// Set Columns Property
        /// </summary>
        /// <param name="columns"></param>
        /// <param name="formattype"></param>
        /// <param name="Format"></param>
        /// <param name="Alignment"></param>
        /// <param name="Width"></param>
        public void SetColumn(string[] columns, FormatType formattype, string Format, HorzAlignment Alignment, int Width)
        {   // 그리드 컬럼 속성 수정 포멧,가로 정렬2014.09.26 이승현
            foreach (string column in columns)
            {
                this.GetGridView().Columns[column].DisplayFormat.FormatType = formattype;
                this.GetGridView().Columns[column].DisplayFormat.FormatString = Format;
                this.GetGridView().Columns[column].AppearanceCell.TextOptions.HAlignment = Alignment;
                this.GetGridView().Columns[column].Width = Width;
            }
        }

        /// <summary>
        /// Set Columns Property
        /// </summary>
        /// <param name="columns"></param>
        /// <param name="formattype"></param>
        /// <param name="Format"></param>
        /// <param name="Alignment"></param>
        /// <param name="Width"></param>
        public void SetColumn(string[] columns, FormatType formattype, string Format, HorzAlignment Alignment)
        {
            foreach (string column in columns)
            {
                this.GetGridView().Columns[column].DisplayFormat.FormatType = formattype;
                this.GetGridView().Columns[column].DisplayFormat.FormatString = Format;
                this.GetGridView().Columns[column].AppearanceCell.TextOptions.HAlignment = Alignment;
            }
        }

        /// <summary>
        /// Set Columns Property
        /// </summary>
        /// <param name="columns"></param>
        /// <param name="Format"></param>
        /// <param name="Alignment"></param>
        /// <param name="Width"></param>
        public void SetColumn(string[] columns, string Format, HorzAlignment Alignment)
        {   // 그리드 컬럼 속성 수정 포멧,가로 정렬2014.09.26 이승현
            foreach (string column in columns)
            {
                this.GetGridView().Columns[column].DisplayFormat.FormatType = FormatType.Custom;
                this.GetGridView().Columns[column].DisplayFormat.FormatString = Format;
                this.GetGridView().Columns[column].AppearanceCell.TextOptions.HAlignment = Alignment;
            }
        }

        /// <summary>
        /// Set column Property
        /// </summary>
        /// <param name="column"></param>
        /// <param name="Format"></param>
        /// <param name="Alignment"></param>
        public void SetColumn(int columnindex, string Format, HorzAlignment Alignment)
        {   // 그리드 컬럼 속성 수정 포멧,가로 정렬2014.09.01 이승현
            this.GetGridView().Columns[columnindex].DisplayFormat.FormatType = FormatType.Custom;
            this.GetGridView().Columns[columnindex].DisplayFormat.FormatString = Format;
            this.GetGridView().Columns[columnindex].AppearanceCell.TextOptions.HAlignment = Alignment;
        }

        /// <summary>
        /// Set Column Property
        /// </summary>
        /// <param name="columnindex"></param>
        /// <param name="Format"></param>
        /// <param name="Alignment"></param>
        /// <param name="Width"></param>
        public void SetColumn(int columnindex, string Format, HorzAlignment Alignment, int Width)
        {   // 그리드 컬럼 속성 수정 포멧,가로 정렬2014.09.01 이승현
            this.GetGridView().Columns[columnindex].DisplayFormat.FormatType = FormatType.Custom;
            this.GetGridView().Columns[columnindex].DisplayFormat.FormatString = Format;
            this.GetGridView().Columns[columnindex].AppearanceCell.TextOptions.HAlignment = Alignment;
            this.GetGridView().Columns[columnindex].Width = Width;
        }

        /// <summary>
        /// Set columnHeader Property
        /// 헤더의 정렬과 높이를 설정
        /// </summary>
        /// <param name="Alignment"></param>
        /// <param name="Height"></param>
        public void SetColumnHeader(HorzAlignment Alignment, int Height)
        {   // 그리드 헤더 속성 수정 정렬, 높이 2014.09.01 이승현
            this.GetGridView().Appearance.HeaderPanel.TextOptions.HAlignment = Alignment;
            if (Height > 0)
            {
                this.GetGridView().ColumnPanelRowHeight = Height;
            }

            this.GetGridView().Appearance.HeaderPanel.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        }

        /// <summary>
        /// Set columnHeader Font Property
        /// 헤더의 폰트 수정
        /// </summary>
        /// <param name="Alignment"></param>
        /// <param name="Height"></param>
        public void SetColumnHeaderFont(string[] Columns, string fontname, FontStyle style, Single size, Color color)
        {    // 그리드 헤더 FONT 수정 2014.09.01 이승현
            //grdInspectList.GetGridView().Columns["1"].AppearanceHeader.Font

            foreach (string str in Columns)
            {
                if (string.IsNullOrEmpty(fontname))
                {
                    fontname = this.GetGridView().Columns[str].AppearanceHeader.Font.FontFamily.ToString();
                }
                if (size == null || size == 0)
                {
                    size = this.GetGridView().Columns[str].AppearanceHeader.Font.Size;
                }

                this.GetGridView().Columns[str].AppearanceHeader.Font = new System.Drawing.Font(fontname, size, style);
                this.GetGridView().Columns[str].AppearanceHeader.ForeColor = color;
            }
        }

        public Dictionary<string, string> GetallChecked()
        {
            return allChecked;
        }

        private void gridView1_InvalidRowException(object sender, InvalidRowExceptionEventArgs e)
        {
            e.ExceptionMode = ExceptionMode.NoAction;
            //e.ExceptionMode = ExceptionMode.DisplayError;
        }




    }

    public class MergedColumnInfo
    {
        //2014-08-13 김정민 추가.
        //중첩 헤더 추가용 클래스
        public string[] strbeMergedColumns;

        public string MergedHeaderColumnText
        {
            get;
            set;
        }

        public int LocationX
        {
            get;
            set;
        }

        public int LocationY
        {
            get;
            set;
        }

        public int sizeX
        {
            get;
            set;
        }

        public int sizeY
        {
            get;
            set;
        }

        public int lastColumnIndex
        {
            get;
            set;
        }

        public MergedColumnInfo(string[] _beMergedColumns, string _MergedHeaderColumnText, DevExpress.XtraGrid.Views.Grid.GridView gridview)
        {
            this.strbeMergedColumns = _beMergedColumns;
            this.MergedHeaderColumnText = _MergedHeaderColumnText;

            lastColumnIndex = 0;
            sizeX = 0;
            if (_beMergedColumns.Length != 0)
            {
                for (int i = 0; i < _beMergedColumns.Length; i++)
                {
                    if (lastColumnIndex < gridview.Columns[_beMergedColumns[i].ToString()].VisibleIndex)
                    {
                        lastColumnIndex = gridview.Columns[_beMergedColumns[i].ToString()].VisibleIndex;
                    }
                    sizeX = sizeX + gridview.Columns[_beMergedColumns[i].ToString()].VisibleWidth;
                }
            }
        }

    }
}
                        
;