public static IBob Get(Model.Entities.ObjectType type, int k) { IBob b = null; bool wrongType = false; try { switch (type) { case Model.Entities.ObjectType.Photo: b = new Photo(k); break; case Model.Entities.ObjectType.Event: b = new Event(k); break; case Model.Entities.ObjectType.Venue: b = new Venue(k); break; case Model.Entities.ObjectType.Place: b = new Place(k); break; case Model.Entities.ObjectType.Thread: b = new Thread(k); break; case Model.Entities.ObjectType.Country: b = new Country(k); break; case Model.Entities.ObjectType.Article: b = new Article(k); break; case Model.Entities.ObjectType.Para: b = new Para(k); break; case Model.Entities.ObjectType.Brand: b = new Brand(k); break; case Model.Entities.ObjectType.Promoter: b = new Promoter(k); break; case Model.Entities.ObjectType.Usr: b = new Usr(k); break; case Model.Entities.ObjectType.Region: b = new Region(k); break; case Model.Entities.ObjectType.Gallery: b = new Gallery(k); break; case Model.Entities.ObjectType.Group: b = new Group(k); break; case Model.Entities.ObjectType.Banner: b = new Banner(k); break; case Model.Entities.ObjectType.GuestlistCredit: b = new GuestlistCredit(k); break; case Model.Entities.ObjectType.Ticket: b = new Ticket(k); break; case Model.Entities.ObjectType.Invoice: b = new Invoice(k); break; case Model.Entities.ObjectType.InsertionOrder: b = new InsertionOrder(k); break; case Model.Entities.ObjectType.CampaignCredit: b = new CampaignCredit(k); break; case Model.Entities.ObjectType.UsrDonationIcon: b = new UsrDonationIcon(k); break; default: wrongType = true; b = null; break; } } catch { } if (wrongType) throw new Exception("Bob.Get attempted to get " + type.ToString() + " - can't do it!!! DUH!"); return b; }
private void LoadModelFromDatabase() { InsertionOrder = new InsertionOrder(Convert.ToInt32(ContainerPage.Url["K"].Value)); SalesUsrs = new List<Usr>(Usr.GetCurrentAndPreviousSalesUsrsNameAndK()); if (InsertionOrderItems == null) { InsertionOrderItems = new List<InsertionOrderItem>(InsertionOrder.InsertionOrderItems); } if (InsertionOrder.PromoterK > 0 && InsertionOrder.Promoter.IsAgency) { InsertionOrder.AgencyDiscount = 0.3d; } }
protected void Page_Load(object sender, EventArgs e) { string type = ""; int k = 0; int pk = 0; if (ContainerPage.Url["type"].Exists) type = ContainerPage.Url["type"].Value; if (ContainerPage.Url["K"].Exists && ContainerPage.Url["K"].IsInt) k = Convert.ToInt32(ContainerPage.Url["K"].Value); if (ContainerPage.Url["PK"].Exists && ContainerPage.Url["PK"].IsInt) pk = Convert.ToInt32(ContainerPage.Url["PK"].Value); //Promoter CurrentPromoter = new Promoter(pk); Usr.KickUserIfNotLoggedIn(); //if (!Usr.Current.IsPromoter && !Usr.Current.IsAdmin) //{ // throw new Exception("You must be a promoter to view this page"); //} //if (CurrentPromoter != null) //{ // if (!Usr.Current.IsPromoterK(CurrentPromoter.K) && !Usr.Current.IsAdmin) // throw new Exception("You can't view these details."); //} if (type.ToUpper() == "STATEMENT") { Promoter promoter = new Promoter(pk); if (!promoter.IsUsrAllowedAccess(Usr.Current)) throw new Exception(Vars.CANT_VIEW_DETAILS); int month = DateTime.Now.Month; int year = DateTime.Now.Year; if (ContainerPage.Url["M"].Exists && ContainerPage.Url["M"].IsInt) month = Convert.ToInt32(ContainerPage.Url["M"].Value); if (ContainerPage.Url["Y"].Exists && ContainerPage.Url["Y"].IsInt) year = Convert.ToInt32(ContainerPage.Url["Y"].Value); Response.Write(promoter.GenerateMonthlyStatementStringBuilder(month, year, true).ToString()); } else if(type.ToUpper().Equals("TICKETFUNDSINVOICE")) { TicketPromoterEvent tpe = new TicketPromoterEvent(pk, k); if (!tpe.IsUsrAllowedAccess(Usr.Current)) throw new Exception(Vars.CANT_VIEW_DETAILS); Response.Write(tpe.GenerateReportStringBuilder(true).ToString()); } else { IBobReport bobReport; switch (type.ToUpper()) { case "TRANSFER": bobReport = new Transfer(k); break; case "INVOICE": // goto credit case "CREDIT": bobReport = new Bobs.Invoice(k); break; case "TICKET": bobReport = new Ticket(k); break; case "TICKETFORPRINTING": bobReport = new TicketForPrinting(k); break; case "INSERTIONORDER": bobReport = new InsertionOrder(k); break; default: bobReport = null; break; } if (bobReport != null) { if (!bobReport.IsUsrAllowedAccess(Usr.Current)) throw new Exception(Vars.CANT_VIEW_DETAILS); Response.Write(bobReport.GenerateReportStringBuilder(true).ToString()); } } }
private void SetupModelWithNewObjects() { if (!IsPostBack) { DuplicateGuid = Guid.NewGuid(); } InsertionOrder = new InsertionOrder() { ActionUsrK = Usr.Current.K, DateTimeCreated = DateTime.Now.Date, TrafficUsrK = Common.Properties.TrafficUsrK, Status = InsertionOrder.InsertionOrderStatus.Proforma, CampaignCredits = 0 }; SalesUsrs = new List<Usr>(Usr.GetCurrentSalesUsrsNameAndK()); if (InsertionOrderItems == null) { InsertionOrderItems = new List<InsertionOrderItem>(); } }