Example #1
0
        private void ShowDataToControl(int ID)
        {
            RW_COMPONENT_BUS busCom = new RW_COMPONENT_BUS();
            RW_COMPONENT     com    = busCom.getData(ID);

            txtTankDiameter.Text                   = com.NominalDiameter.ToString();
            txtCurrentThickness.Text               = com.CurrentThickness.ToString();
            txtCurrentCorrosionRate.Text           = com.CurrentCorrosionRate.ToString();
            txtShellCourseHeight.Text              = com.ShellHeight.ToString();
            txtNominalThickness.Text               = com.NominalThickness.ToString();
            chkDamageFoundDuringInspection.Checked = com.DamageFoundInspection == 1 ? true : false;
            chkConcreteAsphalt.Checked             = com.ConcreteFoundation == 1 ? true : false;
            chkPresenceCracks.Checked              = com.CracksPresent == 1 ? true : false;
            chkPreventionBarrier.Checked           = com.ReleasePreventionBarrier == 1 ? true : false;
            chkTrampElements.Checked               = com.TrampElements == 1 ? true : false;
            txtMinRequiredThickness.Text           = com.MinReqThickness.ToString();
            for (int i = 0; i < itemsBrinnellHardness.Length; i++)
            {
                if (itemsBrinnellHardness[i] == com.BrinnelHardness)
                {
                    cbMaxBrillnessHardness.SelectedIndex = i + 1;
                    break;
                }
            }
            for (int i = 0; i < itemsComplexityProtrusion.Length; i++)
            {
                if (itemsComplexityProtrusion[i] == com.ComplexityProtrusion)
                {
                    cbComplexityProtrusion.SelectedIndex = i + 1;
                    break;
                }
            }
            for (int i = 0; i < itemsSeverity.Length; i++)
            {
                if (itemsSeverity[i] == com.SeverityOfVibration)
                {
                    cbSeverityVibration.SelectedIndex = i + 1;
                    break;
                }
            }
        }
Example #2
0
        public void ShowDatatoControl(int ID)
        {
            RW_COMPONENT_BUS    comBus        = new RW_COMPONENT_BUS();
            List <RW_COMPONENT> listComponent = comBus.getDataSource();

            foreach (RW_COMPONENT comp in listComponent)
            {
                if (comp.ID == ID)
                {
                    txtNominalDiameter.Text                = comp.NominalDiameter.ToString();
                    txtNominalThickness.Text               = comp.NominalThickness.ToString();
                    txtCurrentThickness.Text               = comp.CurrentThickness.ToString();
                    txtMinRequiredThickness.Text           = comp.MinReqThickness.ToString();
                    txtCurrentCorrosionRate.Text           = comp.CurrentCorrosionRate.ToString();
                    chkPresenceCracks.Checked              = comp.CracksPresent == 1 ? true : false;
                    chkPresenceInjectionMixPoint.Checked   = comp.ChemicalInjection == 1?true:false;
                    chkHighlyEffectiveMixPoint.Checked     = comp.HighlyInjectionInsp == 1? true:false;
                    chkDamageFoundDuringInspection.Checked = comp.DamageFoundInspection == 1?true:false;
                    txtDeltaFATT.Text         = comp.DeltaFATT.ToString();
                    chkVisibleAudible.Checked = comp.ShakingDetected == 1?true:false;
                    chkTrampElements.Checked  = comp.TrampElements == 1 ? true : false;

                    for (int i = 0; i < itemsAccumulatedTimeShaking.Length; i++)
                    {
                        if (comp.ShakingTime == itemsAccumulatedTimeShaking[i])
                        {
                            cbAccumalatedTimeShakingPipe.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsCorrectiveAction.Length; i++)
                    {
                        if (comp.CorrectiveAction == itemsCorrectiveAction[i])
                        {
                            cbCorrectiveAction.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsCyclicLoading.Length; i++)
                    {
                        if (comp.CyclicLoadingWitin15_25m == itemsCyclicLoading[i])
                        {
                            cbCyclicLoading.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsBranchDiameter.Length; i++)
                    {
                        if (comp.BranchDiameter == itemsBranchDiameter[i])
                        {
                            cbBranchDiameter.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsBranchJointType.Length; i++)
                    {
                        if (comp.BranchJointType == itemsBranchJointType[i])
                        {
                            cbJointTypeBranch.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsBrinnellHardness.Length; i++)
                    {
                        if (comp.BrinnelHardness == itemsBrinnellHardness[i])
                        {
                            cbMaxBrillnessHardness.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsNumberPipeFittings.Length; i++)
                    {
                        if (comp.NumberPipeFittings == itemsNumberPipeFittings[i])
                        {
                            cbNumberFittingPipe.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsPipeCondition.Length; i++)
                    {
                        if (comp.PipeCondition == itemsPipeCondition[i])
                        {
                            cbPipeCondition.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsPreviousFailure.Length; i++)
                    {
                        if (comp.PreviousFailures == itemsPreviousFailure[i])
                        {
                            cbPreviousFailures.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsAmountShaking.Length; i++)
                    {
                        if (comp.ShakingAmount == itemsAmountShaking[i])
                        {
                            cbAmountShakingPipe.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsProtrusionComplexity.Length; i++)
                    {
                        if (comp.ComplexityProtrusion == itemsProtrusionComplexity[i])
                        {
                            cbComplexityProtrusion.SelectedIndex = i + 1;
                        }
                    }
                }
            }
        }
        private void btnImport_Click(object sender, EventArgs e)
        {
            SplashScreenManager.ShowForm(typeof(WaitForm2));
            // data from file
            SITES_BUS                 busSite         = new SITES_BUS();
            FACILITY_BUS              busFacility     = new FACILITY_BUS();
            MANUFACTURER_BUS          busManufacture  = new MANUFACTURER_BUS();
            DESIGN_CODE_BUS           busDesign       = new DESIGN_CODE_BUS();
            EQUIPMENT_MASTER_BUS      busEqMaster     = new EQUIPMENT_MASTER_BUS();
            COMPONENT_MASTER_BUS      busComMaster    = new COMPONENT_MASTER_BUS();
            RW_ASSESSMENT_BUS         busAss          = new RW_ASSESSMENT_BUS();
            RW_EQUIPMENT_BUS          busEq           = new RW_EQUIPMENT_BUS();
            RW_COMPONENT_BUS          buscom          = new RW_COMPONENT_BUS();
            RW_EXTCOR_TEMPERATURE_BUS busExcort       = new RW_EXTCOR_TEMPERATURE_BUS();
            RW_STREAM_BUS             busStream       = new RW_STREAM_BUS();
            RW_MATERIAL_BUS           busMaterial     = new RW_MATERIAL_BUS();
            RW_COATING_BUS            busCoat         = new RW_COATING_BUS();
            RW_INPUT_CA_LEVEL_1_BUS   busInputCA      = new RW_INPUT_CA_LEVEL_1_BUS();
            FACILITY_RISK_TARGET_BUS  busRiskTarget   = new FACILITY_RISK_TARGET_BUS();
            Bus_PLANT_PROCESS_Excel   busExcelProcess = new Bus_PLANT_PROCESS_Excel();

            busExcelProcess.path = txtPathFileExcel.Text;
            List <SITES> listSite = busExcelProcess.getAllSite();

            foreach (SITES s in listSite)
            {
                if (!busSite.checkExist(s.SiteName))
                {
                    busSite.add(s);
                }
                else
                {
                    busSite.edit(s);
                }
            }

            List <FACILITY> listFacility = busExcelProcess.getFacility();

            foreach (FACILITY f in listFacility)
            {
                if (busFacility.checkExist(f.FacilityName))
                {
                    busFacility.edit(f);
                }
                else
                {
                    busFacility.add(f);
                    int FaciID = busFacility.getLastFacilityID();
                    FACILITY_RISK_TARGET riskTarget = new FACILITY_RISK_TARGET();
                    riskTarget.FacilityID = FaciID;
                    busRiskTarget.add(riskTarget);
                }
            }

            List <string> manufacture = busExcelProcess.getAllManufacture();

            for (int i = 0; i < manufacture.Count; i++)
            {
                MANUFACTURER manu = new MANUFACTURER();
                manu.ManufacturerID   = busManufacture.getIDbyName(manufacture[i]);
                manu.ManufacturerName = manufacture[i];
                if (busManufacture.getIDbyName(manufacture[i]) == 0)
                {
                    busManufacture.add(manu);
                }
                else
                {
                    busManufacture.edit(manu);
                }
            }

            List <String> designcode = busExcelProcess.getAllDesigncode();

            for (int i = 0; i < designcode.Count; i++)
            {
                DESIGN_CODE design = new DESIGN_CODE();
                design.DesignCodeID  = busDesign.getIDbyName(designcode[i]);
                design.DesignCode    = designcode[i];
                design.DesignCodeApp = "";
                if (design.DesignCodeID == 0)
                {
                    busDesign.add(design);
                }
                else
                {
                    busDesign.edit(design);
                }
            }

            List <EQUIPMENT_MASTER> listEpMaster = busExcelProcess.getEquipmentMaster();

            foreach (EQUIPMENT_MASTER eqM in listEpMaster)
            {
                if (busEqMaster.check(eqM.EquipmentNumber))
                {
                    busEqMaster.edit(eqM);
                }
                else
                {
                    busEqMaster.add(eqM);
                }
            }

            List <COMPONENT_MASTER> listComMaster = busExcelProcess.getComponentMaster();

            foreach (COMPONENT_MASTER comM in listComMaster)
            {
                if (busComMaster.checkExist(comM.ComponentNumber))
                {
                    busComMaster.edit(comM);
                }
                else
                {
                    busComMaster.add(comM);
                }
            }

            List <RW_ASSESSMENT> listRW_Assessment = busExcelProcess.getAssessment();
            List <int>           editExcel         = new List <int>();
            List <int>           addExcel          = new List <int>();

            foreach (RW_ASSESSMENT rwAss in listRW_Assessment)
            {
                //kiem tra xem Proposal add bang file Excel hay add bang tay
                List <int[]> ID_checkAddbyExcel = busAss.getCheckAddExcel_ID(rwAss.ComponentID, rwAss.EquipmentID);
                if (ID_checkAddbyExcel.Count != 0)
                {
                    for (int i = 0; i < ID_checkAddbyExcel.Count; i++)
                    {
                        if (ID_checkAddbyExcel[i][0] != 0) //kiem tra xem co phai Assessment nay duoc them tu file Excel ko, !=0 la them tu file Excel
                        {
                            rwAss.ID = ID_checkAddbyExcel[i][1];
                            editExcel.Add(rwAss.ID);
                            busAss.edit(rwAss);
                        }
                    }
                }
                else
                {
                    rwAss.AddByExcel = 1;
                    busAss.add(rwAss);
                    int assID = busAss.getLastID();
                    addExcel.Add(assID);
                    RW_INPUT_CA_LEVEL_1 inputCA = new RW_INPUT_CA_LEVEL_1();
                    inputCA.ID = assID;
                    busInputCA.add(inputCA);
                }
            }

            List <RW_EQUIPMENT> listRw_eq = busExcelProcess.getRwEquipment();

            for (int i = 0; i < listRw_eq.Count; i++)
            {
                if (editExcel.Count != 0)
                {
                    for (int j = 0; j < editExcel.Count; j++)
                    {
                        if (listRw_eq[i].ID == editExcel[j])
                        {
                            busEq.edit(listRw_eq[i]);
                        }
                    }
                }
                if (addExcel.Count != 0)
                {
                    for (int j = 0; j < addExcel.Count; j++)
                    {
                        if (listRw_eq[i].ID == addExcel[j])
                        {
                            busEq.add(listRw_eq[i]);
                        }
                    }
                }
            }

            List <RW_COMPONENT> listRw_com = busExcelProcess.getRwComponent();

            for (int i = 0; i < listRw_com.Count; i++)
            {
                if (editExcel.Count != 0)
                {
                    for (int j = 0; j < editExcel.Count; j++)
                    {
                        if (listRw_com[i].ID == editExcel[j])
                        {
                            buscom.edit(listRw_com[i]);
                        }
                    }
                }
                if (addExcel.Count != 0)
                {
                    for (int j = 0; j < addExcel.Count; j++)
                    {
                        if (listRw_com[i].ID == addExcel[j])
                        {
                            buscom.add(listRw_com[i]);
                        }
                    }
                }
            }

            List <RW_EXTCOR_TEMPERATURE> listRw_extcor = busExcelProcess.getRwExtTemp();

            //MessageBox.Show(listRw_extcor.Count.ToString());
            for (int i = 0; i < listRw_extcor.Count; i++)
            {
                if (editExcel.Count != 0)
                {
                    for (int j = 0; j < editExcel.Count; j++)
                    {
                        if (listRw_extcor[i].ID == editExcel[j])
                        {
                            //MessageBox.Show("add file excel");
                            busExcort.edit(listRw_extcor[i]);
                        }
                    }
                }
                if (addExcel.Count != 0)
                {
                    for (int j = 0; j < addExcel.Count; j++)
                    {
                        if (listRw_extcor[i].ID == addExcel[j])
                        {
                            //MessageBox.Show("add file excel");
                            busExcort.add(listRw_extcor[i]);
                        }
                    }
                }
            }

            List <RW_STREAM> listRw_stream = busExcelProcess.getRwStream();

            for (int i = 0; i < listRw_stream.Count; i++)
            {
                if (editExcel.Count != 0)
                {
                    for (int j = 0; j < editExcel.Count; j++)
                    {
                        if (listRw_stream[i].ID == editExcel[j])
                        {
                            busStream.edit(listRw_stream[i]);
                        }
                    }
                }
                if (addExcel.Count != 0)
                {
                    for (int j = 0; j < addExcel.Count; j++)
                    {
                        if (listRw_stream[i].ID == addExcel[j])
                        {
                            busStream.add(listRw_stream[i]);
                        }
                    }
                }
            }

            List <RW_MATERIAL> listRw_material = busExcelProcess.getRwMaterial();

            for (int i = 0; i < listRw_material.Count; i++)
            {
                if (editExcel.Count != 0)
                {
                    for (int j = 0; j < editExcel.Count; j++)
                    {
                        if (listRw_material[i].ID == editExcel[j])
                        {
                            busMaterial.edit(listRw_material[i]);
                        }
                    }
                }
                if (addExcel.Count != 0)
                {
                    for (int j = 0; j < addExcel.Count; j++)
                    {
                        if (listRw_material[i].ID == addExcel[j])
                        {
                            busMaterial.add(listRw_material[i]);
                        }
                    }
                }
            }

            List <RW_COATING> listRw_coat = busExcelProcess.getRwCoating();

            for (int i = 0; i < listRw_coat.Count; i++)
            {
                if (editExcel.Count != 0)
                {
                    for (int j = 0; j < editExcel.Count; j++)
                    {
                        if (listRw_coat[i].ID == editExcel[j])
                        {
                            busCoat.edit(listRw_coat[i]);
                        }
                    }
                }
                if (addExcel.Count != 0)
                {
                    for (int j = 0; j < addExcel.Count; j++)
                    {
                        if (listRw_coat[i].ID == addExcel[j])
                        {
                            busCoat.add(listRw_coat[i]);
                        }
                    }
                }
            }
            ButtonOKClicked = true;
            SplashScreenManager.CloseForm();
            MessageBox.Show("All data have been saved! You need to add Risk Target in Facility!", "Cortek RBI", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            this.Close();
        }
        private void btnImport_Click(object sender, EventArgs e)
        {
            SplashScreenManager.ShowForm(typeof(WaitForm2));
            SITES_BUS                 busSite        = new SITES_BUS();
            FACILITY_BUS              busFacility    = new FACILITY_BUS();
            MANUFACTURER_BUS          busManufacture = new MANUFACTURER_BUS();
            DESIGN_CODE_BUS           busDesignCode  = new DESIGN_CODE_BUS();
            FACILITY_RISK_TARGET_BUS  busRiskTarget  = new FACILITY_RISK_TARGET_BUS();
            EQUIPMENT_MASTER_BUS      busEquipMaster = new EQUIPMENT_MASTER_BUS();
            COMPONENT_MASTER_BUS      busCompMaster  = new COMPONENT_MASTER_BUS();
            RW_ASSESSMENT_BUS         busAss         = new RW_ASSESSMENT_BUS();
            RW_EQUIPMENT_BUS          busEquip       = new RW_EQUIPMENT_BUS();
            RW_COMPONENT_BUS          busCom         = new RW_COMPONENT_BUS();
            RW_EXTCOR_TEMPERATURE_BUS busExtcor      = new RW_EXTCOR_TEMPERATURE_BUS();
            RW_STREAM_BUS             busStream      = new RW_STREAM_BUS();
            RW_MATERIAL_BUS           busMaterial    = new RW_MATERIAL_BUS();
            RW_COATING_BUS            busCoating     = new RW_COATING_BUS();
            RW_INPUT_CA_TANK_BUS      busInputCATank = new RW_INPUT_CA_TANK_BUS();
            Bus_PLANT_PROCESS_Excel   busExcel       = new Bus_PLANT_PROCESS_Excel();

            busExcel.path = txtPathFileExcel.Text;
            //Sites
            List <SITES> lstSite = busExcel.getAllSite();

            foreach (SITES s in lstSite)
            {
                if (!busSite.checkExist(s.SiteName))
                {
                    busSite.add(s);
                }
                else
                {
                    busSite.edit(s);
                }
            }

            //Facility
            List <FACILITY> lstFacility = busExcel.getFacility();

            foreach (FACILITY f in lstFacility)
            {
                if (busFacility.checkExist(f.FacilityName))
                {
                    busFacility.edit(f);
                }
                else
                {
                    busFacility.add(f);
                    int FaciID = busFacility.getLastFacilityID();
                    FACILITY_RISK_TARGET riskTarget = new FACILITY_RISK_TARGET();
                    riskTarget.FacilityID = FaciID;
                    busRiskTarget.add(riskTarget);
                }
            }

            //Manufacture
            List <string> manufacture = busExcel.getAllManufacture();

            for (int i = 0; i < manufacture.Count; i++)
            {
                MANUFACTURER manu = new MANUFACTURER();
                manu.ManufacturerID   = busManufacture.getIDbyName(manufacture[i]);
                manu.ManufacturerName = manufacture[i];
                if (busManufacture.getIDbyName(manufacture[i]) == 0)
                {
                    busManufacture.add(manu);
                }
                else
                {
                    busManufacture.edit(manu);
                }
            }

            //Design Code
            List <string> designCode = busExcel.getAllDesigncode();

            for (int i = 0; i < designCode.Count; i++)
            {
                DESIGN_CODE design = new DESIGN_CODE();
                design.DesignCodeID  = busDesignCode.getIDbyName(designCode[i]);
                design.DesignCode    = designCode[i];
                design.DesignCodeApp = "";
                if (design.DesignCodeID == 0)
                {
                    busDesignCode.add(design);
                }
                else
                {
                    busDesignCode.edit(design);
                }
            }

            //Equipment Master
            List <EQUIPMENT_MASTER> lstEquipMaster = busExcel.getEquipmentMaster();

            foreach (EQUIPMENT_MASTER eq in lstEquipMaster)
            {
                if (busEquipMaster.check(eq.EquipmentNumber))
                {
                    busEquipMaster.edit(eq);
                }
                else
                {
                    busEquipMaster.add(eq);
                }
            }

            //Component Master
            List <COMPONENT_MASTER> lstCompMaster = busExcel.getComponentMaster();

            foreach (COMPONENT_MASTER com in lstCompMaster)
            {
                if (busCompMaster.checkExist(com.ComponentNumber))
                {
                    com.ComponentID = busCompMaster.getIDbyName(com.ComponentNumber);
                    busCompMaster.edit(com);
                }
                else
                {
                    busCompMaster.add(com);
                }
            }

            //Rw Assessment
            List <RW_ASSESSMENT> lstAssessment = busExcel.getAssessment();
            List <int>           editExcel     = new List <int>();
            List <int>           addExcel      = new List <int>();

            foreach (RW_ASSESSMENT ass in lstAssessment)
            {
                List <int[]> ID_checkAddbyExcel = busAss.getCheckAddExcel_ID(ass.ComponentID, ass.EquipmentID);
                if (ID_checkAddbyExcel.Count != 0)
                {
                    for (int i = 0; i < ID_checkAddbyExcel.Count; i++)
                    {
                        if (ID_checkAddbyExcel[i][0] != 0) //kiem tra xem co phai Assessment nay duoc them tu file Excel ko
                        {
                            ass.ID = ID_checkAddbyExcel[i][1];
                            editExcel.Add(ass.ID);
                            busAss.edit(ass);
                        }
                    }
                }
                else
                {
                    ass.AddByExcel = 1;
                    busAss.add(ass);
                    int assID = busAss.getLastID();
                    addExcel.Add(assID);
                    RW_INPUT_CA_TANK inputCATank = new RW_INPUT_CA_TANK();
                    inputCATank.ID = assID;
                    busInputCATank.add(inputCATank);
                }
            }

            //RW Equipment
            List <RW_EQUIPMENT> lstEquipment = busExcel.getRwEquipmentTank();

            for (int i = 0; i < lstEquipment.Count; i++)
            {
                if (editExcel.Count != 0)
                {
                    for (int j = 0; j < editExcel.Count; j++)
                    {
                        if (lstEquipment[i].ID == editExcel[j])
                        {
                            busEquip.edit(lstEquipment[i]);
                        }
                    }
                }
                if (addExcel.Count != 0)
                {
                    for (int j = 0; j < addExcel.Count; j++)
                    {
                        if (lstEquipment[i].ID == addExcel[j])
                        {
                            busEquip.add(lstEquipment[i]);
                        }
                    }
                }
            }

            //RW Component
            List <RW_COMPONENT> lstComponent = busExcel.getRwComponentTank();

            for (int i = 0; i < lstComponent.Count; i++)
            {
                if (editExcel.Count != 0)
                {
                    for (int j = 0; j < editExcel.Count; j++)
                    {
                        if (lstComponent[i].ID == editExcel[j])
                        {
                            busCom.edit(lstComponent[i]);
                        }
                    }
                }
                if (addExcel.Count != 0)
                {
                    for (int j = 0; j < addExcel.Count; j++)
                    {
                        if (lstComponent[i].ID == addExcel[j])
                        {
                            busCom.add(lstComponent[i]);
                        }
                    }
                }
            }

            //RW Extcor temperature
            List <RW_EXTCOR_TEMPERATURE> lstExtcor = busExcel.getRwExtTemp();

            for (int i = 0; i < lstExtcor.Count; i++)
            {
                if (editExcel.Count != 0)
                {
                    for (int j = 0; j < editExcel.Count; j++)
                    {
                        if (lstExtcor[i].ID == editExcel[j])
                        {
                            busExtcor.edit(lstExtcor[i]);
                        }
                    }
                }
                if (addExcel.Count != 0)
                {
                    for (int j = 0; j < addExcel.Count; j++)
                    {
                        if (lstExtcor[i].ID == addExcel[j])
                        {
                            busExtcor.add(lstExtcor[i]);
                        }
                    }
                }
            }

            //RW Stream
            List <RW_STREAM> lstStream = busExcel.getRwStreamTank();

            for (int i = 0; i < lstStream.Count; i++)
            {
                if (editExcel.Count != 0)
                {
                    for (int j = 0; j < editExcel.Count; j++)
                    {
                        if (lstStream[i].ID == editExcel[j])
                        {
                            busStream.edit(lstStream[i]);
                        }
                    }
                }
                if (addExcel.Count != 0)
                {
                    for (int j = 0; j < addExcel.Count; j++)
                    {
                        if (lstStream[i].ID == addExcel[j])
                        {
                            busStream.add(lstStream[i]);
                        }
                    }
                }
            }

            //RW Material
            List <RW_MATERIAL> lstMaterial = busExcel.getRwMaterialTank();

            for (int i = 0; i < lstMaterial.Count; i++)
            {
                if (editExcel.Count != 0)
                {
                    for (int j = 0; j < editExcel.Count; j++)
                    {
                        if (lstMaterial[i].ID == editExcel[j])
                        {
                            busMaterial.edit(lstMaterial[i]);
                        }
                    }
                }
                if (addExcel.Count != 0)
                {
                    for (int j = 0; j < addExcel.Count; j++)
                    {
                        if (lstMaterial[i].ID == addExcel[j])
                        {
                            busMaterial.add(lstMaterial[i]);
                        }
                    }
                }
            }

            //RW Coating
            List <RW_COATING> lstCoating = busExcel.getRwCoating();

            for (int i = 0; i < lstCoating.Count; i++)
            {
                if (editExcel.Count != 0)
                {
                    for (int j = 0; j < editExcel.Count; j++)
                    {
                        if (lstCoating[i].ID == editExcel[j])
                        {
                            busCoating.edit(lstCoating[i]);
                        }
                    }
                }
                if (addExcel.Count != 0)
                {
                    for (int j = 0; j < addExcel.Count; j++)
                    {
                        if (lstCoating[i].ID == addExcel[j])
                        {
                            busCoating.add(lstCoating[i]);
                        }
                    }
                }
            }
            ButtonOKClicked = true;
            SplashScreenManager.CloseForm();
            MessageBox.Show("All data have been saved! You need to add Risk Target in Facility!", "Cortek RBI", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            this.Close();
        }
        private void ShowDataToControl(int ID, string diameter, string thickness, string corrosionRate, string volumeUnit, string stressUnit)
        {
            RW_COMPONENT_BUS busCom   = new RW_COMPONENT_BUS();
            RW_COMPONENT     comp     = busCom.getData(ID);
            BUS_UNITS        convUnit = new BUS_UNITS();

            if (diameter == "INCH")
            {
                txtTankDiameter.Text = (comp.NominalDiameter / convUnit.inch).ToString();                    // converst mm sang in
            }
            else if (diameter == "MM")
            {
                txtTankDiameter.Text = comp.NominalDiameter.ToString();                        // giữ nguyên
            }
            if (thickness == "MM")
            {
                txtNominalThickness.Text         = comp.NominalThickness.ToString(); //giữ nguyên
                txtMinRequiredThickness.Text     = comp.MinReqThickness.ToString();  //  giữ nguyên
                txtCurrentThickness.Text         = comp.CurrentThickness.ToString();
                txtBrittleFractureThickness.Text = comp.BrittleFractureThickness.ToString();
                txtStructuralThickness.Text      = comp.StructuralThickness.ToString();
            }
            else if (thickness == "INCH")
            {
                txtNominalThickness.Text         = (comp.NominalThickness / convUnit.inch).ToString(); //converst mm sang in
                txtMinRequiredThickness.Text     = (comp.MinReqThickness / convUnit.inch).ToString();  //convert mm sang in
                txtCurrentThickness.Text         = (comp.CurrentThickness / convUnit.inch).ToString();
                txtBrittleFractureThickness.Text = (comp.BrittleFractureThickness / convUnit.inch).ToString();
                txtStructuralThickness.Text      = (comp.StructuralThickness / convUnit.inch).ToString();
            }
            if (corrosionRate == "MMYR")
            {
                txtCurrentCorrosionRate.Text = comp.CurrentCorrosionRate.ToString(); // converst mm sang mm
            }
            else
            {
                txtCurrentCorrosionRate.Text = (comp.CurrentCorrosionRate / convUnit.mil).ToString();  // converst mm sang mil
            }
            if (stressUnit == "KSI")
            {
                txtAllowableStress.Text = (comp.AllowableStress / convUnit.ksi).ToString();
            }
            else if (stressUnit == "PSI")
            {
                txtAllowableStress.Text = (comp.AllowableStress / convUnit.psi).ToString();
            }
            else if (stressUnit == "MPA")
            {
                txtAllowableStress.Text = (comp.AllowableStress).ToString();
            }
            else if (stressUnit == "BAR")
            {
                txtAllowableStress.Text = (comp.AllowableStress / convUnit.bar).ToString();
            }
            else if (stressUnit == "NM2")
            {
                txtAllowableStress.Text = (comp.AllowableStress / convUnit.NpM2).ToString();
            }
            else
            {
                txtAllowableStress.Text = (comp.AllowableStress / convUnit.NpCM2).ToString();
            }

            if (volumeUnit == "M3")
            {
                txtComponentVolume.Text = comp.ComponentVolume.ToString();
            }
            else
            {
                txtComponentVolume.Text = (comp.ComponentVolume / convUnit.ft3).ToString();
            }

            chkConcreteAsphalt.Checked   = comp.ConcreteFoundation == 1 ? true : false;
            chkPresenceCracks.Checked    = comp.CracksPresent == 1 ? true : false;
            chkPreventionBarrier.Checked = comp.ReleasePreventionBarrier == 1 ? true : false;
            for (int i = 0; i < itemsBrinnellHardness.Length; i++)
            {
                if (itemsBrinnellHardness[i] == comp.BrinnelHardness)
                {
                    cbMaxBrillnessHardness.SelectedIndex = i + 1;
                    break;
                }
            }
            for (int i = 0; i < itemsComplexityProtrusion.Length; i++)
            {
                if (itemsComplexityProtrusion[i] == comp.ComplexityProtrusion)
                {
                    cbComplexityProtrusion.SelectedIndex = i + 1;
                    break;
                }
            }
            for (int i = 0; i < itemsSeverity.Length; i++)
            {
                if (itemsSeverity[i] == comp.SeverityOfVibration)
                {
                    cbSeverityVibration.SelectedIndex = i + 1;
                    break;
                }
            }
        }
        public void ShowDatatoControl(int ID, string diameter, string thickness, string corrosionRate, string volumeUnit, string stressUnit)
        {
            RW_COMPONENT_BUS    comBus        = new RW_COMPONENT_BUS();
            BUS_UNITS           convUnit      = new BUS_UNITS();
            List <RW_COMPONENT> listComponent = comBus.getDataSource();

            foreach (RW_COMPONENT comp in listComponent)
            {
                if (comp.ID == ID)
                {
                    // mai
                    if (diameter == "INCH")
                    {
                        txtNominalDiameter.Text = (comp.NominalDiameter / convUnit.inch).ToString();                     // converst mm sang in
                    }
                    else if (diameter == "MM")
                    {
                        txtNominalDiameter.Text = comp.NominalDiameter.ToString();                       // giữ nguyên
                    }
                    if (thickness == "MM")
                    {
                        txtNominalThickness.Text         = comp.NominalThickness.ToString(); //giữ nguyên
                        txtMinRequiredThickness.Text     = comp.MinReqThickness.ToString();  //  giữ nguyên
                        txtCurrentThickness.Text         = comp.CurrentThickness.ToString();
                        txtBrittleFractureThickness.Text = comp.BrittleFractureThickness.ToString();
                        txtStructuralThickness.Text      = comp.StructuralThickness.ToString();
                    }
                    else if (thickness == "INCH")
                    {
                        txtNominalThickness.Text         = (comp.NominalThickness / convUnit.inch).ToString(); //converst mm sang in
                        txtMinRequiredThickness.Text     = (comp.MinReqThickness / convUnit.inch).ToString();  //convert mm sang in
                        txtCurrentThickness.Text         = (comp.CurrentThickness / convUnit.inch).ToString();
                        txtBrittleFractureThickness.Text = (comp.BrittleFractureThickness / convUnit.inch).ToString();
                        txtStructuralThickness.Text      = (comp.StructuralThickness / convUnit.inch).ToString();
                    }
                    if (corrosionRate == "MMYR")
                    {
                        txtCurrentCorrosionRate.Text = comp.CurrentCorrosionRate.ToString(); // converst mm sang mm
                    }
                    else
                    {
                        txtCurrentCorrosionRate.Text = (comp.CurrentCorrosionRate / convUnit.mil).ToString();  // converst mm sang mil
                    }
                    if (stressUnit == "KSI")
                    {
                        txtAllowableStress.Text = (comp.AllowableStress / convUnit.ksi).ToString();
                    }
                    else if (stressUnit == "PSI")
                    {
                        txtAllowableStress.Text = (comp.AllowableStress / convUnit.psi).ToString();
                    }
                    else if (stressUnit == "MPA")
                    {
                        txtAllowableStress.Text = (comp.AllowableStress).ToString();
                    }
                    else if (stressUnit == "BAR")
                    {
                        txtAllowableStress.Text = (comp.AllowableStress / convUnit.bar).ToString();
                    }
                    else if (stressUnit == "NM2")
                    {
                        txtAllowableStress.Text = (comp.AllowableStress / convUnit.NpM2).ToString();
                    }
                    else
                    {
                        txtAllowableStress.Text = (comp.AllowableStress / convUnit.NpCM2).ToString();
                    }

                    if (volumeUnit == "M3")
                    {
                        txtComponentVolume.Text = comp.ComponentVolume.ToString();
                    }
                    else
                    {
                        txtComponentVolume.Text = (comp.ComponentVolume / convUnit.ft3).ToString();
                    }

                    txtWeldJointEfficiency.Text = comp.WeldJointEfficiency.ToString();

                    //// end mai
                    chkMinimumStructuralThicknessGoverns.Checked = comp.MinimumStructuralThicknessGoverns == 1 ? true : false;
                    chkPresenceCracks.Checked                = comp.CracksPresent == 1 ? true : false;
                    txtDeltaFATT.Text                        = comp.DeltaFATT.ToString();
                    chkVisibleAudible.Checked                = comp.ShakingDetected == 1 ? true : false;
                    chkFabricatedSteel.Checked               = comp.FabricatedSteel == 1 ? true : false;
                    chkEquipmentSatisfied.Checked            = comp.EquipmentSatisfied == 1 ? true : false;
                    chkNominalOperating.Checked              = comp.NominalOperatingConditions == 1 ? true : false;
                    chkCETGreaterOrEqual.Checked             = comp.CETGreaterOrEqual == 1 ? true : false;
                    chkCyclicServiceFatigueVibration.Checked = comp.CyclicServiceFatigueVibration == 1 ? true : false;
                    chkEquipmentCircuitShock.Checked         = comp.EquipmentCircuitShock == 1 ? true : false;
                    chkHTHADamageObserved.Checked            = comp.HTHADamageObserved == 1 ? true : false;

                    for (int i = 0; i < itemsConfidenceCorrosionRate.Length; i++)
                    {
                        if (comp.ConfidenceCorrosionRate == itemsConfidenceCorrosionRate[i])
                        {
                            cbConfidenceCorrosionRate.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsAccumulatedTimeShaking.Length; i++)
                    {
                        if (comp.ShakingTime == itemsAccumulatedTimeShaking[i])
                        {
                            cbAccumalatedTimeShakingPipe.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsCorrectiveAction.Length; i++)
                    {
                        if (comp.CorrectiveAction == itemsCorrectiveAction[i])
                        {
                            cbCorrectiveAction.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsCyclicLoading.Length; i++)
                    {
                        if (comp.CyclicLoadingWitin15_25m == itemsCyclicLoading[i])
                        {
                            cbCyclicLoading.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsBranchDiameter.Length; i++)
                    {
                        if (comp.BranchDiameter == itemsBranchDiameter[i])
                        {
                            cbBranchDiameter.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsBranchJointType.Length; i++)
                    {
                        if (comp.BranchJointType == itemsBranchJointType[i])
                        {
                            cbJointTypeBranch.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsBrinnellHardness.Length; i++)
                    {
                        if (comp.BrinnelHardness == itemsBrinnellHardness[i])
                        {
                            cbMaxBrillnessHardness.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsNumberPipeFittings.Length; i++)
                    {
                        if (comp.NumberPipeFittings == itemsNumberPipeFittings[i])
                        {
                            cbNumberFittingPipe.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsPipeCondition.Length; i++)
                    {
                        if (comp.PipeCondition == itemsPipeCondition[i])
                        {
                            cbPipeCondition.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsPreviousFailure.Length; i++)
                    {
                        if (comp.PreviousFailures == itemsPreviousFailure[i])
                        {
                            cbPreviousFailures.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsAmountShaking.Length; i++)
                    {
                        if (comp.ShakingAmount == itemsAmountShaking[i])
                        {
                            cbAmountShakingPipe.SelectedIndex = i + 1;
                        }
                    }
                    for (int i = 0; i < itemsComplexityProtrusion.Length; i++)
                    {
                        if (comp.ComplexityProtrusion == itemsComplexityProtrusion[i])
                        {
                            cbComplexityProtrusion.SelectedIndex = i + 1;
                        }
                    }
                }
            }
        }
Example #7
0
        private void ShowDataToControl(int ID, string diameter, string thickness, string corrosionRate)
        {
            RW_COMPONENT_BUS busCom   = new RW_COMPONENT_BUS();
            RW_COMPONENT     com      = busCom.getData(ID);
            BUS_UNITS        convUnit = new BUS_UNITS();

            if (diameter == "in")
            {
                txtTankDiameter.Text = (com.NominalDiameter / convUnit.inch).ToString();                  // converst mm sang in
            }
            else if (diameter == "mm")
            {
                txtTankDiameter.Text = com.NominalDiameter.ToString();                        // giữ nguyên
            }
            else
            {
                txtTankDiameter.Text = (com.NominalDiameter / 1000).ToString();  // converst mm sang m
            }
            if (thickness == "mm")
            {
                txtNominalThickness.Text     = com.NominalThickness.ToString(); //giữ nguyên
                txtCurrentThickness.Text     = com.CurrentThickness.ToString(); // giữ nguyên
                txtMinRequiredThickness.Text = com.MinReqThickness.ToString();  //  giữ nguyên
            }
            else if (thickness == "in")
            {
                txtNominalThickness.Text     = (com.NominalThickness / convUnit.inch).ToString(); //converst mm sang in
                txtCurrentThickness.Text     = (com.CurrentThickness / convUnit.inch).ToString(); //converst mm sang in
                txtMinRequiredThickness.Text = (com.MinReqThickness / convUnit.inch).ToString();  //converst mm sang in
            }
            else
            {
                txtNominalThickness.Text     = (com.NominalThickness / 1000).ToString(); // converst mm sang m
                txtCurrentThickness.Text     = (com.CurrentThickness / 1000).ToString(); // converst mm sang m
                txtMinRequiredThickness.Text = (com.MinReqThickness / 1000).ToString();  // converst mm sang m
            }

            if (corrosionRate == "mm/yr")
            {
                txtCurrentCorrosionRate.Text = com.CurrentCorrosionRate.ToString();                           // converst mm sang mm
            }
            else
            {
                txtCurrentCorrosionRate.Text = (com.CurrentCorrosionRate / convUnit.mil).ToString();  // converst mm sang mil
            }
            txtShellCourseHeight.Text = com.ShellHeight.ToString();
            chkDamageFoundDuringInspection.Checked = com.DamageFoundInspection == 1 ? true : false;
            chkConcreteAsphalt.Checked             = com.ConcreteFoundation == 1 ? true : false;
            chkPresenceCracks.Checked    = com.CracksPresent == 1 ? true : false;
            chkPreventionBarrier.Checked = com.ReleasePreventionBarrier == 1 ? true : false;
            chkTrampElements.Checked     = com.TrampElements == 1 ? true : false;
            for (int i = 0; i < itemsBrinnellHardness.Length; i++)
            {
                if (itemsBrinnellHardness[i] == com.BrinnelHardness)
                {
                    cbMaxBrillnessHardness.SelectedIndex = i + 1;
                    break;
                }
            }
            for (int i = 0; i < itemsComplexityProtrusion.Length; i++)
            {
                if (itemsComplexityProtrusion[i] == com.ComplexityProtrusion)
                {
                    cbComplexityProtrusion.SelectedIndex = i + 1;
                    break;
                }
            }
            for (int i = 0; i < itemsSeverity.Length; i++)
            {
                if (itemsSeverity[i] == com.SeverityOfVibration)
                {
                    cbSeverityVibration.SelectedIndex = i + 1;
                    break;
                }
            }
        }