using ClientLib; using ClientLib.CommonService2; 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 CustBaseManager : PublicLib.CommonMDI { public CustBaseManager() { InitializeComponent(); spinEdit_YY.Value = 2018; // DateTime.Now.Year; spinEdit_MM.Value = 12; // DateTime.Now.Month; textEdit_Search.KeyPress += (sender, e) => { if (e.KeyChar == '\r') { searchProc(); } }; spinEdit_MM.ButtonClick += (sender, e) => { }; gridView_Main.FocusedRowChanged += (sender, e) => { DataRow aRow = gridView_Main.GetFocusedDataRow(); gridView_Main.Columns["YYMM"].OptionsColumn.AllowEdit = (aRow != null) && (aRow.RowState == DataRowState.Added || aRow.RowState == DataRowState.Detached); }; 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("YYMM", SqlDbType.NVarChar, spinEdit_YY.Value.ToString("0000") + "-" + spinEdit_MM.Value.ToString("00")), ClientClass.CreateSqlParameter("SEARCH", SqlDbType.NVarChar, textEdit_Search.Text) }; ResultData resultData = ClientClass.GetData("GetCustBaseManager", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } gridControl_Main.DataSource = resultData.TableData; this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } public override void newProc() { gridView_Main.PostEditor(); gridView_Main.UpdateCurrentRow(); gridView_Main.AddNewRow(); gridView_Main.Focus(); gridView_Main.FocusedColumn = gridView_Main.Columns["YYMM"]; } 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 cust_cd = ""; if (row != null) { cust_cd = UtilClass.toStr(row["CUST_CD"]); } DataTable aData = gridControl_Main.DataSource as DataTable; ResultData[] dataList = null; ResultData data1 = new ResultData(); DataTable dtData1 = UtilClass.GetDataTable(aData, true, "COMP_CD", "CUST_CD", "YYMM", "CLOSE_DATE", "BASE_MY" ); dtData1.TableName = "ADATA"; data1.TableData = dtData1; for (int i = 0; i < dtData1.Rows.Count; i++) { if (UtilClass.isNull(dtData1.Rows[i]["YYMM"])) { throw new Exception("기준연월을 입력하지 않았습니다."); } } dataList = new ResultData[] { data1 }; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD), ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID), ClientClass.CreateSqlParameter("RESULT_STR", SqlDbType.NVarChar, "", ParameterDirection.Output, 1000) }; ResultData result = ClientClass.SetTableData("SaveCustBaseManager", dataList, aParam); if (result.isError || !UtilClass.isNull(result.ResultValue)) { throw new Exception(result.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 excelProc() { this.ExportExcelGrid(gridControl_Main); } } }