private void addAffectedComponentButton_Click(object sender, EventArgs e)
        {
            int selectedIndex = this.affectedComponentsNameList.SelectedIndex;

            if (this.affectedComponentsNameList.SelectedIndex == -1)
            {
                return;
            }
            this.currentAffectedComponent = Tools.DataBase[selectedIndex];
            if (this.currentAffectedComponentsList == null)
            {
                this.currentAffectedComponentsList = new List <SystemComponent>();
                this.currentAffectedComponentsList.Add(this.currentAffectedComponent);
                Tools.loadListIntoDataGridView(this.currentAffectedComponentsList, this.affectedComponentsView, false);
            }
            else if (Tools.findComponentInListOfComponents(this.currentAffectedComponentsList, this.currentAffectedComponent.getName()) == null)
            {
                this.currentAffectedComponentsList.Add(this.currentAffectedComponent);
                Tools.loadListIntoDataGridView(this.currentAffectedComponentsList, this.affectedComponentsView, false);
            }
            else
            {
                int num = (int)MessageBox.Show(Tools.ALREADY_EXISTS_COMPONENT_ERROR, Tools.ERROR, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
 public static void getAffectingComponents(
     SystemComponent selectedComponent,
     List <SystemComponent> listOfAffectingComponents)
 {
     for (int index1 = 0; index1 < Tools.DataBase.Count; ++index1)
     {
         if (selectedComponent.getName() != Tools.DataBase[index1].getName())
         {
             for (int index2 = 0; index2 < Tools.DataBase[index1].getFaultsList().Count; ++index2)
             {
                 for (int index3 = 0; index3 < Tools.DataBase[index1].getFaultsList()[index2].getAffectedComponents().Count; ++index3)
                 {
                     if (selectedComponent.getName() == Tools.DataBase[index1].getFaultsList()[index2].getAffectedComponents()[index3].getName() && Tools.findComponentInListOfComponents(listOfAffectingComponents, Tools.DataBase[index1].getName()) == null)
                     {
                         listOfAffectingComponents.Add(Tools.DataBase[index1]);
                         if (!Tools.isComponentParentIsAlsoHisSon(Tools.DataBase[index1], selectedComponent))
                         {
                             Tools.getAffectingComponents(Tools.DataBase[index1], listOfAffectingComponents);
                         }
                     }
                 }
             }
         }
     }
 }
 public static void createAffectedComponentsList(
     SystemComponent selectedComponent,
     Fault selectedFault,
     List <SystemComponent> affectedComponents)
 {
     affectedComponents.Add(selectedComponent);
     Tools.getAffeectedComponents(selectedComponent.getName(), selectedFault, affectedComponents);
 }
 public static void DeleteFromDB(SystemComponent component)
 {
     for (int index = 0; index < Tools.DataBase.Count; ++index)
     {
         if (component.isEquals(Tools.DataBase[index]))
         {
             Tools.DataBase.RemoveAt(index);
             Tools.componentsList.RemoveAt(index);
         }
     }
 }
 public static bool isComponentParentIsAlsoHisSon(
     SystemComponent parent,
     SystemComponent selectedComponent)
 {
     for (int index1 = 0; index1 < selectedComponent.getFaultsList().Count; ++index1)
     {
         for (int index2 = 0; index2 < selectedComponent.getFaultsList()[index1].getAffectedComponents().Count; ++index2)
         {
             if (parent.getName() == selectedComponent.getFaultsList()[index1].getAffectedComponents()[index2].getName())
             {
                 return(true);
             }
         }
     }
     return(false);
 }
 public static void getAffeectedComponents(
     string selectedComponentName,
     Fault selectedFault,
     List <SystemComponent> affectedComponents)
 {
     for (int index1 = 0; index1 < selectedFault.getAffectedComponents().Count; ++index1)
     {
         SystemComponent affectedComponent = selectedFault.getAffectedComponents()[index1];
         if (affectedComponent.getName() != selectedComponentName && Tools.findComponentInListOfComponents(selectedFault.getAffectedComponents(), selectedComponentName) == null)
         {
             affectedComponents.Add(affectedComponent);
             for (int index2 = 0; index2 < affectedComponent.getFaultsList().Count; ++index2)
             {
                 Tools.getAffeectedComponents(affectedComponent.getName(), affectedComponent.getFaultsList()[index2], affectedComponents);
             }
         }
     }
 }
        public static List <SystemComponent> selectedItemsList(
            DataGridView componentsView)
        {
            List <SystemComponent> systemComponentList = new List <SystemComponent>();

            for (int index = 0; index < componentsView.Rows.Count; ++index)
            {
                DataGridViewRow row = componentsView.Rows[index];
                if (row.Cells[0].Value != null && (bool)row.Cells[0].Value)
                {
                    SystemComponent listOfComponents = Tools.findComponentInListOfComponents(Tools.DataBase, (string)row.Cells[1].Value);
                    if (listOfComponents != null)
                    {
                        systemComponentList.Add(listOfComponents);
                    }
                }
            }
            return(systemComponentList);
        }
 public bool isEquals(SystemComponent component)
 {
     return(this.name == component.getName());
 }