Ejemplo n.º 1
0
    private void BindDataCategoriesToDDL()
    {
        var activeCategories = PtcAdvertCategory.GetActiveCategories();
        var dictlist         = new Dictionary <string, string>();

        foreach (var category in activeCategories)
        {
            dictlist[category.Id.ToString()] = category.Name;
        }
        CategoriesDDL.DataSource     = dictlist;
        CategoriesDDL.DataTextField  = "Value";
        CategoriesDDL.DataValueField = "Key";
        CategoriesDDL.DataBind();
    }
Ejemplo n.º 2
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;
        }
    }