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 RoutingManager : CommonMDI { public RoutingManager() { InitializeComponent(); this.Shown += (sender, e) => { setLookup(); searchProc(); }; gridView_Main.FocusedRowChanged += (sender, e) => { DataRow row = gridView_Main.GetFocusedDataRow(); gridView_Main.Columns["ROUT_CD"].OptionsColumn.AllowEdit = row != null && (row.RowState == DataRowState.Added || row.RowState == DataRowState.Detached); }; } 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)) }; ResultData result = ClientClass.GetData("GetRoutingManager", 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 newProc() { gridView_Main.PostEditor(); gridView_Main.UpdateCurrentRow(); gridView_Main.AddNewRow(); gridView_Main.GetFocusedDataRow()["COMP_CD"] = lookUpEdit_COMP_CD.Tag; gridView_Main.GetFocusedDataRow()["REG_USER_ID"] = ConstClass._USR_ID; gridView_Main.Focus(); gridView_Main.FocusedColumn = gridView_Main.Columns["ROUT_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_YN = '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 rout_cd = ""; if (row != null) { rout_cd = UtilClass.toStr(row["ROUT_CD"]); } DataTable aData = gridControl_Main.DataSource as DataTable; ResultData[] dataList = null; ResultData data1 = new ResultData(); DataTable dtData1 = UtilClass.GetDataTable(aData, true, "ROUT_CD", "ROUT_NM", "MAJR_MACH_CD", "PRNNO" ); dtData1.TableName = "ADATA"; data1.TableData = dtData1; for (int i = 0; i < dtData1.Rows.Count; i++) { if (UtilClass.isNull(dtData1.Rows[i]["ROUT_CD"])) { throw new Exception("코드가 입력되지 않은 데이터가 있습니다."); } if (UtilClass.isNull(dtData1.Rows[i]["ROUT_NM"])) { throw new Exception(UtilClass.toStr(dtData1.Rows[i]["ROUT_CD"]) + "코드의 코드명이 입력되지 않았습니다."); } } 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("SaveRoutingManager", dataList, aParam); if (result.isError) { throw new Exception(result.ResultValue); } MessageBox.Show("정상적으로 저장하였습니다."); searchProc(); if (!UtilClass.isNull(rout_cd)) { for (int i = 0; i < gridView_Main.RowCount; i++) { if (UtilClass.isEqual(rout_cd, gridView_Main.GetDataRow(i)["ROUT_CD"])) { gridView_Main.FocusedRowHandle = i; break; } } } this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } } }