Пример #1
0
        private void addQuestionButton_Click(object sender, EventArgs e)
        {
            if (StenerManagementListView.SelectedItems.Count > 0)
            {
                currentStenerManagementMode          = stenerManagementMode.AddQuestion;
                questionTextbox.Enabled              = true;
                submitStenerManagementButton.Enabled = true;

                StenerManagementListView.Enabled     = false;
                stenerManagementQuestionList.Enabled = false;

                stenerManagementStatusLabel.Text = "Adding question.";
            }
            else
            {
                stenerManagementStatusLabel.Text = "Error adding question.";
            }
        }
Пример #2
0
        private void modifyQuestionButton_Click(object sender, EventArgs e)
        {
            if (StenerManagementListView.SelectedItems.Count > 0 && stenerManagementQuestionList.SelectedItems.Count > 0)
            {
                currentStenerManagementMode          = stenerManagementMode.ModifyQuestion;
                questionTextbox.Enabled              = true;
                submitStenerManagementButton.Enabled = true;
                questionTextbox.Text = stenerManagementQuestionList.SelectedItems[0].SubItems[1].Text;

                StenerManagementListView.Enabled     = false;
                stenerManagementQuestionList.Enabled = false;

                stenerManagementStatusLabel.Text = "Modifying question.";
            }
            else
            {
                stenerManagementStatusLabel.Text = "Error modifying question.";
            }
        }
Пример #3
0
        private void createQuestionSetButton_Click(object sender, EventArgs e)
        {
            departmentComboBox.Enabled           = true;
            priorityComboBox.Enabled             = true;
            dueDateCalendar.Enabled              = true;
            questionTextbox.Enabled              = true;
            submitStenerManagementButton.Enabled = true;
            categoryTextBox.Enabled              = true;

            departmentComboBox.Items.Clear();

            List <string> departmentNames = departmentManagement.GetDepartmentNames();

            foreach (string dept in departmentNames)
            {
                departmentComboBox.Items.Add(dept);
            }

            currentStenerManagementMode = stenerManagementMode.CreateQuestionSet;
        }
Пример #4
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;
        }