/// <summary> /// Loads new data for this control. /// </summary> public void LoadData() { // If working with existing record if (ItemID > 0) { pollAnswerObj = PollAnswerInfoProvider.GetPollAnswerInfo(ItemID); EditedObject = pollAnswerObj; if (pollAnswerObj != null) { // Fill editing form if (!RequestHelper.IsPostBack()) { ReloadData(); } // When saved, display info message if (Saved) { ShowChangesSaved(); Saved = false; } PollId = pollAnswerObj.AnswerPollID; } } // If creating new record else { plcVotes.Visible = false; txtVotes.Text = "0"; } }
protected void Page_Load(object sender, EventArgs e) { // Get AnswerID and PollID from querystring int pollId = QueryHelper.GetInteger("pollid", 0); string currentPollAnswer = GetString("Polls_Answer_Edit.NewItemCaption"); int answerId = QueryHelper.GetInteger("answerId", 0); if (QueryHelper.GetInteger("saved", 0) == 1) { AnswerEdit.Saved = true; } AnswerEdit.ItemID = answerId; AnswerEdit.PollId = pollId; if (answerId > 0) { // Modifying existing answer this.CurrentMaster.Title.HelpTopicName = "answer_edit"; PollAnswerInfo pollAnswerObj = PollAnswerInfoProvider.GetPollAnswerInfo(answerId); EditedObject = pollAnswerObj; if (pollAnswerObj != null) { currentPollAnswer = GetString("Polls_Answer_Edit.AnswerLabel") + " " + pollAnswerObj.AnswerOrder.ToString(); pollId = pollAnswerObj.AnswerPollID; } } else { // Creating new answer - check if parent object exists EditedObject = PollInfoProvider.GetPollInfo(pollId); this.CurrentMaster.Title.HelpTopicName = "new_answer"; } // Initializes page title control string[,] breadcrumbs = new string[2, 3]; breadcrumbs[0, 0] = GetString("Polls_Answer_Edit.ItemListLink"); breadcrumbs[0, 1] = "~/CMSModules/Polls/Tools/Polls_Answer_List.aspx?pollId=" + pollId; breadcrumbs[0, 2] = ""; breadcrumbs[1, 0] = currentPollAnswer; breadcrumbs[1, 1] = ""; breadcrumbs[1, 2] = ""; this.CurrentMaster.Title.Breadcrumbs = breadcrumbs; // New item link string[,] actions = new string[1, 6]; actions[0, 0] = HeaderActions.TYPE_HYPERLINK; actions[0, 1] = GetString("Polls_Answer_List.NewItemCaption"); actions[0, 2] = null; actions[0, 3] = ResolveUrl("Polls_Answer_Edit.aspx?pollId=" + pollId.ToString()); actions[0, 4] = null; actions[0, 5] = GetImageUrl("CMSModules/CMS_Polls/addanswer.png"); this.CurrentMaster.HeaderActions.Actions = actions; AnswerEdit.OnSaved += new EventHandler(AnswerEdit_OnSaved); AnswerEdit.IsLiveSite = false; }
/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { // Load current answer object if (pollAnswerObj == null) { pollAnswerObj = PollAnswerInfoProvider.GetPollAnswerInfo(this.ItemID); } // Check permission for answer object (global/site poll) if (!CheckModifyPermission(this.PollId)) { return; } string errorMessage = null; // Validate the input if (txtVotes.Visible) { errorMessage = new Validator().NotEmpty(txtAnswerText.Text, rfvAnswerText.ErrorMessage) .IsPositiveNumber(txtVotes.Text, GetString("Polls_Answer_Edit.VotesNotNumber"), true) .IsInteger(txtVotes.Text, GetString("Polls_Answer_Edit.VotesNotNumber")).Result; } else { errorMessage = new Validator().NotEmpty(txtAnswerText.Text, rfvAnswerText.ErrorMessage).Result; } if (String.IsNullOrEmpty(errorMessage)) { // If pollAnswer doesn't already exist, create new one if (pollAnswerObj == null) { pollAnswerObj = new PollAnswerInfo(); pollAnswerObj.AnswerOrder = PollAnswerInfoProvider.GetLastAnswerOrder(this.PollId) + 1; pollAnswerObj.AnswerCount = 0; pollAnswerObj.AnswerPollID = this.PollId; } // Set the fields pollAnswerObj.AnswerEnabled = chkAnswerEnabled.Checked; pollAnswerObj.AnswerText = txtAnswerText.Text.Trim(); pollAnswerObj.AnswerCount = ValidationHelper.GetInteger(this.txtVotes.Text, 0); // Save the data PollAnswerInfoProvider.SetPollAnswerInfo(pollAnswerObj); this.Saved = true; this.ItemID = pollAnswerObj.AnswerID; // Raise event; RaiseOnSaved(); } else { // Error message - Validation lblError.Visible = true; lblError.Text = errorMessage; } }
protected void Page_Load(object sender, EventArgs e) { // Get AnswerID and PollID from querystring int pollId = QueryHelper.GetInteger("pollid", 0); string currentPollAnswer = GetString("Polls_Answer_Edit.NewItemCaption"); int answerId = QueryHelper.GetInteger("answerId", 0); if (QueryHelper.GetInteger("saved", 0) == 1) { AnswerEdit.Saved = true; } AnswerEdit.ItemID = answerId; AnswerEdit.PollId = pollId; if (answerId > 0) { // Modifying existing answer PollAnswerInfo pollAnswerObj = PollAnswerInfoProvider.GetPollAnswerInfo(answerId); EditedObject = pollAnswerObj; if (pollAnswerObj != null) { currentPollAnswer = GetString("Polls_Answer_Edit.AnswerLabel") + " " + pollAnswerObj.AnswerOrder.ToString(); pollId = pollAnswerObj.AnswerPollID; } } else { // Creating new answer - check if parent object exists EditedObject = PollInfoProvider.GetPollInfo(pollId); } var poll = EditedObject as PollInfo ?? PollInfoProvider.GetPollInfo(pollId); CheckPollsReadPermission(poll.PollSiteID); // Create breadcrumbs CreateBreadCrumbs(pollId, currentPollAnswer); HeaderAction add = new HeaderAction { Text = GetString("Polls_Answer_List.NewItemCaption"), RedirectUrl = ResolveUrl("Polls_Answer_Edit.aspx?pollId=" + pollId), }; CurrentMaster.HeaderActions.AddAction(add); AnswerEdit.OnSaved += AnswerEdit_OnSaved; AnswerEdit.IsLiveSite = false; }
/// <summary> /// Initializes breadcrumbs items. /// </summary> private void InitializeBreadcrumbs() { ucBreadcrumbs.Items.Clear(); ucBreadcrumbs.AddBreadcrumb(new BreadcrumbItem { Text = GetString("Polls_Answer_Edit.ItemListLink"), OnClientClick = ControlsHelper.GetPostBackEventReference(lnkBackHidden) + "; return false;" }); PollAnswerInfo pollAnswerObj = (AnswerEdit.ItemID > 0) ? PollAnswerInfoProvider.GetPollAnswerInfo(AnswerEdit.ItemID) : null; ucBreadcrumbs.AddBreadcrumb(new BreadcrumbItem { Text = (pollAnswerObj == null) ? GetString("Polls_Answer_Edit.NewItemCaption") : GetString("Polls_Answer_Edit.AnswerLabel") + " " + pollAnswerObj.AnswerOrder.ToString(), }); }
/// <summary> /// Reloads answer data. /// </summary> public override void ReloadData() { ClearForm(); if (pollAnswerObj == null) { pollAnswerObj = PollAnswerInfoProvider.GetPollAnswerInfo(ItemID); } if (pollAnswerObj != null) { // Load the fields txtAnswerText.Text = pollAnswerObj.AnswerText; chkAnswerEnabled.Checked = pollAnswerObj.AnswerEnabled; txtVotes.Text = pollAnswerObj.AnswerCount.ToString(); pnlGeneral.GroupingText = GetString("general.general"); plcVotes.Visible = true; // Check if bizform module is available (for open-ended answers). if (ModuleEntry.IsModuleLoaded(ModuleEntry.BIZFORM) && ResourceSiteInfoProvider.IsResourceOnSite(ModuleEntry.BIZFORM, CMSContext.CurrentSiteName)) { // Show open-ended answer settings only for site poll PollInfo pi = PollInfoProvider.GetPollInfo(pollAnswerObj.AnswerPollID); plcOpenAnswer.Visible = (pi != null) && (pi.PollSiteID > 0) && (pi.PollGroupID == 0); chkAnswerIsOpenEnded.Checked = plcOpenAnswerSettings.Visible = pollAnswerObj.AnswerIsOpenEnded; bizFormElem.Value = pollAnswerObj.AnswerForm; alternativeFormElem.ClassName = "BizForm." + bizFormElem.Text; alternativeFormElem.Value = pollAnswerObj.AnswerAlternativeForm; chkAnswerHideForm.Checked = pollAnswerObj.AnswerHideForm; pnlAnswerForm.GroupingText = GetString("polls.answerformsettings"); } } else { txtAnswerText.Text = String.Empty; plcVotes.Visible = false; pnlGeneral.GroupingText = string.Empty; } }
/// <summary> /// Loads new data for this control. /// </summary> public void LoadData() { // If working with existing record if (this.ItemID > 0) { pollAnswerObj = PollAnswerInfoProvider.GetPollAnswerInfo(this.ItemID); EditedObject = pollAnswerObj; if (pollAnswerObj != null) { // Fill editing form if (!RequestHelper.IsPostBack()) { this.ReloadData(); } // When saved, display info message if (this.Saved) { lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); this.Saved = false; } // Otherwise hide info message else { lblInfo.Visible = false; } this.PollId = pollAnswerObj.AnswerPollID; } } // If creating new record else { plcVotes.Visible = false; txtVotes.Text = "0"; } }
/// <summary> /// Reloads answer data. /// </summary> public override void ReloadData() { this.ClearForm(); if (pollAnswerObj == null) { pollAnswerObj = PollAnswerInfoProvider.GetPollAnswerInfo(this.ItemID); } if (pollAnswerObj != null) { // Load the fields txtAnswerText.Text = pollAnswerObj.AnswerText; chkAnswerEnabled.Checked = pollAnswerObj.AnswerEnabled; txtVotes.Text = pollAnswerObj.AnswerCount.ToString(); plcVotes.Visible = true; } else { txtAnswerText.Text = String.Empty; plcVotes.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { // Get AnswerID and PollID from querystring pollId = QueryHelper.GetInteger("pollId", 0); answerId = QueryHelper.GetInteger("answerId", 0); groupId = QueryHelper.GetInteger("groupId", 0); string currentPollAnswer = GetString("Polls_Answer_Edit.NewItemCaption"); // Initialize AnswerEdit control if (QueryHelper.GetInteger("saved", 0) == 1) { AnswerEdit.Saved = true; } AnswerEdit.ItemID = answerId; AnswerEdit.PollId = pollId; AnswerEdit.OnSaved += new EventHandler(AnswerEdit_OnSaved); AnswerEdit.OnCheckPermissions += new CMSAdminControl.CheckPermissionsEventHandler(AnswerEdit_OnCheckPermissions); if (answerId > 0) { CurrentMaster.Title.HelpTopicName = "answer_edit"; PollAnswerInfo pollAnswerObj = PollAnswerInfoProvider.GetPollAnswerInfo(answerId); EditedObject = pollAnswerObj; if (pollAnswerObj != null) { // Check that poll belongs to the specified group if ((pollAnswerObj.AnswerPollID > 0) && (groupId > 0)) { PollInfo poll = PollInfoProvider.GetPollInfo(pollAnswerObj.AnswerPollID); // Answer not found or doesn't belong to specified group if ((poll == null) || (poll.PollGroupID != groupId)) { RedirectToAccessDenied(GetString("community.group.pollnotassigned")); } } // Set control currentPollAnswer = GetString("Polls_Answer_Edit.AnswerLabel") + " " + pollAnswerObj.AnswerOrder.ToString(); pollId = pollAnswerObj.AnswerPollID; } } else { CurrentMaster.Title.HelpTopicName = "new_answer"; } // Validate EditedObject = PollInfoProvider.GetPollInfo(pollId); // Initializes page title control string[,] breadcrumbs = new string[2, 3]; breadcrumbs[0, 0] = GetString("Polls_Answer_Edit.ItemListLink"); breadcrumbs[0, 1] = "~/CMSModules/Groups/Tools/Polls/Polls_Edit_Answer_List.aspx?pollId=" + pollId + "&groupId=" + groupId; breadcrumbs[0, 2] = ""; breadcrumbs[1, 0] = currentPollAnswer; breadcrumbs[1, 1] = ""; breadcrumbs[1, 2] = ""; CurrentMaster.Title.Breadcrumbs = breadcrumbs; // New item link HeaderAction add = new HeaderAction() { ControlType = HeaderActionTypeEnum.Hyperlink, Text = GetString("Polls_Answer_List.NewItemCaption"), RedirectUrl = ResolveUrl("Polls_Edit_Answer_Edit.aspx?pollId=" + pollId.ToString() + "&groupId=" + groupId), ImageUrl = GetImageUrl("Objects/Polls_PollAnswer/add.png") }; CurrentMaster.HeaderActions.AddAction(add); }
/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { // Load current answer object if (pollAnswerObj == null) { pollAnswerObj = PollAnswerInfoProvider.GetPollAnswerInfo(ItemID); } // Check permission for answer object (global/site poll) if (!CheckModifyPermission(PollId)) { return; } string errorMessage = null; // Validate the input if (txtVotes.Visible) { errorMessage = new Validator().NotEmpty(txtAnswerText.Text, rfvAnswerText.ErrorMessage) .IsPositiveNumber(txtVotes.Text, GetString("Polls_Answer_Edit.VotesNotNumber"), true) .IsInteger(txtVotes.Text, GetString("Polls_Answer_Edit.VotesNotNumber")).Result; } else { errorMessage = new Validator().NotEmpty(txtAnswerText.Text, rfvAnswerText.ErrorMessage).Result; } if (String.IsNullOrEmpty(errorMessage)) { // If pollAnswer doesn't already exist, create new one if (pollAnswerObj == null) { pollAnswerObj = new PollAnswerInfo(); pollAnswerObj.AnswerOrder = PollAnswerInfoProvider.GetLastAnswerOrder(PollId) + 1; pollAnswerObj.AnswerCount = 0; pollAnswerObj.AnswerPollID = PollId; } // Set the fields pollAnswerObj.AnswerEnabled = chkAnswerEnabled.Checked; pollAnswerObj.AnswerText = txtAnswerText.Text.Trim(); pollAnswerObj.AnswerCount = ValidationHelper.GetInteger(txtVotes.Text, 0); if (plcOpenAnswer.Visible) { string answerForm = ValidationHelper.GetString(bizFormElem.Value, string.Empty); if (chkAnswerIsOpenEnded.Checked && string.IsNullOrEmpty(answerForm)) { ShowError(GetString("Polls_Answer_Edit.SelectForm")); return; } pollAnswerObj.AnswerForm = answerForm; pollAnswerObj.AnswerAlternativeForm = ValidationHelper.GetString(alternativeFormElem.Value, string.Empty); pollAnswerObj.AnswerHideForm = chkAnswerHideForm.Checked; } // Save the data PollAnswerInfoProvider.SetPollAnswerInfo(pollAnswerObj); Saved = true; ItemID = pollAnswerObj.AnswerID; // Raise event; RaiseOnSaved(); } else { // Error message - Validation ShowError(errorMessage); } }
protected void Page_Load(object sender, EventArgs e) { // Get AnswerID and PollID from querystring pollId = QueryHelper.GetInteger("pollId", 0); answerId = QueryHelper.GetInteger("answerId", 0); groupId = QueryHelper.GetInteger("groupId", 0); string currentPollAnswer = GetString("Polls_Answer_Edit.NewItemCaption"); // Initialize AnswerEdit control if (QueryHelper.GetInteger("saved", 0) == 1) { AnswerEdit.Saved = true; } AnswerEdit.ItemID = answerId; AnswerEdit.PollId = pollId; AnswerEdit.OnSaved += AnswerEdit_OnSaved; AnswerEdit.OnCheckPermissions += AnswerEdit_OnCheckPermissions; if (answerId > 0) { PollAnswerInfo pollAnswerObj = PollAnswerInfoProvider.GetPollAnswerInfo(answerId); EditedObject = pollAnswerObj; if (pollAnswerObj != null) { // Check that poll belongs to the specified group if ((pollAnswerObj.AnswerPollID > 0) && (groupId > 0)) { PollInfo poll = PollInfoProvider.GetPollInfo(pollAnswerObj.AnswerPollID); // Answer not found or doesn't belong to specified group if ((poll == null) || (poll.PollGroupID != groupId)) { RedirectToAccessDenied(GetString("community.group.pollnotassigned")); } } // Set control currentPollAnswer = GetString("Polls_Answer_Edit.AnswerLabel") + " " + pollAnswerObj.AnswerOrder.ToString(); pollId = pollAnswerObj.AnswerPollID; } } // Validate EditedObject = PollInfoProvider.GetPollInfo(pollId); // Initialize breadcrumbs PageBreadcrumbs.Items.Add(new BreadcrumbItem { Text = GetString("Polls_Answer_Edit.ItemListLink"), RedirectUrl = ResolveUrl("~/CMSModules/Groups/Tools/Polls/Polls_Edit_Answer_List.aspx?pollId=" + pollId + "&groupId=" + groupId), }); PageBreadcrumbs.Items.Add(new BreadcrumbItem { Text = currentPollAnswer, }); // New item link HeaderAction add = new HeaderAction { Text = GetString("Polls_Answer_List.NewItemCaption"), RedirectUrl = ResolveUrl("Polls_Edit_Answer_Edit.aspx?pollId=" + pollId.ToString() + "&groupId=" + groupId) }; CurrentMaster.HeaderActions.AddAction(add); }
/// <summary> /// Displays appropriate controls regarding set properties. /// </summary> private void DisplayControls(string selectedPage, bool forceReload) { PollProperties.Visible = false; AnswerList.Visible = false; PollSecurity.Visible = false; PollView.Visible = false; PollView.StopProcessing = true; headerLinks.Visible = false; pnlPollsBreadcrumbs.Visible = false; pnlPollsLinks.Visible = false; AnswerEdit.Visible = false; btnResetAnswers.Visible = true; imgResetAnswers.Visible = true; if (forceReload) { selectedPage = "0"; tabMenu.SelectedTab = 0; } // Display appropriate tab switch (selectedPage) { // Poll properties case "0": default: PollProperties.Visible = true; PollProperties.ItemID = ItemID; PollProperties.ReloadData(); break; // Answer list case "1": AnswerList.Visible = true; AnswerList.PollId = ItemID; AnswerList.ReloadData(true); headerLinks.Visible = true; pnlPollsLinks.Visible = true; break; // Answer edit case "answersedit": headerLinks.Visible = true; pnlPollsBreadcrumbs.Visible = true; pnlPollsLinks.Visible = true; AnswerEdit.Visible = true; AnswerEdit.PollId = ItemID; AnswerEdit.ReloadData(); btnResetAnswers.Visible = false; imgResetAnswers.Visible = false; AnswerEditSelected = true; // Initialize breadcrumbs string currentPollAnswer = GetString("Polls_Answer_Edit.NewItemCaption"); if (AnswerEdit.ItemID > 0) { PollAnswerInfo pollAnswerObj = PollAnswerInfoProvider.GetPollAnswerInfo(AnswerEdit.ItemID); if (pollAnswerObj != null) { currentPollAnswer = GetString("Polls_Answer_Edit.AnswerLabel") + " " + pollAnswerObj.AnswerOrder.ToString(); } } lblAnswer.Text = currentPollAnswer; break; // Poll security case "2": PollSecurity.Visible = true; PollSecurity.ItemID = ItemID; PollSecurity.ReloadData(); break; // Poll view case "3": PollView.Visible = true; InitPollView(ItemID); PollView.StopProcessing = false; PollView.ReloadData(false); break; } }