/// <summary>
		/// The Page_Load event handler on this User Control is used to
        /// obtain a DataReader of banner information from the Banners
        /// table, and then databind the results to a templated DataList
        /// server control.  It uses the DotNetNuke.BannerDB()
        /// data component to encapsulate all data functionality.
		/// </summary>
		protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            cmdUpdate.Click += cmdUpdate_Click;
            cmdCancel.Click += cmdCancel_Click;
            DNNTxtBannerGroup.PopulateOnDemand += DNNTxtBannerGroup_PopulateOnDemand;

            try
            {
                if (!Page.IsPostBack)
                {
					//Obtain banner information from the Banners table and bind to the list control
                    var objBannerTypes = new BannerTypeController();

                    cboType.DataSource = objBannerTypes.GetBannerTypes();
                    cboType.DataBind();
                    cboType.Items.Insert(0, new ListItem(Localization.GetString("AllTypes", LocalResourceFile), "-1"));

                    if (ModuleId > 0)
                    {
                        if (optSource.Items.FindByValue(Convert.ToString(Settings["bannersource"])) != null)
                        {
                            optSource.Items.FindByValue(Convert.ToString(Settings["bannersource"])).Selected = true;
                        }
                        else
                        {
                            optSource.Items.FindByValue("L").Selected = true;
                        }
                        if (cboType.Items.FindByValue(Convert.ToString(Settings["bannertype"])) != null)
                        {
                            cboType.Items.FindByValue(Convert.ToString(Settings["bannertype"])).Selected = true;
                        }
                        if (!String.IsNullOrEmpty(Convert.ToString(Settings["bannergroup"])))
                        {
                            DNNTxtBannerGroup.Text = Convert.ToString(Settings["bannergroup"]);
                        }
                        if (optOrientation.Items.FindByValue(Convert.ToString(Settings["orientation"])) != null)
                        {
                            optOrientation.Items.FindByValue(Convert.ToString(Settings["orientation"])).Selected = true;
                        }
                        else
                        {
                            optOrientation.Items.FindByValue("V").Selected = true;
                        }
                        if (!String.IsNullOrEmpty(Convert.ToString(Settings["bannercount"])))
                        {
                            txtCount.Text = Convert.ToString(Settings["bannercount"]);
                        }
                        else
                        {
                            txtCount.Text = "1";
                        }
                        if (!String.IsNullOrEmpty(Convert.ToString(Settings["border"])))
                        {
                            txtBorder.Text = Convert.ToString(Settings["border"]);
                        }
                        else
                        {
                            txtBorder.Text = "0";
                        }
                        if (!String.IsNullOrEmpty(Convert.ToString(Settings["padding"])))
                        {
                            txtPadding.Text = Convert.ToString(Settings["padding"]);
                        }
                        else
                        {
                            txtPadding.Text = "4";
                        }
                        txtBorderColor.Text = Convert.ToString(Settings["bordercolor"]);
                        txtRowHeight.Text = Convert.ToString(Settings["rowheight"]);
                        txtColWidth.Text = Convert.ToString(Settings["colwidth"]);
                        txtBannerClickThroughURL.Text = Convert.ToString(Settings["bannerclickthroughurl"]);
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemplo n.º 2
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/21/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            cmdCancel.Click += OnCancelClick;
            cmdCopy.Click += OnCopyClick;
            cmdDelete.Click += OnDeleteClick;
            cmdEmail.Click += OnEmailClick;
            cmdUpdate.Click += OnUpdateClick;

            try
            {
                if ((Request.QueryString["VendorId"] != null))
                {
                    VendorId = Int32.Parse(Request.QueryString["VendorId"]);
                }
                if ((Request.QueryString["BannerId"] != null))
                {
                    BannerId = Int32.Parse(Request.QueryString["BannerId"]);
                }
				
                if (Page.IsPostBack == false)
                {
                    ctlImage.FileFilter = Globals.glbImageFileTypes;

                    var objBannerTypes = new BannerTypeController();
                    //Get the banner types from the database
                    cboBannerType.DataSource = objBannerTypes.GetBannerTypes();
                    cboBannerType.DataBind();

                    var objBanners = new BannerController();
                    if (BannerId != Null.NullInteger)
                    {
                        //Obtain a single row of banner information
                        BannerInfo banner = objBanners.GetBanner(BannerId);
                        if (banner != null)
                        {
                            txtBannerName.Text = banner.BannerName;
                            cboBannerType.Items.FindByValue(banner.BannerTypeId.ToString()).Selected = true;
                            DNNTxtBannerGroup.Text = banner.GroupName;
                            ctlImage.Url = banner.ImageFile;
                            if (banner.Width != 0)
                            {
                                txtWidth.Text = banner.Width.ToString();
                            }
                            if (banner.Height != 0)
                            {
                                txtHeight.Text = banner.Height.ToString();
                            }
                            txtDescription.Text = banner.Description;
                            if (!String.IsNullOrEmpty(banner.URL))
                            {
                                ctlURL.Url = banner.URL;
                            }
                            txtImpressions.Text = banner.Impressions.ToString();
                            txtCPM.Text = banner.CPM.ToString();
                            
                            StartDatePicker.SelectedDate = Null.IsNull(banner.StartDate) ? (DateTime?) null : banner.StartDate;
                            EndDatePicker.SelectedDate = Null.IsNull(banner.EndDate) ? (DateTime?)null : banner.EndDate;
                            
                            optCriteria.Items.FindByValue(banner.Criteria.ToString()).Selected = true;

                            ctlAudit.CreatedByUser = banner.CreatedByUser;
                            ctlAudit.CreatedDate = banner.CreatedDate.ToString();

                            var arrBanners = new ArrayList();

                            arrBanners.Add(banner);
                            bannersRow.Visible = true;
                            lstBanners.DataSource = arrBanners;
                            lstBanners.DataBind();       
                        }
                        else //security violation attempt to access item not related to this Module
                        {
                            Response.Redirect(EditUrl("VendorId", VendorId.ToString()), true);
                        }
                    }
                    else
                    {
                        txtImpressions.Text = "0";
                        txtCPM.Text = "0";
                        optCriteria.Items.FindByValue("1").Selected = true;
                        cmdDelete.Visible = false;
                        cmdCopy.Visible = false;
                        cmdEmail.Visible = false;
                        ctlAudit.Visible = false;
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }