views:

66

answers:

2

Hello Friends,

I'm developing a project in ASP.Net(c#). My project definition is Online Travels Booking System.

In my project there is a seating selection module. When I select a particular seat for a particular route using a check box, I create a session for the selected seat so that if I ever choose the same route, the selected seats should not displayed.

The problem I am facing is when I select a different route, I get a selected seat which I hadn't not selected previously.

This is urgent. Can any one help me to solve this problem?

Thanks.

+1  A: 

You need to bind the seat occupancy to each route - you can use or define a special data-type-structure to hold this info. You can create your own struct or array which holds the information of each seat occupied by each route. You can store this data-structure into a session and use it as and when you need it. You will need to update the data-structure in session whenever a new seat is occupied or a pre-occupied seat is released.

You can also use the database to store the information which I guess would be a better option.

this. __curious_geek
+1  A: 

A dictionary might work well for your application
http://msdn.microsoft.com/en-us/library/xfhwa508.aspx

In psuedocode:

//  Read the selected seats and store them
OnCheckChanged( ... )
{
   Dictionary<Route,Seat> reservedSeats = Session["reservedSeats"] as Dictionary<Route,Seat>;
   reservedSeats[Current Route] = Selected Seat;
   Session["reservedSeats"] = reservedSeats;
}

//  Show the selected seats when they come to a specific route
OnLoad(...)
{
   Dictionary<Route,Seat> reservedSeats = Session["reservedSeats"] as Dictionary<Route,Seat>;
   SetSeatSelection( reservedSeats[Current Route] );
}

Basically, you can store a dictionary object in the session with one entry for each route. Each session is particular to a specific user so this should suffice.

Although, you may want to just store it in a database if you want the selection to be remembered between visits etc.

TJB