Ejemplo n.º 1
0
		public void PanelSignUpFormClick(object o, System.EventArgs e)
		{
			Page.Validate();
			if (Page.IsValid)
			{
				if (IsEdit)
				{
					if (!CanEdit)
						throw new Exception("You can't edit this promoter!");
					#region Store changes to promoter in admin note
					string oldDetails = "";
					if (!Cambro.Web.Helpers.StripHtml(Name.Text).Equals(CurrentPromoter.Name))
						oldDetails += "Name: [" + CurrentPromoter.Name + "] - [" + Cambro.Web.Helpers.StripHtml(Name.Text) + "]\n";
					if (!Cambro.Web.Helpers.StripHtml(ContactName.Text).Equals(CurrentPromoter.ContactName))
						oldDetails += "ContactName: [" + CurrentPromoter.ContactName + "] - [" + Cambro.Web.Helpers.StripHtml(ContactName.Text) + "]\n";
					if (!Cambro.Web.Helpers.StripHtml(PhoneNumber.Text).Equals(CurrentPromoter.PhoneNumber))
						oldDetails += "PhoneNumber: [" + CurrentPromoter.PhoneNumber + "] - [" + Cambro.Web.Helpers.StripHtml(PhoneNumber.Text) + "]\n";
					if (!Cambro.Web.Helpers.StripHtml(AddressStreet.Text).Equals(CurrentPromoter.AddressStreet))
						oldDetails += "AddressStreet: [" + CurrentPromoter.AddressStreet + "] - [" + Cambro.Web.Helpers.StripHtml(AddressStreet.Text) + "]\n";
					if (!Cambro.Web.Helpers.StripHtml(AddressArea.Text).Equals(CurrentPromoter.AddressArea))
						oldDetails += "AddressArea: [" + CurrentPromoter.AddressArea + "] - [" + Cambro.Web.Helpers.StripHtml(AddressArea.Text) + "]\n";
					if (!Cambro.Web.Helpers.StripHtml(AddressTown.Text).Equals(CurrentPromoter.AddressTown))
						oldDetails += "AddressTown: [" + CurrentPromoter.AddressTown + "] - [" + Cambro.Web.Helpers.StripHtml(AddressTown.Text) + "]\n";
					if (!Cambro.Web.Helpers.StripHtml(AddressCounty.Text).Equals(CurrentPromoter.AddressCounty))
						oldDetails += "AddressCounty: [" + CurrentPromoter.AddressCounty + "] - [" + Cambro.Web.Helpers.StripHtml(AddressCounty.Text) + "]\n";
					if (!Cambro.Web.Helpers.StripHtml(AddressPostcode.Text).Equals(CurrentPromoter.AddressPostcode))
						oldDetails += "AddressPostcode: [" + CurrentPromoter.AddressPostcode + "] - [" + Cambro.Web.Helpers.StripHtml(AddressPostcode.Text) + "]\n";
					if (!int.Parse(AddressCountry.SelectedValue).Equals(CurrentPromoter.AddressCountryK))
						oldDetails += "CountryK: [" + CurrentPromoter.AddressCountryK + "] - [" + int.Parse(AddressCountry.SelectedValue).ToString() + "]\n";
					if (!((Promoter.VatStatusEnum)Convert.ToInt32(VatStatusDropDownList.SelectedValue)).Equals(CurrentPromoter.VatStatus))
						oldDetails += "VatStatus: [" + CurrentPromoter.VatStatus.ToString() + "] - [" + ((Promoter.VatStatusEnum)Convert.ToInt32(VatStatusDropDownList.SelectedValue)).ToString() + "]\n";
					if (!Cambro.Web.Helpers.StripHtml(VatNumberTextBox.Text.Trim()).Equals(CurrentPromoter.VatNumber))
						oldDetails += "VatNumber: [" + CurrentPromoter.VatNumber + "] - [" + Cambro.Web.Helpers.StripHtml(VatNumberTextBox.Text.Trim()) + "]\n";
					if (!Convert.ToInt32(VatCountryDropDownList.SelectedValue).Equals(CurrentPromoter.VatCountryK))
						oldDetails += "VatCountryK: [" + CurrentPromoter.VatCountryK.ToString() + "] - [" + Convert.ToInt32(VatCountryDropDownList.SelectedValue).ToString() + "]\n";
                    if (!Cambro.Web.Helpers.StripHtml(BankNameTextBox.Text).Equals(CurrentPromoter.BankName))
                        oldDetails += "BankName: [" + CurrentPromoter.BankName + "] - [" + Cambro.Web.Helpers.StripHtml(BankNameTextBox.Text) + "]\n";
                    if (!Cambro.Web.Helpers.StripHtml(BankAccountNameTextBox.Text).Equals(CurrentPromoter.BankAccountName))
                        oldDetails += "BankAccountName: [" + CurrentPromoter.BankAccountName + "] - [" + Cambro.Web.Helpers.StripHtml(BankAccountNameTextBox.Text) + "]\n";
                    if (!Cambro.Web.Helpers.StripHtml(BankAccountNumberTextBox.Text).Equals(CurrentPromoter.BankAccountNumber))
                        oldDetails += "BankAccountNumber: [" + CurrentPromoter.BankAccountNumber + "] - [" + Cambro.Web.Helpers.StripHtml(BankAccountNumberTextBox.Text) + "]\n";
                    if (!Cambro.Web.Helpers.StripHtml(BankAccountSortCodeTextBox.Text).Equals(CurrentPromoter.BankAccountSortCode))
                        oldDetails += "BankAccountSortCode: [" + CurrentPromoter.BankAccountSortCode + "] - [" + Cambro.Web.Helpers.StripHtml(BankNameTextBox.Text) + "]\n";
					if (uiAgency.Checked != CurrentPromoter.IsAgency)
						oldDetails += "IsAgency: [" + CurrentPromoter.IsAgency.ToString() + "] - [" + uiAgency.Checked.ToString() + "]\n";
					if (oldDetails.Length > 0)
						CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") changed these details on " + DateTime.Now.ToString() + ":\n" + oldDetails;
					#endregion
				}
				else
				{
					Guid DuplicateGuid = (Guid)ViewState["PromoterDuplicateGuid"];
					PromoterSet ps = new PromoterSet(new Query(new Q(Promoter.Columns.DuplicateGuid, DuplicateGuid)));
					if (ps.Count > 0)
					{
						Response.Redirect(ps[0].UrlApp("edit"));
						return;
					}
					else
					{
						#region Initialise promoter record
						CurrentPromoter = new Promoter();
						CurrentPromoter.DateTimeSignUp = DateTime.Now;
						CurrentPromoter.AddedByUsrK = Usr.Current.K;
						CurrentPromoter.HasGuestlist = true;
						CurrentPromoter.GuestlistCharge = 0.25m;
						CurrentPromoter.GuestlistCredit = 20;
						CurrentPromoter.GuestlistCreditLimit = 0;
						CurrentPromoter.Status = Promoter.StatusEnum.Enabled;
						CurrentPromoter.PricingMultiplier = 1.0;
						CurrentPromoter.TotalPaid = 0;
						CurrentPromoter.DuplicateGuid = (Guid)ViewState["PromoterDuplicateGuid"];
						
						CurrentPromoter.LetterType = Promoter.LetterTypes.CurrentNewPromoter;
						CurrentPromoter.LetterStatus = Promoter.LetterStatusEnum.New;
						CurrentPromoter.IsSkeleton = false;
						CurrentPromoter.OfferType = Promoter.OfferTypes.None;
						Random r = new Random();
						CurrentPromoter.AccessCodeRandom = r.Next(1000, 9999).ToString() + r.Next(1000, 9999).ToString();
						
						CurrentPromoter.ClientSector = (Promoter.ClientSectorEnum)Convert.ToInt32(Sector.SelectedValue);
						CurrentPromoter.SalesCampaignK = int.Parse(SalesCampaignDropDown.SelectedValue);
						

						if (!Usr.Current.IsAdmin)
						{
							CurrentPromoter.PrimaryUsrK = Usr.Current.K;
							CurrentPromoter.AddedMethod = Promoter.AddedMedhods.EndUser;
						}
						else
						{
							CurrentPromoter.AddedMethod = Promoter.AddedMedhods.SalesUser;
						}

						// assign new Promoter to Usr.Current if they are on a promoter sales team or to a randomly assigned promoter sales person, as requested by Dave 7/2/07
						if (Usr.Current.SalesTeam > 0)
						{
							CurrentPromoter.SalesStatus = Promoter.SalesStatusEnum.Proactive;
							CurrentPromoter.SalesUsrK = Usr.Current.K;
						}
						else
						{
							CurrentPromoter.SalesStatus = Promoter.SalesStatusEnum.New;
							// Randomly assign a sales usr
							List<Usr> promoterSalesUsrs;
							if (CurrentPromoter.ClientSector.Equals(Promoter.ClientSectorEnum.Promoter))
								promoterSalesUsrs = Usr.GetNewPromoterSalesUsrsNameAndK().ToList();
							else
								promoterSalesUsrs = new List<Usr>() { new Usr(1) };
							CurrentPromoter.SalesUsrK = promoterSalesUsrs[r.Next(0, promoterSalesUsrs.Count)].K;
						}											

						CurrentPromoter.SalesStatusExpires = DateTime.Today.AddMonths(3);
						CurrentPromoter.SalesNextCall = DateTime.Now.AddDays(3);
						// If first call is on a weekend, then make it Monday
						if(CurrentPromoter.SalesNextCall.DayOfWeek == DayOfWeek.Saturday)
							CurrentPromoter.SalesNextCall = DateTime.Now.AddDays(2);
						else if(CurrentPromoter.SalesNextCall.DayOfWeek == DayOfWeek.Sunday)
							CurrentPromoter.SalesNextCall = DateTime.Now.AddDays(1);

						#endregion
					}
				}
				#region Update promoter record with form contents
				CurrentPromoter.Name = Cambro.Web.Helpers.StripHtml(Name.Text);
				CurrentPromoter.ContactName = Cambro.Web.Helpers.StripHtml(ContactName.Text);
				CurrentPromoter.PhoneNumber = Cambro.Web.Helpers.StripHtml(PhoneNumber.Text);
				CurrentPromoter.AddressStreet = Cambro.Web.Helpers.StripHtml(AddressStreet.Text);
				CurrentPromoter.AddressArea = Cambro.Web.Helpers.StripHtml(AddressArea.Text);
				CurrentPromoter.AddressTown = Cambro.Web.Helpers.StripHtml(AddressTown.Text);
				CurrentPromoter.AddressCounty = Cambro.Web.Helpers.StripHtml(AddressCounty.Text);
				CurrentPromoter.AddressPostcode = Cambro.Web.Helpers.StripHtml(AddressPostcode.Text);

				bool updateTicketInvoices = false;
				// new VAT details, for Ticket System. 22/5/07
				if (CurrentPromoter.VatStatus != Promoter.VatStatusEnum.Registered && CurrentPromoter.VatStatus != (Promoter.VatStatusEnum)Convert.ToInt32(VatStatusDropDownList.SelectedValue))
					updateTicketInvoices = true;

				CurrentPromoter.VatStatus = (Promoter.VatStatusEnum)Convert.ToInt32(VatStatusDropDownList.SelectedValue);
				CurrentPromoter.VatCountryK = Convert.ToInt32(VatCountryDropDownList.SelectedValue);
				CurrentPromoter.VatNumber = Cambro.Web.Helpers.StripHtml(VatNumberTextBox.Text.Trim());
				
				// new Admin only data entry fields, as requested by Dave 7/2/07
				if (Usr.Current.IsAdmin || Usr.Current.IsSuperAdmin)
				{
					CurrentPromoter.AccountsEmail = Cambro.Web.Helpers.StripHtml(AccountsEmail.Text);
					CurrentPromoter.AccountsName = Cambro.Web.Helpers.StripHtml(AccountsName.Text);
					CurrentPromoter.AccountsPhone = Cambro.Web.Helpers.StripHtml(AccountsPhone.Text);
					CurrentPromoter.ContactPersonalTitle = Cambro.Web.Helpers.StripHtml(PersonalTitle.Text);
					CurrentPromoter.ContactTitle = Cambro.Web.Helpers.StripHtml(JobTitle.Text);
					CurrentPromoter.PhoneNumber2 = Cambro.Web.Helpers.StripHtml(PhoneNumber2.Text);
					CurrentPromoter.WebAddress = Cambro.Web.Helpers.StripHtml(WebAddress.Text);
					CurrentPromoter.ClientSector = (Promoter.ClientSectorEnum)Convert.ToInt32(Sector.SelectedValue);
					CurrentPromoter.SalesCampaignK = int.Parse(SalesCampaignDropDown.SelectedValue);
					CurrentPromoter.IsAgency = uiAgency.Checked;

                    // new admin only bank details, as requested by Dave 15/6/07
                    CurrentPromoter.BankName = Cambro.Web.Helpers.StripHtml(BankNameTextBox.Text);
                    CurrentPromoter.BankAccountName = Cambro.Web.Helpers.StripHtml(BankAccountNameTextBox.Text);
                    CurrentPromoter.BankAccountNumber = Cambro.Web.Helpers.StripHtml(BankAccountNumberTextBox.Text);
                    CurrentPromoter.BankAccountSortCode = Cambro.Web.Helpers.StripHtml(BankAccountSortCodeTextBox.Text);

					
					if (this.AccessMultiRadio.Checked && this.uiAccessUsersMultiSelector.Count > 0 && (Usr.Current.IsAdmin || Usr.Current.IsSuperAdmin)){
						CurrentPromoter.PrimaryUsrK = int.Parse(uiPrimaryUserDropDown.SelectedValue);
					}else
					{
						CurrentPromoter.PrimaryUsrK = 0;
						CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") has setup this account with no primary user - " + DateTime.Now.ToString() + "\n";
					}
				}

				if (!IsEdit)
				{
					if (CurrentPromoter.PrimaryUsrK > 0)
						CurrentPromoter.AddQuestionsThread(CurrentPromoter.PrimaryUsr, Cambro.Web.Helpers.StripHtml(Name.Text));
					else
						CurrentPromoter.AddQuestionsThread(Usr.Current, Cambro.Web.Helpers.StripHtml(Name.Text));
				}

				Country newCountry = new Country(int.Parse(AddressCountry.SelectedValue));
				CurrentPromoter.AddressCountryK = newCountry.K;
				CurrentPromoter.Update();
				if (updateTicketInvoices)
					CurrentPromoter.UpdateTicketInvoiceItemTaxCode();
				CurrentPromoter.CreateUniqueUrlName();
				#endregion
				#region Add / remove selected users
				if (CurrentPromoter.PrimaryUsrK == Usr.Current.K || Usr.Current.IsAdmin || Usr.Current.IsSuperAdmin)
				{
					ArrayList SelectedUsers = new ArrayList();
					ArrayList CurrentUsers = new ArrayList();
					if (CurrentPromoter.PrimaryUsrK > 0)
					{
						SelectedUsers.Add(CurrentPromoter.PrimaryUsrK);
					}
					if (AccessMultiRadio.Checked)
					{
						foreach (var pair in this.uiAccessUsersMultiSelector.Selections)
						{
							Usr u = new Usr(int.Parse(pair.Value));
							if (!SelectedUsers.Contains(u.K))
								SelectedUsers.Add(u.K);
						}
					}
					foreach (Usr u in CurrentPromoter.AdminUsrs)
					{
						if (!CurrentUsers.Contains(u.K))
							CurrentUsers.Add(u.K);
					}

					if (SelectedUsers.Count > 0)
					{
						Usr JohnB = new Usr(1);
						Thread t = new Thread(CurrentPromoter.QuestionsThreadK);
						foreach (int usrK in SelectedUsers)
						{
							if (!CurrentUsers.Contains(usrK))
							{
								PromoterUsr pu = new PromoterUsr();
								pu.PromoterK = CurrentPromoter.K;
								pu.UsrK = usrK;
								pu.Update();

								t.Invite(new List<int>(new int[] { usrK }), JohnB, DateTime.Now, new List<int>(), !IsEdit, null, false);

								ThreadUsr tu = new ThreadUsr(CurrentPromoter.QuestionsThreadK, usrK);
								tu.Favourite = true;
								tu.Update();

								CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") added new user to admins - " + DateTime.Now.ToString() + " - " + pu.UsrK.ToString() + " (" + pu.Usr.NickName + ")\n";
								CurrentPromoter.Update();

								pu.Usr.UpdateIsPromoter();
							}
						}
					}
					//if (!AccessNoAccountUsersRadio.Checked)
					//{
						foreach (int usrK in CurrentUsers)
						{
							if (!SelectedUsers.Contains(usrK))
							{
								PromoterUsr pu = new PromoterUsr(CurrentPromoter.K, usrK);

								CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") removed user from the admins - " + DateTime.Now.ToString() + " - " + pu.UsrK.ToString() + " (" + pu.Usr.NickName + ")\n";
								CurrentPromoter.Update();

								pu.Delete();
								pu.Update();

								pu.Usr.UpdateIsPromoter();

								try
								{
									ThreadUsr tu = new ThreadUsr(CurrentPromoter.QuestionsThreadK, usrK);
									tu.Delete();
									tu.Update();

									UpdateTotalParticipantsJob job = new UpdateTotalParticipantsJob(tu.Thread);
									job.ExecuteSynchronously();

								}
								catch { }
							}
						}
					//}
					//else
					//{
					//    foreach (int usrK in CurrentUsers)
					//    {
					//        PromoterUsr pu = new PromoterUsr(CurrentPromoter.K, usrK);

					//        CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") removed user from the admins - " + DateTime.Now.ToString() + " - " + pu.UsrK.ToString() + " (" + pu.Usr.NickName + ")\n";
					//        CurrentPromoter.Update();

					//        pu.Delete();
					//        pu.Update();

					//        pu.Usr.UpdateIsPromoter();

					//        try
					//        {
					//            ThreadUsr tu = new ThreadUsr(CurrentPromoter.QuestionsThreadK, usrK);
					//            tu.Delete();
					//            tu.Update();
					//            tu.Thread.UpdateTotalParticipants();
					//        }
					//        catch { }
					//    }
					//}
				}
				#endregion
				#region Add / remove selected brands
					ArrayList SelectedBrands = new ArrayList();
					ArrayList CurrentBrands = new ArrayList();
					if (AccountTypeRadioEvents.Checked)
					{
						foreach (var pair in this.uiBrandMultiSelector.Selections)
						{
							Brand b = new Brand(int.Parse(pair.Value));
							if (!SelectedBrands.Contains(b.K))
								SelectedBrands.Add(b.K);
						}
					}
					CurrentPromoter.AllBrands = null;
					foreach (Brand b in CurrentPromoter.AllBrands)
					{
						if (!CurrentBrands.Contains(b.K))
							CurrentBrands.Add(b.K);
					}

					string failedBrands = "";

					foreach (int brandK in SelectedBrands)
					{
						if (!CurrentBrands.Contains(brandK))
						{
							Brand b = new Brand(brandK);
							bool changeStatus = false;
							if (b.PromoterK == 0)
							{
								CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") added brand - " + DateTime.Now.ToString() + " - " + b.K + " (" + b.Name + ") - ";
								b.PromoterK = CurrentPromoter.K;
								changeStatus = true;
							}
							else if (b.PromoterStatus.Equals(Brand.PromoterStatusEnum.Unconfirmed))
							{
								CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") added brand - " + DateTime.Now.ToString() + " - " + b.K + " (" + b.Name + ") - removed from promoter " + b.PromoterK + " (" + b.Promoter.Name + ") - ";
								b.PromoterK = CurrentPromoter.K;
								changeStatus = true;
							}
							else //brand owned by someone else!
							{
								CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") attempted to add brand - " + DateTime.Now.ToString() + " - " + b.K + " (" + b.Name + "), but it's already confirmed to promoter " + b.PromoterK + " (" + b.Promoter.Name + ")\n";

								failedBrands = (failedBrands.Length == 0 ? "" : ", ") + b.Name;
							}
							if (changeStatus)
							{
								bool foundBrandOwner = false;
								CurrentPromoter.AdminUsrs = null;
								foreach (Usr u in CurrentPromoter.AdminUsrs)
								{
									if (b.OwnerUsrK == u.K)
										foundBrandOwner = true;
								}
								if (foundBrandOwner || Usr.Current.IsAdmin)
								{
									b.PromoterStatus = Brand.PromoterStatusEnum.Confirmed;
									CurrentPromoter.AdminNote += "(status confirmed)\n";
								}
								else
								{
									b.PromoterStatus = Brand.PromoterStatusEnum.Unconfirmed;
									CurrentPromoter.AdminNote += "(status new)\n";
								}
							}
							b.Update();
							CurrentPromoter.Update();
						}
					}
					foreach (int brandK in CurrentBrands)
					{
						if (!SelectedBrands.Contains(brandK))
						{
							Brand b = new Brand(brandK);
							CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") removed brand - " + DateTime.Now.ToString() + " - " + b.K + " (" + b.Name + ")";
							b.PromoterStatus = Brand.PromoterStatusEnum.Unconfirmed;
							b.PromoterK = 0;
							b.Update();
							CurrentPromoter.Update();
						}
					}
					#endregion
				#region Add / remove selected venues
				ArrayList SelectedVenues = new ArrayList();
				ArrayList CurrentVenues = new ArrayList();
				if (VenuesRadioYes.Checked)
				{
					foreach (var pair in this.uiVenuesMultiSelector.Selections)
					{
						Venue v = new Venue(int.Parse(pair.Value));
						if (!SelectedVenues.Contains(v.K))
							SelectedVenues.Add(v.K);
					}
				}
				CurrentPromoter.AllVenues = null;
				foreach (Venue v in CurrentPromoter.AllVenues)
				{
					if (!CurrentVenues.Contains(v.K))
						CurrentVenues.Add(v.K);
				}

				string failedVenues = "";

				foreach (int venueK in SelectedVenues)
				{
					if (!CurrentVenues.Contains(venueK))
					{
						Venue v = new Venue(venueK);
						bool changeStatus = false;
						if (v.PromoterK == 0)
						{
							CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") added venue - " + DateTime.Now.ToString() + " - " + v.K + " (" + v.Name + ") - ";
							v.PromoterK = CurrentPromoter.K;
							changeStatus = true;
						}
						else if (v.PromoterStatus.Equals(Venue.PromoterStatusEnum.Unconfirmed))
						{
							CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") added venue - " + DateTime.Now.ToString() + " - " + v.K + " (" + v.Name + ") - removed from promoter " + v.PromoterK + " (" + v.Promoter.Name + ") - ";
							v.PromoterK = CurrentPromoter.K;
							changeStatus = true;
						}
						else //venue owned by someone else!
						{
							CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") attempted to add venue - " + DateTime.Now.ToString() + " - " + v.K + " (" + v.Name + "), but it's already confirmed to promoter " + v.PromoterK + " (" + v.Promoter.Name + ")\n";

							failedVenues = (failedVenues.Length == 0 ? "" : ", ") + v.Name + " in " + v.Place.Name;
						}
						if (changeStatus)
						{
							bool foundVenueOwner = false;
							CurrentPromoter.AdminUsrs = null;
							foreach (Usr u in CurrentPromoter.AdminUsrs)
							{
								if (v.OwnerUsrK == u.K)
									foundVenueOwner = true;
							}
							if (foundVenueOwner || Usr.Current.IsAdmin)
							{
								v.PromoterStatus = Venue.PromoterStatusEnum.Confirmed;
								CurrentPromoter.AdminNote += "(status confirmed)\n";
							}
							else
							{
								v.PromoterStatus = Venue.PromoterStatusEnum.Unconfirmed;
								CurrentPromoter.AdminNote += "(status new)\n";
							}
						}
						v.Update();
						CurrentPromoter.Update();
					}
				}
				foreach (int venueK in CurrentVenues)
				{
					if (!SelectedVenues.Contains(venueK))
					{
						Venue v = new Venue(venueK);
						CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") removed venue - " + DateTime.Now.ToString() + " - " + v.K + " (" + v.Name + ")";
						v.PromoterStatus = Venue.PromoterStatusEnum.Unconfirmed;
						v.PromoterK = 0;
						v.Update();
						CurrentPromoter.Update();
					}
				}
				#endregion

				this.ViewState["CurrentPromoterK"] = CurrentPromoter.K;
				CurrentPromoter = new Promoter(CurrentPromoter.K);
				CurrentPromoter.FixQuestionsThreadUsrs();
				CurrentPromoter.UpdateModerators();

				Usr.Current.LegalTermsPromoter2 = true;
				Usr.Current.Update();


				if (failedBrands.Length > 0 || failedVenues.Length > 0)
				{
					//show error form...
					BrandErrorLabel.Text = failedBrands;
					VenueErrorLabel.Text = failedVenues;
					BrandErrorPanel.Visible = failedBrands.Length > 0;
					VenueErrorPanel.Visible = failedVenues.Length > 0;

					ChangePanel(PanelBrandVenueError);
				}
				else
				{
					if (IsEdit)
					{
						if (Usr.Current.IsAdmin)
							Response.Redirect(CurrentPromoter.Url());
						else
							ChangePanel(PanelEditDone);
					}
					else
					{
						if (!Usr.Current.IsAdmin)
						{
							Thread t = new Thread(CurrentPromoter.QuestionsThreadK);
							Response.Redirect(t.Url());
						}
						else
						{
							Response.Redirect(CurrentPromoter.Url());
						}
					}
				}

			}
		}
Ejemplo n.º 2
0
		public void InitialiseSkeletonAndAddPrimaryUser(Usr CurrentUsr, string CompanyNameUpdate, string ContactNameUpdate, string PhoneUpdate)
		{
			//update the promoter
			bool addToPromoter = true;
			foreach (Usr u in this.AdminUsrs)
			{
				if (u.K == CurrentUsr.K)
					addToPromoter = false;
			}

			if (addToPromoter)
			{
				PromoterUsr pu = new PromoterUsr();
				pu.PromoterK = this.K;
				pu.UsrK = CurrentUsr.K;
				pu.Update();
				this.AdminUsrs = null;
				if (this.PrimaryUsrK == 0)
				{
					this.PrimaryUsrK = CurrentUsr.K;
				}
			}

			if (this.LetterType.Equals(Promoter.LetterTypes.AutoVenue))
			{
				//conirm venues
				foreach (Venue v in this.AllVenues)
				{
					v.PromoterStatus = Venue.PromoterStatusEnum.Confirmed;
					v.Update();
				}
			}

			//	if (false) // When should be confirm party brands?
			//	{
			//		//conirm brands
			//		foreach (Brand b in CurrentPromoter.AllBrands)
			//		{
			//			b.PromoterStatus = Brand.PromoterStatusEnum.Confirmed;
			//			b.Update();
			//		}
			//	}

			if (CompanyNameUpdate.Length > 0)
				this.Name = Cambro.Web.Helpers.Strip(CompanyNameUpdate);

			if (ContactNameUpdate.Length > 0)
				this.ContactName = Cambro.Web.Helpers.Strip(ContactNameUpdate);

			if (PhoneUpdate.Length > 0)
				this.PhoneNumber = Cambro.Web.Helpers.Strip(PhoneUpdate);

			if (this.IsSkeleton)
			{
				this.IsSkeleton = false;
				this.DateTimeSignUp = DateTime.Now;
			}

			if (!this.OfferType.Equals(Promoter.OfferTypes.DoubleSlots))
			{
				this.OfferType = Promoter.OfferTypes.DoubleSlots;
				this.OfferExpireDateTime = DateTime.Now.AddDays(32);
			}

			this.Status = Promoter.StatusEnum.Active;
			this.SalesHold = false;
			this.SalesNextCall = DateTime.Today;

			if (this.QuestionsThreadK == 0)
				this.AddQuestionsThread(CurrentUsr, this.Name);

			this.Update();
			this.CreateUniqueUrlName();
			this.UpdateModerators();
		}