using ClientLib; using ClientLib.CommonService; using DevExpress.XtraGrid.Views.Grid.ViewInfo; using PublicLib; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace HANMI_STD { public partial class CustManager : PublicLib.CommonMDI { private string m_COMP_CD, m_COMP_NM; public CustManager() { InitializeComponent(); m_COMP_CD = ""; m_COMP_NM = ""; 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"]; row["ADDR2"] = ""; gridView_Main.FocusedColumn = gridView_Main.Columns["ADDR2"]; } }; gridView_Main.CellValueChanged += (sender, e) => { gridView_Main.UpdateCurrentRow(); }; gridView_Main.FocusedRowChanged += (sender, e) => { if (gridControl_Main.DataSource != null) { gridView_Main.PostEditor(); gridView_Main.UpdateCurrentRow(); } }; DataView custKind = new DataView(ConstClass._DATA); custKind.RowFilter = "GRP_CD = 'C06'"; DataView gradeCD = new DataView(ConstClass._DATA); gradeCD.RowFilter = "GRP_CD = 'C07'"; DataView natnCD = new DataView(ConstClass._DATA); natnCD.RowFilter = "GRP_CD = 'C02'"; DataView exch_curr = new DataView(ConstClass._DATA); exch_curr.RowFilter = "GRP_CD = 'C05'"; DataView vatCD = new DataView(ConstClass._DATA); vatCD.RowFilter = "GRP_CD = 'C01'"; UtilClass.SetLookup(repositoryItemLookUpEdit_CUST_KIND, custKind, "NO_CD", "NO_CD_NM", true); UtilClass.SetLookup(repositoryItemLookUpEdit_GRADE_CD, gradeCD, "NO_CD", "NO_CD_NM", true); UtilClass.SetLookup(repositoryItemLookUpEdit_NATN_CD, natnCD, "NO_CD", "NO_CD_NM", true); UtilClass.SetLookup(repositoryItemLookUpEdit_EXCH_CURR, exch_curr, "NO_CD", "NO_CD_NM", true); UtilClass.SetLookup(repositoryItemLookUpEdit_VAT_CD, vatCD, "NO_CD", "NO_CD_NM", true); UtilClass.SetLookup(lookUpEdit_CUST_KIND, custKind, "NO_CD", "NO_CD_NM", true, true); this.Shown += (sender, e) => { try { //ResultData commonResult = ClientClass.GetData("GetCustManagerLookup", null); //if (commonResult.isError) //{ // throw new Exception(commonResult.ResultValue); //} SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("MENU_ID", SqlDbType.NVarChar, this.m_MenuID), ClientClass.CreateSqlParameter("USR_ID", SqlDbType.NVarChar, ConstClass._USR_ID) }; ResultData resultComp = ClientClass.GetData("GetCompanyListByMenuUser", aParam); if (resultComp.isError) { throw new Exception(resultComp.ResultValue); } UtilClass.SetLookup(lookUpEdit_COMP_CD, resultComp.TableData, "COMP_CD", "COMP_NM", true); searchProc(); } catch (Exception ex) { MessageBox.Show(ex.Message); this.Close(); } }; } public override void searchProc() { try { if (UtilClass.isNull(lookUpEdit_COMP_CD.EditValue)) { return; } this.Cursor = Cursors.WaitCursor; gridControl_Main.DataSource = null; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, lookUpEdit_COMP_CD.EditValue), ClientClass.CreateSqlParameter("SEARCH", SqlDbType.NVarChar, textEdit_Search.Text), ClientClass.CreateSqlParameter("CUST_KIND", SqlDbType.NVarChar, lookUpEdit_CUST_KIND.EditValue), ClientClass.CreateSqlParameter("DEAL_YN", SqlDbType.Int, comboBoxEdit_DEAL_YN.SelectedIndex) }; ResultData resultData = ClientClass.GetData("GetCustManager", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } m_COMP_CD = UtilClass.toStr(lookUpEdit_COMP_CD.EditValue); m_COMP_NM = lookUpEdit_COMP_CD.Text.Trim(); gridControl_Main.DataSource = resultData.TableData; this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } public override void newProc() { CustManagerPopup form = new CustManagerPopup(m_COMP_CD); if (form.ShowDialog() == DialogResult.Yes) { lookUpEdit_COMP_CD.EditValue = m_COMP_CD; searchProc(); gridView_Main.FocusedRowHandle = gridView_Main.RowCount - 1; } } //public override void updateProc() //{ // DataRow row = gridView_Main.GetFocusedDataRow(); // if (row == null) // { // return; // } // string cust_cd = UtilClass.toStr(row["CUST_CD"]); // CustManagerPopup form = new CustManagerPopup(m_COMP_CD); // string str = form.setData(m_COMP_NM, cust_cd); // if (!UtilClass.isNull(str)) // { // MessageBox.Show(str); // return; // } // if (form.ShowDialog() == DialogResult.Yes) // { // lookUpEdit_COMP_CD.EditValue = m_COMP_CD; // searchProc(); // for (int i = 0; i < gridView_Main.RowCount; i++) // { // if (UtilClass.isEqual(cust_cd, gridView_Main.GetDataRow(i)["CUST_CD"])) // { // 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 cust_cd = ""; if (row != null) { cust_cd = UtilClass.toStr(row["CUST_CD"]); } DataTable aData = gridControl_Main.DataSource as DataTable; DataTable dtData = UtilClass.GetDataTable(aData, false, "COMP_CD", "CUST_CD", "CUST_KIND", "CUST_NM", "CUST_ENG_NM", "CUST_SMP_NM", "INIT_WORD_NM", "DEAL_YN", "DEAL_START_DT", "DEAL_FINISH_DT", "GRADE_CD", "FORN_YN", "NATN_CD", "EXCH_CURR", "VAT_CD", "POST_NO", "ADDR1", "ADDR2", "TEL_NO", "FAX_NO", "EMAIL", "HOMEPAGE", "BIZ_NO", "OWNER_NM", "OWNER_TEL_NO", "COND_NM", "EVNT_NM", "DEL_YN", "MGR_NM", "MGR_TEL_NO", "MGR_EMAIL", "REMARK" ); if (dtData.Rows.Count < 1) { throw new Exception("변경된 내용이 없습니다."); } dtData.TableName = "ADATA"; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID) }; ResultData data1 = new ResultData(); data1.TableData = dtData; ResultData[] dataList = new ResultData[] { data1 }; ResultData resultData = ClientClass.SetTableData("SaveCustManager2", dataList, aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } this.Cursor = Cursors.Arrow; MessageBox.Show("저장 완료"); searchProc(); if (!UtilClass.isNull(cust_cd)) { for (int i = 0; i < gridView_Main.RowCount; i++) { if (UtilClass.isEqual(cust_cd, gridView_Main.GetDataRow(i)["CUST_CD"])) { gridView_Main.FocusedRowHandle = i; break; } } } } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } public override void deleteProc() { try { DataRow row = gridView_Main.GetFocusedDataRow(); if (row == null) { return; } if (MessageBox.Show("삭제하시겠습니까?", "삭제", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes) { return; } this.Cursor = Cursors.WaitCursor; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, row["COMP_CD"]), ClientClass.CreateSqlParameter("CUST_CD", SqlDbType.NVarChar, row["CUST_CD"]), ClientClass.CreateSqlParameter("RUN_RESULT", SqlDbType.NVarChar, "", ParameterDirection.Output, 1000) }; ResultData result = ClientClass.SetData("DeleteCustManager", aParam); if (result.isError || !UtilClass.isNull(result.ResultValue)) { throw new Exception(result.ResultValue); } this.Cursor = Cursors.Arrow; MessageBox.Show("삭제 완료!"); searchProc(); } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } public override void excelProc() { this.ExportExcelGrid(gridControl_Main); } } }