using ClientLib; using ClientLib.CommonService2; using DevExpress.XtraGrid.Views.Grid.ViewInfo; using DevExpress.XtraGrid.Views.Base; using DevExpress.XtraEditors; 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_MACH { public partial class MachASManager : PublicLib.CommonMDI { private DataView m_MATView; public MachASManager() { InitializeComponent(); dateEdit_SDATE.DateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM") + "-01"); dateEdit_FDATE.DateTime = DateTime.Now; textEdit_Search.KeyPress += (sender, e) => { if (e.KeyChar == '\r') { searchProc(); } }; ////AS태 구분 DataView fab_kind_cd = new DataView(ConstClass._DATA); fab_kind_cd.RowFilter = "CATE_CD = 'E' and GRP_CD = 'E02'"; UtilClass.SetLookup(replookedit_AS_KIND, fab_kind_cd, "NO_CD", "NO_CD_NM", true); gridView_Main.ShownEditor += (sender, e) => { if (gridView_Main.FocusedColumn.FieldName == "MAT_CD") { DataRow row = gridView_Main.GetFocusedDataRow(); //gridView_Main.Columns["MACH_CD"].OptionsColumn.AllowEdit = row != null && (row.RowState == DataRowState.Added || row.RowState == DataRowState.Detached); LookUpEdit editor = (LookUpEdit)gridView_Main.ActiveEditor; if (row != null) { if (m_MATView != null) { m_MATView.RowFilter = " MACH_CD = '" + UtilClass.toStr(row["MACH_CD"]) + "'"; string MAT ; MAT = UtilClass.toStr(row["MAT_CD"]); UtilClass.SetLookup(editor, m_MATView, "MAT_CD", "MAT_NM", true); editor.EditValue = MAT; } } }; m_MATView.RowFilter = ""; }; this.Shown += (sender, e) => { try { lookUpEdit_MACH_CD.Properties.DataSource = null; if (UtilClass.isNull(ConstClass._COMP_CD)) { return; } this.Cursor = Cursors.WaitCursor; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, ConstClass._COMP_CD) }; ResultData resultMACH = ClientClass.GetData("getMachineForLookup", aParam); if (resultMACH.isError) { throw new Exception(resultMACH.ResultValue); } UtilClass.SetLookup(lookUpEdit_MACH_CD, resultMACH.DataList.Tables[0], "MACH_CD", "MACH_NM", true); UtilClass.SetLookup(replookedit_MACH_CD, resultMACH.DataList.Tables[0], "MACH_CD", "MACH_NM", true); m_MATView = new DataView(resultMACH.DataList.Tables[2]); UtilClass.SetLookup(replookedit_MAT_CD, m_MATView, "MAT_CD", "MAT_NM", true); this.Cursor = Cursors.Arrow; searchProc(); } catch (Exception ex) { MessageBox.Show(ex.Message); this.Close(); } }; } 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("MACH_CD", SqlDbType.NVarChar, lookUpEdit_MACH_CD.EditValue), ClientClass.CreateSqlParameter("SDATE", SqlDbType.NVarChar, checkEdit_PO_DATE.Checked ? dateEdit_SDATE.DateTime.ToString("yyyy-MM-dd") : ""), ClientClass.CreateSqlParameter("FDATE", SqlDbType.NVarChar, dateEdit_FDATE.DateTime.ToString("yyyy-MM-dd")), ClientClass.CreateSqlParameter("SEARCH", SqlDbType.NVarChar, textEdit_Search.Text) }; ResultData resultData = ClientClass.GetData("GetMachASManager", aParam); if (resultData.isError) { throw new Exception(resultData.ResultValue); } gridControl_Main.DataSource = resultData.TableData; lookUpEdit_MACH_CD.Tag = lookUpEdit_MACH_CD.EditValue; this.Cursor = Cursors.Arrow; } catch (Exception ex) { this.Cursor = Cursors.Arrow; MessageBox.Show(ex.Message); } } public override void newProc() { MachASManagerPopup form = new MachASManagerPopup(UtilClass.toStr(ConstClass._COMP_CD), UtilClass.toStr(lookUpEdit_MACH_CD.Tag)); if (form.ShowDialog() == DialogResult.Yes) { // lookUpEdit_COMP_CD.EditValue = m_COMP_CD; searchProc(); gridView_Main.FocusedRowHandle = gridView_Main.RowCount - 1; } } public override void updateProc() { } 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 { this.Cursor = Cursors.WaitCursor; gridView_Main.PostEditor(); gridView_Main.UpdateCurrentRow(); Application.DoEvents(); DataRow row = gridView_Main.GetFocusedDataRow(); //string item_cd = ""; //if (row != null) //{ // item_cd = UtilClass.toStr(row["ITEM_CD"]); //} DataTable aData = gridControl_Main.DataSource as DataTable; ResultData[] dataList = null; ResultData data1 = new ResultData(); DataTable dtData1 = UtilClass.GetDataTable(aData, true, "COMP_CD", "MACH_CD", "AS_DT", "AS_SEQ", "AS_KIND_CD", "MAT_CD", "AS_CUSTNM", "AS_TEL", "AS_MANAGER", "AS_MANAGERTEL", "AS_MY", "AS_VAT_MY", "AS_SUM_MY", "AS_WORK_DESC", "AS_M_RMK"); dtData1.TableName = "ADATA"; data1.TableData = dtData1; dataList = new ResultData[] { data1 }; SerializedSqlParam[] aParam = new SerializedSqlParam[] { ClientClass.CreateSqlParameter("REG_ID", SqlDbType.NVarChar, ConstClass._USR_ID), ClientClass.CreateSqlParameter("RESULT_STR", SqlDbType.NVarChar, "", ParameterDirection.Output, 1000) }; ResultData result = ClientClass.SetTableData("SaveMachineASManager", dataList, aParam); if (result.isError || !UtilClass.isNull(result.ResultValue)) { throw new Exception(result.ResultValue); } this.Cursor = Cursors.Arrow; MessageBox.Show("정상적으로 저장하였습니다."); searchProc(); //if (!UtilClass.isNull(item_cd)) //{ // for (int i = 0; i < gridView_Main.RowCount; i++) // { // if (UtilClass.isEqual(item_cd, gridView_Main.GetDataRow(i)["ITEM_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); } private void repLOOKUP_FACT_Popup(object sender, EventArgs e) { } private void gridControl_Main_Click(object sender, EventArgs e) { } } }