Aaron Soggi

Aaron Soggi

  • NA
  • 7
  • 609

I want to create a simple seat reservation for my application

Mar 21 2021 12:10 AM
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 "availableSeat" it will turn green. If the user attempts to select another seat with the status "availableSeat" i want the application to throw an error message. "please unmatch your current seat, before selecting another" etc. Below is the codee that 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 user clicks on a picture box that is set as "seatTaken", i simply just want it to change back to "availableSeat". Secondly if the user selects a seat which is set as availablethey still receive an error message which is not what i want.
 
All picture boxes are part of the same click event. Can anyone help? i'd really really appreciate it
  1. Bitmap availableSeat = Properties.Resources.availableSeatt;    
  2. Bitmap seatTaken = Properties.Resources.provisional;    
  3.   
  4. private void Button_Click(object sender, EventArgs e)    
  5. {    
  6.     var pb = (PictureBox)sender;    
  7.          
  8.     if (n == 1 || pb.Image == seatTaken && n ==1)    
  9.     {    
  10.         MessageBox.Show("Please unmatch seat");    
  11.     }    
  12.   
  13.     if (pb.Image == availableSeat)    
  14.     {    
  15.                
  16.         pb.Image = seatTaken;    
  17.         n = 1;    
  18.              
  19.     }    
  20.     else    
  21.     {    
  22.         pb.Image = availableSeat;    
  23.         n = 0;    
  24.     }    
  25.          
  26.     selectedSeatNo = pb.Tag.ToString();    
  27. }  

Answers (1)