//#region ReleaseFundsOptionsDropDownListSetup
		//public void ReleaseFundsOptionsDropDownListSetup()
		//{
		//    string releaseFundsOptionsJavascript = "this.options[this.selectedIndex].value == "
		//                                            + Convert.ToInt32(ReleaseFundsOptions.AssignExistingTransferK).ToString() + " ? document.getElementById('" + ReleaseFundsTransferKTextBox.UniqueID.Replace("$", "_") + "').style.display = '' : document.getElementById('" + ReleaseFundsTransferKTextBox.UniqueID.Replace("$", "_") + "').style.display = 'none';"
		//                                            + "this.options[this.selectedIndex].value == "
		//                                            + Convert.ToInt32(ReleaseFundsOptions.CreateReleaseTransfer).ToString() + " ? document.getElementById('" + TransferMethodsDropDownList.UniqueID.Replace("$", "_") + "').style.display = '' : document.getElementById('" + TransferMethodsDropDownList.UniqueID.Replace("$", "_") + "').style.display = 'none';";

		//    if (!this.IsPostBack)
		//    {
		//        ReleaseFundsOptionsDropDownList.Items.Clear();
		//        //ReleaseFundsOptionsDropDownList.Items.Add(new ListItem("<Release Funds Options>", "-1"));
		//        ReleaseFundsOptionsDropDownList.Items.Add(new ListItem(Utilities.CamelCaseToString(ReleaseFundsOptions.AssignExistingTransferK.ToString()), Convert.ToInt32(ReleaseFundsOptions.AssignExistingTransferK).ToString()));
		//        ReleaseFundsOptionsDropDownList.Items.Add(new ListItem(Utilities.CamelCaseToString(ReleaseFundsOptions.CreateReleaseTransfer.ToString()), Convert.ToInt32(ReleaseFundsOptions.CreateReleaseTransfer).ToString()));
		//        ReleaseFundsOptionsDropDownList.Attributes.Remove("onchange");
		//        ReleaseFundsOptionsDropDownList.Attributes.Add("onchange", "javascript:" + releaseFundsOptionsJavascript);
		//    }
		//    ReleaseFundsOptionsJavascriptLabel.Visible = true;
		//    ReleaseFundsOptionsJavascriptLabel.Text = "<script type=\"text/javascript\">" + releaseFundsOptionsJavascript.Replace("this.", "document.getElementById('" + ReleaseFundsOptionsDropDownList.UniqueID.Replace("$", "_") + "').") + "</script>";
		//}
		//#endregion

		//#region TransferTypesDropDownListSetup
		//public void TransferMethodsDropDownListSetup()
		//{
		//    this.TransferMethodsDropDownList.Items.Clear();
		//    this.TransferMethodsDropDownList.Items.Add(new ListItem(Utilities.CamelCaseToString(Transfer.Methods.BankTransfer.ToString()), Convert.ToInt32(Transfer.Methods.BankTransfer).ToString()));
		//    this.TransferMethodsDropDownList.Items.Add(new ListItem(Transfer.Methods.Cheque.ToString(), Convert.ToInt32(Transfer.Methods.Cheque).ToString()));
		//}
		//#endregion

		#region GetTicketPromoterEvents
		public void GetTicketPromoterEvents()
		{
			Query ticketPromoterEventFundsQuery = new Query();

			List<Q> QueryConditionList = new List<Q>();

			ticketPromoterEventFundsQuery.TableElement = new Join(TicketPromoterEvent.Columns.EventK, Event.Columns.K);
			ticketPromoterEventFundsQuery.OrderBy = new OrderBy(Event.Columns.DateTime, OrderBy.OrderDirection.Descending);

			if (this.uiPromotersAutoComplete.Value != null && !uiPromotersAutoComplete.Value.Equals(""))
				QueryConditionList.Add(new Q(TicketPromoterEvent.Columns.PromoterK, Convert.ToInt32(uiPromotersAutoComplete.Value)));
			if (this.StatusDropDownList.SelectedValue != "")
			{
				if (this.StatusDropDownList.SelectedValue == "Locked")
					QueryConditionList.Add(TicketPromoterEvent.LockedFundsQ);
				else if (this.StatusDropDownList.SelectedValue == "Funds Released")
					QueryConditionList.Add(TicketPromoterEvent.FundsReleasedQ);
				else if (this.StatusDropDownList.SelectedValue == "Funds Not Released")
					QueryConditionList.Add(TicketPromoterEvent.AwaitingFundsReleaseQ);
				else if (this.StatusDropDownList.SelectedValue == "Funds Released With Money Remaining")
				{
					QueryConditionList.Add(TicketPromoterEvent.FundsReleasedQ);
					ticketPromoterEventFundsQuery.TableElement = new Join(ticketPromoterEventFundsQuery.TableElement, Transfer.Columns.K, TicketPromoterEvent.Columns.FundsTransferK);
					QueryConditionList.Add(new Q(Transfer.Columns.IsFullyApplied, false));
				}
				else if (this.StatusDropDownList.SelectedValue == "No Plus Account")
				{
					QueryConditionList.Add(new Or(new Q(Promoter.Columns.EnableTickets, QueryOperator.IsNull, null),
												  new Q(Promoter.Columns.EnableTickets, false)));					
				}
			}
			if (this.SalesUsrDropDownList.SelectedValue != "")
				QueryConditionList.Add(new Q(Promoter.Columns.SalesUsrK, Convert.ToInt32(SalesUsrDropDownList.SelectedValue)));
			if (this.SalesUsrDropDownList.SelectedValue != "" || this.StatusDropDownList.SelectedValue == "No Plus Account")
				ticketPromoterEventFundsQuery.TableElement = new Join(ticketPromoterEventFundsQuery.TableElement, Promoter.Columns.K, TicketPromoterEvent.Columns.PromoterK);
			if (this.FromDateCal.Date != DateTime.MinValue)
				QueryConditionList.Add(new Q(Event.Columns.DateTime, QueryOperator.GreaterThanOrEqualTo, this.FromDateCal.Date));
			if (this.ToDateCal.Date != DateTime.MinValue)
				QueryConditionList.Add(new Q(Event.Columns.DateTime, QueryOperator.LessThanOrEqualTo, this.ToDateCal.Date));
            

			ticketPromoterEventFundsQuery.QueryCondition = new And(QueryConditionList.ToArray());      

            //ticketPromoterEventFundsQuery.Paging.RecordsPerPage = this.RecordsPerPage;
            //ticketPromoterEventFundsQuery.Paging.RequestedPage = this.PageNumber;
			//ticketPromoterEventFundsQuery.TopRecords = (this.PageNumber * this.RecordsPerPage) + 1;

			var ticketPromoterEventSet = new TicketPromoterEventSet(ticketPromoterEventFundsQuery);

			

			TicketPromoterEvent.CalculateTicketsAndRunFundLocksChecksAndReleaseFunds(ticketPromoterEventSet);
			
			ticketPromoterEventSet.Reset();
			List<TicketPromoterEvent> ticketPromoterEvents = ticketPromoterEventSet.ToList().FindAll(tpe => tpe.TotalFunds > 0 || this.ShowZeroMoneyTicketRunsCheckBox.Checked);

			if (this.StatusDropDownList.SelectedValue == "Funds Released With Money Remaining")
			{
				for (int i = ticketPromoterEvents.Count - 1; i >= 0; i--)
				{
					if (ticketPromoterEvents[i].FundsTransfer != null && ticketPromoterEvents[i].FundsTransfer.AmountRemaining() == 0)
						ticketPromoterEvents.RemoveAt(i);
				}
			}

			this.TicketPromoterEventFundsGridView.DataSource = ticketPromoterEvents; 
			this.TicketPromoterEventFundsGridView.DataBind();

			TotalsP.Visible = ticketPromoterEvents.Count > 0;
			if (ticketPromoterEvents.Count > 0)
			{
				decimal totalFunds = 0;
				decimal totalBookingFees = 0;
				int totalTickets = 0;
				int totalRefundTickets = 0;
				foreach (TicketPromoterEvent tpe in ticketPromoterEvents)
				{
					totalFunds += tpe.TotalFunds;
                    totalBookingFees += tpe.TotalBookingFees;
					totalTickets += tpe.SoldTickets;
					totalRefundTickets += tpe.CancelledTickets;
				}
				this.TotalFundsLabel.Text = totalFunds.ToString("c");
                this.TotalBookingFeesLabel.Text = totalBookingFees.ToString("c");
				this.TotalTicketsLabel.Text = totalTickets.ToString() + (totalRefundTickets > 0 ? " (" + totalRefundTickets.ToString() + ")" : "");
			}

			//this.SelectAllTicketFundsLinkButton.Enabled = !FundsSelection.Equals(FundsSelectionEnum.All);
			//this.SelectAwaitingFundsReleaseLinkButton.Enabled = !FundsSelection.Equals(FundsSelectionEnum.AwaitingFundsRelease);
			//this.SelectLockedFundsLinkButton.Enabled = !FundsSelection.Equals(FundsSelectionEnum.LockedFunds);

			//H1Title.InnerHtml = Utilities.CamelCaseToString(FundsSelection.ToString());

			//this.NextPageLinkButton.Enabled = ticketPromoterEventSet.Paging.ShowNextPageLink;
			//this.PrevPageLinkButton.Enabled = ticketPromoterEventSet.Paging.ShowPrevPageLink;
		}