private void subSaveECList() { try { if (MessageBox.Show("ECID 리스트를 업데이트 합니다.\n양산중인 장비에서 이 기능을 실행하면\n심각한 문제가 발생 할 수 있습니다.\n진행하겠습니까?", "경고", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) return; File.Copy(Application.StartupPath + @"\system\System.mdb", Application.StartupPath + @"\system\System.mdb.bak", true); int dintECID = 0; string dstrECName = string.Empty; Single dsngMin = 0; Single dsngECSLL = 0; Single dsngECWLL = 0; Single dsngECDEF = 0; Single dsngECWUL = 0; Single dsngECSUL = 0; Single dsngMax = 0; //string dstrDesc = string.Empty; bool dbolUse = false; string dstrModuleID = string.Empty; #region "유효성검사" for (int dintLoop = 0; dintLoop < dataGridView1.RowCount -1; dintLoop++) { try { dintECID = Convert.ToInt32(dataGridView1.Rows[dintLoop].Cells[0].Value); dstrECName = dataGridView1.Rows[dintLoop].Cells[1].Value.ToString(); dsngMin = Convert.ToInt32(dataGridView1.Rows[dintLoop].Cells[2].Value); dsngECSLL = Convert.ToSingle(dataGridView1.Rows[dintLoop].Cells[3].Value); dsngECWLL = Convert.ToSingle(dataGridView1.Rows[dintLoop].Cells[4].Value); dsngECDEF = Convert.ToSingle(dataGridView1.Rows[dintLoop].Cells[5].Value); dsngECWUL = Convert.ToSingle(dataGridView1.Rows[dintLoop].Cells[6].Value); dsngECSUL = Convert.ToSingle(dataGridView1.Rows[dintLoop].Cells[7].Value); dsngMax = Convert.ToInt32(dataGridView1.Rows[dintLoop].Cells[8].Value); dbolUse = Convert.ToBoolean(dataGridView1.Rows[dintLoop].Cells[10].Value); dstrModuleID = dataGridView1.Rows[dintLoop].Cells[11].Value.ToString().Trim(); if (dsngECSLL > dsngECDEF || dsngECSLL > dsngECSUL || dsngECDEF > dsngECSUL) { MessageBox.Show("ECID: " + dintECID.ToString() + "의 입력값의 범위가 옳지 않습니다.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } bool ModuleIDExist = false; foreach (int dintUnitID in this.pInfo.Unit()) { clsUnit tempUnit = this.pInfo.Unit(dintUnitID); if (tempUnit.SubUnit(0).ModuleID.Equals(dstrModuleID)) { ModuleIDExist = true; break; } } if (!ModuleIDExist) { MessageBox.Show("ECID: " + dintECID.ToString() + "의 ModuleID가 존재하지 않습니다.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch { MessageBox.Show("ECID: " + dintECID.ToString() + "의 입력값이 형식이 맞지 않습니다.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } #endregion #region "EC List Update" if (!DBAct.clsDBAct.funBeginTransaction()) { MessageBox.Show("DB Transaction NG!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //DataAdapter 생성 OleDbDataAdapter dataAdapter = new OleDbDataAdapter("SELECT * FROM tbECID order by ECID", DBAct.clsDBAct.funOleDbConnect()); OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(dataAdapter); //DataAdapter를 이용하여 DB로 업데이트를 한다. dataAdapter.SelectCommand.Transaction = DBAct.clsDBAct.funOleDbTransaction(); dataAdapter.Update((DataTable)pECIDBindingSource.DataSource); if (!DBAct.clsDBAct.funCommitTransaction()) { MessageBox.Show("DB Commit Transaction NG!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); DBAct.clsDBAct.funRollbackTransaction(); return; } #endregion #region "ECID Reload" string dstrSQL = "SELECT * FROM tbECID order by ECID"; DataTable dDT = DBAct.clsDBAct.funSelectQuery(dstrSQL); int dintIndex = 0; if (dDT != null) { pInfo.Unit(0).SubUnit(0).RemoveECID(); foreach (DataRow dr in dDT.Rows) { dintIndex = Convert.ToInt32(dr["ECID"]); pInfo.Unit(0).SubUnit(0).AddECID(dintIndex); pInfo.Unit(0).SubUnit(0).ECID(dintIndex).Name = dr["ECNAME"].ToString(); //pInfo.Unit(0).SubUnit(0).ECID(dintIndex).Unit = dr["Unit"].ToString(); pInfo.Unit(0).SubUnit(0).ECID(dintIndex).Min = dr["Min"].ToString(); pInfo.Unit(0).SubUnit(0).ECID(dintIndex).ECDEF = dr["ECDEF"].ToString(); pInfo.Unit(0).SubUnit(0).ECID(dintIndex).Max = dr["Max"].ToString(); //pInfo.Unit(0).SubUnit(0).ECID(dintIndex).Use = Convert.ToBoolean(dr["Use"]); pInfo.Unit(0).SubUnit(0).ECID(dintIndex).Format = dr["Format"].ToString(); pInfo.Unit(0).SubUnit(0).ECID(dintIndex).DESC = dr["Description"].ToString(); pInfo.Unit(0).SubUnit(0).ECID(dintIndex).UnitID = 0; pInfo.Unit(0).SubUnit(0).ECID(dintIndex).ModuleID = dr["ModuleID"].ToString(); } this.pInfo.All.HOSTReportECIDCount = dDT.Rows.Count; pInfo.DeleteTable("ECID"); pInfo.AddDataTable("ECID", dDT); tabfrmSetupECID_Load(this, null); } subSaveLastModified(); MessageBox.Show("Data Save Success!", "Jobs Complete", MessageBoxButtons.OK, MessageBoxIcon.Information); #endregion } catch (Exception ex) { pInfo.subLog_Set(InfoAct.clsInfo.LogType.CIM, ex.ToString()); MessageBox.Show("EC List Update Fail!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }