コード例 #1
0
ファイル: Links.ascx.cs プロジェクト: arrioja/shared-citroen
        /// <summary>
        /// The Page_Load event handler on this User Control is used to
        /// obtain a DataReader of link information from the Links
        /// table, and then databind the results to a templated DataList
        /// server control.  It uses the Rainbow.LinkDB()
        /// 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)
        {
            // Set the link image type
            if (IsEditable)
            {
                System.Web.UI.WebControls.Image myImage = portalSettings.GetCurrentTheme().GetImage("Buttons_Edit", "edit.gif");
                linkImage         = myImage.ImageUrl;
                linkTextKey       = "EDIT_THIS_ITEM";
                linkAlternateText = "Edit this item";
            }
            else
            {
                System.Web.UI.WebControls.Image myImage = portalSettings.GetCurrentTheme().GetImage("NavLink", "navlink.gif");
                linkImage         = myImage.ImageUrl;
                linkTextKey       = string.Empty;
                linkAlternateText = string.Empty;
            }

            // Obtain links information from the Links table
            // and bind to the datalist control
            LinkDB links = new LinkDB();

            myDataList.DataSource = links.GetLinks(ModuleID, Version);
            myDataList.DataBind();
        }
コード例 #2
0
        /// <summary>
        /// The DeleteBtn_Click event handler on this Page is used to delete
        /// a link.  It  uses the Rainbow.LinksDB()
        /// 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)
            {
                LinkDB links = new LinkDB();
                links.DeleteLink(ItemID);
            }

            // Redirect back to the portal home page
            this.RedirectBackToReferringPage();
        }
コード例 #3
0
        /// <summary>
        /// The Page_Load event on this Page is used to obtain the
        /// ItemID of the link to edit.
        /// It then uses the Rainbow.LinkDB() data component
        /// to populate the page's edit controls with the links 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
            // link itemID value is specified, and if so populate page
            // contents with the link details

            if (Page.IsPostBack == false)
            {
                TargetField.Items.Add("_new");
                TargetField.Items.Add("_blank");
                TargetField.Items.Add("_parent");
                TargetField.Items.Add("_self");
                TargetField.Items.Add("_top");

                if (ItemID != 0)
                {
                    // Obtain a single row of link information
                    LinkDB        links = new LinkDB();
                    SqlDataReader dr    = links.GetSingleLink(ItemID, WorkFlowVersion.Staging);

                    try
                    {
                        // Read in first row from database
                        if (dr.Read())
                        {
                            TitleField.Text       = (string)dr["Title"].ToString();
                            DescriptionField.Text = (string)dr["Description"].ToString();
                            UrlField.Text         = (string)dr["Url"].ToString();
                            MobileUrlField.Text   = (string)dr["MobileUrl"].ToString();
                            ViewOrderField.Text   = dr["ViewOrder"].ToString();
                            CreatedBy.Text        = (string)dr["CreatedByUser"].ToString();
                            CreatedDate.Text      = ((DateTime)dr["CreatedDate"]).ToShortDateString();
                            TargetField.Items.FindByText((string)dr["Target"]).Selected = true;
                            // 15/7/2004 added localization by Mario Endara [email protected]
                            if (CreatedBy.Text == "unknown")
                            {
                                CreatedBy.Text = Esperantus.Localize.GetString("UNKNOWN", "unknown");
                            }
                        }
                    }
                    finally
                    {
                        // Close datareader
                        dr.Close();
                    }
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// The UpdateBtn_Click event handler on this Page is used to either
        /// create or update a link.  It  uses the Rainbow.LinkDB()
        /// data component to encapsulate all data functionality.
        /// </summary>
        override protected void OnUpdate(EventArgs e)
        {
            base.OnUpdate(e);

            if (Page.IsValid == true)
            {
                // Create an instance of the Link DB component
                LinkDB links = new LinkDB();

                if (ItemID == 0)
                {
                    // Add the link within the Links table
                    links.AddLink(ModuleID, ItemID, PortalSettings.CurrentUser.Identity.Email, TitleField.Text, UrlField.Text, MobileUrlField.Text, Int32.Parse(ViewOrderField.Text), DescriptionField.Text, TargetField.SelectedItem.Text);
                }
                else
                {
                    // Update the link within the Links table
                    links.UpdateLink(ModuleID, ItemID, PortalSettings.CurrentUser.Identity.Email, TitleField.Text, UrlField.Text, MobileUrlField.Text, Int32.Parse(ViewOrderField.Text), DescriptionField.Text, TargetField.SelectedItem.Text);
                }

                // Redirect back to the portal home page
                this.RedirectBackToReferringPage();
            }
        }