using ClientLib; using ClientLib.CommonService2; using DevExpress.XtraEditors; using DevExpress.XtraTreeList; using DevExpress.XtraTreeList.Nodes; 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.Text; using System.Windows.Forms; namespace HANMI_STD { public partial class BankManager : CommonMDI { public BankManager() { InitializeComponent(); DataView bankCD = new DataView(ConstClass._DATA); bankCD.RowFilter = "CATE_CD = 'C' and GRP_CD = 'C04'"; UtilClass.SetLookup(repositoryItemLookUpEdit_BANK_CD, bankCD, "NO_CD", "NO_CD_NM", true); this.Shown += (sender, e) => { setLookup(); searchProc(); }; } private void setLookup() { try { ResultData resultData = ClientClass.GetData("GetCompanyList", null); if (resultData.isError) { throw new Exception(resultData.ResultValue); } UtilClass.SetLookup(lookUpEdit_COMP_CD, resultData.TableData, "COMP_CD", "COMP_NM", true); } catch (Exception ex) { MessageBox.Show(ex.Message); } } public override void searchProc() { try { this.Cursor = Cursors.WaitCursor; gridControl_Main.DataSource = null; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, UtilClass.toStr(lookUpEdit_COMP_CD.EditValue)), ClientClass.CreateSqlParameter("SEARCH", SqlDbType.NVarChar, textEdit_Search.Text) }; ResultData result = ClientClass.GetData("GetBankManager", aParam); if (result.isError) { throw new Exception(result.ResultValue); } gridControl_Main.DataSource = result.TableData; lookUpEdit_COMP_CD.Tag = lookUpEdit_COMP_CD.EditValue; this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } public override void refreshProc() { setLookup(); } public override void newProc() { gridView_Main.PostEditor(); gridView_Main.UpdateCurrentRow(); gridView_Main.AddNewRow(); gridView_Main.GetFocusedDataRow()["COMP_CD"] = lookUpEdit_COMP_CD.Tag; gridView_Main.Focus(); gridView_Main.FocusedColumn = gridView_Main.Columns["BANK_CD"]; } 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) { MessageBox.Show("삭제할 항목을 선택하십시오."); return; } foreach (DataRow row in rows) { row.Delete(); } } 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 acc_no = ""; if (row != null) { acc_no = UtilClass.toStr(row["ACC_NO"]); } DataTable aData = gridControl_Main.DataSource as DataTable; ResultData[] dataList = null; ResultData data1 = new ResultData(); DataTable dtData1 = UtilClass.GetDataTable(aData, true, "BANK_SEQ", "BANK_CD", "ACC_NO", "ACC_NM", "OPEN_DATE", "END_DATE", "FEE_RATE", "OPEN_MY", "MM_IN_MY", "IN_DD" ); dtData1.TableName = "ADATA"; data1.TableData = dtData1; for (int i = 0; i < dtData1.Rows.Count; i++) { if (UtilClass.isNull(dtData1.Rows[i]["BANK_CD"])) { throw new Exception("금융기관을 입력하세요."); } if (UtilClass.isNull(dtData1.Rows[i]["ACC_NO"])) { throw new Exception("예금계좌번호를 입력하세요."); } } dataList = new ResultData[] { data1 }; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, lookUpEdit_COMP_CD.Tag), ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID), ClientClass.CreateSqlParameter("RESULT_STR", SqlDbType.NVarChar, "", ParameterDirection.Output, 1000) }; ResultData result = ClientClass.SetTableData("SaveBankManager", dataList, aParam); if (result.isError) { throw new Exception(result.ResultValue); } MessageBox.Show("정상적으로 저장하였습니다."); searchProc(); if (!UtilClass.isNull(acc_no)) { for (int i = 0; i < gridView_Main.RowCount; i++) { if (UtilClass.isEqual(acc_no, gridView_Main.GetDataRow(i)["ACC_NO"])) { gridView_Main.FocusedRowHandle = i; break; } } } this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } } }