using ClientLib; using ClientLib.CommonService; 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.Linq; using System.Net; using System.Text; using System.Windows.Forms; namespace HANMI_STD { public partial class CustUserManager : PublicLib.CommonMDI { public CustUserManager() { InitializeComponent(); textEdit_Search.ImeMode = System.Windows.Forms.ImeMode.Alpha; textEdit_Search.KeyPress += (sender, e) => { if (e.KeyChar == '\r') { searchProc(); } }; gridView_Main.DoubleClick += (sender, e) => { Point aPT = gridControl_Main.PointToClient(Control.MousePosition); GridHitInfo aInfo = gridView_Main.CalcHitInfo(aPT); if (aInfo.InRowCell) { updateProc(); } }; repositoryItemButtonEdit_POST_NO.ButtonClick += (sender, e) => { DataRow row = gridView_Main.GetFocusedDataRow(); if (row == null) { return; } PostNoForm form = new PostNoForm(); if (form.ShowDialog() == DialogResult.Yes) { row["POST_NO"] = form.ResultRow["POST_NO"]; row["ADDR1"] = form.ResultRow["ADDR1"]; gridView_Main.FocusedColumn = gridView_Main.Columns["BIZ_NO"]; } }; this.Shown += (sender, e) => { searchProc(); }; } public override void searchProc() { try { this.Cursor = Cursors.WaitCursor; gridControl_Main.DataSource = null; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD), ClientClass.CreateSqlParameter("SEARCH", SqlDbType.NVarChar, textEdit_Search.Text) }; ResultData resultData = ClientClass.GetData("GetCustUserManager", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } gridControl_Main.DataSource = resultData.TableData; this.Cursor = Cursors.Arrow; } catch (Exception ex) { m_Searching = false; this.Cursor = Cursors.Arrow; XtraMessageBox.Show(ex.Message); } } public override void newProc() { CustUserManagerPopup form = new CustUserManagerPopup(); string str = form.initProc(""); if (!UtilClass.isNull(str)) { XtraMessageBox.Show(str); return; } if (form.ShowDialog() == DialogResult.Yes) { searchProc(); } } public override void updateProc() { DataRow row = gridView_Main.GetFocusedDataRow(); if (row == null) { return; } string usr_id = UtilClass.toStr(row["USR_ID"]); CustUserManagerPopup form = new CustUserManagerPopup(); string str = form.initProc(usr_id); if (!UtilClass.isNull(str)) { XtraMessageBox.Show(str); return; } if (form.ShowDialog() == DialogResult.Yes) { searchProc(); for (int i = 0; i < gridView_Main.RowCount; i++) { if (UtilClass.isEqual(gridView_Main.GetDataRow(i)["USR_ID"], usr_id)) { gridView_Main.FocusedRowHandle = i; break; } } } } public override void saveProc() { try { if (gridControl_Main.DataSource == null) { return; } this.Cursor = Cursors.WaitCursor; gridView_Main.PostEditor(); gridView_Main.UpdateCurrentRow(); Application.DoEvents(); DataRow row = gridView_Main.GetFocusedDataRow(); string usr_id = ""; if (row != null) { usr_id = UtilClass.toStr(row["USR_ID"]); } DataTable aData = gridControl_Main.DataSource as DataTable; ResultData[] dataList = null; ResultData data1 = new ResultData(); DataTable dtData1 = UtilClass.GetDataTable(aData, true, "COMP_CD", "CUST_CD", "USR_ID", "USR_NM", "USR_PWD", "TEL_NO", "POST_NO", "ADDR1", "BIZ_NO", "DEL_YN" ); dtData1.TableName = "ADATA"; data1.TableData = dtData1; dataList = new ResultData[] { data1 }; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID), ClientClass.CreateSqlParameter("RESULT_STR", SqlDbType.NVarChar, "", ParameterDirection.Output, 1000) }; ResultData result = ClientClass.SetTableData("SaveCustUserManager", dataList, aParam); if (result.isError || !UtilClass.isNull(result.ResultValue)) { throw new Exception(result.ResultValue); } this.Cursor = Cursors.Arrow; XtraMessageBox.Show("정상적으로 저장하였습니다."); searchProc(); if (!UtilClass.isNull(usr_id)) { for (int i = 0; i < gridView_Main.RowCount; i++) { if (UtilClass.isEqual(usr_id, gridView_Main.GetDataRow(i)["USR_ID"])) { gridView_Main.FocusedRowHandle = i; break; } } } } catch (Exception ex) { this.Cursor = Cursors.Arrow; XtraMessageBox.Show(ex.Message); } } public override void deleteProc() { gridView_Main.PostEditor(); gridView_Main.UpdateCurrentRow(); Application.DoEvents(); DataTable data = gridControl_Main.DataSource as DataTable; DataRow[] rows = data.Select("SEL_FIELD = 'Y'"); if (rows == null || rows.Length < 1) { XtraMessageBox.Show("삭제할 항목을 선택하십시오."); return; } foreach (DataRow row in rows) { row.Delete(); } } public override void excelProc() { ExportExcelGrid(gridControl_Main); } } }