Resolved Creating a seat reservation feature on windows forms.

sock1992

Well-known member
Joined
May 20, 2020
Messages
99
Programming Experience
Beginner
I'm making a coach booking system and I'm at the final stage where the user has to select a seat before inserting the data within a table.

When the user selects one of the picture boxes it'll turn green, and that specific seat Id will be stored within the Booking table.

If another customer logs in and wants to place a booking the seats that have already been selected should be highlighted red.

I was thinking of creating another table called "seats" to represent the individual seats on the UI (see below).


1615826879352.png
1615826896171.png


What I'm then trying to figure out is how to link each of those icons to a seat Id. Is there an easier way of doing this? Any help would be appreciated :)
 
Last edited:

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
5,239
Location
Chesapeake, VA
Programming Experience
10+

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
5,239
Location
Chesapeake, VA
Programming Experience
10+
Show us your updated schema. From what I recall from the other threads, there was enough information is the schema you had previously shown along with the tweaks that had been suggested that there is no real need for yet another table just to keep track of seat vacancies (unless there is a serious performance issue with determine occupied seats due to the required JOIN operations being too complex).
 

sock1992

Well-known member
Joined
May 20, 2020
Messages
99
Programming Experience
Beginner
Show us your updated schema. From what I recall from the other threads, there was enough information is the schema you had previously shown along with the tweaks that had been suggested that there is no real need for yet another table just to keep track of seat vacancies (unless there is a serious performance issue with determine occupied seats due to the required JOIN operations being too complex).
Okay so below are the updated tables from before:

1615842357778.png
1615842388599.png
1615842405012.png

1615842781979.png


What i would like to do is, when one of the seats are selected from the UI, this will be saved in the bookings table once confirmed. At the moment i have all the data i need to insert the data into the booking table except for the seat number.

That's why i was asking if there was anyway to have each of the icons represent a number from 1-28. Then when the user control is loaded depending on which schedule is chosen, i can iterate through the picture Boxes in a foreach loop and check their tag to determine the colour of the seats, if that makes sense.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
5,239
Location
Chesapeake, VA
Programming Experience
10+
Is every coach the same layout and number of seats? Or do you have different kinds of coaches in your fleet? Some with more seats. Some with less seats. Some with extra space for people with disabilities.

Will you ever have to mark a seat for a particular coach as out of commission?
 

sock1992

Well-known member
Joined
May 20, 2020
Messages
99
Programming Experience
Beginner
The system will be pretty simple, there are two types of coaches, single decker and double decker. Double decker will have more seats. For this i was thinking of creating another User control - and then displaying this within a panel in the User control above depending on what schedule is chosen.
 
Last edited:

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
5,239
Location
Chesapeake, VA
Programming Experience
10+
Personally, I think that your seatNo column on Booking table from post #5 is sufficient to let you derive your seat occupancy chart.
 

sock1992

Well-known member
Joined
May 20, 2020
Messages
99
Programming Experience
Beginner
Yeah that is true. Just got to figure out how to set the seat Number once one of the icons are selected.

Edit: I could do this by calling Name of the control right? when the icon is selected i could obtain the Name and then assign that to the seatNo?
 
Last edited:

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
5,239
Location
Chesapeake, VA
Programming Experience
10+
You can assign a seat number in the Tag property of each instance of the control you use to represent a seat.

I recall when I did a project similar to this back in my CS programming class, we could write a console program, and it was a simple matter of the seat number being the row number * number of seats per row + the seat number on that row. I opted to use the Borland Graphics library and draw a custom widget for each seat. In my widget's data structure I stashed seat number along with the pixel positions on the screen.

If you decide to use a vanilla Button, or if you decide to roll your own UserControl to render that seat, you will have that property available to you. Should you decide to go with the latter choice, you can even add your own property that is better named, and likely better typed.
 
Top Bottom