void FolderListBind() { Query q = new Query(); q.QueryCondition = new Q(BannerFolder.Columns.PromoterK, CurrentPromoter.K); q.OrderBy = new OrderBy(BannerFolder.Columns.DateTimeCreated, OrderBy.OrderDirection.Descending); BannerFolderSet bfs = new BannerFolderSet(q); FolderDropDown.DataSource = bfs; FolderDropDown.DataTextField = "Name"; FolderDropDown.DataValueField = "K"; FolderDropDown.DataBind(); FolderDropDown.Items.Insert(0, new ListItem("Choose a folder...", "0")); }
protected void Folder_Init(object sender, EventArgs eventArgs) { if (!Page.IsPostBack) { FolderExistingDropDown.Items.Clear(); FolderExistingDropDown.Items.Add(new ListItem("", "0")); Query q = new Query(); q.TopRecords = 50; q.QueryCondition = new Q(BannerFolder.Columns.PromoterK, CurrentPromoter.K); q.OrderBy = new OrderBy(BannerFolder.Columns.DateTimeCreated, OrderBy.OrderDirection.Descending); BannerFolderSet bfs = new BannerFolderSet(q); bool found = false; foreach (BannerFolder bf in bfs) { if (Edit && bf.K == CurrentBanner.BannerFolderK) found = true; FolderExistingDropDown.Items.Add(new ListItem(Cambro.Misc.Utility.Snip(bf.Name, 40), bf.K.ToString())); } if (Edit && !found) FolderExistingDropDown.Items.Add(new ListItem(Cambro.Misc.Utility.Snip(CurrentBanner.BannerFolder.Name, 40), CurrentBanner.BannerFolderK.ToString())); if (Edit) { if (CurrentBanner.EventK > 0 && CurrentBanner.BannerFolder.EventK == CurrentBanner.EventK) { FolderActionEventRadio.Checked = true; } else { FolderActionExistingRadio.Checked = true; FolderExistingDropDown.SelectedValue = CurrentBanner.BannerFolderK.ToString(); } } } }
protected void SaveToDatabase() { if (Page.IsValid) { Banner b; if (CurrentBanner == null) { Query q = new Query(); q.QueryCondition = new Q(Banner.Columns.DuplicateGuid, (Guid)ViewState["BannerDuplicateGuid"]); BannerSet bs = new BannerSet(q); if (bs.Count == 0) { b = new Banner(); b.UsrK = Usr.Current.K; b.StatusEnabled = true; //b.DateLastHit = DateTime.Today; b.PromoterK = CurrentPromoter.K; b.DuplicateGuid = (Guid)ViewState["BannerDuplicateGuid"]; } else { Response.Redirect(bs[0].Url()); return; } } else { b = CurrentBanner; } if (((IBuyableCredits)b).IsLocked) throw new DsiUserFriendlyException("It looks we're processing a payment for this banner... If not - wait a minute before trying again."); #region Link b.LinkTarget = GetSelectedLinkTarget(); b.EventK = b.LinkTarget.Equals(Banner.LinkTargets.Event) ? CurrentEvent.K : 0; b.BrandK = b.LinkTarget.Equals(Banner.LinkTargets.Brand) || b.LinkTarget.Equals(Banner.LinkTargets.TicketsBrand) ? CurrentBrand.K : 0; b.VenueK = b.LinkTarget.Equals(Banner.LinkTargets.Venue) || b.LinkTarget.Equals(Banner.LinkTargets.TicketsVenue) ? CurrentVenue.K : 0; b.LinkUrl = b.LinkTarget.Equals(Banner.LinkTargets.InternalUrl) || b.LinkTarget.Equals(Banner.LinkTargets.ExternalUrl) ? LinkCustomTextBox.Text : ""; #endregion #region Position if (!LockedPosition) { b.Position = GetSelectedBannerPosition(); } #endregion #region Dates if (!LockedDates) { if (CustomDatesSelected) { b.AutomaticDates = false; b.AutomaticDatesWeeks = 0; } else { b.AutomaticDates = true; b.AutomaticDatesWeeks = GetSelectedAutomaticDatesWeeks(); } b.FirstDay = GetSelectedFirstDay(); b.LastDay = GetSelectedLastDay(); } #endregion #region Exposure if (!LockedExposure) { int impressions; int credits; if (ExposureCustomRadio.Checked) { b.AutomaticExposure = false; b.AutomaticExposureLevel = Banner.ExposureLevels.None; impressions = int.Parse(ImpressionsTextBox.Text.Replace(",", "")); //credits = (int)Math.Ceiling((double)impressions / (double)GetImpressionsPerCredit()); } else { b.AutomaticExposure = true; b.AutomaticExposureLevel = GetSelectedExposureLevel(); credits = GetCreditsPerDay(b.AutomaticExposureLevel) * GetTotalDays(); impressions = credits * GetImpressionsPerCredit(); } b.TotalRequiredImpressions = impressions; //b.PriceStored = credits; //Should we be storing credits somewhere? } #endregion #region Targetting if (DisplayTargettingAutomaticSpan() && TargettingAutomaticRadio.Checked) { b.AutomaticTargetting = true; //we update the music / place targetting below (we need a banner k to do it) } else if (TargettingCustomRadio.Checked) { b.AutomaticTargetting = false; //we update the music / place targetting below (we need a banner k to do it) } else { b.AutomaticTargetting = false; b.IsMusicTargetted = false; b.IsPlaceTargetted = false; } #endregion #region Artwork if (!LockedArtwork) { b.DisplayType = GetSelectedDisplayType(); b.DesignType = GetSelectedDesignType(); if (DisplayArtworkAutomaticSpan() && ArtworkAutomaticRadio.Checked) { b.SetAutomaticBannerText(AutomaticEventBannerHidden.Value); if (!b.StatusArtwork && b.FirstDay < DateTime.Today) b.FirstDay = DateTime.Today; b.StatusArtwork = true; } if (Edit) { //Remove any non-relevant assigned files if (b.DisplayType.Equals(Banner.DisplayTypes.AutoEventBanner) || b.DisplayType.Equals(Banner.DisplayTypes.CustomAutoEventBanner)) { b.MiscK = 0; b.NewMiscK = 0; } else if (b.Misc != null && !b.Misc.DisplayType.Equals(CurrentBanner.DisplayType)) { b.MiscK = 0; } } } #endregion #region Name b.Name = Cambro.Web.Helpers.Strip(NameTextBox.Text); #endregion #region Folder if (DisplayFolderActionEventSpan() && FolderActionEventRadio.Checked) { Query q = new Query(); q.QueryCondition = new And( new Q(BannerFolder.Columns.EventK, CurrentEvent.K), new Q(BannerFolder.Columns.PromoterK, CurrentPromoter.K)); BannerFolderSet bfs = new BannerFolderSet(q); if (bfs.Count == 0) { BannerFolder bf = new BannerFolder(); bf.PromoterK = CurrentPromoter.K; bf.EventK = CurrentEvent.K; bf.Name = "Event: " + Cambro.Misc.Utility.Snip(CurrentEvent.Name, 30) + " @ " + Cambro.Misc.Utility.Snip(CurrentEvent.Venue.Name, 20) + ", " + CurrentEvent.DateTime.ToString("MMM dd yy"); bf.DuplicateGuid = (Guid)ViewState["BannerFolderDuplicateGuid"]; bf.DateTimeCreated = DateTime.Now; bf.Update(); b.BannerFolderK = bf.K; } else b.BannerFolderK = bfs[0].K; } else if (FolderActionExistingRadio.Checked) { BannerFolder bf = new BannerFolder(int.Parse(FolderExistingDropDown.SelectedValue)); if (bf.PromoterK != CurrentPromoter.K) throw new DsiUserFriendlyException("Selected banner folder isn't in your promoter account!"); b.BannerFolderK = bf.K; } else if (FolderActionNewRadio.Checked) { Query q = new Query(); q.QueryCondition = new And( new Q(BannerFolder.Columns.DuplicateGuid, (Guid)ViewState["BannerFolderDuplicateGuid"])); BannerFolderSet bfs = new BannerFolderSet(q); if (bfs.Count == 0) { BannerFolder bf = new BannerFolder(); bf.PromoterK = CurrentPromoter.K; bf.Name = Cambro.Web.Helpers.Strip(FolderNewTextBox.Text); bf.DuplicateGuid = (Guid)ViewState["BannerFolderDuplicateGuid"]; bf.DateTimeCreated = DateTime.Now; bf.Update(); b.BannerFolderK = bf.K; } else { if (bfs[0].PromoterK != CurrentPromoter.K) throw new DsiUserFriendlyException("Selected banner folder isn't in your promoter account!"); b.BannerFolderK = bfs[0].K; } } #endregion #region if Copy - extra Properties to Copy from existing Banner if (Copy) { b.TargettingProperties0 = CopyBanner.TargettingProperties0; b.TargettingProperties1 = CopyBanner.TargettingProperties1; if (b.DesignType == Banner.DesignTypes.None) { if (!b.StatusArtwork && CopyBanner.StatusArtwork && b.FirstDay < DateTime.Today) b.FirstDay = DateTime.Today; b.StatusArtwork = CopyBanner.StatusArtwork; b.MiscK = CopyBanner.MiscK; } } #endregion b.Update(); if (b.AutomaticTargetting) { b.IsPlaceTargetted = b.SavePlaceTargetting(CurrentEvent); b.IsMusicTargetted = b.SaveMusicTargetting(CurrentEvent); b.Update(); } else if (TargettingCustomRadio.Checked) { b.IsPlaceTargetted = b.SavePlaceTargetting(new List<string>(LocationTargettingHidden.Value.Split(',')).ConvertAll(s => int.Parse(s.Trim()))); b.IsMusicTargetted = b.SaveMusicTargetting(new List<string>(MusicTargettingHidden.Value.Split(',')).ConvertAll(s => int.Parse(s.Trim()))); b.Update(); } else { b.IsPlaceTargetted = b.SavePlaceTargetting(new List<int>(0)); b.IsMusicTargetted = b.SaveMusicTargetting(new List<int>(1) { 1 }); b.Update(); } CurrentBanner = b; //if (Add || Copy) //{ // if (HasFixedCurrentEvent) // Response.Redirect(CurrentPromoter.UrlEventOptions(CurrentEvent)); // else // Response.Redirect(CurrentPromoter.UrlApp("banners")); //} //else //{ // if (HasFixedCurrentEvent) // Response.Redirect(CurrentBanner.OptionsUrl("eventk", CurrentEvent.K.ToString())); // else Response.Redirect(CurrentBanner.Url()); //} } }