/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void uniGrid_OnAction(string actionName, object actionArgument) { if (actionName == "edit") { SelectedItemID = Convert.ToInt32(actionArgument); RaiseOnEdit(); } else if (actionName == "delete") { if (!AllowEdit) { return; } if (GroupId > 0) { CMSGroupPage.CheckGroupPermissions(GroupId, PERMISSION_MANAGE); } // Delete PollAnswerInfo object from database PollAnswerInfoProvider.DeletePollAnswerInfo(Convert.ToInt32(actionArgument)); ReloadData(true); } else if (actionName == "moveup") { if (!AllowEdit) { return; } if (GroupId > 0) { CMSGroupPage.CheckGroupPermissions(GroupId, PERMISSION_MANAGE); } // Move the answer up in order PollAnswerInfoProvider.MoveAnswerUp(PollId, Convert.ToInt32(actionArgument)); ReloadData(true); } else if (actionName == "movedown") { if (!AllowEdit) { return; } if (GroupId > 0) { CMSGroupPage.CheckGroupPermissions(GroupId, PERMISSION_MANAGE); } // Move the answer down in order PollAnswerInfoProvider.MoveAnswerDown(PollId, Convert.ToInt32(actionArgument)); ReloadData(true); } }
/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void uniGrid_OnAction(string actionName, object actionArgument) { if (actionName == "edit") { this.SelectedItemID = Convert.ToInt32(actionArgument); this.RaiseOnEdit(); } else if (actionName == "delete") { if (!CheckModifyPermission()) { return; } // Delete PollAnswerInfo object from database PollAnswerInfoProvider.DeletePollAnswerInfo(Convert.ToInt32(actionArgument)); this.ReloadData(true); } else if (actionName == "moveup") { if (!CheckModifyPermission()) { return; } // Move the answer up in order PollAnswerInfoProvider.MoveAnswerUp(this.PollId, Convert.ToInt32(actionArgument)); this.ReloadData(true); } else if (actionName == "movedown") { if (!CheckModifyPermission()) { return; } // Move the answer down in order PollAnswerInfoProvider.MoveAnswerDown(this.PollId, Convert.ToInt32(actionArgument)); this.ReloadData(true); } }
/// <summary> /// Deletes answer. Called when the "Delete answer" button is pressed. /// Expects the CreateAnswer method to be run first. /// </summary> private bool DeleteAnswer() { // Get the poll PollInfo updatePoll = PollInfoProvider.GetPollInfo("MyNewPoll", SiteContext.CurrentSiteID); if (updatePoll != null) { // Get the answer DataSet answers = PollAnswerInfoProvider.GetAnswers(updatePoll.PollID, 1, null); if (!DataHelper.DataSourceIsEmpty(answers)) { PollAnswerInfo deleteAnswer = new PollAnswerInfo(answers.Tables[0].Rows[0]); // Delete the answer PollAnswerInfoProvider.DeletePollAnswerInfo(deleteAnswer); return(deleteAnswer != null); } } return(false); }