Exemplo n.º 1
0
        /// <summary>
        /// Handler when the user has added a risk to the project.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addRiskToProject(object sender, AddRiskToProjectEvent e)
        {
            if (e.projectID != this.projectID)
            {
                return;
            }
            ARA_ListItem clickedText = (ARA_ListItem)sender;

            if (clickedText != null)
            {
                //Is the risk already in the project?
                if (clickedText.BackgroundColor == ARA_Colors.ARA_Green)
                {
                    //Change its color and remove it from the database.
                    clickedText.BackgroundColor = Color.White;
                    this.queriesTableAdapter1.Delete_From_ProjectRisks(e.projectID, e.riskID);
                }
                else
                {
                    //Change its color and add a new risk to the database.
                    clickedText.BackgroundColor = ARA_Colors.ARA_Green;
                    this.queriesTableAdapter1.Insert_In_ProjectRisks(e.projectID, e.riskID);
                }
                //Update the text.
                clickedText.Invalidate();
            }

            //Let the application know we added a risk.
            ARA_Events.triggerRiskAddedToProjectEvent(this.projectID);
        }
        /// <summary>
        /// Handler when the user wants to add the selected risks to the current opend project.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void onCopyRisksButtonClicked(object sender, EventArgs e)
        {
            //Do we have our selection?
            if (this.copyRisksDataGrid.SelectedRows.Count > 0 && this.copyRisksComboBoxProjects.SelectedValue != null)
            {
                //Loop through selected rows.
                foreach (DataGridViewRow row in this.copyRisksDataGrid.SelectedRows)
                {
                    //Execute procedure to copy risks to another project.
                    this.queriesTableAdapter1.Copy_Risk_From_Project_Into_Project((Int32)row.Cells["riskIDDataGridViewTextBoxColumn"].Value, (Int32)this.copyRisksComboBoxProjects.SelectedValue, this.projectID);
                }

                //Let other forms in the application know we added some new risks to this project.
                ARA_Events.triggerRiskAddedToProjectEvent(this.projectID);

                //Let the user know the added some risks to the current opend project.
                System.Windows.Forms.MessageBox.Show(ARA_Constants.messageBoxSuccesCopiedRisks, ARA_Constants.messageBoxSuccesCopiedRisksHead, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Deletes or adds a risk to the project directly from the searchbar.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void onDataGridRowDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                //Execute query to add or delete the risk to the project.
                if (this.addRiskToProjectSearchDataGrid.Rows[e.RowIndex].Cells["inProjectDataGridViewTextBoxColumn"].Value.ToString() == "1")
                {
                    this.queriesTableAdapter1.Delete_From_ProjectRisks(this.projectID, Int32.Parse(this.addRiskToProjectSearchDataGrid.Rows[e.RowIndex].Cells["riskIDDataGridViewTextBoxColumn"].Value.ToString()));
                }
                else
                {
                    this.queriesTableAdapter1.Insert_In_ProjectRisks(this.projectID, Int32.Parse(this.addRiskToProjectSearchDataGrid.Rows[e.RowIndex].Cells["riskIDDataGridViewTextBoxColumn"].Value.ToString()));
                }
                //Sneaky way to fire a textchange event without changing the text.
                this.addRiskToProjectSearchTextBox.Text += "";

                //Let the application know we added a risk.
                ARA_Events.triggerRiskAddedToProjectEvent(this.projectID);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds component types to a component group.
        /// </summary>
        /// <param name="parentGroup"></param>
        public void addTypeControlsToGroupControl(ARA_ListGroup parentGroup)
        {
            if (parentGroup.ARA_ListGroupDropDownButton.ConnectedPanel.Controls.Count != 0)
            {
                return;
            }
            foreach (DataRow datarow in this.get_TypeNames_In_GroupTableAdapter.GetData(parentGroup.DropDownButtonText).Rows)
            {
                ARA_ListGroup listType = new ARA_ListGroup();
                styleListGroupAsType(parentGroup, listType);
                listType.DropDownButtonText = datarow["TypeName"].ToString();

                //Add functions.
                listType.addFunction(delegate()
                {
                    DataRow risksInTypeDataRow = this.get_Risks_In_Project_TypeTableAdapter.GetData(this.projectID, parentGroup.DropDownButtonText, datarow["TypeName"].ToString()).Rows[0];
                    listType.LabelText         = risksInTypeDataRow["RisksInProjectGroup"] + "/" + risksInTypeDataRow["RisksInGroup"];
                });
                listType.updateControl();
                listType.addFunction(delegate() { this.addRiskControlsToTypeControl(parentGroup, listType); });

                //Add click handler for mass insert/delete risks in project on doubleclick.
                listType.DoubleClick += delegate(object o, EventArgs e)
                {
                    DataRow risksInTypeDataRow = this.get_Risks_In_Project_TypeTableAdapter.GetData(this.projectID, parentGroup.DropDownButtonText, datarow["TypeName"].ToString()).Rows[0];
                    //Execute procedure to add or remove risks from a specific type in the project.
                    this.queriesTableAdapter1.Insert_Risks_From_Type_Into_Project
                    (
                        this.projectID,
                        parentGroup.DropDownButtonText,
                        datarow["TypeName"].ToString(),
                        risksInTypeDataRow["RisksInProjectGroup"].ToString() != risksInTypeDataRow["RisksInGroup"].ToString()
                    );

                    //Let the application know we added a risk.
                    ARA_Events.triggerRiskAddedToProjectEvent(this.projectID);
                };
            }
        }