using ClientLib; using ClientLib.CommonService2; using DevExpress.XtraEditors; using DevExpress.XtraGrid.Views.Grid.ViewInfo; using PublicLib; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Reflection; using System.Text; using System.Threading; using System.Windows.Forms; namespace HANMI_SALE { partial class SelectBillCustForm : XtraForm { private DataView m_View; public DataTable m_Data, m_Det; public SelectBillCustForm(DataTable data) { InitializeComponent(); m_Data = null; m_View = new DataView(data); m_Det = data.Clone(); gridControl_Main.DataSource = m_View; gridControl_Det.DataSource = m_Det; simpleButton_Add.Click += (sender, e) => { AddCustomerProc(); }; gridView_Main.DoubleClick += (sender, e) => { Point aPT = gridControl_Main.PointToClient(Control.MousePosition); GridHitInfo aInfo = gridView_Main.CalcHitInfo(aPT); if (aInfo.InRowCell) { DataRow row = gridView_Main.GetFocusedDataRow(); row["SEL_FIELD"] = "Y"; AddCustomerProc(); row["SEL_FIELD"] = "N"; } }; simpleButton_Delete.Click += (sender, e) => { int ii = 0; while (ii < m_Det.Rows.Count) { if (UtilClass.isEqual(m_Det.Rows[ii]["SEL_FIELD"], "Y")) { m_Det.Rows.RemoveAt(ii); } else { ii++; } } }; simpleButton_Cancel.Click += (sender, e) => { this.DialogResult = DialogResult.Cancel; this.Close(); }; simpleButton_OK.Click += (sender, e) => { if (gridControl_Main.DataSource == null) { return; } m_Data = m_Det.Copy(); foreach (DataRow row in m_Data.Rows) { row["SEL_FIELD"] = "Y"; } this.DialogResult = DialogResult.Yes; this.Close(); }; simpleButton_DetSelectAll.Click += (sender, e) => { try { gridView_Det.BeginDataUpdate(); for (int i = 0; i < m_Det.Rows.Count; i++) { m_Det.Rows[i]["SEL_FIELD"] = "Y"; } } finally { gridView_Det.EndDataUpdate(); } }; simpleButton_DetSelectNone.Click += (sender, e) => { try { gridView_Det.BeginDataUpdate(); for (int i = 0; i < m_Det.Rows.Count; i++) { m_Det.Rows[i]["SEL_FIELD"] = "N"; } } finally { gridView_Det.EndDataUpdate(); } }; simpleButton_SelectAll.Click += (sender, e) => { try { gridView_Main.BeginDataUpdate(); for (int i = 0; i < m_View.Count; i++) { m_View[i]["SEL_FIELD"] = "Y"; } } finally { gridView_Main.EndDataUpdate(); } }; simpleButton_SelectNone.Click += (sender, e) => { try { gridView_Main.BeginDataUpdate(); for (int i = 0; i < m_View.Count; i++) { m_View[i]["SEL_FIELD"] = "N"; } } finally { gridView_Main.EndDataUpdate(); } }; textEdit_Search.EditValueChanged += (sender, e) => { m_View.RowFilter = "CUST_NM like '%" + textEdit_Search.Text.Trim() + "%'"; }; } private void AddCustomerProc() { DataRow row; DataRow[] rows; for (int i = 0; i < m_View.Count; i++) { if (!UtilClass.isEqual(m_View[i]["SEL_FIELD"], "Y")) { continue; } rows = m_Det.Select("CUST_CD = '" + UtilClass.toStr(m_View[i]["CUST_CD"]) + "'"); if (rows != null && rows.Length > 0) { continue; } row = m_Det.NewRow(); row.ItemArray = m_View[i].Row.ItemArray; row["SEL_FIELD"] = "N"; m_Det.Rows.Add(row); } } } }