Helllo
I'm doing a theatre booking system for an assignment. I have got to the stage where I can
generate the seating plan from the database. The problem that I am having is that the seats are running in the wrong direction.
I have swapped my x's and y's but it seems to make no difference.
Can anyone see what I am getting mixed up please?
Thank you ... John:S
private void Seating(DataSet dsTickets)
{
Button[,] seatButton = new Button[30, 30];//multidimensional array
seatBox.Controls.Clear();
//dsTickets
int R = 30;
int S = 30;
for (int x = 0; x < R; x++)//loop for rows
{
for (int y = 0; y < S; y++)//loop for columns
{
string seatNumber = Convert.ToChar(x + 65).ToString() + (y + 1).ToString();
foreach (DataRow drTickets in dsTickets.Tables[0].Rows)// loop through rows / seats and check
{
//check if available
//
if (drTickets["SeatNumber"].ToString().TrimEnd() == seatNumber)// if the seat numbers in the database match the button I am about to create
{
seatButton[x, y] = new Button();//Create the Buttons
seatButton[x, y].Name = "seatButton" + seatNumber;//name and coordinates and set up number, number to show//name and coordinates and set up number, number to show
seatButton[x, y].Width = 15;//sizing
seatButton[x, y].Height = 15;//sizing
//seatButton[x, y].Left = seatButton[x, y].Left + seatButton[x, y].Width + (x * 15);
//seatButton[x, y].Top = seatButton[x, y].Top + seatButton[x, y].Top + 15 + (y * 15);//Centre the button
seatButton[x, y].Location = new Point(x * 15, y * 15);
seatButton[x, y].Text = " ";//declares text variable
seatButton[x, y].BackColor = Color.SlateGray;
seatButton[x, y].ForeColor = Color.AntiqueWhite;//set initial text colour to white
seatButton[x, y].Text = "A";//Set initial text A for available
seatBox.Controls.Add(seatButton[x, y]);//Add them to the panel
seatButton[x, y].Tag = drTickets;
seatButton[x, y].Click += new System.EventHandler(Button_Click);
if (drTickets["AvailableOrsold"].ToString().TrimEnd() == "S")
{
if (drTickets["TicketType"].ToString() == "A")
{
seatButton[x, y].BackColor = Color.Orange;
seatButton[x, y].ForeColor = Color.Black;
seatButton[x, y].Text = "S";
}
else if (drTickets["TicketType"].ToString() == "C")
{
seatButton[x, y].BackColor = Color.SpringGreen;
seatButton[x, y].ForeColor = Color.Black;
seatButton[x, y].Text = "S";
}
else if (drTickets["TicketType"].ToString() == "F")
{
seatButton[x, y].BackColor = Color.PaleGoldenrod;
seatButton[x, y].ForeColor = Color.Black;
seatButton[x, y].Text = "S";
}
seatBox.Controls.Add(seatButton[x, y]);//Add them to the panel
string toolTipText = Convert.ToChar(x + 65).ToString() + (x + 1).ToString();
ToolTip buttonTooltip = new ToolTip();
buttonTooltip.SetToolTip(seatButton[x, y], toolTipText);
}
}
}
}
}
}