private void SaveTicketRun() { bool redirect = true; Page.Validate("SaveTicketRun"); if (Page.IsValid) { try { base.VerifyUserPermissions(); // Do not save for new ticket run when duplicate guid exists in DB if (!((CurrentTicketRun.K == 0) && Bobs.TicketRun.DoesDuplicateGuidExistInDb((Guid)this.ViewState["DuplicateGuid"]))) { if (!CurrentTicketRun.IsUpdateable) { LoadScreenFromTicketRun(); ErrorMessageCustomValidator.ErrorMessage = "This ticket run is not updateable."; ErrorMessageCustomValidator.IsValid = false; return; } LoadTicketRunFromScreen(); //try //{ // UK countryK = 224 if (CurrentPromoter.AddressCountryK != 224 || (CurrentPromoter.VatCountryK != 224 && CurrentPromoter.VatCountryK != 0)) { ErrorMessageCustomValidator.ErrorMessage = NO_TICKET_SALES_FOR_NONUK_PROMOTERS; ErrorMessageCustomValidator.IsValid = false; return; } //} //catch //{ // ErrorMessageCustomValidator.ErrorMessage = "Unable to find the country where the venue is located. Ticket sales are not currently available outside the UK."; // ErrorMessageCustomValidator.IsValid = false; // return; //} if (CurrentTicketRun.IsCircularDependancy()) { LoadScreenFromTicketRun(); ErrorMessageCustomValidator.ErrorMessage = "Cannot follow ticket run " + CurrentTicketRun.FollowsTicketRun.PriceBrandName + ". This would create a circular dependancy."; ErrorMessageCustomValidator.IsValid = false; return; } CurrentTicketRun.Update(); try { TicketPromoterEvent tpe = new TicketPromoterEvent(CurrentTicketRun.PromoterK, CurrentTicketRun.EventK); if (ContactEmailTextBox.Text.Trim().Length != 0) { tpe.ContactEmail = ContactEmailTextBox.Text.Trim(); tpe.Update(); } if (CurrentTicketRun.EndDateTime <= DateTime.Now && !CurrentTicketRun.EmailSent) { Utilities.EmailTicketRunStatusUpdate(tpe); CurrentTicketRun.EmailSent = true; CurrentTicketRun.Update(); } } catch { TicketPromoterEvent tpe = new TicketPromoterEvent(); tpe.PromoterK = CurrentTicketRun.PromoterK; tpe.EventK = CurrentTicketRun.EventK; if (ContactEmailTextBox.Text.Trim().Length != 0) tpe.ContactEmail = ContactEmailTextBox.Text.Trim(); tpe.Update(); if (CurrentPromoter == null) throw new Exception("SaveTicketRunButton_Click(): CurrentPromoter==null"); if (!CurrentPromoter.EnableTickets) { // send out email reminding them to fill out ticket application form Utilities.EmailPromoterReminderToSubmitTicketApplicationForm(tpe); } } CurrentTicketRun.Event.UpdateIsTicketsAvailable(false); CurrentTicketRun.Event.UpdateHasHighlight(false); CurrentTicketRun.Event.Update(); } } catch (Exception ex) { SavingErrorCustomValidator.IsValid = false; Utilities.AdminEmailAlert("Exception occurred in TicketRunScreen SaveTicketRun for promoter " + CurrentPromoter.Name + " (" + CurrentPromoter.K.ToString() + ")" + " TicketRunK=" + CurrentTicketRun.K.ToString(), "Exception occurred in TicketRunScreen SaveTicketRun for promoter " + CurrentPromoter.Name + " (" + CurrentPromoter.K.ToString() + ")" + " TicketRunK=" + CurrentTicketRun.K.ToString(), ex, CurrentTicketRun); } if (redirect) { // Redirect to page user was on before entering this page RedirectToReferringPage(); } } }
public static void CreateNewTicketPromoterEventsWhenNeeded() { try { // Testing started in May 2007, so include all events after that date. We do not want to include past ticket runs, SW4 2006. Query ticketPromoterEventNotCreatedQuery = new Query(new And(new Q(TicketPromoterEvent.Columns.EventK, QueryOperator.IsNull, null), new Q(Event.Columns.DateTime, QueryOperator.LessThan, DateTime.Today), new Q(Event.Columns.DateTime, QueryOperator.GreaterThanOrEqualTo, Vars.TICKETS_NEW_SYSTEM_START_DATE))); ticketPromoterEventNotCreatedQuery.TableElement = new Join(new Join(TicketRun.Columns.EventK, Event.Columns.K), new TableElement(TablesEnum.TicketPromoterEvent), QueryJoinType.Left, new And(new Q(TicketPromoterEvent.Columns.EventK, Event.Columns.K, true), new Q(TicketPromoterEvent.Columns.PromoterK, TicketRun.Columns.PromoterK, true))); ticketPromoterEventNotCreatedQuery.Columns = new ColumnSet(TicketRun.Columns.PromoterK, TicketRun.Columns.EventK); ticketPromoterEventNotCreatedQuery.GroupBy = new GroupBy(new GroupBy(TicketRun.Columns.PromoterK), new GroupBy(TicketRun.Columns.EventK)); TicketRunSet ticketRunsWithoutTicketPromoterEvents = new TicketRunSet(ticketPromoterEventNotCreatedQuery); foreach (TicketRun ticketRunWithoutTicketPromoterEvent in ticketRunsWithoutTicketPromoterEvents) { TicketPromoterEvent ticketPromoterEvent = new TicketPromoterEvent(); try { ticketPromoterEvent = new TicketPromoterEvent(ticketRunWithoutTicketPromoterEvent.PromoterK, ticketRunWithoutTicketPromoterEvent.EventK); } catch { ticketPromoterEvent.PromoterK = ticketRunWithoutTicketPromoterEvent.PromoterK; ticketPromoterEvent.EventK = ticketRunWithoutTicketPromoterEvent.EventK; ticketPromoterEvent.FundsLockText = ""; ticketPromoterEvent.FundsReleased = false; ticketPromoterEvent.Update(); if (!ticketPromoterEvent.Promoter.EnableTickets) { Utilities.EmailPromoterReminderToSubmitTicketApplicationForm(ticketPromoterEvent); } } } } catch (Exception ex) { Utilities.AdminEmailAlert("Exception in TicketPromoterEvent.CreateTicketPromoterEventsWhenNeeded()", "Exception in TicketPromoterEvent.CreateTicketPromoterEventsWhenNeeded()", ex); } }