/// <summary> /// The UpdateBtn_Click event handler on this Page is used to either /// create or update an announcement. It uses the Rainbow.AnnouncementsDB() /// data component to encapsulate all data functionality. /// </summary> override protected void OnUpdate(EventArgs e) { base.OnUpdate(e); // Only Update if the Entered Data is Valid if (Page.IsValid == true) { // Create an instance of the Announcement DB component AnnouncementsDB announcementDB = new AnnouncementsDB(); if (ItemID == 0) { // Add the announcement within the Announcements table announcementDB.AddAnnouncement(ModuleID, ItemID, PortalSettings.CurrentUser.Identity.Email, TitleField.Text, DateTime.Parse(ExpireField.Text), DesktopText.Text, MoreLinkField.Text, MobileMoreField.Text); } else { // Update the announcement within the Announcements table announcementDB.UpdateAnnouncement(ModuleID, ItemID, PortalSettings.CurrentUser.Identity.Email, TitleField.Text, DateTime.Parse(ExpireField.Text), DesktopText.Text, MoreLinkField.Text, MobileMoreField.Text); } // Redirect back to the portal home page this.RedirectBackToReferringPage(); } }
/// <summary> /// The Page_Load event handler on this User Control is used to /// obtain a DataSet of announcement information from the Announcements /// table, and then databind the results to a templated DataList /// server control. It uses the Rainbow.AnnouncementsDB() /// data component to encapsulate all data functionality. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Page_Load(object sender, System.EventArgs e) { if (Page.IsPostBack == false) { //myDataList appearance if (bool.Parse(Settings["ShowBorder"].ToString())) { myDataList.ItemStyle.BorderWidth = Unit.Pixel(1); } myDataList.RepeatDirection = (Settings["RepeatDirectionSetting"].ToString() == "Horizontal" ? RepeatDirection.Horizontal : RepeatDirection.Vertical); myDataList.RepeatColumns = Int32.Parse(Settings["RepeatColumns"].ToString()); //myDataList content string sortField = Settings["SortField"].ToString(); string sortDirection = Settings["SortDirection"].ToString(); // Obtain announcement information from Announcements table // and bind to the datalist control AnnouncementsDB announcements = new AnnouncementsDB(); DataSet announces = announcements.GetAnnouncements(ModuleID, Version); DataView myDataView = new DataView(); myDataView = announces.Tables[0].DefaultView; myDataView.Sort = sortField + " " + sortDirection; myDataList.DataSource = myDataView; myDataList.DataBind(); } }
/// <summary> /// The DeleteBtn_Click event handler on this Page is used to delete an /// an announcement. It uses the Rainbow.AnnouncementsDB() /// data component to encapsulate all data functionality. /// </summary> override protected 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) { AnnouncementsDB announcementDB = new AnnouncementsDB(); announcementDB.DeleteAnnouncement(ItemID); } // Redirect back to the portal home page this.RedirectBackToReferringPage(); }
/// <summary> /// The Page_Load event on this Page is used to obtain the ModuleID /// and ItemID of the announcement to edit. /// It then uses the Rainbow.AnnouncementsDB() data component /// to populate the page's edit controls with the annoucement details. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Page_Load(object sender, System.EventArgs e) { // If the page is being requested the first time, determine if an // announcement itemID value is specified, and if so populate page // contents with the announcement details //Indah Fuldner Rainbow.UI.DataTypes.HtmlEditorDataType h = new Rainbow.UI.DataTypes.HtmlEditorDataType(); h.Value = moduleSettings["Editor"].ToString(); DesktopText = h.GetEditor(PlaceHolderHTMLEditor, ModuleID, bool.Parse(moduleSettings["ShowUpload"].ToString()), portalSettings); DesktopText.Width = new System.Web.UI.WebControls.Unit(moduleSettings["Width"].ToString()); DesktopText.Height = new System.Web.UI.WebControls.Unit(moduleSettings["Height"].ToString()); //End Indah Fuldner // 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 (Page.IsPostBack == false) { if (ItemID != 0) { // Obtain a single row of announcement information AnnouncementsDB announcementDB = new AnnouncementsDB(); SqlDataReader dr = announcementDB.GetSingleAnnouncement(ItemID, WorkFlowVersion.Staging); try { // Load first row into DataReader if (dr.Read()) { TitleField.Text = (string)dr["Title"]; MoreLinkField.Text = (string)dr["MoreLink"]; MobileMoreField.Text = (string)dr["MobileMoreLink"]; DesktopText.Text = (string)dr["Description"]; ExpireField.Text = ((DateTime)dr["ExpireDate"]).ToShortDateString(); CreatedBy.Text = (string)dr["CreatedByUser"]; CreatedDate.Text = ((DateTime)dr["CreatedDate"]).ToShortDateString(); // 15/7/2004 added localization by Mario Endara [email protected] if (CreatedBy.Text == "unknown") { CreatedBy.Text = Esperantus.Localize.GetString("UNKNOWN", "unknown"); } } } finally { // Close the datareader dr.Close(); } } else { ExpireField.Text = DateTime.Now.AddDays(Int32.Parse(moduleSettings["DelayExpire"].ToString())).ToShortDateString(); deleteButton.Visible = false; // Cannot delete an unexsistent item } } }