Click here to Skip to main content
13,301,591 members (94,906 online)
Click here to Skip to main content
Add your own
alternative version

Stats

41.1K views
4.6K downloads
17 bookmarked
Posted 8 May 2014

Ticket Booking

, 8 May 2014
Rate this:
Please Sign up or sign in to vote.
Online Ticket Booking Application that allows a user to view booked seats

Ticket Booking

Introduction

Online Ticket Booking process is one of the major aspects of the modern world.

This is a simple ticket booking system I have developed for .NET programmer who wants to see a booked ticket information. Using this system, you will learn how to make a simple ticket book application which allows the user to view booked and available seat for the particular user.

Background

The basic idea before developing the script is to allow the user to check information about seat availability.

Using the Code

Create Database (TicketBooking)

Create table in SQL Server:

CREATE TABLE  BookedTickets
(
    id int IDENTITY (1,1) NOT NULL,
    SeatNo nchar (10) NULL,
    Status bit NULL
); 

Insert some data into the BookedTicket table.

INSERT INTO BookedTickets(SeatNo,Status) VALUES ('A13','True');
INSERT INTO BookedTickets(SeatNo,Status) VALUES ('A14','True');  

Code

Now select Seat Number from the BookedTickets table:

string query = @"SELECT SeatNo FROM BookedTickets WHERE (Status='True')";
SqlDataAdapter  adapter = new SqlDataAdapter(query, con);
DataTable dt = new DataTable();
adapter.Fill(dt);
for(int i = 0; i < dt.Rows.Count; i++)
{
       getSeat = getSeat + "" + dt.Rows[i][0].ToString().Trim() + " ";
}

Check whether seat is booked / available and generate seat:

protected string checkSeat(string sitting)
{
  try
  {
    string [] words = getSeat.Split(' ');
    foreach (string word in words)
    {
     try
     {
      if (sitting.Equals(word))
      {
        chair = "<img id='" + sitting + "'
        alt='Booked' src='images/chair/R_chair.gif'/>";
        return chair;
      }
      else
          chair = "<img id='" + sitting + "'
          alt='Unbooked' onclick=\"seat('" + sitting +"')\"
          src='images/chair/G_chair.gif' style='cursor:pointer;'/>";
      }
      catch (ArgumentOutOfRangeException) { }
     }
   }
   catch (NullReferenceException)
   {
      chair = "<img id='" + sitting + "' alt='Unbooked'
      onclick=\"seat('" + sitting + "')\"
      src='images/chair/G_chair.gif' style='cursor:pointer;'/>";
   }
    return chair;
 }
Andan H M

Andan H M
M Tech (CSE)
Amrita School of Engineering,Bangalore
IndiaAndan H M (INDIA)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Andan HM
Software Developer Tiger Innovations
India India
No Biography provided

You may also be interested in...

Comments and Discussions

 
Questionwhen i clicked on project it shows error Pin
Member 1342623023-Sep-17 21:30
memberMember 1342623023-Sep-17 21:30 
QuestionI need help please Pin
RollaDes5-Sep-17 22:23
memberRollaDes5-Sep-17 22:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171207.1 | Last Updated 8 May 2014
Article Copyright 2014 by Andan HM
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid