Ejemplo n.º 1
0
    protected void BgColorsDDL_SelectedIndexChanged(object sender, EventArgs e)
    {
        RefreshAdvertAndPrice(sender, e);
        var color = new PtcAdvertBgColor(Convert.ToInt32(BgColorsDDL.SelectedValue));

        BgColorsDDL.Attributes.Add("style", string.Format("background-color:{0};color:white;", color.BgColor));
    }
Ejemplo n.º 2
0
 protected void BgColorsDDL_DataBound(object sender, EventArgs e)
 {
     for (int i = 0; i < BgColorsDDL.Items.Count; i++)
     {
         var color = new PtcAdvertBgColor(Convert.ToInt32(BgColorsDDL.Items[i].Value));
         BgColorsDDL.Items[i].Attributes.Add("style", string.Format("background-color:{0}", color.BgColor));
     }
     if (BgColorsDDL.Items.Count > 0)
     {
         BgColorsDDL.Attributes.Remove("style");
         BgColorsDDL.Attributes.Add("style", string.Format("background-color:{0};color:white;", new PtcAdvertBgColor(Convert.ToInt32(BgColorsDDL.SelectedValue)).BgColor));
     }
 }
Ejemplo n.º 3
0
    protected void BindDataBgColorsToDDL(Object sender, EventArgs e)
    {
        var activeColors = PtcAdvertBgColor.GetActiveBgColors();

        var dictlist = new Dictionary <string, string>();

        foreach (var color in activeColors)
        {
            dictlist[color.Id.ToString()] = color.Price.ToString();
        }
        BgColorsDDL.DataSource     = dictlist;
        BgColorsDDL.DataTextField  = "Value";
        BgColorsDDL.DataValueField = "Key";
        BgColorsDDL.DataBind();
    }
Ejemplo n.º 4
0
    protected void GetAdWithPrice(ref PtcAdvert Ad, ref Money AdCost, ref PtcAdvertPack Pack, bool throwExceptions = true)
    {
        try
        {
            ErrorMessagePanel.Visible = false;
            int packId = int.Parse(ddlOptions.SelectedValue);

            //Use Ad Credits only
            if (packId == -1)
            {
                Pack = null;
                if (!UseExtraViewsCheckBox.Checked && throwExceptions)
                {
                    throw new MsgException(U5006.SELECTUSEXTRAVIEWS);
                }
            }
            else
            {
                Pack = new PtcAdvertPack(packId);
            }

            AdCost = Money.Zero;

            if (Pack != null && Ad.Pack.Id != Pack.Id)
            {
                AdCost       = PtcAdvertManager.GetDiscountedPTCPackPrice(Pack);
                Ad.PackPrice = AdCost;
            }

            //Set basics
            if (AppSettings.PtcAdverts.CashLinkViewEnabled == AppSettings.PTCViewMode.CashLink)
            {
                Ad.Title = "Cash Link"; //Fixed title for cash links
            }
            else
            {
                Ad.Title = InputChecker.HtmlEncode(Title.Text, Title.MaxLength, L1.TITLE);
            }

            Ad.TargetUrl = URL.Text;

            int categoryId = -1;

            if (AppSettings.PtcAdverts.PTCCategoryPolicy == AppSettings.PTCCategoryPolicy.Custom)
            {
                int.TryParse(CategoriesDDL.SelectedValue, out categoryId);
            }

            Ad.CategoryId = categoryId;

            if (chbDescription.Checked)
            {
                if (Ad.Description == null || Ad.Description == string.Empty)
                {
                    AdCost += AppSettings.PtcAdverts.DescriptionCost;
                }

                Ad.Description = InputChecker.HtmlEncode(Description.Text, Description.MaxLength, L1.DESCRIPTION);
            }
            else
            {
                Ad.Description = string.Empty;
            }

            if (chbBold.Checked)
            {
                if (!Ad.HasBoldTitle)
                {
                    AdCost += AppSettings.PtcAdverts.FontBoldCost;
                }

                Ad.HasBoldTitle = true;
            }

            if (chbGeolocation.Checked)
            {
                if ((Ad.GeolocatedCC == null || Ad.GeolocatedCC == string.Empty) && Ad.GeolocatedAgeMin == 0 && Ad.GeolocatedAgeMax == 0 && Ad.GeolocatedGender == Gender.Null)
                {
                    AdCost += AppSettings.PtcAdverts.GeolocationCost;
                }

                //Now get it from client-state
                var CTable   = GeoCountries.Items;
                var geoUList = GeolocationUtils.GeoCountData.Keys;

                StringBuilder sb = new StringBuilder();

                foreach (ListItem item in CTable)
                {
                    if (geoUList.Contains <string>(item.Value))
                    {
                        var countryCode = CountryManager.GetCountryCode(item.Value);
                        if (!string.IsNullOrWhiteSpace(countryCode))
                        {
                            sb.Append(CountryManager.GetCountryCode(item.Value));
                            sb.Append(",");
                        }
                    }
                }

                Ad.GeolocatedCC     = sb.ToString().Trim(',');
                Ad.GeolocatedAgeMin = Convert.ToInt32(GeoAgeMin.Text);
                Ad.GeolocatedAgeMax = Convert.ToInt32(GeoAgeMax.Text);
                Ad.GeolocatedGender = (Gender)Convert.ToInt32(GeoGenderList.SelectedValue);
            }
            else
            {
                Ad.GeolocatedCC     = string.Empty;
                Ad.GeolocatedAgeMin = Ad.GeolocatedAgeMax = 0;
                Ad.GeolocatedGender = Gender.Null;
            }

            if (BackgroundColorCheckBox.Checked)
            {
                BgColorsDDL.Visible = true;
                var bgColor = new PtcAdvertBgColor(Convert.ToInt32(BgColorsDDL.SelectedValue));
                BgColorsDDL.Attributes.Add("style", string.Format("background-color:{0};color:white;", new PtcAdvertBgColor(Convert.ToInt32(BgColorsDDL.SelectedValue)).BgColor));

                if (Ad.BackgroundColor != bgColor.BgColor)
                {
                    AdCost            += bgColor.Price;
                    Ad.BackgroundColor = bgColor.BgColor;
                }
            }

            if (AppSettings.PtcAdverts.FeedbackCaptchaEnabled)
            {
                Ad.CaptchaQuestion = InputChecker.HtmlEncode(CaptchaQuestionTexbox.Text, CaptchaQuestionTexbox.MaxLength, U6013.YESNOCAPTCHAQUESTION);
            }

            if (AppSettings.PtcAdverts.StarredAdsEnabled && StarredAdCheckBox.Checked)
            {
                if (!Ad.IsStarredAd)
                {
                    AdCost += AppSettings.PtcAdverts.StarredAdsPrice;
                }

                Ad.IsStarredAd = true;
            }

            if (AppSettings.PtcAdverts.PTCImagesEnabled)
            {
                Ad.ImagePath = PTCImage_Image.DescriptionUrl;
            }
            else
            {
                Ad.ImagePath = null;
            }
        }
        catch (MsgException ex)
        {
            ErrorMessagePanel.Visible = true;
            ErrorMessage.Text         = ex.Message;
        }
    }
Ejemplo n.º 5
0
    private void BindEditWindow()
    {
        if (!Member.IsLogged)
        {
            return;
        }

        MenuMultiView.SetActiveView(View1);
        int adId = Convert.ToInt32(ViewState["editid"]);

        EditId = "?editid=" + adId.ToString();

        PtcAdvert ad = new PtcAdvert(adId);

        if (ad.AdvertiserUserId != Member.CurrentId || ad.Status == AdvertStatus.Rejected)
        {
            Response.Redirect("~/default.aspx");
        }
        Title.Text = ad.Title;
        URL.Text   = ad.TargetUrl;

        if (AppSettings.PtcAdverts.PTCCategoryPolicy == AppSettings.PTCCategoryPolicy.Custom)
        {
            if (PtcAdvertCategory.GetActiveCategories().Any(x => x.Id == ad.CategoryId))
            {
                CategoriesDDL.SelectedValue = ad.CategoryId.ToString();
            }
        }

        var where = TableHelper.MakeDictionary("IsVisibleByMembers", true);

        if (AppSettings.PtcAdverts.PTCCreditsEnabled)
        {
            where["EndMode"] = (int)End.Mode.Clicks;
        }

        var listPacks = TableHelper.SelectRows <PtcAdvertPack>(where);

        if (listPacks.Any(x => x.Id == ad.Pack.Id))
        {
            ddlOptions.SelectedValue = ad.Pack.Id.ToString();
        }

        chbDescription.Checked = !string.IsNullOrEmpty(ad.Description);
        Description.Visible    = chbDescription.Checked;

        if (chbDescription.Checked)
        {
            Description.Text = ad.Description;
        }
        else
        {
            Description.Text = string.Empty;
        }

        chbGeolocation.Checked = ad.IsGeolocated;

        if (ad.IsGeolocatedByAge)
        {
            GeoAgeMin.Text = ad.GeolocatedAgeMin.ToString();
            GeoAgeMax.Text = ad.GeolocatedAgeMax.ToString();
        }

        if (ad.IsGeolocatedByGender)
        {
            GeoGenderList.SelectedValue = ((int)ad.GeolocatedGender).ToString();
        }

        chbBold.Checked           = ad.HasBoldTitle;
        StarredAdCheckBox.Checked = ad.IsStarredAd;

        var activeColors = PtcAdvertBgColor.GetActiveBgColors();

        if (activeColors.Any(x => x.BgColor == ad.BackgroundColor))
        {
            BgColorsDDL.SelectedValue = activeColors.Where(x => x.BgColor == ad.BackgroundColor).ToList()[0].Id.ToString();
        }

        var freeBgColors = activeColors.Where(x => x.Price == Money.Zero);

        BackgroundColorCheckBox.Checked = !freeBgColors.Any(x => x.BgColor == ad.BackgroundColor);

        CaptchaQuestionCheckBox.Checked = ad.CaptchaQuestion != AppSettings.PtcAdverts.PTCDefaultCaptchaQuestion;
        CaptchaQuestionTexbox.Visible   = CaptchaQuestionCheckBox.Checked;
        CaptchaQuestionTexbox.Text      = ad.CaptchaQuestion;

        if (ad.ExtraViews != -1)
        {
            BuyWithPTCCreditsPlaceHolder2.Visible = UseExtraViewsCheckBox.Checked = true;
            PTCCreditsTextBox.Text = ad.ExtraViews.ToString();
        }

        if (ad.ImagePath != null)
        {
            PTCImage_Image.ImageUrl = ad.ImagePath;
        }
    }