private void addResource_Button_Click(object sender, EventArgs e)
 {
     using (ResourceWindowsConfigurationForm addForm = new ResourceWindowsConfigurationForm(tabControl_Types.SelectedTab.Text))
     {
         addForm.ShowDialog();
         if (addForm.DialogResult == DialogResult.OK)
         {
             ResourceWindowsCategory newServer = addForm.Resource;
             string newCategoryType            = addForm.CategoryType;
             LoadResourceTypeTabs();
             tabControl_Types.SelectedTab  = tabControl_Types.TabPages[newServer.CategoryType];
             listBox_Resource.SelectedItem = newServer.Name;
             Update_GridView((int)listBox_Resource.SelectedValue);
         }
     }
 }
        private void addAssociated_Button_Click(object sender, EventArgs e)
        {
            List <string> associatedServices         = new List <string>();
            List <ResourceWindowsCategory> services  = new List <ResourceWindowsCategory>();
            ResourceWindowsCategory        component = new ResourceWindowsCategory();

            using (EnterpriseTestContext context = new EnterpriseTestContext())
            {
                component = ResourceWindowsCategory.SelectById(context, (int)listBox_Resource.SelectedValue);
                services  = ResourceWindowsCategory.SelectByParent(context, (int)listBox_Resource.SelectedValue);
            }

            foreach (ResourceWindowsCategory service in services)
            {
                associatedServices.Add(service.Name);
            }

            try
            {
                if (pingServer(component.Name))
                {
                    ResourceWindowsConfigurationForm addForm = new ResourceWindowsConfigurationForm(component, associatedServices);
                    addForm.ShowDialog();
                    if (addForm.DialogResult == DialogResult.OK)
                    {
                        ResourceWindowsCategory newServer = addForm.Resource;
                        string newCategoryType            = addForm.CategoryType;
                        LoadResourceTypeTabs();
                        tabControl_Types.SelectedTab  = tabControl_Types.TabPages[newServer.CategoryType];
                        listBox_Resource.SelectedItem = newServer.Name;
                        Update_GridView((int)listBox_Resource.SelectedValue);
                    }
                }
            }
            catch
            {
                string errorMessage = "Error: No access to " + component.Name;
                MessageBox.Show(errorMessage, "Server Access Failure", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }