コード例 #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>
        /// Setup navigation between tabs
        /// </summary>
        private void SetupNavigation()
        {
            navAdapter.AddTab(Home_Tab.getInstance(), true);
            navAdapter.AddTab(Users_Tab.getInstance(), false);
            navAdapter.AddTab(Projects_Tab.getInstance(), false);
            navAdapter.AddTab(Defects_Tab.getInstance(), false);

            panelTabs_Holder.Controls.Add(Users_Tab_Child.getInstance());
            Users_Tab_Child.getInstance().Dock = DockStyle.Fill;
            panelTabs_Holder.Controls.Add(Projects_Tab_Child.getInstance());
            Projects_Tab_Child.getInstance().Dock = DockStyle.Fill;
            panelTabs_Holder.Controls.Add(Modules_Tab.getInstance());
            Modules_Tab.getInstance().Dock = DockStyle.Fill;
            panelTabs_Holder.Controls.Add(Modules_Tab_Child.getInstance());
            Modules_Tab_Child.getInstance().Dock = DockStyle.Fill;
            panelTabs_Holder.Controls.Add(Defects_Tab_Child.getInstance());
            Defects_Tab_Child.getInstance().Dock = DockStyle.Fill;
            panelTabs_Holder.Controls.Add(Defects_Tab_Child2.getInstance());
            Defects_Tab_Child2.getInstance().Dock = DockStyle.Fill;
        }
コード例 #3
0
 /// <summary>
 /// Navigate to Add Defect view
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnAddNewDefect_Click(object sender, EventArgs e)
 {
     Defects_Tab_Child.getInstance().BringToFront();
     Defects_Tab_Child.getInstance().changeView(null);
 }
コード例 #4
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
                    }
                }
            }
        }