Beispiel #1
0
 private void SaveData()
 {
     _bannerInfo.Title = txtTitle.Text;
     _bannerInfo.Slug  = HtmlHelper.RemoveIllegalCharacters(txtTitle.Text);
     if (!String.IsNullOrEmpty(Request.Params["thumbnailSrcAvatar"]))
     {
         _bannerInfo.ImagePath = Request.Params["thumbnailSrcAvatar"];
     }
     _bannerInfo.Priority   = 1;
     _bannerInfo.Position   = Convert.ToInt32(txtPosition.Text);
     _bannerInfo.Type       = int.Parse(ddlType.SelectedValue);
     _bannerInfo.IsMobile   = false;//cbIsMobile.Checked;
     _bannerInfo.Content    = txtContent.Text;
     _bannerInfo.CategoryId = int.Parse(ddlCategory.SelectedValue);
     if (!String.IsNullOrEmpty(dteStartDate.Value))
     {
         var startDate = Convert.ToDateTime(dteStartDate.Value, new CultureInfo("vi-VN"));
         _bannerInfo.StartDate = new DateTime(startDate.Year, startDate.Month, startDate.Day, Convert.ToInt32(ddlStartHours.Value), Convert.ToInt32(ddlStartMinute.Value), 0);
     }
     if (!String.IsNullOrEmpty(dteEndDate.Value))
     {
         var endDate = Convert.ToDateTime(dteEndDate.Value, new CultureInfo("vi-VN"));
         _bannerInfo.EndDate = new DateTime(endDate.Year, endDate.Month, endDate.Day, Convert.ToInt32(ddlEndHours.Value), Convert.ToInt32(ddlEndMinute.Value), 0);
     }
     if (_bannerInfo.BannerId == 0)
     {
         _bannerController.InsertBanner(_bannerInfo);
     }
     else
     {
         _bannerController.UpdateBanner(_bannerInfo);
     }
     Response.Redirect("~/Pages/ListPrice.aspx?xml=Price");
 }
Beispiel #2
0
 private void SaveData()
 {
     _bannerInfo.Title = txtTitle.Text;
     if (!String.IsNullOrEmpty(Request.Params["thumbnailSrcAvatar"]))
     {
         _bannerInfo.ImagePath = Request.Params["thumbnailSrcAvatar"];
     }
     _bannerInfo.Priority = byte.Parse(ddlPriority.SelectedValue);
     _bannerInfo.Position = int.Parse(txtPosition.Text);
     _bannerInfo.Type     = 1;
     _bannerInfo.Url      = txtUrl.Text;
     if (!String.IsNullOrEmpty(dteStartDate.Value))
     {
         var startDate = Convert.ToDateTime(dteStartDate.Value, new CultureInfo("vi-VN"));
         _bannerInfo.StartDate = new DateTime(startDate.Year, startDate.Month, startDate.Day, Convert.ToInt32(ddlStartHours.Value), Convert.ToInt32(ddlStartMinute.Value), 0);
     }
     if (!String.IsNullOrEmpty(dteEndDate.Value))
     {
         var endDate = Convert.ToDateTime(dteEndDate.Value, new CultureInfo("vi-VN"));
         _bannerInfo.EndDate = new DateTime(endDate.Year, endDate.Month, endDate.Day, Convert.ToInt32(ddlEndHours.Value), Convert.ToInt32(ddlEndMinute.Value), 0);
     }
     if (_bannerInfo.BannerId == 0)
     {
         _bannerController.InsertBanner(_bannerInfo);
     }
     else
     {
         _bannerController.UpdateBanner(_bannerInfo);
     }
     Response.Redirect("~/Pages/ListBanner.aspx?xml=Banner");
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdUpdate_Click runs when the Update Button is clicked
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	9/21/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void OnUpdateClick(object sender, EventArgs e)
        {
            try
            {
                //Only Update if the Entered Data is val
                if (Page.IsValid)
                {
                    if (!cmdCopy.Visible)
                    {
                        BannerId = -1;
                    }
                    DateTime StartDate = Null.NullDate;
                    if (!String.IsNullOrEmpty(txtStartDate.Text))
                    {
                        StartDate = Convert.ToDateTime(txtStartDate.Text);
                    }
                    DateTime EndDate = Null.NullDate;
                    if (!String.IsNullOrEmpty(txtEndDate.Text))
                    {
                        EndDate = Convert.ToDateTime(txtEndDate.Text);
                    }

                    //Create an instance of the Banner DB component
                    var objBanner = new BannerInfo();
                    objBanner.BannerId     = BannerId;
                    objBanner.VendorId     = VendorId;
                    objBanner.BannerName   = txtBannerName.Text;
                    objBanner.BannerTypeId = Convert.ToInt32(cboBannerType.SelectedItem.Value);
                    objBanner.GroupName    = DNNTxtBannerGroup.Text;
                    objBanner.ImageFile    = ctlImage.Url;
                    if (!String.IsNullOrEmpty(txtWidth.Text))
                    {
                        objBanner.Width = int.Parse(txtWidth.Text);
                    }
                    else
                    {
                        objBanner.Width = 0;
                    }
                    if (!String.IsNullOrEmpty(txtHeight.Text))
                    {
                        objBanner.Height = int.Parse(txtHeight.Text);
                    }
                    else
                    {
                        objBanner.Height = 0;
                    }
                    objBanner.Description   = txtDescription.Text;
                    objBanner.URL           = ctlURL.Url;
                    objBanner.Impressions   = int.Parse(txtImpressions.Text);
                    objBanner.CPM           = double.Parse(txtCPM.Text);
                    objBanner.StartDate     = StartDate;
                    objBanner.EndDate       = EndDate;
                    objBanner.Criteria      = int.Parse(optCriteria.SelectedItem.Value);
                    objBanner.CreatedByUser = UserInfo.UserID.ToString();

                    var objBanners = new BannerController();
                    if (BannerId == Null.NullInteger)
                    {
                        //Add the banner within the Banners table
                        objBanners.AddBanner(objBanner);
                    }
                    else
                    {
                        //Update the banner within the Banners table
                        objBanners.UpdateBanner(objBanner);
                    }

                    //Redirect back to the portal home page
                    Response.Redirect(EditUrl("VendorId", VendorId.ToString()), true);
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }