/// <summary> /// The method updates the chosen question /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void QuestionUpdate_Click(object sender, EventArgs e) { //initialize variables string newQuestion = DescriptionTextBox.Text.Trim(); int questionID = Convert.ToInt32(QuestionDDL.SelectedValue); MessageUserControl.TryRun(() => { //allows access to the question text controller QuestionTextController sysmgr = new QuestionTextController(); //updates the text sysmgr.UpdateQuestionsText(questionID, newQuestion); editQuestion.Visible = true; editResponse.Visible = true; }, "Success", headerText.InnerText + " has been successfully updated"); // display success message }
/// <summary> /// changes the viewable question for editing. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void QuestionDDL_SelectedIndexChanged(object sender, EventArgs e) { try { //initialize variables int selectedQuestion = int.Parse(QuestionDDL.SelectedValue); string description; //allows access to the question text controller QuestionTextController sysmgr = new QuestionTextController(); //returns the question description from the database description = sysmgr.GetQuestionText(selectedQuestion); //if nothing is returned if (String.IsNullOrEmpty(description)) { //don't show the question and the response editQuestion.Visible = false; editResponse.Visible = false; } else { //show the question and the response editQuestion.Visible = true; editResponse.Visible = true; //don't show the message Message.Visible = false; // this is the ID for Question ID on the Question Table QuestionID.Value = QuestionDDL.SelectedItem.Value; headerText.InnerText = QuestionDDL.SelectedItem.Text; DescriptionTextBox.Text = description; } } catch { //don't show the question and the response editQuestion.Visible = false; editResponse.Visible = false; //show the message Message.Visible = true; } }
/// <summary> /// The method loads during the start of the page /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (Session["takingSurvey"] == null || // if participant doesn't take a survey (Session["Unit"] == null && // doesn't choose an option for unit number Session["MealType"] == null && // doesn't choose an option for meal type Session["ParticipantType"] == null && // doesn't choose an option for participant type Session["Q4"] == null)) // doesn't choose an option for Question 4 { // abandon the session and redirect the participant to the survey access page Session.Abandon(); Response.Redirect("~/"); } if (!IsPostBack) { QuestionTextController sysmgr = new QuestionTextController(); // this allows access to the question text controller GenderLabel.Text = sysmgr.GetQuestionGender(); // populates the gender drop-down AgeRangeLabel.Text = sysmgr.GetQuestionAgeRange(); // populates the age range drop-down //if there is a session for the customer profile check box, assign the session to the session value if (Session["CustomerProfileCheckBox"] != null) { //coverts the session customer profile check box to a boolean CustomerProfileCheckBox.Checked = Convert.ToBoolean(Session["CustomerProfileCheckBox"]); } //if customer profile check box is checked if (CustomerProfileCheckBox.Checked) { //dislay the gender and age range drop-downs CustomerProfileContent.Visible = true; AgeDDL.SelectedValue = Session["AgeDDL"].ToString(); GenderDDL.SelectedValue = Session["GenderDDL"].ToString(); } else { //else don't display the the gender and age range drop-downs CustomerProfileContent.Visible = false; } //if there is a session for the contact requests check box, assign the session to the session value if (Session["ContactRequestsCheckBox"] != null) { ContactRequestsCheckBox.Checked = Convert.ToBoolean(Session["ContactRequestsCheckBox"]); } //if contact requests check box is checked if (ContactRequestsCheckBox.Checked) { //display the phone number and room number text boxes ContactRequestsContent.Visible = true; PhoneTextBox.Text = Session["PhoneTextBox"].ToString(); RoomTextBox.Text = Session["RoomTextBox"].ToString(); } else { //else don't display the phone number and room number text boxes. ContactRequestsContent.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { // if the participant doesn't take a survey if (Session["takingSurvey"] == null) { //abandon the session Session.Abandon(); //redirect the participant to the survey access page Response.Redirect("~/"); } if (!IsPostBack) { SiteController site = new SiteController(); //allows access to the site controller //displays the hospital name at the top of the survey SiteName.Text = "Hospital: <span style=font-weight:bold;>" + site.DisplaySiteName(Convert.ToInt32(Session["siteID"])) + "</span>"; //Populate question labels QuestionTextController sysmgr = new QuestionTextController(); //allows access to the question text controller Q1.Text = "1. " + sysmgr.GetQuestion1(); Q1A.Text = sysmgr.GetQuestion1A(); Q1B.Text = sysmgr.GetQuestion1B(); Q1C.Text = sysmgr.GetQuestion1C(); Q1D.Text = sysmgr.GetQuestion1D(); Q1E.Text = sysmgr.GetQuestion1E(); Q2.Text = "2. " + sysmgr.GetQuestion2(); Q3.Text = "3. " + sysmgr.GetQuestion3(); Q4.Text = "4. " + sysmgr.GetQuestion4(); Q5.Text = "5. " + sysmgr.GetQuestion5(); //if there is a session value for unit if (Session["Unit"] != null) { //choose selected unit UnitDropDownList.SelectedValue = Session["Unit"].ToString(); UnitDropDownList.SelectedItem.Selected = true; } //if there is a session value for participant type if (Session["ParticipantType"] != null) { //choose selected participant type ParticipantTypeDropDownList.SelectedValue = Session["ParticipantType"].ToString(); ParticipantTypeDropDownList.SelectedItem.Selected = true; } //if there is a session value for meal type if (Session["MealType"] != null) { //choose selected meal type MealTypeDropDownList.SelectedValue = Session["MealType"].ToString(); MealTypeDropDownList.SelectedItem.Selected = true; } //if there is a session for Q1A if (Session["Q1A"] != null) { //choose selected Q1A Q1AResponse.SelectedValue = Session["Q1A"].ToString(); Q1AResponse.SelectedItem.Selected = true; } //if there is a session for Q1B if (Session["Q1B"] != null) { //choose selected Q1B Q1BResponse.SelectedValue = Session["Q1B"].ToString(); Q1BResponse.SelectedItem.Selected = true; } //if there is a session for Q1C if (Session["Q1C"] != null) { //choose selected Q1C Q1CResponse.SelectedValue = Session["Q1C"].ToString(); Q1CResponse.SelectedItem.Selected = true; } //if there is a session for Q1D if (Session["Q1D"] != null) { //choose selected Q1D Q1DResponse.SelectedValue = Session["Q1D"].ToString(); Q1DResponse.SelectedItem.Selected = true; } //if there is a session for Q1E if (Session["Q1E"] != null) { //choose selected Q1E Q1EResponse.SelectedValue = Session["Q1E"].ToString(); Q1EResponse.SelectedItem.Selected = true; } //if there is a session for Q2 if (Session["Q2"] != null) { //choose selected Q2 Q2Response.SelectedValue = Session["Q2"].ToString(); Q2Response.SelectedItem.Selected = true; } //if there is a session for Q3 if (Session["Q3"] != null) { //choose selected Q3 Q3Response.SelectedValue = Session["Q3"].ToString(); Q3Response.SelectedItem.Selected = true; } //if there is a session for Q4 if (Session["Q4"] != null) { //choose selected Q4 Q4Response.SelectedValue = Session["Q4"].ToString(); Q4Response.SelectedItem.Selected = true; } //if there is a session for Q5 if (Session["Q5"] != null) { //choose selected Q5 Question5.Text = Session["Q5"].ToString(); } } }