Example #1
0
        private void NewUserOK_Click(object sender, EventArgs e)
        {
            var newUser          = new AccountManagement();
            var department       = new DepartmentManagement();
            var departmentByName = department.GetDepartmentByName(departmentAssign.Text);

            if (newUsername.Text == "" || newUserPassword.Text == "" || confirmNewUserPassword.Text == "" ||
                departmentAssign.Text == "" || permissionsBox.Text == "" || confirmNewUserPassword.Text == "")
            {
                MessageBox.Show("You must have a value for ALL fields");
            }
            else if (newUserPassword.Text != "" || confirmNewUserPassword.Text != "")
            {
                if (confirmNewUserPassword.Text == newUserPassword.Text)
                {
                    newUser.CreateUser(newUsername.Text, newUserPassword.Text, departmentByName.DepartmentUid,
                                       Convert.ToInt32(permissionsBox.Text));
                    Hide();
                }
            }
            else
            {
                MessageBox.Show("Passwords do not match, Please re-enter");
            }
        }
Example #2
0
        private void submitStenerManagementButton_Click(object sender, EventArgs e)
        {
            bool   success       = false;
            string statusMessage = "";

            if (currentStenerManagementMode == stenerManagementMode.CreateQuestionSet)
            {
                // TODO: Need to populate the department drop down box dynamically and get a string name
                if (departmentComboBox.SelectedItem != null &&
                    priorityComboBox.SelectedItem != null &&
                    dueDateCalendar.SelectionStart != null &&
                    questionTextbox.Text != "" &&
                    categoryTextBox.Text != "")
                {
                    string   departmentName = departmentComboBox.SelectedItem.ToString();
                    int      priority       = Convert.ToInt32(priorityComboBox.SelectedItem);
                    DateTime dueDate        = dueDateCalendar.SelectionStart;
                    string   question       = questionTextbox.Text;
                    string   category       = categoryTextBox.Text;

                    int departmentID = departmentManagement.GetDepartmentByName(departmentName).DepartmentUID;

                    bool result = stenerManagement.CreateQuestionSet(departmentID, priority, dueDate, question, category);

                    if (result == true)
                    {
                        success       = true;
                        statusMessage = "Successfully added the new question set.";
                        currentStenerManagementMode = stenerManagementMode.None;
                        departmentComboBox.Items.Clear();
                        questionTextbox.Text = "";
                        categoryTextBox.Text = "";
                    }
                    else
                    {
                        success       = false;
                        statusMessage = "Error adding the new question set.";
                    }
                }
                else
                {
                    success       = false;
                    statusMessage = "Cannot submit until all fields have a selection or an value entered!";
                }
            }
            else if (currentStenerManagementMode == stenerManagementMode.ModifyQuestion)
            {
                if (StenerManagementListView.SelectedItems.Count > 0 && stenerManagementQuestionList.SelectedItems.Count > 0 && questionTextbox.Text != "")
                {
                    int qSetID = Convert.ToInt32(StenerManagementListView.SelectedItems[0].SubItems[0].Text);
                    int qID    = Convert.ToInt32(stenerManagementQuestionList.SelectedItems[0].SubItems[0].Text);

                    bool result = stenerManagement.ModifyQuestion(questionTextbox.Text, qSetID, qID);

                    if (result == true)
                    {
                        success = true;

                        statusMessage = "Successfully modified the question.";
                        currentStenerManagementMode = stenerManagementMode.None;
                        questionTextbox.Text        = "";
                        this.refreshStenerManagementList();
                    }
                    else
                    {
                        success = false;

                        statusMessage        = "Error modifying the question.";
                        questionTextbox.Text = "";
                    }
                }
                else
                {
                    success = false;

                    statusMessage = "Error modifying the question.";
                }
            }
            else if (currentStenerManagementMode == stenerManagementMode.AddQuestion)
            {
                if (StenerManagementListView.SelectedItems.Count > 0 && questionTextbox.Text != "")
                {
                    int qSetID = Convert.ToInt32(StenerManagementListView.SelectedItems[0].SubItems[0].Text);

                    bool result = stenerManagement.AddQuestion(questionTextbox.Text, qSetID);

                    if (result == true)
                    {
                        success = true;

                        statusMessage = "Successfully added the question.";
                        currentStenerManagementMode = stenerManagementMode.None;
                        questionTextbox.Text        = "";
                        this.refreshStenerManagementList();
                    }
                    else
                    {
                        success = false;

                        statusMessage        = "Error adding the question.";
                        questionTextbox.Text = "";
                    }
                }
                else
                {
                    success = false;

                    statusMessage = "Error modifying the question.";
                }
            }
            else if (currentStenerManagementMode == stenerManagementMode.None)
            {
            }
            else
            {
                //error stuffs
            }

            // disable everything if submission was successfull

            if (success == true)
            {
                StenerManagementListView.Enabled     = true;
                stenerManagementQuestionList.Enabled = true;

                departmentComboBox.Enabled           = false;
                priorityComboBox.Enabled             = false;
                dueDateCalendar.Enabled              = false;
                questionTextbox.Enabled              = false;
                submitStenerManagementButton.Enabled = false;
                categoryTextBox.Enabled              = false;
            }

            stenerManagementStatusLabel.Text = statusMessage;
        }