using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Betfair.Gamex.API.Entities;
using Betfair.Gamex.API;
using System.Text;

namespace Betfair.Gamex.API.UberClient.Controls
{
	/// <summary>
	/// AccountStatement shows the entire paginated account statement
	/// </summary>
	public class AccountStatement : System.Windows.Forms.Form
    {
		private System.Windows.Forms.Label lblAvailableToBet;
		private System.Windows.Forms.Label lblGamesBalance;
		private System.Windows.Forms.Label lblTransferIn;
		private System.Windows.Forms.Label lblTransferOut;
		private System.Windows.Forms.Label lblCurrency;
		private System.Windows.Forms.Label lblCurrentExposure;
		private System.Windows.Forms.Label lblExposureLimit;
        private System.Windows.Forms.Label lblRetainedCommission;
        private System.Windows.Forms.Panel pnlAccountItems;
		private System.Windows.Forms.Button btnPrevious;
		private System.Windows.Forms.Button btnNext;
        private Adapter m_ApiAdapter;
		private accountStatement m_Statement;

        public AccountStatement(Adapter adapter)
		{
			InitializeComponent();
			m_ApiAdapter = adapter;
			GetAccountDetails();
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            System.Windows.Forms.Label label1;
            System.Windows.Forms.Label label2;
            System.Windows.Forms.Label label3;
            System.Windows.Forms.Label label4;
            System.Windows.Forms.Label label5;
            System.Windows.Forms.Label label6;
            System.Windows.Forms.Label label8;
            System.Windows.Forms.Label label9;
            System.Windows.Forms.GroupBox groupBox1;
            System.Windows.Forms.GroupBox groupBox2;
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AccountStatement));
            System.Windows.Forms.Label label14;
            System.Windows.Forms.Label label10;
            System.Windows.Forms.Label label13;
            System.Windows.Forms.Label label12;
            System.Windows.Forms.Label label15;
            System.Windows.Forms.Label label11;
            this.lblTransferOut = new System.Windows.Forms.Label();
            this.lblExposureLimit = new System.Windows.Forms.Label();
            this.lblCurrentExposure = new System.Windows.Forms.Label();
            this.lblTransferIn = new System.Windows.Forms.Label();
            this.lblGamesBalance = new System.Windows.Forms.Label();
            this.lblCurrency = new System.Windows.Forms.Label();
            this.lblRetainedCommission = new System.Windows.Forms.Label();
            this.lblAvailableToBet = new System.Windows.Forms.Label();
            this.pnlAccountItems = new System.Windows.Forms.Panel();
            this.btnPrevious = new System.Windows.Forms.Button();
            this.btnNext = new System.Windows.Forms.Button();
            label1 = new System.Windows.Forms.Label();
            label2 = new System.Windows.Forms.Label();
            label3 = new System.Windows.Forms.Label();
            label4 = new System.Windows.Forms.Label();
            label5 = new System.Windows.Forms.Label();
            label6 = new System.Windows.Forms.Label();
            label8 = new System.Windows.Forms.Label();
            label9 = new System.Windows.Forms.Label();
            groupBox1 = new System.Windows.Forms.GroupBox();
            groupBox2 = new System.Windows.Forms.GroupBox();
            label14 = new System.Windows.Forms.Label();
            label10 = new System.Windows.Forms.Label();
            label13 = new System.Windows.Forms.Label();
            label12 = new System.Windows.Forms.Label();
            label15 = new System.Windows.Forms.Label();
            label11 = new System.Windows.Forms.Label();
            groupBox1.SuspendLayout();
            groupBox2.SuspendLayout();
            this.SuspendLayout();
            // 
            // label1
            // 
            label1.BackColor = System.Drawing.Color.Transparent;
            label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label1.Location = new System.Drawing.Point(13, 27);
            label1.Name = "label1";
            label1.Size = new System.Drawing.Size(136, 23);
            label1.TabIndex = 0;
            label1.Text = "Available To Bet";
            label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label2
            // 
            label2.BackColor = System.Drawing.Color.Transparent;
            label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label2.Location = new System.Drawing.Point(13, 108);
            label2.Name = "label2";
            label2.Size = new System.Drawing.Size(136, 23);
            label2.TabIndex = 1;
            label2.Text = "Available To Transfer Out";
            label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label3
            // 
            label3.BackColor = System.Drawing.Color.Transparent;
            label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label3.Location = new System.Drawing.Point(13, 54);
            label3.Name = "label3";
            label3.Size = new System.Drawing.Size(136, 23);
            label3.TabIndex = 2;
            label3.Text = "Betfair Games Balance";
            label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label4
            // 
            label4.BackColor = System.Drawing.Color.Transparent;
            label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label4.Location = new System.Drawing.Point(13, 135);
            label4.Name = "label4";
            label4.Size = new System.Drawing.Size(136, 23);
            label4.TabIndex = 3;
            label4.Text = "Currency";
            label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label5
            // 
            label5.BackColor = System.Drawing.Color.Transparent;
            label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label5.Location = new System.Drawing.Point(13, 162);
            label5.Name = "label5";
            label5.Size = new System.Drawing.Size(136, 23);
            label5.TabIndex = 4;
            label5.Text = "Current Exposure";
            label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label6
            // 
            label6.BackColor = System.Drawing.Color.Transparent;
            label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label6.Location = new System.Drawing.Point(13, 189);
            label6.Name = "label6";
            label6.Size = new System.Drawing.Size(136, 23);
            label6.TabIndex = 5;
            label6.Text = "Exposure Limit";
            label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label8
            // 
            label8.BackColor = System.Drawing.Color.Transparent;
            label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label8.Location = new System.Drawing.Point(13, 216);
            label8.Name = "label8";
            label8.Size = new System.Drawing.Size(136, 23);
            label8.TabIndex = 7;
            label8.Text = "Retained Commission";
            label8.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label9
            // 
            label9.BackColor = System.Drawing.Color.Transparent;
            label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label9.Location = new System.Drawing.Point(13, 81);
            label9.Name = "label9";
            label9.Size = new System.Drawing.Size(136, 23);
            label9.TabIndex = 8;
            label9.Text = "Available To Transfer In";
            label9.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // groupBox1
            // 
            groupBox1.BackColor = System.Drawing.Color.Transparent;
            groupBox1.Controls.Add(this.lblTransferOut);
            groupBox1.Controls.Add(this.lblExposureLimit);
            groupBox1.Controls.Add(this.lblCurrentExposure);
            groupBox1.Controls.Add(label1);
            groupBox1.Controls.Add(label6);
            groupBox1.Controls.Add(label2);
            groupBox1.Controls.Add(this.lblTransferIn);
            groupBox1.Controls.Add(this.lblGamesBalance);
            groupBox1.Controls.Add(this.lblCurrency);
            groupBox1.Controls.Add(label4);
            groupBox1.Controls.Add(this.lblRetainedCommission);
            groupBox1.Controls.Add(label9);
            groupBox1.Controls.Add(label3);
            groupBox1.Controls.Add(label8);
            groupBox1.Controls.Add(label5);
            groupBox1.Controls.Add(this.lblAvailableToBet);
            groupBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            groupBox1.Location = new System.Drawing.Point(8, 8);
            groupBox1.Name = "groupBox1";
            groupBox1.Size = new System.Drawing.Size(288, 256);
            groupBox1.TabIndex = 18;
            groupBox1.TabStop = false;
            groupBox1.Text = "Summary";
            // 
            // lblTransferOut
            // 
            this.lblTransferOut.BackColor = System.Drawing.SystemColors.Window;
            this.lblTransferOut.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.lblTransferOut.Location = new System.Drawing.Point(168, 108);
            this.lblTransferOut.Name = "lblTransferOut";
            this.lblTransferOut.Size = new System.Drawing.Size(104, 23);
            this.lblTransferOut.TabIndex = 12;
            this.lblTransferOut.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lblExposureLimit
            // 
            this.lblExposureLimit.BackColor = System.Drawing.SystemColors.Window;
            this.lblExposureLimit.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.lblExposureLimit.Location = new System.Drawing.Point(168, 189);
            this.lblExposureLimit.Name = "lblExposureLimit";
            this.lblExposureLimit.Size = new System.Drawing.Size(104, 23);
            this.lblExposureLimit.TabIndex = 15;
            this.lblExposureLimit.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lblCurrentExposure
            // 
            this.lblCurrentExposure.BackColor = System.Drawing.SystemColors.Window;
            this.lblCurrentExposure.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.lblCurrentExposure.Location = new System.Drawing.Point(168, 162);
            this.lblCurrentExposure.Name = "lblCurrentExposure";
            this.lblCurrentExposure.Size = new System.Drawing.Size(104, 23);
            this.lblCurrentExposure.TabIndex = 14;
            this.lblCurrentExposure.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lblTransferIn
            // 
            this.lblTransferIn.BackColor = System.Drawing.SystemColors.Window;
            this.lblTransferIn.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.lblTransferIn.Location = new System.Drawing.Point(168, 81);
            this.lblTransferIn.Name = "lblTransferIn";
            this.lblTransferIn.Size = new System.Drawing.Size(104, 23);
            this.lblTransferIn.TabIndex = 11;
            this.lblTransferIn.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lblGamesBalance
            // 
            this.lblGamesBalance.BackColor = System.Drawing.SystemColors.Window;
            this.lblGamesBalance.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.lblGamesBalance.Location = new System.Drawing.Point(168, 54);
            this.lblGamesBalance.Name = "lblGamesBalance";
            this.lblGamesBalance.Size = new System.Drawing.Size(104, 23);
            this.lblGamesBalance.TabIndex = 10;
            this.lblGamesBalance.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lblCurrency
            // 
            this.lblCurrency.BackColor = System.Drawing.SystemColors.Window;
            this.lblCurrency.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.lblCurrency.Location = new System.Drawing.Point(168, 135);
            this.lblCurrency.Name = "lblCurrency";
            this.lblCurrency.Size = new System.Drawing.Size(104, 23);
            this.lblCurrency.TabIndex = 13;
            this.lblCurrency.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lblRetainedCommission
            // 
            this.lblRetainedCommission.BackColor = System.Drawing.SystemColors.Window;
            this.lblRetainedCommission.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.lblRetainedCommission.Location = new System.Drawing.Point(168, 216);
            this.lblRetainedCommission.Name = "lblRetainedCommission";
            this.lblRetainedCommission.Size = new System.Drawing.Size(104, 23);
            this.lblRetainedCommission.TabIndex = 16;
            this.lblRetainedCommission.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lblAvailableToBet
            // 
            this.lblAvailableToBet.BackColor = System.Drawing.SystemColors.Window;
            this.lblAvailableToBet.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.lblAvailableToBet.Location = new System.Drawing.Point(168, 27);
            this.lblAvailableToBet.Name = "lblAvailableToBet";
            this.lblAvailableToBet.Size = new System.Drawing.Size(104, 23);
            this.lblAvailableToBet.TabIndex = 9;
            this.lblAvailableToBet.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // groupBox2
            // 
            groupBox2.BackColor = System.Drawing.Color.Transparent;
            groupBox2.Controls.Add(this.pnlAccountItems);
            groupBox2.Controls.Add(this.btnPrevious);
            groupBox2.Controls.Add(this.btnNext);
            groupBox2.Controls.Add(label14);
            groupBox2.Controls.Add(label10);
            groupBox2.Controls.Add(label13);
            groupBox2.Controls.Add(label12);
            groupBox2.Controls.Add(label15);
            groupBox2.Controls.Add(label11);
            groupBox2.Location = new System.Drawing.Point(304, 8);
            groupBox2.Name = "groupBox2";
            groupBox2.Size = new System.Drawing.Size(504, 256);
            groupBox2.TabIndex = 19;
            groupBox2.TabStop = false;
            groupBox2.Text = "Statement";
            // 
            // pnlAccountItems
            // 
            this.pnlAccountItems.AutoScroll = true;
            this.pnlAccountItems.Location = new System.Drawing.Point(8, 40);
            this.pnlAccountItems.Name = "pnlAccountItems";
            this.pnlAccountItems.Size = new System.Drawing.Size(488, 176);
            this.pnlAccountItems.TabIndex = 2;
            // 
            // btnPrevious
            // 
            this.btnPrevious.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnPrevious.BackgroundImage")));
            this.btnPrevious.Cursor = System.Windows.Forms.Cursors.Hand;
            this.btnPrevious.Location = new System.Drawing.Point(216, 224);
            this.btnPrevious.Name = "btnPrevious";
            this.btnPrevious.Size = new System.Drawing.Size(25, 24);
            this.btnPrevious.TabIndex = 1;
            this.btnPrevious.Click += new System.EventHandler(this.btnPrevious_Click);
            // 
            // btnNext
            // 
            this.btnNext.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnNext.BackgroundImage")));
            this.btnNext.Cursor = System.Windows.Forms.Cursors.Hand;
            this.btnNext.Location = new System.Drawing.Point(248, 224);
            this.btnNext.Name = "btnNext";
            this.btnNext.Size = new System.Drawing.Size(24, 24);
            this.btnNext.TabIndex = 0;
            this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
            // 
            // label14
            // 
            label14.BackColor = System.Drawing.Color.Transparent;
            label14.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            label14.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label14.Location = new System.Drawing.Point(369, 16);
            label14.Name = "label14";
            label14.Size = new System.Drawing.Size(56, 23);
            label14.TabIndex = 5;
            label14.Text = "Amount";
            label14.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // label10
            // 
            label10.BackColor = System.Drawing.Color.Transparent;
            label10.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label10.Location = new System.Drawing.Point(8, 16);
            label10.Name = "label10";
            label10.Size = new System.Drawing.Size(64, 23);
            label10.TabIndex = 1;
            label10.Text = "Type";
            label10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // label13
            // 
            label13.BackColor = System.Drawing.Color.Transparent;
            label13.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            label13.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label13.Location = new System.Drawing.Point(205, 16);
            label13.Name = "label13";
            label13.Size = new System.Drawing.Size(165, 23);
            label13.TabIndex = 4;
            label13.Text = "Details";
            label13.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // label12
            // 
            label12.BackColor = System.Drawing.Color.Transparent;
            label12.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label12.Location = new System.Drawing.Point(134, 16);
            label12.Name = "label12";
            label12.Size = new System.Drawing.Size(72, 23);
            label12.TabIndex = 3;
            label12.Text = "Settled";
            label12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // label15
            // 
            label15.BackColor = System.Drawing.Color.Transparent;
            label15.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            label15.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label15.Location = new System.Drawing.Point(424, 16);
            label15.Name = "label15";
            label15.Size = new System.Drawing.Size(56, 23);
            label15.TabIndex = 6;
            label15.Text = "Balance";
            label15.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // label11
            // 
            label11.BackColor = System.Drawing.Color.Transparent;
            label11.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            label11.Location = new System.Drawing.Point(71, 16);
            label11.Name = "label11";
            label11.Size = new System.Drawing.Size(64, 23);
            label11.TabIndex = 2;
            label11.Text = "Placed";
            label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // AccountStatement
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
            this.ClientSize = new System.Drawing.Size(818, 276);
            this.Controls.Add(groupBox2);
            this.Controls.Add(groupBox1);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "AccountStatement";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Account Statement";
            groupBox1.ResumeLayout(false);
            groupBox2.ResumeLayout(false);
            this.ResumeLayout(false);

		}
		#endregion

		private void GetAccountDetails()
		{
			accountSnapshot gamesAccount = m_ApiAdapter.GetAccountSnapshot();
			betfairAvailableBalance betfairBalance = m_ApiAdapter.GetAccountBetfairSnapshot();
			m_Statement = m_ApiAdapter.GetAccountStatement();

			DisplayAccountSummary(gamesAccount, betfairBalance);
			DisplayAccountStatement();
		}

		private void DisplayAccountSummary(accountSnapshot gamesAccount, betfairAvailableBalance betfairBalance)
		{
			lblAvailableToBet.Text = gamesAccount.availableToBetBalance.ToString("0.00");
			lblGamesBalance.Text = gamesAccount.betfairGamesBalance.ToString("0.00");
			lblTransferIn.Text = betfairBalance.availableToTransferIn.ToString("0.00");
			lblTransferOut.Text = gamesAccount.availableToTransferOut.ToString("0.00");
			lblCurrency.Text = gamesAccount.currency;
			lblCurrentExposure.Text = gamesAccount.currentExposure.ToString("0.00");
			lblExposureLimit.Text = gamesAccount.exposureLimit.ToString("0.00");
			lblRetainedCommission.Text = gamesAccount.retainedCommission.ToString("0.00");
		}

		private void DisplayAccountStatement()
		{
			// Clear any items which are visible
			pnlAccountItems.Controls.Clear();

			// Decide which buttons should be visible
			btnPrevious.Visible = (m_Statement.previousPage != null);
			btnNext.Visible = (m_Statement.nextPage != null);

			// Create an item for each line in the statement
			foreach (accountStatementItem statementItem in m_Statement.item)
			{
				// Create the item
				AccountItem acItem = new AccountItem(GetAccountItemType(statementItem) + " " + statementItem.refNo, statementItem.placedDate, statementItem.settledDate, GetDetails(statementItem), statementItem.amount, statementItem.balance);

				// Set the item location 
				acItem.Location = new Point(0, pnlAccountItems.Controls.Count * acItem.Height);

				// Add the item to the panel
				pnlAccountItems.Controls.Add(acItem);
			}
		}

        private string GetAccountItemType(accountStatementItem statementItem)
		{
			if(statementItem.accountStatementDescription.accountStatementBetDescription != null)
			{
				return "Bet";
			}
			else if(statementItem.accountStatementDescription.accountStatementCommissionDescription != null)
			{
				return "Commission";
			}
			else if(statementItem.accountStatementDescription.accountStatementGameStateDescription != null)
			{
				return "Void";
			}
			else
			{
				return "Transfer";
			}
		}

        private string GetDetails(accountStatementItem statementItem)
		{
			StringBuilder strBuilder = new StringBuilder();

			if(statementItem.accountStatementDescription.accountStatementBetDescription != null)
			{
				accountStatementBetDescription betDesc = statementItem.accountStatementDescription.accountStatementBetDescription;
				strBuilder.Append(betDesc.selectionReference.marketReference.channelName + " ");
				strBuilder.Append(betDesc.selectionReference.marketReference.marketId);
				strBuilder.Append(Environment.NewLine);
				strBuilder.Append(betDesc.bidType + " ");
				strBuilder.Append(betDesc.winLose + " ");
				strBuilder.Append(betDesc.size);
				strBuilder.Append("@");
				strBuilder.Append(betDesc.averagePrice);
			}
			else if(statementItem.accountStatementDescription.accountStatementCommissionDescription != null)
			{
				return "Commission"; 
			}
			else if(statementItem.accountStatementDescription.accountStatementGameStateDescription != null)
			{
				return "Void";
			}
			else
			{
				return "Transfer";
			}

			return strBuilder.ToString();
		}

		/// <summary>
		/// Display the next page of the statement
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void btnNext_Click(object sender, System.EventArgs e)
		{
			m_Statement =  m_ApiAdapter.GetAccountStatement(m_Statement.nextPage.resource.href);
			DisplayAccountStatement();
		}

		/// <summary>
		/// Display the previous page of the statement
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void btnPrevious_Click(object sender, System.EventArgs e)
		{
			m_Statement =  m_ApiAdapter.GetAccountStatement(m_Statement.previousPage.resource.href);
			DisplayAccountStatement();
		}
	}
}
