/// <summary> /// Is used to either create or update an Article. /// It uses the Rainbow.ArticlesDB() /// data component to encapsulate all data functionality. /// </summary> protected override void OnUpdate(EventArgs e) { base.OnUpdate(e); // Only Update if Input Data is Valid if (Page.IsValid == true) { ArticlesDB Articles = new ArticlesDB(); if (AbstractText.Text == string.Empty) { AbstractText.Text = ((HTMLText)DesktopText.Text).GetAbstractText(500); } if (ItemID == 0) { Articles.AddArticle(ModuleID, PortalSettings.CurrentUser.Identity.Email, ((HTMLText)TitleField.Text).InnerText, ((HTMLText)SubtitleField.Text).InnerText, AbstractText.Text, Server.HtmlEncode(DesktopText.Text), DateTime.Parse(StartField.Text), DateTime.Parse(ExpireField.Text), true, string.Empty); } else { Articles.UpdateArticle(ModuleID, ItemID, PortalSettings.CurrentUser.Identity.Email, ((HTMLText)TitleField.Text).InnerText, ((HTMLText)SubtitleField.Text).InnerText, AbstractText.Text, Server.HtmlEncode(DesktopText.Text), DateTime.Parse(StartField.Text), DateTime.Parse(ExpireField.Text), true, string.Empty); } RedirectBackToReferringPage(); } }
/// <summary> /// The BindData method is used to obtain details of a message /// from the Articles table, and update the page with /// the message content. /// </summary> private void BindData(int ItemID) { if (IsEditable) { editLinkDetail.NavigateUrl = HttpUrlBuilder.BuildUrl("~/DesktopModules/CommunityModules/Articles/ArticlesEdit.aspx", "ItemID=" + ItemID + "&mid=" + ModuleID); editLinkDetail.Visible = true; } else { editLinkDetail.Visible = false; } // Obtain the selected item from the Articles table ArticlesDB Article = new ArticlesDB(); SqlDataReader dr = Article.GetSingleArticle(ItemID, Version); try { // Load first row from database if (dr.Read()) { // Update labels with message contents TitleDetail.Text = dr["Title"].ToString(); //[email protected] 5/24/04 added subtitle to ArticlesView. if (dr["Subtitle"].ToString().Length > 0) { SubtitleDetail.Text = dr["Subtitle"].ToString(); } StartDateDetail.Text = ((DateTime)dr["StartDate"]).ToShortDateString(); StartDateDetail.Visible = bool.Parse(Settings["ShowDate"].ToString()); Description.Text = Server.HtmlDecode(dr["Description"].ToString()); CreatedDate.Text = ((DateTime)dr["CreatedDate"]).ToShortDateString(); CreatedBy.Text = dr["CreatedByUser"].ToString(); // 15/7/2004 added localization by Mario Endara [email protected] if (CreatedBy.Text == "unknown") { CreatedBy.Text = General.GetString("UNKNOWN", "unknown"); } //Chris Farrell, [email protected], 5/24/2004 if (!bool.Parse(Settings["MODULESETTINGS_SHOW_MODIFIED_BY"].ToString())) { CreatedLabel.Visible = false; CreatedDate.Visible = false; OnLabel.Visible = false; CreatedBy.Visible = false; } } } finally { // close the datareader dr.Close(); } }
/// <summary> /// The DeleteBtn_Click event handler on this Page is used to delete an /// a Article. It uses the Rainbow.ArticlesDB() /// data component to encapsulate all data functionality. /// </summary> /// <param name="e"></param> protected override void OnDelete(EventArgs e) { base.OnDelete(e); // Only attempt to delete the item if it is an existing item // (new items will have "ItemID" of 0) if (ItemID != 0) { ArticlesDB Articles = new ArticlesDB(); Articles.DeleteArticle(ItemID); } RedirectBackToReferringPage(); }
/// <summary> /// The BindData method is used to obtain details of a message /// from the Articles table, and update the page with /// the message content. /// </summary> private void BindData() { WorkFlowVersion Version = Request.QueryString["wversion"] == "Staging" ? WorkFlowVersion.Staging : WorkFlowVersion.Production; // Obtain the selected item from the Articles table ArticlesDB Article = new ArticlesDB(); SqlDataReader dr = Article.GetSingleArticle(ItemID, Version); try { // Load first row from database if (dr.Read()) { // Update labels with message contents Title.Text = dr["Title"].ToString(); //[email protected] 5/24/04 added subtitle to ArticlesView. if (dr["Subtitle"].ToString().Length > 0) { Subtitle.Text = "(" + dr["Subtitle"].ToString() + ")"; } StartDate.Text = ((DateTime)dr["StartDate"]).ToShortDateString(); Description.Text = Server.HtmlDecode(dr["Description"].ToString()); CreatedDate.Text = ((DateTime)dr["CreatedDate"]).ToShortDateString(); CreatedBy.Text = dr["CreatedByUser"].ToString(); // 15/7/2004 added localization by Mario Endara [email protected] if (CreatedBy.Text == "unknown") { CreatedBy.Text = General.GetString("UNKNOWN", "unknown"); } //Chris Farrell, [email protected], 5/24/2004 if (!bool.Parse(moduleSettings["MODULESETTINGS_SHOW_MODIFIED_BY"].ToString())) { CreatedLabel.Visible = false; CreatedDate.Visible = false; OnLabel.Visible = false; CreatedBy.Visible = false; } } } finally { // close the datareader dr.Close(); } }
/// <summary> /// The Page_Load event handler on this User Control is used to /// obtain a DataReader of Article information from the Articles /// table, and then databind the results to a templated DataList /// server control. It uses the Rainbow.ArticleDB() /// data component to encapsulate all data functionality. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> private void Page_Load(object sender, EventArgs e) { // Obtain Articles information from the Articles table // and bind to the datalist control ArticlesDB Articles = new ArticlesDB(); if (PortalSecurity.IsInRoles(Settings["EXPIRED_PERMISSION_ROLE"].ToString())) { myDataList.DataSource = Articles.GetArticlesAll(ModuleID, Version); } else { myDataList.DataSource = Articles.GetArticles(ModuleID, Version); } myDataList.DataBind(); }
/// <summary> /// Raises OnInit event. /// </summary> /// <param name="e">The event arguments.</param> protected override void OnInit(EventArgs e) { // View state is not needed here, so we are disabling. - jminond this.MyDataList.EnableViewState = false; // Add support for the edit page this.AddText = "ADD_ARTICLE"; this.AddUrl = "~/DesktopModules/CommunityModules/Articles/ArticlesEdit.aspx"; // Obtain Articles information from the Articles table // and bind to the data list control var articles = new ArticlesDB(); this.MyDataList.DataSource = PortalSecurity.IsInRoles(this.Settings["EXPIRED_PERMISSION_ROLE"].ToString()) ? articles.GetArticlesAll(this.ModuleID, this.Version) : articles.GetArticles(this.ModuleID, this.Version); this.MyDataList.DataBind(); base.OnInit(e); }
/// <summary> /// The Page_Load event on this Page is used to obtain the ModuleID /// and ItemID of the Article to edit. /// It then uses the Rainbow.ArticlesDB() data component /// to populate the page's edit controls with the Article details. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> private void Page_Load(object sender, EventArgs e) { // Add the setting HtmlEditorDataType editor = new HtmlEditorDataType(); editor.Value = moduleSettings["Editor"].ToString(); DesktopText = editor.GetEditor(PlaceHolderHTMLEditor, ModuleID, bool.Parse(moduleSettings["ShowUpload"].ToString()), portalSettings); DesktopText.Width = new Unit(moduleSettings["Width"].ToString()); DesktopText.Height = new Unit(moduleSettings["Height"].ToString()); HtmlEditorDataType abstractEditor = new HtmlEditorDataType(); if (moduleSettings["ARTICLES_RICHABSTRACT"] != null && bool.Parse(moduleSettings["ARTICLES_RICHABSTRACT"].ToString())) { abstractEditor.Value = moduleSettings["Editor"].ToString(); AbstractText = abstractEditor.GetEditor(PlaceHolderAbstractHTMLEditor, ModuleID, bool.Parse(moduleSettings["ShowUpload"].ToString()), portalSettings); } else { abstractEditor.Value = "Plain Text"; AbstractText = abstractEditor.GetEditor(PlaceHolderAbstractHTMLEditor, ModuleID, bool.Parse(moduleSettings["ShowUpload"].ToString()), portalSettings); } AbstractText.Width = new Unit(moduleSettings["Width"].ToString()); AbstractText.Height = new Unit("130px"); // Construct the page // Added css Styles by Mario Endara <*****@*****.**> (2004/10/26) updateButton.CssClass = "CommandButton"; PlaceHolderButtons.Controls.Add(updateButton); PlaceHolderButtons.Controls.Add(new LiteralControl(" ")); cancelButton.CssClass = "CommandButton"; PlaceHolderButtons.Controls.Add(cancelButton); PlaceHolderButtons.Controls.Add(new LiteralControl(" ")); deleteButton.CssClass = "CommandButton"; PlaceHolderButtons.Controls.Add(deleteButton); // If the page is being requested the first time, determine if an // Article itemID value is specified, and if so populate page // contents with the Article details if (Page.IsPostBack == false) { if (ItemID != 0) { // Obtain a single row of Article information ArticlesDB Articles = new ArticlesDB(); SqlDataReader dr = Articles.GetSingleArticle(ItemID, WorkFlowVersion.Staging); try { // Load first row into Datareader if (dr.Read()) { StartField.Text = ((DateTime)dr["StartDate"]).ToShortDateString(); ExpireField.Text = ((DateTime)dr["ExpireDate"]).ToShortDateString(); TitleField.Text = (string)dr["Title"].ToString(); SubtitleField.Text = (string)dr["Subtitle"].ToString(); AbstractText.Text = (string)dr["Abstract"].ToString(); DesktopText.Text = Server.HtmlDecode(dr["Description"].ToString()); CreatedBy.Text = (string)dr["CreatedByUser"].ToString(); CreatedDate.Text = ((DateTime)dr["CreatedDate"]).ToString(); // 15/7/2004 added localization by Mario Endara [email protected] if (CreatedBy.Text == "unknown") { CreatedBy.Text = General.GetString("UNKNOWN", "unknown"); } } } finally { dr.Close(); } } else { //New article - set defaults StartField.Text = DateTime.Now.ToShortDateString(); ExpireField.Text = DateTime.Now.AddDays(int.Parse(moduleSettings["DefaultVisibleDays"].ToString())). ToShortDateString(); CreatedBy.Text = PortalSettings.CurrentUser.Identity.Email; CreatedDate.Text = DateTime.Now.ToString(); } } }