public void createSeats() { for (int i = 0; i < 3; i++) { for (int j = 0; j < 5; j++) { SeatButton b = new SeatButton(false, i + j * 6 + 1, new Point((i * (tabPage2.Width - 10)) / 6, 8 + (((j * tabPage2.Height) - 10) / 7))); b.Name = (i + j * 6 + 1).ToString(); b.Click += new EventHandler(button_Click); b.Text = b.Name; ToolTip tt = new ToolTip(); tt.SetToolTip(b, "Seat #" + b.Name); tabPage2.Controls.Add(b); seatButtons[i + j * 6] = b; } } for (int i = 3; i < 6; i++) { for (int j = 0; j < 5; j++) { SeatButton b = new SeatButton(false, i + j * 6 + 1, new Point(((210 + i * (tabPage2.Width - 10)) / 6), 8 + (((j * tabPage2.Height) - 10) / 7))); b.Name = (i + j * 6 + 1).ToString(); b.Click += new EventHandler(button_Click); b.Text = b.Name; ToolTip tt = new ToolTip(); tt.SetToolTip(b, "Seat #" + b.Name); tabPage2.Controls.Add(b); seatButtons[i + j * 6] = b; } } }
protected void button_Click(object sender, EventArgs e) { SeatButton b = sender as SeatButton; if (!b.occupied) { users[users.Count - 1].selectSeat(b.seatNumber + 1); b.BackColor = Color.LightBlue; b.occupySeat(users[users.Count - 1]); b.occupied = true; addPassengers(users[users.Count - 1]); } }