コード例 #1
0
        /// <summary>
        /// Method for populating the DataDridView
        /// </summary>
        public void populateDataGridView()
        {
            if (DbConnector.OpenSQLConnection()) // Open connection to the database
            {
                // Connection opened
                DefectDataAccess defect = new DefectDataAccess();
                dgvDefect.AutoGenerateColumns = false; // To only show the columns needed
                if (FormProvider.Dashboard.role == "Tester")
                {
                    dgvDefect.DataSource = defect.FindDefects(FormProvider.Dashboard.username, "Tester");
                }
                else if (FormProvider.Dashboard.role == "Developer")
                {
                    dgvDefect.DataSource = defect.FindDefects(FormProvider.Dashboard.username, "Dev");
                }
                else
                {
                    dgvDefect.DataSource = defect.GetAllDefects();
                }
                txtSearchDefects.Text = "";
                Defects_Tab_Child.getInstance().clearDefectText();
            }
            else
            {
                // Connection could not be opened
                MessageBox.Show("Connection to the database could not be established", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            DbConnector.CloseSQLConnection(); // Close connection to the database
        }
コード例 #2
0
        /// <summary>
        /// Method for populating the Charts
        /// </summary>
        public void populateCharts()
        {
            if (DbConnector.OpenSQLConnection()) // Open connection to the database
            {
                ReportsGenerator      reportGen     = new ReportsGenerator();
                List <StatusAnalysis> statusAnalyis = reportGen.StatusAnalysis();

                barChart.DataSource = statusAnalyis.OrderBy(i => i.Status);
                barChart.Series["Defect Count"].XValueMember  = "Status";
                barChart.Series["Defect Count"].YValueMembers = "Count";
                barChart.Series["Defect Count"].YValueType    = ChartValueType.Int32;

                doughnutChart.DataSource = statusAnalyis.OrderBy(i => i.Status);
                doughnutChart.Series["Count"].XValueMember  = "Status";
                doughnutChart.Series["Count"].YValueMembers = "Count";
                doughnutChart.Series["Count"].YValueType    = ChartValueType.Int32;

                DefectDataAccess defect = new DefectDataAccess();
                var defects             = defect.GetAllDefects();
                drePointChart.DataSource = defect.GetAllDefects();
                drePointChart.Series["DRE"].XValueMember  = "DefectId";
                drePointChart.Series["DRE"].YValueMembers = "DRE";
                drePointChart.Series["DRE"].YValueType    = ChartValueType.Int32;

                List <AgeAnalysis> ageAnalysis = new List <AgeAnalysis>();
                foreach (var d in defects.Zip(reportGen.calculateAge(defects), Tuple.Create))
                {
                    ageAnalysis.Add(new AgeAnalysis
                    {
                        DefectId = d.Item1.DefectId,
                        Age      = d.Item2
                    });
                }
                agePointChart.DataSource = ageAnalysis;
                agePointChart.Series["Age"].XValueMember  = "DefectId";
                agePointChart.Series["Age"].YValueMembers = "Age";
                agePointChart.Series["Age"].YValueType    = ChartValueType.Int32;
            }
            else
            {
                // Connection could not be opened
                MessageBox.Show("Connection to the database could not be established", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            DbConnector.CloseSQLConnection(); // Close connection to the database
        }
コード例 #3
0
        private void btnSearchDRE_Click(object sender, EventArgs e)
        {
            if (DbConnector.OpenSQLConnection()) // Open connection to the database
            {
                // Connection opened
                DefectDataAccess defect = new DefectDataAccess();
                dgvDREAnalysis.AutoGenerateColumns = false; // To only show the columns needed
                dgvDREAnalysis.DataSource          = defect.SearchDefectsAnalysis(txtSearchDRE.Text.Trim());
            }
            else
            {
                // Connection could not be opened
                MessageBox.Show("Connection to the database could not be established", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            DbConnector.CloseSQLConnection(); // Close connection to the database
        }
コード例 #4
0
        /// <summary>
        /// Method for populating the DataDridViews
        /// </summary>
        public void populateDataGridDREAnalysis()
        {
            if (DbConnector.OpenSQLConnection()) // Open connection to the database
            {
                // Connection opened
                DefectDataAccess defect = new DefectDataAccess();
                var defects             = defect.GetAllDefects();
                dgvDREAnalysis.AutoGenerateColumns = false; // To only show the columns needed
                dgvDREAnalysis.DataSource          = defects;
                txtSearchDRE.Text = "";
            }
            else
            {
                // Connection could not be opened
                MessageBox.Show("Connection to the database could not be established", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            DbConnector.CloseSQLConnection(); // Close connection to the database
        }
コード例 #5
0
        /// <summary>
        /// Populate the datagridview with search result
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSearchDefects_Click(object sender, EventArgs e)
        {
            if (DbConnector.OpenSQLConnection()) // Open connection to the database
            {
                // Connection opened
                DefectDataAccess defect = new DefectDataAccess();
                dgvDefect.AutoGenerateColumns = false; // To only show the columns needed
                if (FormProvider.Dashboard.role == "Tester")
                {
                    if (txtSearchDefects.Text != "")
                    {
                        dgvDefect.DataSource = defect.SearchDefects(FormProvider.Dashboard.username, txtSearchDefects.Text.Trim(), "Tester");
                    }
                    else
                    {
                        dgvDefect.DataSource = defect.FindDefects(FormProvider.Dashboard.username, "Tester");
                    }
                }
                else if (FormProvider.Dashboard.role == "Developer")
                {
                    if (txtSearchDefects.Text != "")
                    {
                        dgvDefect.DataSource = defect.SearchDefects(FormProvider.Dashboard.username, txtSearchDefects.Text.Trim(), "Dev");
                    }
                    else
                    {
                        dgvDefect.DataSource = defect.FindDefects(FormProvider.Dashboard.username, "Dev");
                    }
                }
                else
                {
                    dgvDefect.DataSource = defect.SearchDefects(txtSearchDefects.Text.Trim());
                }
            }
            else
            {
                // Connection could not be opened
                MessageBox.Show("Connection to the database could not be established", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            DbConnector.CloseSQLConnection(); // Close connection to the database
        }
コード例 #6
0
        /// <summary>
        /// Method for populating the DataDridViews
        /// </summary>
        public void populateDataGridAgeAnalysis()
        {
            if (DbConnector.OpenSQLConnection()) // Open connection to the database
            {
                // Connection opened
                DefectDataAccess defect = new DefectDataAccess();
                var defects             = defect.GetAllDefects();
                dgvAgeAnalysis.AutoGenerateColumns = false; // To only show the columns needed
                dgvAgeAnalysis.DataSource          = defects;
                txtSearchDefects.Text = "";
                for (int i = 0; i < defects.Count; i++)
                {
                    ReportsGenerator reportGen = new ReportsGenerator();
                    dgvAgeAnalysis.Rows[i].Cells[7].Value = reportGen.calculateAge(defects)[i];
                }
            }
            else
            {
                // Connection could not be opened
                MessageBox.Show("Connection to the database could not be established", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            DbConnector.CloseSQLConnection(); // Close connection to the database
        }
コード例 #7
0
        /// <summary>
        /// Handle the function of adding a defect to the database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDefectSave_Click(object sender, EventArgs e)
        {
            string projectName = comboBoxProject.Text;
            string moduleName  = comboBoxModule.Text;
            string description = txtDescription.Text.Trim();
            string steps       = txtSteps.Text.Trim();
            string raisedBy    = txtRaisedBy.Text.Trim();
            string assignedTo  = comboBoxAssignedTo.Text;
            string status      = comboBoxStatus.Text;
            string priority    = "";

            if (RadioButtonPriorityLow.Checked == true)
            {
                priority = "Low";
            }
            else if (RadioButtonPriorityMed.Checked == true)
            {
                priority = "Medium";
            }
            else
            {
                priority = "High";
            }

            if (projectName != "" && moduleName != "" && description != "" && raisedBy != "" && status != "") // Check if required fields are filled
            {
                if (DbConnector.OpenSQLConnection())                                                          // Open connection to the database
                {
                    // Connection opened
                    DefectDataAccess defect = new DefectDataAccess();

                    if (btnDefectSave.Text == "Save")
                    {
                        if (defect.InsertDefect(projectName, moduleName, description, steps, raisedBy, priority))
                        {
                            // Record inserted successfully
                            MessageBox.Show("Record has been inserted successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Defects_Tab.getInstance().BringToFront();
                            Defects_Tab.getInstance().populateDataGridView();
                        }
                        else
                        {
                            // Record was not inserted
                            MessageBox.Show("The record could not be saved", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else if (btnDefectSave.Text == "Update")
                    {
                        UserDataAccess user = new UserDataAccess();
                        DateTime?      dateClosed;
                        if (defect.UpdateDefect(defectId, projectName, moduleName, description, steps, assignedTo, status, priority,
                                                comboBoxStatus.Text == "Closed" ? dateClosed = DateTime.Now.Date : null, comboBoxStatus.Text != defectStatus && (comboBoxStatus.Text == "Rejected" ||
                                                                                                                                                                 comboBoxStatus.Text == "Duplicate") ? drr - 1 : drr, comboBoxStatus.Text != defectStatus && (comboBoxStatus.Text == "Rejected" ||
                                                                                                                                                                                                                                                              comboBoxStatus.Text == "Duplicate") ? dre - 1 : comboBoxStatus.Text != defectStatus && comboBoxStatus.Text == "Re-Opened" ? dre + 1 : dre) &&
                            user.UpdateUserStatus(currentAssigned, "Available") &&
                            (user.UpdateUserStatus(comboBoxStatus.Text == "Closed" || comboBoxStatus.Text == "Rejected" || comboBoxStatus.Text == "Duplicate" ?
                                                   assignedTo = null : comboBoxAssignedTo.Text, "Assigned")))
                        {
                            // Record updated successfully
                            MessageBox.Show("Record has been updated successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Defects_Tab.getInstance().BringToFront();
                            Defects_Tab.getInstance().populateDataGridView();
                        }
                        else
                        {
                            // Record was not updated
                            MessageBox.Show("The record could not be updated", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    // Connection could not be opened
                    MessageBox.Show("Connection to the database could not be established", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                // Fields not filled correctly
                MessageBox.Show("Please fill all the required fields", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #8
0
        /// <summary>
        /// Handles DataGridView button click events
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvDefect_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var Column = ((DataGridView)sender).Columns[e.ColumnIndex];

            if (Column is DataGridViewButtonColumn && e.RowIndex >= 0)
            {
                if (DbConnector.OpenSQLConnection()) // Open connection to the database
                {
                    // Connection opened
                    DefectDataAccess defect = new DefectDataAccess();
                    var result = defect.FindDefect(Convert.ToInt32(dgvDefect.Rows[e.RowIndex].Cells[0].Value));

                    if (Column.Index == 11) // Details button
                    {
                        if (result != null)
                        {
                            Defects_Tab_Child2.getInstance().BringToFront();
                            Defects_Tab_Child2.getInstance().populate(result);
                        }
                    }
                    else if (Column.Index == 12) // Update button
                    {
                        if (result != null)
                        {
                            Defects_Tab_Child.getInstance().BringToFront();
                            Defects_Tab_Child.getInstance().changeView(result);
                        }
                    }
                }
                else
                {
                    // Connection could not be opened
                    MessageBox.Show("Connection to the database could not be established", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                DbConnector.CloseSQLConnection(); // Close connection to the database

                if (Column.Index == 13)           // Delete button
                {
                    if (MessageBox.Show("Are you sure you want to delete this record?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        if (DbConnector.OpenSQLConnection()) // Open connection to the database
                        {
                            // Connection opened
                            DefectDataAccess defect = new DefectDataAccess();
                            if (defect.DeleteDefect(Convert.ToInt32(dgvDefect.Rows[e.RowIndex].Cells[0].Value)))
                            {
                                // Record deleted successfully
                                MessageBox.Show("Record has been deleted successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                populateDataGridView();
                            }
                            else
                            {
                                // Record was not deleted
                                MessageBox.Show("The record could not be deleted", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            // Connection could not be opened
                            MessageBox.Show("Connection to the database could not be established", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        DbConnector.CloseSQLConnection(); // Close connection to the database
                    }
                }
            }
        }