protected void btnDeleteChoice_Click(object sender, EventArgs e) { int curr_poll_choice_id = Convert.ToInt32(Request.QueryString["pollChoiceID"]); qSoc_PollChoice2 choice = new qSoc_PollChoice2(); choice.DeletePollChoice(curr_poll_choice_id); qSoc_PollAnswer2 answers = new qSoc_PollAnswer2(); answers.DeleteAllPollChoiceAnswers(curr_poll_choice_id); BindChoices(); plhEditChoice.Visible = false; }
protected void btnSaveChoice_Click(object sender, EventArgs e) { Page.Validate("choice"); if (Page.IsValid) { if (String.IsNullOrEmpty(Request.QueryString["pollChoiceID"])) { int curr_poll_id = (Int32)ViewState["vsPollID"]; qSoc_PollChoice2 choice = new qSoc_PollChoice2(); choice.PollID = curr_poll_id; choice.Choice = txtChoice.Text; choice.ChoiceMediaHTML = txtMediaChoiceHTML.Text; choice.FeedbackTitle = txtFeedbackTitle.Text; choice.FeedbackDescription = txtFeedbackText.Text; choice.FeedbackUrl = txtFeedbackLink.Text; if (rblIsCorrect.SelectedValue == "Yes") choice.Correct = "Yes"; choice.Insert(); int new_poll_choice_id = choice.PollChoiceID; BindChoices(); plhEditChoice.Visible = false; } else { int curr_poll_id = (Int32)ViewState["vsPollID"]; int curr_poll_choice_id = Convert.ToInt32(Request.QueryString["pollChoiceID"]); qSoc_PollChoice2 choice = new qSoc_PollChoice2(curr_poll_choice_id); choice.Choice = txtChoice.Text; choice.ChoiceMediaHTML = txtMediaChoiceHTML.Text; choice.FeedbackTitle = txtFeedbackTitle.Text; choice.FeedbackDescription = txtFeedbackText.Text; choice.FeedbackUrl = txtFeedbackLink.Text; if (rblIsCorrect.SelectedValue == "Yes") choice.Correct = "Yes"; choice.Update(); BindChoices(); plhEditChoice.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { plhAvailableTimes.Visible = false; if (Page.IsPostBack) { // re-bind choices if (String.IsNullOrEmpty(Convert.ToString(poll_id))) if (!String.IsNullOrEmpty(Request.QueryString["pollID"])) poll_id = (Int32)ViewState["vsPollID"]; } if (!Page.IsPostBack) { populateThemes(); if (!String.IsNullOrEmpty(Request.QueryString["pollID"])) { poll_id = Convert.ToInt32(Request.QueryString["pollID"]); ViewState.Add("vsPollID", poll_id); populateKeywords(poll_id, (int)qSoc_ContentType.Types.Poll); populateTopics(poll_id, (int)qSoc_ContentType.Types.Poll); qSoc_Poll2 poll = new qSoc_Poll2(poll_id); lblTitle.Text = "Edit poll (ID: " + poll.PollID + ")"; txtQuestion.Text = poll.Question; rblAvailable.SelectedValue = poll.Available; if (!String.IsNullOrEmpty(Convert.ToString(poll.ThemeID))) ddlTheme.SelectedValue = Convert.ToString(poll.ThemeID); if (poll.PollType == "Fact") { ddlPollType.SelectedValue = "Fact"; } else if (poll.PollType == "Opinion") { if (poll.ExperienceType == "Poll") { ddlPollType.SelectedValue = "Opinion"; } else { ddlPollType.SelectedValue = "Think"; } } rdtStartTime.SelectedDate = poll.StartDate; rdtEndTime.SelectedDate = poll.EndDate; poll_type = poll.ExperienceType; BindChoices(); if (poll.ExperienceType == "Think") { plhAddResponse.Visible = false; repChoices.Visible = false; repNoEditChoices.Visible = true; } else { repChoices.Visible = true; repNoEditChoices.Visible = false; } ddlPollType.Enabled = false; lblPollTypeMessage.Text = "*** You cannot change the poll type once the poll has been created ***"; lblPollTypeMessage.Visible = true; lblMessage.Visible = true; if (rblAvailable.SelectedValue == "Yes") { // disabled since no longer using start dates //plhAvailableTimes.Visible = true; //rfvStartTime.Enabled = true; //rfvEndTime.Enabled = true; plhHighlightedPoll.Visible = true; } else { plhAvailableTimes.Visible = false; rfvStartTime.Enabled = false; rfvEndTime.Enabled = false; plhHighlightedPoll.Visible = false; } // see if in feed qSoc_Feed feed = new qSoc_Feed((int)qSoc_ContentType.Types.Poll, poll_id); plhExistingFeedItem.Visible = false; if (feed != null) { if (feed.FeedID > 0 && feed.MarkAsDelete == 0 && feed.VisibleFeed == true) { chkDisplayInFeed.Checked = true; plhExistingFeedItem.Visible = true; } if (feed.FeedID > 0 && feed.MarkAsDelete == 0 && feed.VisibleExplore == true) { chkDisplayInExplore.Checked = true; } string reserved_keywords = string.Empty; if (!string.IsNullOrEmpty(feed.ReservedKeywords)) { reserved_keywords = feed.ReservedKeywords; } } } else { lblTitle.Text = "New poll"; plhTools.Visible = false; rblAvailable.SelectedValue = "Yes"; populateKeywords(0, (int)qSoc_ContentType.Types.Poll); plhChoices.Visible = false; plhAdditionalInfo.Visible = false; lblMessage.Text = "*** You must first enter and save the basic poll info and then you can add response choices"; rfvAvailable.Enabled = false; rfvEndTime.Enabled = false; rfvStartTime.Enabled = false; plhDisplayInSiteSettings.Visible = false; } if (Convert.ToString(Request.QueryString["mode"]) == "add-successful") { lblMessage.Text = "*** Record Successfully Added - you can now configure additional poll info ***"; lblMessageBottom.Text = "*** Record Successfully Added - you can now configure additional poll info ***"; } if (Request.QueryString["mode"] == "edit-choice") { int poll_choice_id = Convert.ToInt32(Request.QueryString["pollChoiceID"]); ViewState.Add("vsPollChoiceID", poll_choice_id); qSoc_PollChoice2 choice = new qSoc_PollChoice2(poll_choice_id); txtChoice.Text = choice.Choice; txtMediaChoiceHTML.Text = choice.ChoiceMediaHTML; rblIsCorrect.SelectedValue = choice.Correct; if (ddlPollType.SelectedValue == "Fact") plhChoiceCorrect.Visible = true; else plhChoiceCorrect.Visible = false; txtFeedbackTitle.Text = choice.FeedbackTitle; txtFeedbackText.Text = choice.FeedbackDescription; txtFeedbackLink.Text = choice.FeedbackUrl; plhEditChoice.Visible = true; } var highlighted_poll = qSoc_Poll2.GetHighlightedPoll(); if (highlighted_poll != null) { if (highlighted_poll.PollID == poll_id) { chkHighlightedPoll.Checked = true; lblHighlightedMessage.Text = "This is the current highlighted poll ID: " + highlighted_poll.PollID; } else lblHighlightedMessage.Text = "Check to set as the highlighted poll"; } else lblHighlightedMessage.Text = "Check to set as the highlighted poll"; } }
protected int createNewChoice(int curr_poll_id, string choice, bool is_correct) { int new_poll_id = 0; qSoc_PollChoice2 new_choice = new qSoc_PollChoice2(); new_choice.PollID = curr_poll_id; new_choice.Choice = choice; if (is_correct == true) new_choice.Correct = "Yes"; new_choice.ChoiceMediaHTML = txtMediaChoiceHTML.Text; new_choice.FeedbackTitle = txtFeedbackTitle.Text; new_choice.FeedbackDescription = txtFeedbackText.Text; new_choice.FeedbackUrl = txtFeedbackLink.Text; new_choice.Insert(); new_poll_id = new_choice.PollChoiceID; return new_poll_id; }