Esempio n. 1
0
 private void Requirements_ListBox_MouseDown(object sender, MouseEventArgs e)
 {
     Risks_ListBox.ClearSelected(); //Prevents risks from being selected while requirements are selected
 }
Esempio n. 2
0
        private void Modify_Button_Click(object sender, EventArgs e)
        {
            //if both listboxes are empty or neither of them have an item selected then dont run the code below
            if (Risks_ListBox.Items.Count == 0 && Requirements_ListBox.Items.Count == 0 || Risks_ListBox.SelectedIndex == -1 && Requirements_ListBox.SelectedIndex == -1)
            {
                return;
            }


            if (Modify_Button.Text == "Modify Selected Item")
            {
                Modify_Button.Text    = "Update Selected Item";
                Add_Button.Enabled    = false;
                Delete_Button.Enabled = false;

                //For modifying risks
                if (Risks_ListBox.SelectedIndex > -1)
                {
                    //Load into fields the selected risk
                    int x = Risks_ListBox.SelectedIndex;
                    Risk_Name_Textbox.Text        = RiskList[x].Name;
                    Risk_Description_TextBox.Text = RiskList[x].Description;
                    Risk_Status_ComboBox.Text     = RiskList[x].RiskStatus;
                    Risks_ListBox.Enabled         = false;
                    Requirements_ListBox.Enabled  = false;
                }

                //For modifying requirements
                if (Requirements_ListBox.SelectedIndex > -1)
                {
                    //Load into fields the selected requirement
                    int y = Requirements_ListBox.SelectedIndex;
                    Requirements_Name_TextBox.Text        = RequirementList[y].Name;
                    Requirements_Description_TextBox.Text = RequirementList[y].Description;
                    bool ReqStatus = RequirementList[y].Functional;
                    if (ReqStatus == true)
                    {
                        Functional_RadioButton.Checked = true;
                    }
                    else
                    {
                        NonFunctional_RadioButton.Checked = true;
                    }
                    Requirements_ListBox.Enabled = false;
                    Risks_ListBox.Enabled        = false;
                }
            }
            else if (Modify_Button.Text == "Update Selected Item")
            {
                Modify_Button.Text    = "Modify Selected Item";
                Add_Button.Enabled    = true;
                Delete_Button.Enabled = true;

                //Rewrites the risk
                if (Risks_ListBox.SelectedIndex > -1)
                {
                    Risk UpdatedRisk = new Risk(Risk_Name_Textbox.Text, Risk_Description_TextBox.Text, Risk_Status_ComboBox.SelectedItem.ToString());
                    RiskList[Risks_ListBox.SelectedIndex]            = UpdatedRisk;
                    Risks_ListBox.Items[Risks_ListBox.SelectedIndex] = Risk_Name_Textbox.Text;
                    Risks_ListBox.ClearSelected();
                    Risk_Name_Textbox.Text        = "";
                    Risk_Description_TextBox.Text = "";
                    Risk_Status_ComboBox.Text     = "";
                    Risks_ListBox.Enabled         = true;
                    Requirements_ListBox.Enabled  = true;
                    TempProj.setProjRisk(RiskList); //update list of risks
                }

                //Rewrites the requirement
                if (Requirements_ListBox.SelectedIndex > -1)
                {
                    bool RequireType = false;
                    if (Functional_RadioButton.Checked == true)
                    {
                        RequireType = true;
                    }
                    else if (NonFunctional_RadioButton.Checked == true)
                    {
                        RequireType = false;
                    }

                    Requirement UpdatedRequirement = new Requirement(Requirements_Name_TextBox.Text, Requirements_Description_TextBox.Text, RequireType);
                    RequirementList[Requirements_ListBox.SelectedIndex]            = UpdatedRequirement;
                    Requirements_ListBox.Items[Requirements_ListBox.SelectedIndex] = Requirements_Name_TextBox.Text;
                    Requirements_ListBox.ClearSelected();
                    Requirements_Name_TextBox.Text        = "";
                    Requirements_Description_TextBox.Text = "";
                    Functional_RadioButton.Checked        = false;
                    NonFunctional_RadioButton.Checked     = false;
                    Requirements_ListBox.Enabled          = true;
                    Risks_ListBox.Enabled = true;
                    TempProj.setProjReq(RequirementList); //updates list of requirements
                }
            }
        }