private void StenerManagementListView_ItemSelectionChanged(object sender, EventArgs e) { stenerManagementQuestionList.Items.Clear(); if (StenerManagementListView.SelectedItems.Count > 0) { int selectedID = Convert.ToInt32(StenerManagementListView.SelectedItems[0].SubItems[0].Text); QuestionSet qSet = stenerManagement.GetQuestionSet(selectedID); if (qSet != null) { foreach (Question question in qSet.Questions) { string[] row = { question.QuestionID.ToString(), question.QuestionText }; var listItem = new ListViewItem(row); stenerManagementQuestionList.Items.Add(listItem); } } } }
// event handler for selecting a stener to work on. private void WorkOnSelectedStenerButton_Click(object sender, EventArgs e) { // verify that a q-set is actually selected if (completeQuestionSetListView.SelectedItems.Count > 0) { var qSetID = Convert.ToInt32(completeQuestionSetListView.SelectedItems[0].SubItems[1].Text); // retrieve the current question set from the db currentQuestionSet = stenerManagement.GetQuestionSet(qSetID); if (currentQuestionSet != null) { currentQuestion = 1; // disable editing of the question set if it has been approved or is still in the review process if (currentQuestionSet.Status == "SUBMITTED" || currentQuestionSet.Status == "APPROVED") { // disable text boxes answerTextBox.Enabled = false; evidenceLocationTextBox.Enabled = false; complianceCheckBox.Enabled = false; planForSolutionTextBox.Enabled = false; // handle button activations saveAndCloseSetButton.Enabled = true; completeQuestionSetListView.Enabled = false; workOnSelectedStenerButton.Enabled = false; refreshCompleteListButton.Enabled = false; } else { answerTextBox.Enabled = true; complianceCheckBox.Enabled = true; } saveAndCloseSetButton.Enabled = true; // populate the text boxes with the question's data questionCountTextBox.Text = currentQuestion + "/" + currentQuestionSet.Questions.Count; questionBodyTextBox.Text = currentQuestionSet.Questions[currentQuestion - 1].QuestionText; complianceCheckBox.Checked = currentQuestionSet.Questions[currentQuestion - 1].Compliance; answerTextBox.Text = currentQuestionSet.Questions[currentQuestion - 1].Answer; planForSolutionTextBox.Text = currentQuestionSet.Questions[currentQuestion - 1].PlanForSolution; evidenceLocationTextBox.Text = currentQuestionSet.Questions[currentQuestion - 1].EvidenceLocation; // enable editing if the question has not been approved and is not in the review process if (currentQuestionSet.Status != "SUBMITTED" && currentQuestionSet.Status != "APPROVED") { if (complianceCheckBox.Checked) { planForSolutionTextBox.Enabled = false; evidenceLocationTextBox.Enabled = true; } else { planForSolutionTextBox.Enabled = true; evidenceLocationTextBox.Enabled = false; } } // if this is this last question disable the next button if (currentQuestion == currentQuestionSet.Questions.Count) { nextButton.Enabled = false; if (currentQuestionSet.Status != "SUBMITTED" && currentQuestionSet.Status != "APPROVED") { submitQuestionSetButton.Enabled = true; } } // otherwise enable the next button else { nextButton.Enabled = true; submitQuestionSetButton.Enabled = false; } // enable back if this is not the first question if (currentQuestion > 1) { backButton.Enabled = true; } // otherwise disable it. else { backButton.Enabled = false; } } } }
private void WorkOnSelectedStenerButton_Click(object sender, EventArgs e) { if (completeQuestionSetListView.SelectedItems.Count > 0) { int qSetID = Convert.ToInt32(completeQuestionSetListView.SelectedItems[0].SubItems[1].Text); currentQuestionSet = stenerManagement.GetQuestionSet(qSetID); if (currentQuestionSet != null) { currentQuestion = 1; if (currentQuestionSet.Status == "SUBMITTED" || currentQuestionSet.Status == "APPROVED") { answerTextBox.Enabled = false; evidenceLocationTextBox.Enabled = false; complianceCheckBox.Enabled = false; planForSolutionTextBox.Enabled = false; saveAndCloseSetButton.Enabled = true; completeQuestionSetListView.Enabled = false; workOnSelectedStenerButton.Enabled = false; refreshCompleteListButton.Enabled = false; } else { answerTextBox.Enabled = true; complianceCheckBox.Enabled = true; } saveAndCloseSetButton.Enabled = true; questionCountTextBox.Text = currentQuestion + "/" + currentQuestionSet.Questions.Count.ToString(); questionBodyTextBox.Text = currentQuestionSet.Questions[currentQuestion - 1].QuestionText; complianceCheckBox.Checked = currentQuestionSet.Questions[currentQuestion - 1].Compliance; answerTextBox.Text = currentQuestionSet.Questions[currentQuestion - 1].Answer; planForSolutionTextBox.Text = currentQuestionSet.Questions[currentQuestion - 1].PlanForSolution; evidenceLocationTextBox.Text = currentQuestionSet.Questions[currentQuestion - 1].EvidenceLocation; if (currentQuestionSet.Status != "SUBMITTED" && currentQuestionSet.Status != "APPROVED") { if (complianceCheckBox.Checked == true) { planForSolutionTextBox.Enabled = false; evidenceLocationTextBox.Enabled = true; } else { planForSolutionTextBox.Enabled = true; evidenceLocationTextBox.Enabled = false; } } if (currentQuestion == currentQuestionSet.Questions.Count) { nextButton.Enabled = false; if (currentQuestionSet.Status != "SUBMITTED" && currentQuestionSet.Status != "APPROVED") { submitQuestionSetButton.Enabled = true; } } else { nextButton.Enabled = true; submitQuestionSetButton.Enabled = false; } if (currentQuestion > 1) { backButton.Enabled = true; } else { backButton.Enabled = false; } } } }