예제 #1
0
        private void subDBLoadInit(int dintType)
        {
            string    dstrSQL = "";
            DataTable dDT     = new DataTable();

            try
            {
                if (dintType == 1)
                {
                    //pInfo.Unit(0).SubUnit(0).RemoveMappingEQPPPID();
                    dstrSQL = "SELECT * FROM tbEQPPPID";
                    dDT     = DBAct.clsDBAct.funSelectQuery(dstrSQL);                      //DataTable을 받아온다.
                    if (dDT != null)
                    {
                        pInfo.DeleteTable("MappingEQPPPID");
                        pInfo.AddDataTable("MappingEQPPPID", dDT);

                        string strEQPPPID = "";
                        foreach (DataRow dr in dDT.Rows)
                        {
                            strEQPPPID = dr["EQPPPID"].ToString().Trim();
                            if (pInfo.Unit(0).SubUnit(0).MappingEQPPPID(strEQPPPID) == null)
                            {
                                pInfo.Unit(0).SubUnit(0).AddMappingEQPPPID(strEQPPPID);

                                pInfo.Unit(0).SubUnit(0).MappingEQPPPID(strEQPPPID).UP_EQPPPID  = dr["UP_PPID"].ToString().Trim();
                                pInfo.Unit(0).SubUnit(0).MappingEQPPPID(strEQPPPID).LOW_EQPPPID = dr["LOW_PPID"].ToString().Trim();
                                pInfo.Unit(0).SubUnit(0).MappingEQPPPID(strEQPPPID).DateTime    = dr["DTIME"].ToString().Trim();
                            }
                        }
                    }
                }
                else
                {
                    //pInfo.Unit(0).SubUnit(0).RemoveHOSTPPID();
                    dstrSQL = "SELECT * FROM tbHOSTPPID";
                    dDT     = DBAct.clsDBAct.funSelectQuery(dstrSQL);                      //DataTable을 받아온다.
                    if (dDT != null)
                    {
                        pInfo.DeleteTable("HOSTPPID");
                        pInfo.AddDataTable("HOSTPPID", dDT);

                        foreach (DataRow dr in dDT.Rows)
                        {
                            pInfo.Unit(0).SubUnit(0).AddHOSTPPID(dr["HOSTPPID"].ToString().Trim());

                            pInfo.Unit(0).SubUnit(0).HOSTPPID(dr["HOSTPPID"].ToString().Trim()).EQPPPID  = dr["EQPPPID"].ToString().Trim();
                            pInfo.Unit(0).SubUnit(0).HOSTPPID(dr["HOSTPPID"].ToString().Trim()).DateTime = dr["DTIME"].ToString().Trim();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                pInfo.subLog_Set(clsInfo.LogType.CIM, ex.ToString());
            }
        }
예제 #2
0
        public void Save()
        {
            string    dstrSQL;
            DataTable dDT;
            int       dintIndex = 0;

            try
            {
                if (MessageBox.Show("Alarm 리스트를 업데이트 합니다.\n양산중인 장비에서 이 기능을 실행하면\n심각한 문제가 발생 할 수 있습니다.\n진행하겠습니까?", "경고", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                {
                    return;
                }

                File.Copy(Application.StartupPath + @"\system\System.mdb", Application.StartupPath + @"\system\System.mdb.bak", true);

                if (!DBAct.clsDBAct.funBeginTransaction())
                {
                    MessageBox.Show("DB Transaction NG!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                //DataAdapter 생성
                OleDbDataAdapter    dataAdapter    = new OleDbDataAdapter("SELECT * FROM tbAlarm order by AlarmID", DBAct.clsDBAct.funOleDbConnect());
                OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(dataAdapter);

                //DataAdapter를 이용하여 DB로 업데이트를 한다.
                dataAdapter.SelectCommand.Transaction = DBAct.clsDBAct.funOleDbTransaction();
                dataAdapter.Update((DataTable)pAlarmListSource.DataSource);

                if (!DBAct.clsDBAct.funCommitTransaction())
                {
                    MessageBox.Show("DB Commit Transaction NG!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    DBAct.clsDBAct.funRollbackTransaction();
                    return;
                }

                //DB에 저장이 성공적으로 완료되면 다시 DB에서 Data를 로딩한다.
                //구조체의 내용 갱신
                //현재 등록되어 있는 모든 Alarm을 삭제한다.
                pInfo.Unit(0).SubUnit(0).RemoveAlarm();

                dstrSQL = "SELECT * FROM tbAlarm order by AlarmID";
                //dDT = DBAct.clsDBAct.funSelectQuery2(dstrSQL);                          //DataTable을 받아온다.
                dDT = DBAct.clsDBAct.funSelectQuery2(dstrSQL);
                if (dDT != null)
                {
                    pInfo.DeleteTable("ALARM");
                    pInfo.AddDataTable("ALARM", dDT);

                    foreach (DataRow dr in dDT.Rows)
                    {
                        if (Convert.ToBoolean(dr["AlarmReport"].ToString().Trim()))
                        {
                            dintIndex = Convert.ToInt32(dr["AlarmID"]);
                            pInfo.Unit(0).SubUnit(0).AddAlarm(dintIndex);

                            pInfo.Unit(0).SubUnit(0).Alarm(dintIndex).AlarmCode   = Convert.ToInt32(dr["AlarmCD"].ToString().Trim());
                            pInfo.Unit(0).SubUnit(0).Alarm(dintIndex).AlarmType   = dr["AlarmType"].ToString().Trim();
                            pInfo.Unit(0).SubUnit(0).Alarm(dintIndex).AlarmDesc   = dr["AlarmDesc"].ToString().Trim();
                            pInfo.Unit(0).SubUnit(0).Alarm(dintIndex).AlarmReport = Convert.ToBoolean(dr["AlarmReport"].ToString().Trim());
                            pInfo.Unit(0).SubUnit(0).Alarm(dintIndex).UnitID      = pInfo.funGetModuleIDToUnitID(dr["ModuleID"].ToString());
                            pInfo.Unit(0).SubUnit(0).Alarm(dintIndex).ModuleID    = dr["ModuleID"].ToString();
                        }
                    }
                }

                //DBAct.clsDBAct.funDisconnect();     // DB 연결을 끊는다.

                subSaveLastModified(); //최종 수정된 날짜를 Ini파일에 저장한다.

                MessageBox.Show("Data Save Success!", "Jobs Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                pInfo.subLog_Set(InfoAct.clsInfo.LogType.CIM, ex.ToString());
                DBAct.clsDBAct.funRollbackTransaction();
                DBAct.clsDBAct.funDisconnect();     // DB 연결을 끊는다.
                MessageBox.Show("DB Update Fail, Because DB Process Error!", "DB Update Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #3
0
        public void Save()
        {
            File.Copy(Application.StartupPath + @"\system\System.mdb", Application.StartupPath + @"\system\System.mdb.bak", true);

            string     dstrSQL;
            DataTable  dDT;
            int        dintIndex    = 0;
            int        dintEOV      = 0;
            bool       dbolError    = false;
            SortedList dHT          = new SortedList();
            string     dstrAfterEOV = "";


            try
            {
                //유효성검사
                for (int dintLoop = 0; dintLoop < this.dataGridView1.RowCount; dintLoop++)
                {
                    dintIndex = Convert.ToInt32(this.dataGridView1.Rows[dintLoop].Cells[0].Value);
                    dintEOV   = Convert.ToInt32(this.dataGridView1.Rows[dintLoop].Cells[5].Value);

                    if (dintEOV >= this.pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOVMin&& dintEOV <= this.pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOVMax)
                    {
                        if (this.pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOID == 8)          //EOID=8이면 VCR Reading Mode임.
                        {
                            if (dintEOV == 0 || dintEOV == 1 || dintEOV == 2 || dintEOV == 3) //VCR Reading Mode는 0,1,2,3 만 값이 있다.
                            {
                            }
                            else
                            {
                                dbolError = true;
                            }
                        }

                        if (this.pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOID == 19) //SEM
                        {
                            if (dintEOV == 1)
                            {
                                //pInfo.All.SEM_ON = true;
                                //if (pInfo.All.CommPort.ToUpper() != "NULL") pInfo.subPLCCommand_Set(InfoAct.clsInfo.PLCCommand.SerialPortOpen);

                                this.pInfo.subPLCCommand_Set(InfoAct.clsInfo.PLCCommand.UDPPortOpen);
                                //SEM Controller에 Start명령을 내린다.
                                this.pInfo.subPLCCommand_Set(InfoAct.clsInfo.PLCCommand.SEMControllerStart);
                            }
                            else
                            {
                                //pInfo.All.SEM_ON = false;
                                this.pInfo.subPLCCommand_Set(InfoAct.clsInfo.PLCCommand.SEMControllerEnd);

                                this.pInfo.subPLCCommand_Set(InfoAct.clsInfo.PLCCommand.UDPPortClose);
                            }
                        }

                        if (this.pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOID == 21) //APC
                        {
                            if (dintEOV == 0 || dintEOV == 1)
                            {
                                if (dintEOV == 0)
                                {
                                    pInfo.All.APCUSE = false;
                                }
                                else
                                {
                                    pInfo.All.APCUSE = true;
                                }
                            }
                            else
                            {
                                dbolError = true;
                            }
                        }

                        if (this.pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOID == 22) //RPC
                        {
                            if (dintEOV == 0 || dintEOV == 1)
                            {
                                if (dintEOV == 0)
                                {
                                    pInfo.All.RPCUSE = false;
                                }
                                else
                                {
                                    pInfo.All.RPCUSE = true;
                                }
                            }
                            else
                            {
                                dbolError = true;
                            }
                        }
                    }
                    else
                    {
                        dbolError = true;
                    }

                    if (dbolError == true)
                    {
                        dstrErrorMsg = this.pInfo.Unit(0).SubUnit(0).EOID(dintIndex).DESC + " 값은 " + this.pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOVMin
                                       + "~" + this.pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOVMax + " 이어야 합니다.";
                        MessageBox.Show(dstrErrorMsg, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }

                //바뀐 EOV 값이 있는지 검사한다.
                for (int dintLoop = 0; dintLoop < this.dataGridView1.RowCount; dintLoop++)
                {
                    //dintIndex = dintLoop + 1;
                    dintIndex = Convert.ToInt32(this.dataGridView1.Rows[dintLoop].Cells[0].Value);
                    dintEOV   = Convert.ToInt32(this.dataGridView1.Rows[dintLoop].Cells[5].Value);
                    if (this.pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOV != dintEOV)
                    {
                        dstrAfterEOV = dstrAfterEOV + dintIndex.ToString() + ";";              //EOID 저장
                        dHT.Add(dintIndex, this.pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOV); //변경전의 EOID, EOV 저장

                        //if (this.PInfo.funGetEOIDLapseTime(dintIndex) == true) dbolProcessTimeOverChange = true;
                    }
                }

                if (dstrAfterEOV == "")
                {
                    MessageBox.Show("변경된 EOV가 하나도 없습니다.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                if (!DBAct.clsDBAct.funBeginTransaction())
                {
                    MessageBox.Show("DB Transaction NG!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                //DataAdapter 생성
                OleDbDataAdapter    dataAdapter    = new OleDbDataAdapter("SELECT * FROM tbEOID order by Index", DBAct.clsDBAct.funOleDbConnect());
                OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(dataAdapter);

                //DataAdapter를 이용하여 DB로 업데이트를 한다.
                dataAdapter.SelectCommand.Transaction = DBAct.clsDBAct.funOleDbTransaction();
                dataAdapter.Update((DataTable)pEOIDListSource.DataSource);

                if (!DBAct.clsDBAct.funCommitTransaction())
                {
                    MessageBox.Show("DB Commit Transaction NG!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    DBAct.clsDBAct.funRollbackTransaction();
                    return;
                }



                dstrSQL = "SELECT * FROM tbEOID order by index";
                //dDT = DBAct.clsDBAct.funSelectQuery2(dstrSQL);                          //DataTable을 받아온다.
                dDT = DBAct.clsDBAct.funSelectQuery2(dstrSQL);
                if (dDT != null)
                {
                    pInfo.Unit(0).SubUnit(0).RemoveEOID();

                    pInfo.DeleteTable("EOID");
                    pInfo.AddDataTable("EOID", dDT);

                    foreach (DataRow dr in dDT.Rows)
                    {
                        dintIndex = Convert.ToInt32(dr["Index"]);
                        pInfo.Unit(0).SubUnit(0).AddEOID(dintIndex);

                        pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOID     = Convert.ToInt32(dr["EOID"]);
                        pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOMD     = Convert.ToInt32(dr["EOMD"]);
                        pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOMDMin  = Convert.ToInt32(dr["EOMDMin"]);
                        pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOMDMax  = Convert.ToInt32(dr["EOMDMax"]);
                        pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOV      = Convert.ToInt32(dr["EOV"]);
                        pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOVMin   = Convert.ToInt32(dr["EOVMin"]);
                        pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOVMax   = Convert.ToInt32(dr["EOVMax"]);
                        pInfo.Unit(0).SubUnit(0).EOID(dintIndex).DESC     = dr["Description"].ToString();
                        pInfo.Unit(0).SubUnit(0).EOID(dintIndex).PLCWrite = Convert.ToBoolean(dr["PLCWrite"]);
                    }
                }
                string[] dstrData = dstrAfterEOV.Split(new char[] { ';' });
                if (dstrData.Length > 1)
                {
                    this.pInfo.All.EOIDChangeBYWHO = "2";       //BY OP

                    //HOST로 EOV값 변경 보고
                    this.pInfo.subSendSF_Set(InfoAct.clsInfo.SFName.S6F11RelatedEquipmentParameterEvent, 101, dstrAfterEOV); //마지막 인자는 EOID Index임

                    this.pInfo.All.EOIDChangeBYWHO = "";                                                                     //초기화

                    //변경 이력 로그 저장
                    foreach (DictionaryEntry de in dHT)
                    {
                        dintIndex = Convert.ToInt32(de.Key);        //EOID Index

                        string dstrLog = "";
                        dstrLog = dstrLog + "EOID" + ",";
                        dstrLog = dstrLog + DateTime.Now.ToString("yyyyMMddHHmmss") + ",";
                        dstrLog = dstrLog + "변경" + ",";
                        dstrLog = dstrLog + this.pInfo.All.UserID + ",";
                        dstrLog = dstrLog + this.pInfo.Unit(0).SubUnit(0).EOID(dintIndex).DESC + ",";
                        dstrLog = dstrLog + de.Value.ToString() + ",";
                        dstrLog = dstrLog + this.pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOV;

                        this.pInfo.subLog_Set(InfoAct.clsInfo.LogType.Parameter, dstrLog); //로그 출력

                        dstrLog = "";                                                      //초기화


                        //만약 EOID중에 PLC로 변경할 것이 있으면 Write해 준다.
                        if (this.pInfo.Unit(0).SubUnit(0).EOID(dintIndex).PLCWrite == true)
                        {
                            switch (dintIndex)
                            {
                            //case 8:                       //VCR Reading Mode
                            //    this.PInfo.subPLCCommand_Set(InfoAct.clsInfo.PLCCommand.VCRReadingMode, this.PInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOV);
                            //    break;

                            case 1:                           //APC(Advanced Process Control) MODE
                                this.pInfo.subPLCCommand_Set(InfoAct.clsInfo.PLCCommand.APCMode, this.pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOV);
                                break;

                            default:
                                break;
                            }
                        }
                        else
                        {
                            switch (dintIndex)
                            {
                            case 2:                           //MCC Reporting Mode

                                if (this.pInfo.Unit(0).SubUnit(0).EOID(dintIndex).EOV == 1)
                                {
                                    FunINIMethod.funINIReadValue("MCC", "MCCFileUploadUse", "True", this.pInfo.All.SystemINIFilePath);
                                }
                                else
                                {
                                    FunINIMethod.funINIReadValue("MCC", "MCCFileUploadUse", "False", this.pInfo.All.SystemINIFilePath);
                                }
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }

                subSaveLastModified(); //최종 수정된 날짜를 Ini파일에 저장한다.

                MessageBox.Show("Data Save Success!", "Jobs Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                pInfo.subLog_Set(InfoAct.clsInfo.LogType.CIM, ex.ToString());
                DBAct.clsDBAct.funRollbackTransaction();
                DBAct.clsDBAct.funDisconnect();     // DB 연결을 끊는다.
                MessageBox.Show("DB Update Fail, Because DB Process Error!", "DB Update Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #4
0
        public void Save()
        {
            string    dstrSQL;
            DataTable dDT;
            string    dstrName = "";

            try
            {
                File.Copy(Application.StartupPath + @"\system\System.mdb", Application.StartupPath + @"\system\System.mdb.bak", true);

                if (!DBAct.clsDBAct.funBeginTransaction())
                {
                    MessageBox.Show("DB Transaction NG!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                //DataAdapter 생성
                OleDbDataAdapter    dataAdapter    = new OleDbDataAdapter("SELECT * FROM tbUser order by UserLevel", DBAct.clsDBAct.funOleDbConnect());
                OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(dataAdapter);

                //DataAdapter를 이용하여 DB로 업데이트를 한다.
                dataAdapter.SelectCommand.Transaction = DBAct.clsDBAct.funOleDbTransaction();
                dataAdapter.Update((DataTable)pUserBindingSource.DataSource);

                if (!DBAct.clsDBAct.funCommitTransaction())
                {
                    MessageBox.Show("DB Commit Transaction NG!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    DBAct.clsDBAct.funRollbackTransaction();
                    return;
                }

                //DB에 저장이 성공적으로 완료되면 다시 DB에서 Data를 로딩한다.
                //구조체의 내용 갱신
                pInfo.Unit(0).SubUnit(0).RemoveUser();

                //DB로부터 User 정보를 읽어들여 저장한다.
                dstrSQL = "SELECT * FROM tbUser order by UserLevel";
                dDT     = DBAct.clsDBAct.funSelectQuery2(dstrSQL);                      //DataTable을 받아온다.
                if (dDT != null)
                {
                    pInfo.DeleteTable("USER");
                    pInfo.AddDataTable("USER", dDT);

                    foreach (DataRow dr in dDT.Rows)
                    {
                        dstrName = dr["UserID"].ToString();
                        pInfo.Unit(0).SubUnit(0).AddUser(dstrName);

                        pInfo.Unit(0).SubUnit(0).User(dstrName).Level    = Convert.ToInt32(dr["UserLevel"].ToString());
                        pInfo.Unit(0).SubUnit(0).User(dstrName).PassWord = dr["Pass"].ToString();
                        pInfo.Unit(0).SubUnit(0).User(dstrName).Desc     = dr["Description"].ToString();
                    }
                }

                //DBAct.clsDBAct.funDisconnect();     // DB 연결을 끊는다.

                subSaveLastModified(); //최종 수정된 날짜를 Ini파일에 저장한다.

                MessageBox.Show("Data Save Success!", "Jobs Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                pInfo.subLog_Set(InfoAct.clsInfo.LogType.CIM, ex.ToString());
                DBAct.clsDBAct.funRollbackTransaction();
                DBAct.clsDBAct.funDisconnect();     // DB 연결을 끊는다.
                MessageBox.Show("DB Update Fail, Because DB Process Error!", "DB Update Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #5
0
        public void Save()
        {
            if (MessageBox.Show("SVID 리스트를 업데이트 합니다.\n양산중인 장비에서 이 기능을 실행하면\n심각한 문제가 발생 할 수 있습니다.\n진행하겠습니까?", "경고", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
            {
                return;
            }

            File.Copy(Application.StartupPath + @"\system\System.mdb", Application.StartupPath + @"\system\System.mdb.bak", true);

            string    dstrSQL;
            DataTable dDT;
            int       dintIndex = 0;

            try
            {
                //if (!DBAct.clsDBAct.funConnect())
                //{
                //    MessageBox.Show("DB Connection Fail!", "Connect Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //    return;
                //}

                if (!DBAct.clsDBAct.funBeginTransaction())
                {
                    MessageBox.Show("DB Transaction NG!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                //DataAdapter 생성
                OleDbDataAdapter    dataAdapter    = new OleDbDataAdapter("SELECT * FROM tbSVID order by SVID", DBAct.clsDBAct.funOleDbConnect());
                OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(dataAdapter);

                //DataAdapter를 이용하여 DB로 업데이트를 한다.
                dataAdapter.SelectCommand.Transaction = DBAct.clsDBAct.funOleDbTransaction();
                dataAdapter.Update((DataTable)pSVIDListSource.DataSource);

                if (!DBAct.clsDBAct.funCommitTransaction())
                {
                    MessageBox.Show("DB Commit Transaction NG!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    DBAct.clsDBAct.funRollbackTransaction();
                    return;
                }



                dstrSQL = "SELECT * FROM tbSVID order by SVID";
                //dDT = DBAct.clsDBAct.funSelectQuery2(dstrSQL);                          //DataTable을 받아온다.
                dDT = DBAct.clsDBAct.funSelectQuery2(dstrSQL);
                if (dDT != null)
                {
                    pInfo.Unit(0).SubUnit(0).RemoveSVID();
                    pInfo.DeleteTable("SVID");
                    pInfo.AddDataTable("SVID", dDT);

                    foreach (DataRow dr in dDT.Rows)
                    {
                        dintIndex = Convert.ToInt32(dr["SVID"]);
                        pInfo.Unit(0).SubUnit(0).AddSVID(dintIndex);

                        pInfo.Unit(0).SubUnit(0).SVID(dintIndex).Name           = dr["SVNAME"].ToString();
                        pInfo.Unit(0).SubUnit(0).SVID(dintIndex).Length         = Convert.ToInt32(dr["Length"].ToString());
                        pInfo.Unit(0).SubUnit(0).SVID(dintIndex).Format         = dr["Format"].ToString();
                        pInfo.Unit(0).SubUnit(0).SVID(dintIndex).Value          = dr["SV"].ToString();
                        pInfo.Unit(0).SubUnit(0).SVID(dintIndex).Type           = dr["Type"].ToString();
                        pInfo.Unit(0).SubUnit(0).SVID(dintIndex).Unit           = dr["Unit"].ToString();
                        pInfo.Unit(0).SubUnit(0).SVID(dintIndex).Range          = dr["Range"].ToString();
                        pInfo.Unit(0).SubUnit(0).SVID(dintIndex).HaveMinusValue = Convert.ToBoolean(dr["HaveMinusValue"]);
                        pInfo.Unit(0).SubUnit(0).SVID(dintIndex).DESC           = dr["Description"].ToString();
                        //PInfo.Unit(0).SubUnit(0).SVID(dintIndex).UnitID = this.PInfo.funGetModuleIDToUnitID(dr["ModuleID"].ToString());
                        pInfo.Unit(0).SubUnit(0).SVID(dintIndex).ModuleID = dr["ModuleID"].ToString();

                        if (pInfo.Unit(0).SubUnit(0).SVID(dintIndex).Format.Trim() != "")
                        {
                            this.pInfo.All.SVIDPLCReadLength = this.pInfo.All.SVIDPLCReadLength + this.pInfo.Unit(0).SubUnit(0).SVID(dintIndex).Length;
                        }
                    }
                }

                subSaveLastModified(); //최종 수정된 날짜를 Ini파일에 저장한다.

                MessageBox.Show("Data Save Success!", "Jobs Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                pInfo.subLog_Set(InfoAct.clsInfo.LogType.CIM, ex.ToString());
                DBAct.clsDBAct.funRollbackTransaction();
                DBAct.clsDBAct.funDisconnect();     // DB 연결을 끊는다.
                MessageBox.Show("DB Update Fail, Because DB Process Error!", "DB Update Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #6
0
        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);
            }
        }