/// <summary>
        /// Handle the function of adding a module to the database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnModuleSave_Click(object sender, EventArgs e)
        {
            string moduleName     = txtModuleName.Text.Trim();
            string moduleFunction = txtModuleFunction.Text.Trim();
            string addedBy        = txtAddedBy.Text.Trim();

            if (moduleName != "" && moduleFunction != "" && addedBy != "") // Check if required fields are filled
            {
                if (DbConnector.OpenSQLConnection())                       // Open connection to the database
                {
                    // Connection opened
                    ModuleDataAccess module = new ModuleDataAccess();

                    if (btnModuleSave.Text == "Save")
                    {
                        if (module.InsertModule(projectId, moduleName, moduleFunction, addedBy))
                        {
                            // Record inserted successfully
                            MessageBox.Show("Record has been inserted successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Modules_Tab.getInstance().BringToFront();
                            Modules_Tab.getInstance().populateDataGridView(projectId);
                        }
                        else
                        {
                            // Record was not inserted
                            MessageBox.Show("The record could not be saved", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else if (btnModuleSave.Text == "Update")
                    {
                        if (module.UpdateModule(moduleId, moduleName, moduleFunction, addedBy))
                        {
                            // Record updated successfully
                            MessageBox.Show("Record has been updated successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Modules_Tab.getInstance().BringToFront();
                            Modules_Tab.getInstance().populateDataGridView(projectId);
                        }
                        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);
            }
        }
示例#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;
        }
 /// <summary>
 /// Navigate to the Modules List view
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnModulesCancel_Click(object sender, EventArgs e)
 {
     Modules_Tab.getInstance().BringToFront();
     Modules_Tab.getInstance().populateDataGridView(projectId);
 }