/// <summary> /// Handles the Click event of the cmdUpdate control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param> protected void cmdUpdate_Click(System.Object sender, System.EventArgs e) { try { // We do not allow for script or markup in the question PortalSecurity objSecurity = new PortalSecurity(); string question = objSecurity.InputFilter(txtQuestionField.Text, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup); string answer = objSecurity.InputFilter(teAnswerField.Text, PortalSecurity.FilterFlag.NoScripting); FAQsController faqsController = new FAQsController(); FAQsInfo faq; int?newCatID = null; if (drpCategory.SelectedValue != "-1") { newCatID = int.Parse(drpCategory.SelectedValue); } // Do we add of update? The Id will tell us if (FaqId != -1) { faq = faqsController.GetFAQ(FaqId); faq.CategoryId = newCatID; faq.FaqHide = chkFaqHide.Checked; faq.PublishDate = datepickerPublishDate.SelectedDate; faq.ExpireDate = datepickerExpireDate.SelectedDate; faq.Question = question; faq.Answer = answer; faq.DateModified = DateTime.Now; faqsController.UpdateFAQ(faq); } else { faq = new FAQsInfo { ItemID = FaqId, CategoryId = newCatID, FaqHide = chkFaqHide.Checked, PublishDate = datepickerPublishDate.SelectedDate, ExpireDate = datepickerExpireDate.SelectedDate, Question = question, Answer = answer, CreatedByUser = UserId.ToString(), ViewCount = 0, DateModified = DateTime.Now, ModuleID = ModuleId, CreatedDate = DateTime.Now }; faqsController.AddFAQ(faq); } Response.Redirect(Globals.NavigateURL(), true); } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param> protected void Page_Load(System.Object sender, System.EventArgs e) { if (Page.IsPostBack == false) { cmdDelete.Attributes.Add("onClick", "javascript:return confirm(\'" + Localization.GetString("DeleteItem") + "\');"); FAQsController FAQsController = new FAQsController(); PopulateCategoriesDropDown(); if (!Null.IsNull(FaqId)) { FAQsInfo FaqItem = FAQsController.GetFAQ(FaqId); if (FaqItem != null) { if (FaqItem.CategoryId != null) { drpCategory.SelectedValue = FaqItem.CategoryId.ToString(); } chkFaqHide.Checked = FaqItem.FaqHide; datepickerPublishDate.SelectedDate = FaqItem.PublishDate; datepickerExpireDate.SelectedDate = FaqItem.ExpireDate; teAnswerField.Text = FaqItem.Answer; txtQuestionField.Text = FaqItem.Question; UserInfo user = UserController.GetUserById(PortalId, Convert.ToInt32(FaqItem.CreatedByUser)); ctlAudit.CreatedByUser = (user != null ? user.DisplayName : ""); if (FaqItem.DateModified == Null.NullDate) { ctlAudit.CreatedDate = FaqItem.CreatedDate.ToString(); } else { ctlAudit.CreatedDate = FaqItem.DateModified.ToString(); } } else { Response.Redirect(Globals.NavigateURL(), true); } } else { cmdDelete.Visible = false; ctlAudit.Visible = false; } } }
/// <summary> /// Raises the client API callback event. /// </summary> /// <param name="eventArgument">The event argument.</param> /// <returns></returns> public string RaiseClientAPICallbackEvent(string eventArgument) { try { int FaqId = int.Parse(eventArgument); FAQsController objFAQs = new FAQsController(); IncrementViewCount(FaqId); FAQsInfo FaqItem = objFAQs.GetFAQ(FaqId); return(HtmlDecode(objFAQs.ProcessTokens(FaqItem, this.AnswerTemplate))); } catch (Exception exc) { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc); } return(""); }
/// <summary> /// Handles the Select event of the lstFAQs control. /// </summary> /// <param name="source">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.DataListCommandEventArgs" /> instance containing the event data.</param> protected void lstFAQs_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e) { FAQsController controller = new FAQsController(); int itemId = System.Convert.ToInt32(e.CommandArgument); int index = e.Item.ItemIndex; int itemCount = FaqData.Count; switch (e.CommandName.ToLower()) { case "select": if (!SupportsClientAPI) { try { Label lblAnswer = (Label) (lstFAQs.Items[index].FindControl("A2")); FAQsInfo FaqItem = controller.GetFAQ(itemId); if (lblAnswer.Text == "") { IncrementViewCount(FaqItem.ItemID); lblAnswer.Text = HtmlDecode(controller.ProcessTokens(FaqItem, this.AnswerTemplate)); } else { lblAnswer.Text = ""; } } catch (Exception exc) //Module failed to load { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc); } } break; case "up": if (index == 0) controller.ReorderFAQ(itemId, ((FAQsInfo)FaqData[itemCount-1]).ItemID, ModuleId); else controller.ReorderFAQ(itemId, ((FAQsInfo)FaqData[index - 1]).ItemID, ModuleId); FaqData = null; BindData(); break; case "down": if (index == itemCount -1) controller.ReorderFAQ(itemId, ((FAQsInfo)FaqData[0]).ItemID, ModuleId); else controller.ReorderFAQ(itemId, ((FAQsInfo)FaqData[index + 1]).ItemID, ModuleId); //Response.Redirect(DotNetNuke.Common.Globals.NavigateURL()); FaqData = null; BindData(); break; } }
/// <summary> /// Raises the client API callback event. /// </summary> /// <param name="eventArgument">The event argument.</param> /// <returns></returns> public string RaiseClientAPICallbackEvent(string eventArgument) { try { int FaqId = int.Parse(eventArgument); FAQsController objFAQs = new FAQsController(); IncrementViewCount(FaqId); FAQsInfo FaqItem = objFAQs.GetFAQ(FaqId); return HtmlDecode(objFAQs.ProcessTokens(FaqItem, this.AnswerTemplate)); } catch (Exception exc) { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc); } return ""; }
/// <summary> /// Handles the Select event of the lstFAQs control. /// </summary> /// <param name="source">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.DataListCommandEventArgs" /> instance containing the event data.</param> protected void lstFAQs_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e) { FAQsController controller = new FAQsController(); int itemId = System.Convert.ToInt32(e.CommandArgument); int index = e.Item.ItemIndex; int itemCount = FaqData.Count; switch (e.CommandName.ToLower()) { case "select": if (!SupportsClientAPI) { try { Label lblAnswer = (Label)(lstFAQs.Items[index].FindControl("A2")); FAQsInfo FaqItem = controller.GetFAQ(itemId); if (lblAnswer.Text == "") { IncrementViewCount(FaqItem.ItemID); lblAnswer.Text = HtmlDecode(controller.ProcessTokens(FaqItem, this.AnswerTemplate)); } else { lblAnswer.Text = ""; } } catch (Exception exc) //Module failed to load { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc); } } break; case "up": if (index == 0) { controller.ReorderFAQ(itemId, ((FAQsInfo)FaqData[itemCount - 1]).ItemID, ModuleId); } else { controller.ReorderFAQ(itemId, ((FAQsInfo)FaqData[index - 1]).ItemID, ModuleId); } FaqData = null; BindData(); break; case "down": if (index == itemCount - 1) { controller.ReorderFAQ(itemId, ((FAQsInfo)FaqData[0]).ItemID, ModuleId); } else { controller.ReorderFAQ(itemId, ((FAQsInfo)FaqData[index + 1]).ItemID, ModuleId); } //Response.Redirect(DotNetNuke.Common.Globals.NavigateURL()); FaqData = null; BindData(); break; } }
/// <summary> /// Handles the Click event of the cmdUpdate control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param> protected void cmdUpdate_Click(System.Object sender, System.EventArgs e) { try { // We do not allow for script or markup in the question PortalSecurity objSecurity = new PortalSecurity(); string question = objSecurity.InputFilter(txtQuestionField.Text, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup); string answer = objSecurity.InputFilter(teAnswerField.Text, PortalSecurity.FilterFlag.NoScripting); FAQsController faqsController = new FAQsController(); FAQsInfo faq; int? newCatID = null; if (drpCategory.SelectedValue != "-1") newCatID = int.Parse(drpCategory.SelectedValue); // Do we add of update? The Id will tell us if (FaqId != -1) { faq = faqsController.GetFAQ(FaqId); faq.CategoryId = newCatID; faq.FaqHide = chkFaqHide.Checked; faq.PublishDate = datepickerPublishDate.SelectedDate; faq.ExpireDate = datepickerExpireDate.SelectedDate; faq.Question = question; faq.Answer = answer; faq.DateModified = DateTime.Now; faqsController.UpdateFAQ(faq); } else { faq = new FAQsInfo { ItemID = FaqId, CategoryId = newCatID, FaqHide = chkFaqHide.Checked, PublishDate = datepickerPublishDate.SelectedDate, ExpireDate = datepickerExpireDate.SelectedDate, Question = question, Answer = answer, CreatedByUser = UserId.ToString(), ViewCount = 0, DateModified = DateTime.Now, ModuleID = ModuleId, CreatedDate = DateTime.Now }; faqsController.AddFAQ(faq); } Response.Redirect(Globals.NavigateURL(), true); } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param> protected void Page_Load(System.Object sender, System.EventArgs e) { if (Page.IsPostBack == false) { cmdDelete.Attributes.Add("onClick", "javascript:return confirm(\'" + Localization.GetString("DeleteItem") + "\');"); FAQsController FAQsController = new FAQsController(); PopulateCategoriesDropDown(); if (!Null.IsNull(FaqId)) { FAQsInfo FaqItem = FAQsController.GetFAQ(FaqId); if (FaqItem != null) { if (FaqItem.CategoryId != null) { drpCategory.SelectedValue = FaqItem.CategoryId.ToString(); } chkFaqHide.Checked = FaqItem.FaqHide; datepickerPublishDate.SelectedDate = FaqItem.PublishDate; datepickerExpireDate.SelectedDate = FaqItem.ExpireDate; teAnswerField.Text = FaqItem.Answer; txtQuestionField.Text = FaqItem.Question; UserInfo user = UserController.GetUserById(PortalId, Convert.ToInt32(FaqItem.CreatedByUser)); ctlAudit.CreatedByUser = (user != null ? user.DisplayName : ""); if (FaqItem.DateModified == Null.NullDate) { ctlAudit.CreatedDate = FaqItem.CreatedDate.ToString(); } else { ctlAudit.CreatedDate = FaqItem.DateModified.ToString(); } } else { Response.Redirect(Globals.NavigateURL(), true); } } else { cmdDelete.Visible = false; ctlAudit.Visible = false; } } }