Exemple #1
0
        //*******************************************************
        //
        // 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 ASPNetPortal.AnnouncementsDB()
        // data component to encapsulate all data functionality.
        //
        //*******************************************************

        private void Page_Load(object sender, System.EventArgs e)
        {
            // Obtain announcement information from Announcements table
            // and bind to the datalist control
            ASPNetPortal.AnnouncementsDB announcements = new ASPNetPortal.AnnouncementsDB();

            // DataBind Announcements to DataList Control
            myDataList.DataSource = announcements.GetAnnouncements(ModuleId);
            myDataList.DataBind();
        }
Exemple #2
0
        //****************************************************************
        //
        // The DeleteBtn_Click event handler on this Page is used to delete an
        // an announcement.  It  uses the ASPNetPortal.AnnouncementsDB()
        // data component to encapsulate all data functionality.
        //
        //****************************************************************

        private void DeleteBtn_Click(Object sender, EventArgs e)
        {
            // Only attempt to delete the item if it is an existing item
            // (new items will have "ItemId" of 0)

            if (itemId != 0)
            {
                ASPNetPortal.AnnouncementsDB announcementDB = new ASPNetPortal.AnnouncementsDB();
                announcementDB.DeleteAnnouncement(itemId);
            }

            // Redirect back to the portal home page
            Response.Redirect((String)ViewState["UrlReferrer"]);
        }
Exemple #3
0
        //****************************************************************
        //
        // The Page_Load event on this Page is used to obtain the ModuleId
        // and ItemId of the announcement to edit.
        //
        // It then uses the ASPNetPortal.AnnouncementsDB() data component
        // to populate the page's edit controls with the annoucement details.
        //
        //****************************************************************

        private void Page_Load(object sender, System.EventArgs e)
        {
            // Determine ModuleId of Announcements Portal Module
            moduleId = Int32.Parse(Request.Params["Mid"]);

            // Verify that the current user has access to edit this module
            if (PortalSecurity.HasEditPermissions(moduleId) == false)
            {
                Response.Redirect("~/Admin/EditAccessDenied.aspx");
            }

            // Determine ItemId of Announcement to Update
            if (Request.Params["ItemId"] != null)
            {
                itemId = Int32.Parse(Request.Params["ItemId"]);
            }

            // 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

            if (Page.IsPostBack == false)
            {
                if (itemId != 0)
                {
                    // Obtain a single row of announcement information
                    ASPNetPortal.AnnouncementsDB announcementDB = new ASPNetPortal.AnnouncementsDB();
                    IDataReader dr = announcementDB.GetSingleAnnouncement(itemId);

                    // Load first row into DataReader
                    dr.Read();

                    TitleField.Text       = (String)dr["title"];
                    MoreLinkField.Text    = (String)dr["morelink"];
                    MobileMoreField.Text  = (String)dr["mobilemorelink"];
                    DescriptionField.Text = (String)dr["description"];
                    ExpireField.Text      = ((DateTime)dr["expiredate"]).ToShortDateString();
                    CreatedBy.Text        = (String)dr["createdbyuser"];
                    CreatedDate.Text      = ((DateTime)dr["createddate"]).ToShortDateString();

                    // Close the datareader
                    dr.Close();
                }

                // Store URL Referrer to return to portal
                ViewState["UrlReferrer"] = Request.UrlReferrer.ToString();
            }
        }
Exemple #4
0
        //****************************************************************
        //
        // The UpdateBtn_Click event handler on this Page is used to either
        // create or update an announcement.  It  uses the ASPNetPortal.AnnouncementsDB()
        // data component to encapsulate all data functionality.
        //
        //****************************************************************

        private void UpdateBtn_Click(Object sender, EventArgs e)
        {
            // Only Update if the Entered Data is Valid
            if (Page.IsValid == true)
            {
                // Create an instance of the Announcement DB component
                ASPNetPortal.AnnouncementsDB announcementDB = new ASPNetPortal.AnnouncementsDB();

                if (itemId == 0)
                {
                    // Add the announcement within the Announcements table
                    announcementDB.AddAnnouncement(moduleId, itemId, Context.User.Identity.Name, TitleField.Text, DateTime.Parse(ExpireField.Text), DescriptionField.Text, MoreLinkField.Text, MobileMoreField.Text);
                }
                else
                {
                    // Update the announcement within the Announcements table
                    announcementDB.UpdateAnnouncement(moduleId, itemId, Context.User.Identity.Name, TitleField.Text, DateTime.Parse(ExpireField.Text), DescriptionField.Text, MoreLinkField.Text, MobileMoreField.Text);
                }

                // Redirect back to the portal home page
                Response.Redirect((String)ViewState["UrlReferrer"]);
            }
        }