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 AlarmManager : CommonMDI { public AlarmManager() { InitializeComponent(); this.Shown += (sender, e) => { try { SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD) }; ResultData result = ClientClass.GetData("GetRoutingManager", aParam); if (result.isError) { throw new Exception(result.ResultValue); } UtilClass.SetLookup(repositoryItemLookUpEdit_ROUT_CD, result.TableData, "ROUT_CD", "ROUT_NM", true, true); } catch (Exception ex) { XtraMessageBox.Show(ex.Message); } searchProc(); }; gridView_Main.FocusedRowChanged += (sender, e) => { }; } 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) }; ResultData result = ClientClass.GetData("GetAlarmManager", aParam); if (result.isError) { throw new Exception(result.ResultValue); } gridControl_Main.DataSource = result.TableData; this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; XtraMessageBox.Show(ex.Message); } } public override void newProc() { gridView_Main.PostEditor(); gridView_Main.UpdateCurrentRow(); gridView_Main.AddNewRow(); gridView_Main.GetFocusedDataRow()["COMP_CD"] = ConstClass._COMP_CD; 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_FIELD = 'Y'"); if (rows == null || rows.Length < 1) { XtraMessageBox.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", "ALARM_MSG", "DISPLAY_YN" ); 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("공정이 입력되지 않은 데이터가 있습니다."); } } 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("SaveAlarmManager", dataList, aParam); if (result.isError) { throw new Exception(result.ResultValue); } XtraMessageBox.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; XtraMessageBox.Show(ex.Message); } } } }