I want to create a simple seat reservation system where the picture box will change to another image once the user has clicked the picture box. If the image is set as "available" it will turn green. If the user attempts to select another seat with the status "available" i want the application to throw an error message. "please unmatch your current seat, before selecting another" etc. Below is what i have so far, I've been trying to do this for a while now and I'm honestly lost, the annoying thing is it seems like its a simple fix. I was thinking of making a separate class and monitoring the seat status that way, but i wouldn't even know where to start.
The problem i have is the user is still given an error message even if the image is set as seatTaken, also if the user selects a seat which is set as available available they still receive an error message which is not what i want.
All picture boxes are part of the same click event aswell. Can anyone help? i'd really appreciate it
The problem i have is the user is still given an error message even if the image is set as seatTaken, also if the user selects a seat which is set as available available they still receive an error message which is not what i want.
All picture boxes are part of the same click event aswell. Can anyone help? i'd really appreciate it
C#:
Bitmap availableSeat = Properties.Resources.availableSeatt;
Bitmap seatTaken = Properties.Resources.provisional;
private void Button_Click(object sender, EventArgs e)
{
var pb = (PictureBox)sender;
if (n == 1 || pb.Image == seatTaken && n ==1)
{
MessageBox.Show("Please unmatch seat");
}
if (pb.Image == availableSeat)
{
pb.Image = seatTaken;
n = 1;
}
else
{
pb.Image = availableSeat;
n = 0;
}
selectedSeatNo = pb.Tag.ToString();
}
Last edited: