182
ONLINE BUS RESERVATION SYSTEM Application of ASP.NET Bikramjit Banerjee CSeT, 2012

Bus Reservation Srs

Embed Size (px)

Citation preview

Page 1: Bus Reservation Srs

Application of ASP.NET

Bikramjit Banerjee

CSeT, 2012

Page 2: Bus Reservation Srs

In bus reservation system there has been a collection of buses, agent who are

booking tickets for customer’s journey which give bus number and departure

time of the bus. According to its name it manages the details of all agent,

tickets, rental details, and timing details and so on. It also manages the updating

of the objects.In the tour detail there is information about bus, who has been

taking customers at their destination, it also contain the detailed information

about the customer, who has been taken from which bus and at what are the

number of members he or she is taking his/her journey.This section also contain

the details of booking time of the seat(s) or collecting time of the tickets, this

section also contain the booking date and the name of agent which is optional,

by which the customer can reserve the seats for his journey In Bus no category

it contains the details of buses which are old/new. New buses are added with the

details with bus no, from city to the city, type of the bus, rent of a single seat, if

the bus has sleeper than the cost of sleeper, if the cabin has the facility for

sitting than the cost of cabin seats, tour timings of the new bus has also been

stored. How many buses are currently given and available in office?In seats

specification, it gives the list of given issued and currently available seats and

contain the information about seats like sleeper, cabin etc.The main objective of

this project is to provide the better work efficiency, security, accuracy,

reliability, feasibility. The error occurred could be reduced to nil and working

conditions can be improved.

Page 3: Bus Reservation Srs

I take this opportunity to convey my sincere gratitude to My Project Guide Ms. Pallabi Chakraborty of CSeT,Kolkata, for not only suggesting me the Project but also for his constant guidance, inspiration, motivation, patience and valuable suggestions & time , given to me throughout the project Development and Documentation.

At the same time I am highly obliged to the other members of my Project Team, for their sincere assistance, co-operation and encouragement, throughout the Project Work. I thank them all, as without them it would not have been possible for me to complete this project successfully.

Last but not the least, I would like to thank the entire college along with our respected Principal sir, our HOD, and all other Faculty Members of my College, as they have all contributed some way or the other, to help me successfully execute this herculean task.

Thanking You All

Page 4: Bus Reservation Srs

I Bikramjit Banerjee, of Camellia School Of Engineerimg & Technology under the Guidance of Ms. Pallabi Chakraborty have completed this Project Online Bus Reservation System Through ASP.NET successfully.

Ms. ..............................

[Project Guide] Date:

Page 5: Bus Reservation Srs

This project is based on Online Reservation of Bus.The basic

purpose of Online reservation is to make the reservation

process faster, user friendly and we do not have to maintain

any written records.All records are managed in the

database.This software keeps the details of all the

reservations,users,buse, etc.

In this website we have used a home page which contains a

log-in option through which both administrator and user can

log-in.It also contains a search bus option. This page leads to

many other pages like administrator home page where

administrator can add, delete and modify bus details.

Search bus option can be used even without logging in.But to

access the booking, cancel ticket, and print ticket options a

user has to register him/her.

Feedback can be provided by both registered and unregistered

user.

Page 6: Bus Reservation Srs

Entity:

1.Passenger

2.Administrator

3.Bus

4.Ticket

5.Seat

6.Feedback

Key Attributes:

1.Passenger-Id

2.Admin-Username

3.Bus-bus No.

4.Ticket-PNR

5.Seat-Seat No.

6.Feedback-

Page 7: Bus Reservation Srs

For Master Page :

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class FeedbackList : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); protected void Page_Load(object sender, EventArgs e) { if (Session["un"] != "Administrator") { Response.Redirect("Login.aspx"); }

Page 8: Bus Reservation Srs

else { SqlDataAdapter da = new SqlDataAdapter("select name,email,phone,subject,comment from feedback_list", con); DataSet ds = new DataSet(); da.Fill(ds, "Feed"); DataTable dt = ds.Tables["Feed"]; GridView1.DataSource = ds.Tables["Feed"]; GridView1.DataBind(); } }}For Home Page:

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class Home : System.Web.UI.Page{

Page 9: Bus Reservation Srs

SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); SqlDataAdapter da; DataSet ds, ds1; DataTable dt; SqlCommand cmd1; protected void Page_Load(object sender, EventArgs e) { Calendar1.Visible = false; string s = Calendar1.TodaysDate.ToShortDateString(); TextBox3.Text = s; if (IsPostBack == false) { cmd1 = new SqlCommand("select distinct source from Bus_Detail", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); DropDownList1.Items.Add("select source"); DropDownList2.Items.Add("select destination"); DropDownList4.Items.Add("select category"); while (dr.Read()) { DropDownList1.Items.Add(dr.GetValue(0).ToString()); } con.Close(); cmd1 = new SqlCommand("select distinct category from Bus_detail", con); con.Open(); dr = cmd1.ExecuteReader();

Page 10: Bus Reservation Srs

while (dr.Read()) { DropDownList4.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } }protected void DropDownList4_SelectedIndexChanged(object sender, EventArgs e) { } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { DropDownList2.Items.Clear(); DropDownList2.Items.Add("select destination"); string s = DropDownList1.Text; cmd1 = new SqlCommand("select distinct destination from Bus_detail", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); while (dr.Read()) { if ((dr.GetValue(0).ToString()) != s) DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); }

Page 11: Bus Reservation Srs

protected void Calendar1_SelectionChanged(object sender, EventArgs e) { string s = Calendar1.SelectedDate.ToShortDateString(); TextBox3.Text = s; Calendar1.Visible = false; } protected void LinkButton3_Click(object sender, EventArgs e) { Response.Redirect("NewUser.aspx"); }

protected void ImageButton3_Click(object sender, ImageClickEventArgs e) { Session["S"] = DropDownList1.Text; Session["D"] = DropDownList2.Text; Session["Date"] = TextBox3.Text; Session["Cat"] = DropDownList4.Text; Response.Redirect("Search.aspx"); } protected void ImageButton4_Click(object sender, ImageClickEventArgs e) { Calendar1.Visible = true; } protected void ImageButton2_Click(object sender, ImageClickEventArgs e) {

Page 12: Bus Reservation Srs

SqlDataAdapter da = new SqlDataAdapter("select name,username,password from user_info", con); DataSet ds = new DataSet(); da.Fill(ds, "user1"); dt = ds.Tables["user1"]; string em1 = TextBox1.Text.ToString(); string pa1 = TextBox2.Text.ToLower().ToString(); for (int i = 0; i < dt.Rows.Count; i++) { string em2 = dt.Rows[i][1].ToString(); string pa2 = dt.Rows[i][2].ToString(); string ad = dt.Rows[i][0].ToString(); if ((em1 == em2) && (pa1 == pa2)) { if (ad == "Administrator") { Session["un"] = TextBox1.Text; Response.Redirect("HomeForAdmin.aspx"); } else { Session["un"] = TextBox1.Text; Response.Redirect("Home.aspx"); } } else Label3.Text = "Invalid Username Or Password"; } } protected void LinkButton4_Click(object sender, EventArgs e)

Page 13: Bus Reservation Srs

{ Response.Redirect("ForgetPassword.aspx"); }}

For Search Page :

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class Search : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); SqlDataAdapter da; DataSet ds, ds1; DataTable dt; SqlCommand cmd1; protected void Page_Load(object sender, EventArgs e)

Page 14: Bus Reservation Srs

{ GridView1.SelectedIndex = -1; TextBox1.Text = Calendar1.TodaysDate.ToShortDateString(); if (IsPostBack == false) { Label7.Visible = false; cmd1 = new SqlCommand("select distinct source from Bus_Detail", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); DropDownList1.Items.Add("select source"); DropDownList2.Items.Add("select destination"); DropDownList3.Items.Add("select category"); while (dr.Read()) { DropDownList1.Items.Add(dr.GetValue(0).ToString()); } con.Close(); cmd1 = new SqlCommand("select distinct category from Bus_detail", con); con.Open(); dr = cmd1.ExecuteReader(); while (dr.Read()) { DropDownList3.Items.Add(dr.GetValue(0).ToString()); } con.Close(); }

Page 15: Bus Reservation Srs

string s1; if (Session["S"] != null) { string s = Session["S"].ToString(); Label2.Text = s; } else { if (IsPostBack == false) Label2.Text = "Not Selected"; } if (Session["D"] != null) { string s = Session["D"].ToString(); Label3.Text = s; } else { if (IsPostBack == false) Label3.Text = "Not Selected"; } if (Session["Date"] != null) { string s = Session["Date"].ToString(); Label4.Text = s; } else { Label4.Text = Calendar1.TodaysDate.ToShortDateString(); if (IsPostBack == false)

Page 16: Bus Reservation Srs

Label4.Text = Calendar1.SelectedDate.ToShortDateString(); } if (Session["Cat"] != null) { string s = Session["Cat"].ToString(); Label5.Text = s; } else { if (IsPostBack == false) Label5.Text = "Not Selected"; } if ((Session["S"] == null) && (DropDownList1.SelectedIndex == 0)) { Label7.Visible = true; Label7.Text = "Select the Source Station"; DropDownList3.SelectedIndex = 0; return; } else if ((Session["D"] == null) && (DropDownList2.SelectedIndex == 0)) { Label7.Visible = true; Label7.Text = "Select the Destination Station"; DropDownList3.SelectedIndex = 0; return; } else {

Page 17: Bus Reservation Srs

Getdata(); if (dt.Rows.Count == 0) { Label6.Text = "Oops! No Service Available for your search"; GridView1.DataSource = null; GridView1.Visible = false; GridView1.DataBind(); return; } else { GridView1.Visible = true; Label6.Text = ""; LoadData(); } } GridView1.SelectedIndex = -1; Label7.Text = ""; s1 = Calendar1.TodaysDate.ToShortDateString(); TextBox1.Text = s1; }

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { Session["S"] = DropDownList1.Text; GridView1.Visible = false; Label11.Text = ""; Label12.Text = "";

Page 18: Bus Reservation Srs

Label13.Text = ""; DropDownList2.Items.Clear(); DropDownList2.Items.Add("select destination"); string s = DropDownList1.Text; Label2.Text = s; cmd1 = new SqlCommand("select distinct destination from Bus_detail", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); while (dr.Read()) { if ((dr.GetValue(0).ToString()) != s) DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } protected void Calendar1_SelectionChanged(object sender, EventArgs e) { Session["Date"] = Calendar1.SelectedDate.ToShortDateString(); GridView1.Visible = false; Label11.Text = ""; Label12.Text = ""; Label13.Text = ""; string s = Calendar1.SelectedDate.ToShortDateString(); TextBox1.Text = s; Label4.Text = s; }

Page 19: Bus Reservation Srs

protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { Session["D"] = DropDownList2.Text; GridView1.Visible = false; Label11.Text = ""; Label12.Text = ""; Label13.Text = ""; string s = DropDownList2.Text; Label3.Text = s; } protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e) { Session["Cat"] = DropDownList3.Text; GridView1.Visible = false; Label11.Text = ""; Label12.Text = ""; Label13.Text = ""; string s = DropDownList3.Text; Label5.Text = s; } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { if (Session["S"] == null) { if (DropDownList1.SelectedIndex == 0) {

Page 20: Bus Reservation Srs

Label7.Text = "Select the Source Station"; DropDownList3.SelectedIndex = 0; return; } } if (Session["D"] == null) { if (DropDownList2.SelectedIndex == 0) { Label7.Text = "Select the Destination Station"; DropDownList3.SelectedIndex = 0; return; } } if (DropDownList3.SelectedIndex == 0) { Session["Cat"] = null; } Getdata(); if (dt.Rows.Count == 0) { Label6.Text = "Oops! No Service Available for your search"; GridView1.DataSource = null; GridView1.Visible = false; GridView1.DataBind(); return; } else { GridView1.Visible = true;

Page 21: Bus Reservation Srs

Label6.Text = ""; LoadData(); } Session["S"] = null; Session["D"] = null; Session["Date"] = Calendar1.TodaysDate.ToShortDateString(); Session["Cat"] = null; } protected void Getdata() { string s,s1,s2,s3; if (Session["Cat"] != null) s2 = Session["Cat"].ToString(); else s2 = DropDownList3.Text; if (Session["S"] != null) s = Session["S"].ToString(); else s = DropDownList1.Text; if (Session["D"] != null) s1 = Session["D"].ToString(); else s1 = DropDownList2.Text; if (Session["Date"] != null) s3 = Session["Date"].ToString(); else s3 = TextBox1.Text; if ((DropDownList3.SelectedIndex == 0) || (Session["Cat"] == null)) {

Page 22: Bus Reservation Srs

da = new SqlDataAdapter("select travels,busno,source,destination,date,time,category,amount,kilometers from bus_detail where source = '" + s + "' and destination ='" + s1 + "' and date ='" + s3 + "'", con); } else { da = new SqlDataAdapter("select travels,busno,source,destination,date,time,category,amount,kilometers from bus_detail where source = '" + s + "' and destination ='" + s1 + "' and date = '" + s3 + "' and category ='" + s2 + "'", con); }

ds = new DataSet(); da.Fill(ds, "detail"); dt = ds.Tables["detail"]; Session["ds"] = ds; } protected void LoadData() { GridView1.DataSource = ((DataSet)Session["ds"]).Tables["detail"]; GridView1.DataBind(); for (int i = 0; i < GridView1.Rows.Count; i++) { GridViewRow r = GridView1.Rows[i]; ImageButton img = (ImageButton)r.FindControl("ImageButton3"); img.ImageUrl = "~/Images/Bus Images/bus" + (i + 1) + ".jpg";

Page 23: Bus Reservation Srs

} }

protected void LinkButton1_Click(object sender, EventArgs e) {

}

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { int index = GridView1.SelectedIndex; if (index > -1 ) { GridViewRow row = GridView1.Rows[index]; Label l; l = (Label)row.FindControl("Label1"); string busno = l.Text.Trim(); Label11.Text = busno; SqlCommand cmd1 = new SqlCommand("select busno,totalseat,availableseat from status where busno=@bno", con); cmd1.Parameters.Add("@bno", SqlDbType.VarChar); cmd1.Parameters["@bno"].Value = busno; SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); if (dr.Read())

Page 24: Bus Reservation Srs

{ Label11.Text = dr.GetValue(0).ToString(); Session["bsno"] = Label11.Text; Label12.Text = dr.GetValue(1).ToString(); Label13.Text = dr.GetValue(2).ToString(); Session["Tseat"] = Label12.Text; Session["Aseat"] = Label13.Text; } con.Close(); } else { Label11.Text = ""; Label12.Text = ""; Label13.Text = ""; } GridView1.SelectedIndex = -1; } protected void ImageButton2_Click(object sender, ImageClickEventArgs e) { Session["Source"] = Label2.Text; Session["Destination"] = Label3.Text; Session["Day"] = Label4.Text; if (Session["un"] == null) { Response.Redirect("Login.aspx"); } else { Response.Redirect("PassengerInfo.aspx");

Page 25: Bus Reservation Srs

} }}

For Log-In page:

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class Login : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); DataTable dt; protected void Page_Load(object sender, EventArgs e) { Session["un"] = null; SqlDataAdapter da = new SqlDataAdapter("select name,username,password from user_info", con);

Page 26: Bus Reservation Srs

DataSet ds = new DataSet(); da.Fill(ds, "user1"); dt = ds.Tables["user1"]; } protected void LinkButton3_Click(object sender, EventArgs e) { Response.Redirect("NewUser.aspx"); }

protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { string em1 = TextBox1.Text.ToString(); string pa1 = TextBox2.Text.ToLower().ToString(); for (int i = 0; i < dt.Rows.Count; i++) { string em2 = dt.Rows[i][1].ToString(); string pa2 = dt.Rows[i][2].ToString(); string ad = dt.Rows[i][0].ToString(); if ((em1 == em2) && (pa1 == pa2)) { if (ad == "Administrator") { Session["un"] = TextBox1.Text; Response.Redirect("HomeForAdmin.aspx"); } else { Session["un"] = TextBox1.Text; Response.Redirect("Search.aspx");

Page 27: Bus Reservation Srs

} } else Label2.Text = "Invalid Username Or Password"; } } protected void LinkButton4_Click(object sender, EventArgs e) { Response.Redirect("ForgetPassword.aspx"); }}

For Passenger Info Page:

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class PassengerInfo : System.Web.UI.Page{

Page 28: Bus Reservation Srs

SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); SqlCommand cmd1; protected void Page_Load(object sender, EventArgs e) { if (Session["un"] == null) Response.Redirect("Login.aspx"); TextBox4.Visible = false; TextBox5.Visible = false; TextBox6.Visible = false; TextBox10.Visible = false; TextBox11.Visible = false; TextBox12.Visible = false; DropDownList2.Visible = false; DropDownList3.Visible = false; DropDownList4.Visible = false; Label2.Visible = false; Label3.Visible = false; Label4.Visible = false; Label8.Visible = false; Label9.Visible = false; Label10.Visible = false; string pn; double r; SqlCommand cmd2 = new SqlCommand("select pnr from passenger_info", con); SqlDataReader dr; con.Open(); dr = cmd2.ExecuteReader(); while (dr.Read())

Page 29: Bus Reservation Srs

{ pn = dr.GetValue(0).ToString(); r = double.Parse(pn); r = r + 16357; pn = r.ToString(); Session["PNR"] = pn.ToString(); } con.Close(); string busno=Session["bsno"].ToString(); SqlCommand cmd3 = new SqlCommand("select time,amount from bus_detail where busno = '" + busno + "'", con); con.Open(); dr = cmd3.ExecuteReader(); if (dr.Read()) { Session["time"] = dr.GetValue(0).ToString(); Session["amount"] = dr.GetValue(1).ToString(); } con.Close(); } protected void TextBox2_TextChanged(object sender, EventArgs e) {

} protected void TextBox1_PreRender(object sender, EventArgs e) { }

Page 30: Bus Reservation Srs

protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e) { if (TextBox1.Text == "") { Label14.Text = "Enter Your Name"; return; } if (TextBox2.Text == "") { Label14.Text = "Enter Your EmailId"; return; } if (TextBox3.Text == "") { Label14.Text = "Enter Passenger's Mobile Number"; return; } if (DropDownList1.SelectedValue == "1") { int seat = (int.Parse(Session["Tseat"].ToString()) - int.Parse(Session["Aseat"].ToString())); seat = seat + 1; Label2.Text = seat.ToString(); Label8.Text = Session["amount"].ToString(); Label2.Visible = true; Label8.Visible = true; TextBox4.Visible = true; TextBox10.Visible = true; DropDownList2.Visible = true;

Page 31: Bus Reservation Srs

Label15.Text = Label8.Text; } if (DropDownList1.SelectedValue.ToString() == "2") { int seat = (int.Parse(Session["Tseat"].ToString()) - int.Parse(Session["Aseat"].ToString())); seat = seat + 1; Label2.Text = seat.ToString(); seat = seat + 1; Label3.Text = seat.ToString(); Label8.Text = Session["amount"].ToString(); Label9.Text = Session["amount"].ToString(); Label2.Visible = true; Label8.Visible = true; Label3.Visible = true; Label9.Visible = true; TextBox4.Visible = true; TextBox10.Visible = true; DropDownList2.Visible = true; TextBox5.Visible = true; TextBox11.Visible = true; DropDownList3.Visible = true; int a = int.Parse(Label8.Text); a = a * 2; Label15.Text = a.ToString(); } if (DropDownList1.SelectedValue.ToString() == "3") { int seat = (int.Parse(Session["Tseat"].ToString()) - int.Parse(Session["Aseat"].ToString())); seat = seat + 1;

Page 32: Bus Reservation Srs

Label2.Text = seat.ToString(); seat = seat + 1; Label3.Text = seat.ToString(); seat = seat + 1; Label4.Text = seat.ToString(); Label8.Text = Session["amount"].ToString(); Label9.Text = Session["amount"].ToString(); Label10.Text = Session["amount"].ToString(); Label2.Visible = true; Label8.Visible = true; Label3.Visible = true; Label9.Visible = true; Label4.Visible = true; Label10.Visible = true; TextBox4.Visible = true; TextBox10.Visible = true; DropDownList2.Visible = true; TextBox5.Visible = true; TextBox11.Visible = true; DropDownList3.Visible = true; TextBox6.Visible = true; TextBox12.Visible = true; DropDownList4.Visible = true; int a = int.Parse(Label8.Text); a = a * 3; Label15.Text = a.ToString(); } } protected void ImageButton1_Click(object sender, ImageClickEventArgs e)

Page 33: Bus Reservation Srs

{ if (DropDownList1.SelectedValue.ToString() == "1") { cmd1 = new SqlCommand("insert into Passenger_info (PNR,P_Nme,Sex,Age,P_Ph,P_to,P_from,bsno,date,time,totalseat,seatnum,amount,status) values(@PNR,@NAM,@S,@A,@PH,@TO,@FR,@BS,@DT,@TM,@TS,@SN,@AM,@ST)", con); cmd1.Parameters.Add("@PNR", SqlDbType.VarChar); cmd1.Parameters.Add("@NAM", SqlDbType.VarChar); cmd1.Parameters.Add("@S", SqlDbType.VarChar); cmd1.Parameters.Add("@A", SqlDbType.Int); cmd1.Parameters.Add("@PH", SqlDbType.VarChar); cmd1.Parameters.Add("@TO", SqlDbType.VarChar); cmd1.Parameters.Add("@FR", SqlDbType.VarChar); cmd1.Parameters.Add("@BS", SqlDbType.VarChar); cmd1.Parameters.Add("@DT", SqlDbType.VarChar); cmd1.Parameters.Add("@TM", SqlDbType.VarChar); cmd1.Parameters.Add("@TS", SqlDbType.Int); cmd1.Parameters.Add("@SN", SqlDbType.VarChar); cmd1.Parameters.Add("@AM", SqlDbType.Float); cmd1.Parameters.Add("@ST", SqlDbType.VarChar);

cmd1.Parameters["@PNR"].Value = Session["PNR"].ToString(); cmd1.Parameters["@NAM"].Value = TextBox4.Text; cmd1.Parameters["@S"].Value = DropDownList2.Text; cmd1.Parameters["@A"].Value = int.Parse(TextBox10.Text);

Page 34: Bus Reservation Srs

cmd1.Parameters["@PH"].Value = TextBox3.Text; cmd1.Parameters["@TO"].Value = Session["Source"].ToString(); cmd1.Parameters["@FR"].Value = Session["Destination"].ToString(); cmd1.Parameters["@BS"].Value = Session["bsno"].ToString(); cmd1.Parameters["@DT"].Value = Session["Day"].ToString(); cmd1.Parameters["@TM"].Value = Session["time"].ToString(); cmd1.Parameters["@TS"].Value = int.Parse(DropDownList1.Text); int seat = (int.Parse(Session["Tseat"].ToString()) - int.Parse(Session["Aseat"].ToString())); seat = seat + 1; cmd1.Parameters["@SN"].Value = seat.ToString(); cmd1.Parameters["@AM"].Value = float.Parse(Session["amount"].ToString()); cmd1.Parameters["@ST"].Value = "Booked";

con.Open(); int n = cmd1.ExecuteNonQuery(); con.Close();

int avai = int.Parse(Session["Aseat"].ToString()); avai = avai - 1; avai.ToString(); SqlCommand cmd = new SqlCommand("update status set availableseat = '" + avai + "' where busno=@BS", con);

Page 35: Bus Reservation Srs

cmd.Parameters.Add("@BS", SqlDbType.VarChar); cmd.Parameters["@BS"].Value = Session["bsno"]; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } else if (DropDownList1.SelectedValue.ToString() == "2") { //for 1st passenger cmd1 = new SqlCommand("insert into Passenger_info (PNR,P_Nme,Sex,Age,P_Ph,P_to,P_from,date,time,totalseat,seatnum,amount,status) values(@PNR,@NAM,@S,@A,@PH,@TO,@FR,@DT,@TM,@TS,@SN,@AM,@ST)", con); cmd1.Parameters.Add("@PNR", SqlDbType.VarChar); cmd1.Parameters.Add("@NAM", SqlDbType.VarChar); cmd1.Parameters.Add("@S", SqlDbType.VarChar); cmd1.Parameters.Add("@A", SqlDbType.Int); cmd1.Parameters.Add("@PH", SqlDbType.VarChar); cmd1.Parameters.Add("@TO", SqlDbType.VarChar); cmd1.Parameters.Add("@FR", SqlDbType.VarChar); cmd1.Parameters.Add("@DT", SqlDbType.VarChar); cmd1.Parameters.Add("@TM", SqlDbType.VarChar); cmd1.Parameters.Add("@TS", SqlDbType.Int); cmd1.Parameters.Add("@SN", SqlDbType.VarChar); cmd1.Parameters.Add("@AM", SqlDbType.Float); cmd1.Parameters.Add("@ST", SqlDbType.VarChar);

cmd1.Parameters["@PNR"].Value = Session["PNR"].ToString();

Page 36: Bus Reservation Srs

cmd1.Parameters["@NAM"].Value = TextBox4.Text; cmd1.Parameters["@S"].Value = DropDownList2.Text; cmd1.Parameters["@A"].Value = int.Parse(TextBox10.Text); cmd1.Parameters["@PH"].Value = TextBox3.Text; cmd1.Parameters["@TO"].Value = Session["Source"].ToString(); cmd1.Parameters["@FR"].Value = Session["Destination"].ToString(); cmd1.Parameters["@DT"].Value = Session["Day"].ToString(); cmd1.Parameters["@TM"].Value = Session["time"].ToString(); cmd1.Parameters["@TS"].Value = int.Parse(DropDownList1.Text); int seat = (int.Parse(Session["Tseat"].ToString()) - int.Parse(Session["Aseat"].ToString())); seat = seat + 1; cmd1.Parameters["@SN"].Value = seat.ToString(); cmd1.Parameters["@AM"].Value = float.Parse(Session["amount"].ToString()); cmd1.Parameters["@ST"].Value = "B";

con.Open(); int n = cmd1.ExecuteNonQuery(); con.Close();

//for second passenger cmd1 = new SqlCommand("insert into Passenger_info (PNR,P_Nme,Sex,Age,P_Ph,P_to,P_from,date,time,totalseat

Page 37: Bus Reservation Srs

,seatnum,amount,status) values(@PNR,@NAM,@S,@A,@PH,@TO,@FR,@DT,@TM,@TS,@SN,@AM,@ST)", con); cmd1.Parameters.Add("@PNR", SqlDbType.VarChar); cmd1.Parameters.Add("@NAM", SqlDbType.VarChar); cmd1.Parameters.Add("@S", SqlDbType.VarChar); cmd1.Parameters.Add("@A", SqlDbType.Int); cmd1.Parameters.Add("@PH", SqlDbType.VarChar); cmd1.Parameters.Add("@TO", SqlDbType.VarChar); cmd1.Parameters.Add("@FR", SqlDbType.VarChar); cmd1.Parameters.Add("@DT", SqlDbType.VarChar); cmd1.Parameters.Add("@TM", SqlDbType.VarChar); cmd1.Parameters.Add("@TS", SqlDbType.Int); cmd1.Parameters.Add("@SN", SqlDbType.VarChar); cmd1.Parameters.Add("@AM", SqlDbType.Float); cmd1.Parameters.Add("@ST", SqlDbType.VarChar);

cmd1.Parameters["@PNR"].Value = Session["PNR"].ToString(); cmd1.Parameters["@NAM"].Value = TextBox5.Text; cmd1.Parameters["@S"].Value = DropDownList3.Text; cmd1.Parameters["@A"].Value = int.Parse(TextBox11.Text); cmd1.Parameters["@PH"].Value = TextBox3.Text; cmd1.Parameters["@TO"].Value = Session["Source"].ToString(); cmd1.Parameters["@FR"].Value = Session["Destination"].ToString();

Page 38: Bus Reservation Srs

cmd1.Parameters["@DT"].Value = Session["Day"].ToString(); cmd1.Parameters["@TM"].Value = Session["time"].ToString(); cmd1.Parameters["@TS"].Value = int.Parse(DropDownList1.Text); seat = (int.Parse(Session["Tseat"].ToString()) - int.Parse(Session["Aseat"].ToString())); seat = seat + 2; cmd1.Parameters["@SN"].Value = seat.ToString(); cmd1.Parameters["@AM"].Value = float.Parse(Session["amount"].ToString()); cmd1.Parameters["@ST"].Value = "B";

con.Open(); n = cmd1.ExecuteNonQuery(); con.Close();

int avai = int.Parse(Session["Aseat"].ToString()); avai = avai - 2; avai.ToString(); SqlCommand cmd = new SqlCommand("update status set availableseat = '" + avai + "' where busno=@BS", con); cmd.Parameters.Add("@BS", SqlDbType.VarChar); cmd.Parameters["@BS"].Value = Session["bsno"]; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } else

Page 39: Bus Reservation Srs

{ //for 1st passenger cmd1 = new SqlCommand("insert into Passenger_info (PNR,P_Nme,Sex,Age,P_Ph,P_to,P_from,date,time,totalseat,seatnum,amount,status) values(@PNR,@NAM,@S,@A,@PH,@TO,@FR,@DT,@TM,@TS,@SN,@AM,@ST)", con); cmd1.Parameters.Add("@PNR", SqlDbType.VarChar); cmd1.Parameters.Add("@NAM", SqlDbType.VarChar); cmd1.Parameters.Add("@S", SqlDbType.VarChar); cmd1.Parameters.Add("@A", SqlDbType.Int); cmd1.Parameters.Add("@PH", SqlDbType.VarChar); cmd1.Parameters.Add("@TO", SqlDbType.VarChar); cmd1.Parameters.Add("@FR", SqlDbType.VarChar); cmd1.Parameters.Add("@DT", SqlDbType.VarChar); cmd1.Parameters.Add("@TM", SqlDbType.VarChar); cmd1.Parameters.Add("@TS", SqlDbType.Int); cmd1.Parameters.Add("@SN", SqlDbType.VarChar); cmd1.Parameters.Add("@AM", SqlDbType.Float); cmd1.Parameters.Add("@ST", SqlDbType.VarChar);

cmd1.Parameters["@PNR"].Value = Session["PNR"].ToString(); cmd1.Parameters["@NAM"].Value = TextBox4.Text; cmd1.Parameters["@S"].Value = DropDownList2.Text; cmd1.Parameters["@A"].Value = int.Parse(TextBox10.Text); cmd1.Parameters["@PH"].Value = TextBox3.Text;

Page 40: Bus Reservation Srs

cmd1.Parameters["@TO"].Value = Session["Source"].ToString(); cmd1.Parameters["@FR"].Value = Session["Destination"].ToString(); cmd1.Parameters["@DT"].Value = Session["Day"].ToString(); cmd1.Parameters["@TM"].Value = Session["time"].ToString(); cmd1.Parameters["@TS"].Value = int.Parse(DropDownList1.Text); int seat = (int.Parse(Session["Tseat"].ToString()) - int.Parse(Session["Aseat"].ToString())); seat = seat + 1; cmd1.Parameters["@SN"].Value = seat.ToString(); cmd1.Parameters["@AM"].Value = float.Parse(Session["amount"].ToString()); cmd1.Parameters["@ST"].Value = "B";

con.Open(); int n = cmd1.ExecuteNonQuery(); con.Close();

//for second passenger cmd1 = new SqlCommand("insert into Passenger_info (PNR,P_Nme,Sex,Age,P_Ph,P_to,P_from,date,time,totalseat,seatnum,amount,status) values(@PNR,@NAM,@S,@A,@PH,@TO,@FR,@DT,@TM,@TS,@SN,@AM,@ST)", con); cmd1.Parameters.Add("@PNR", SqlDbType.VarChar); cmd1.Parameters.Add("@NAM", SqlDbType.VarChar);

Page 41: Bus Reservation Srs

cmd1.Parameters.Add("@S", SqlDbType.VarChar); cmd1.Parameters.Add("@A", SqlDbType.Int); cmd1.Parameters.Add("@PH", SqlDbType.VarChar); cmd1.Parameters.Add("@TO", SqlDbType.VarChar); cmd1.Parameters.Add("@FR", SqlDbType.VarChar); cmd1.Parameters.Add("@DT", SqlDbType.VarChar); cmd1.Parameters.Add("@TM", SqlDbType.VarChar); cmd1.Parameters.Add("@TS", SqlDbType.Int); cmd1.Parameters.Add("@SN", SqlDbType.VarChar); cmd1.Parameters.Add("@AM", SqlDbType.Float); cmd1.Parameters.Add("@ST", SqlDbType.VarChar);

cmd1.Parameters["@PNR"].Value = Session["PNR"].ToString(); cmd1.Parameters["@NAM"].Value = TextBox5.Text; cmd1.Parameters["@S"].Value = DropDownList3.Text; cmd1.Parameters["@A"].Value = int.Parse(TextBox11.Text); cmd1.Parameters["@PH"].Value = TextBox3.Text; cmd1.Parameters["@TO"].Value = Session["Source"].ToString(); cmd1.Parameters["@FR"].Value = Session["Destination"].ToString(); cmd1.Parameters["@DT"].Value = Session["Day"].ToString(); cmd1.Parameters["@TM"].Value = Session["time"].ToString(); cmd1.Parameters["@TS"].Value = int.Parse(DropDownList1.Text);

Page 42: Bus Reservation Srs

seat = (int.Parse(Session["Tseat"].ToString()) - int.Parse(Session["Aseat"].ToString())); seat = seat + 2; cmd1.Parameters["@SN"].Value = seat.ToString(); cmd1.Parameters["@AM"].Value = float.Parse(Session["amount"].ToString()); cmd1.Parameters["@ST"].Value = "B";

con.Open(); n = cmd1.ExecuteNonQuery(); con.Close();

//for 3rd passenger cmd1 = new SqlCommand("insert into Passenger_info (PNR,P_Nme,Sex,Age,P_Ph,P_to,P_from,date,time,totalseat,seatnum,amount,status) values(@PNR,@NAM,@S,@A,@PH,@TO,@FR,@DT,@TM,@TS,@SN,@AM,@ST)", con); cmd1.Parameters.Add("@PNR", SqlDbType.VarChar); cmd1.Parameters.Add("@NAM", SqlDbType.VarChar); cmd1.Parameters.Add("@S", SqlDbType.VarChar); cmd1.Parameters.Add("@A", SqlDbType.Int); cmd1.Parameters.Add("@PH", SqlDbType.VarChar); cmd1.Parameters.Add("@TO", SqlDbType.VarChar); cmd1.Parameters.Add("@FR", SqlDbType.VarChar); cmd1.Parameters.Add("@DT", SqlDbType.VarChar); cmd1.Parameters.Add("@TM", SqlDbType.VarChar); cmd1.Parameters.Add("@TS", SqlDbType.Int); cmd1.Parameters.Add("@SN", SqlDbType.VarChar); cmd1.Parameters.Add("@AM", SqlDbType.Float);

Page 43: Bus Reservation Srs

cmd1.Parameters.Add("@ST", SqlDbType.VarChar);

cmd1.Parameters["@PNR"].Value = Session["PNR"].ToString(); cmd1.Parameters["@NAM"].Value = TextBox6.Text; cmd1.Parameters["@S"].Value = DropDownList4.Text; cmd1.Parameters["@A"].Value = int.Parse(TextBox12.Text); cmd1.Parameters["@PH"].Value = TextBox3.Text; cmd1.Parameters["@TO"].Value = Session["Source"].ToString(); cmd1.Parameters["@FR"].Value = Session["Destination"].ToString(); cmd1.Parameters["@DT"].Value = Session["Day"].ToString(); cmd1.Parameters["@TM"].Value = Session["time"].ToString(); cmd1.Parameters["@TS"].Value = int.Parse(DropDownList1.Text); seat = (int.Parse(Session["Tseat"].ToString()) - int.Parse(Session["Aseat"].ToString())); seat = seat + 3; cmd1.Parameters["@SN"].Value = seat.ToString(); cmd1.Parameters["@AM"].Value = float.Parse(Session["amount"].ToString()); cmd1.Parameters["@ST"].Value = "B";

con.Open(); n = cmd1.ExecuteNonQuery(); con.Close();

Page 44: Bus Reservation Srs

int avai = int.Parse(Session["Aseat"].ToString()); avai = avai - 3; avai.ToString(); SqlCommand cmd = new SqlCommand("update status set availableseat = '" + avai + "' where busno=@BS", con); cmd.Parameters.Add("@BS", SqlDbType.VarChar); cmd.Parameters["@BS"].Value = Session["bsno"]; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; DropDownList1.SelectedIndex = -1; Response.Redirect("Payment.aspx"); }}

For Payment Details Page :

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;

Page 45: Bus Reservation Srs

using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;

public partial class Payment : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { if (Session["un"] == null) Response.Redirect("Login.aspx"); } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { if (DropDownList1.SelectedValue.ToString() == "Cheque") { Label3.Text = "Enter Cheque No. :"; } if (DropDownList1.SelectedIndex.ToString() == "2") { Label3.Text = "Enter Address :"; } if (DropDownList1.SelectedValue.ToString() == "Paypal") { Label3.Text = "Enter Your bank"; }

Page 46: Bus Reservation Srs

if (DropDownList1.SelectedValue.ToString() == "Credit Card") { Label3.Text = "Enter Credit Card Number"; } } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { if(TextBox1.Text == "") { Label4.Text="Enter all details"; return; } if (DropDownList1.SelectedValue.ToString() == "Cheque") { if (TextBox1.Text.Length != 10) { Label4.Text = "Invalid Cheque number"; } } if (DropDownList1.SelectedValue.ToString() == "Credit Card") { if (TextBox1.Text.Length != 10) { Label4.Text = "Invalid Card number"; } }

Page 47: Bus Reservation Srs

if (DropDownList1.SelectedValue.ToString() == "Cheque") { Label3.Text = "Enter Cheque No. :"; } DropDownList1.SelectedIndex = -1; TextBox1.Text = ""; Response.Redirect("PrintTicket.aspx"); }}

For Print Ticket Page:

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class PrintTicket : System.Web.UI.Page{

Page 48: Bus Reservation Srs

SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); DataTable dt; protected void Page_Load(object sender, EventArgs e) { if (Session["un"] == null) { Response.Redirect("Login.aspx"); return; } if (Session["PNR"] == null) { Response.Redirect("EnterPNR.aspx"); return; } SqlDataAdapter da = new SqlDataAdapter("select pnr,p_nme,P_ph,P_to,P_from,date,time,totalseat,seatnum,amount from passenger_info where pnr = '" + Session["PNR"].ToString() + "'", con); DataSet ds = new DataSet(); da.Fill(ds, "user1"); dt = ds.Tables["user1"]; for (int i = 0; i < dt.Rows.Count; i++) {

Label3.Text = dt.Rows[i][0].ToString(); Label4.Text = dt.Rows[i][1].ToString(); Label11.Text = dt.Rows[i][2].ToString(); Label12.Text = dt.Rows[i][3].ToString(); Label5.Text = dt.Rows[i][4].ToString();

Page 49: Bus Reservation Srs

Label6.Text = dt.Rows[i][5].ToString(); Label10.Text = dt.Rows[i][6].ToString(); Label14.Text = dt.Rows[i][7].ToString(); if (dt.Rows[i][7].ToString() == "1") Label7.Text = dt.Rows[i][8].ToString(); if (dt.Rows[i][7].ToString() == "2") { string r = dt.Rows[i][8].ToString(); int n = int.Parse(r); n = n + 1; n.ToString(); Label7.Text = dt.Rows[i][8].ToString() + "," + n; } if (dt.Rows[i][7].ToString() == "3") { string r = dt.Rows[i][8].ToString(); int n = int.Parse(r); n = n + 1; n.ToString(); int n1 = int.Parse(r); n1 = n1 + 2; n1.ToString(); Label7.Text = dt.Rows[i][8].ToString() + "," + n + "," + n1; } if (dt.Rows[i][7].ToString() == "1") Label15.Text = dt.Rows[i][9].ToString(); if (dt.Rows[i][7].ToString() == "2") { string r = dt.Rows[i][9].ToString(); int n = int.Parse(r);

Page 50: Bus Reservation Srs

n = n * 2; r = n.ToString(); Label15.Text = r; } if (dt.Rows[i][7].ToString() == "3") { string r = dt.Rows[i][8].ToString(); int n = int.Parse(r); n = n * 3; r = n.ToString(); Label15.Text = r; } break; } }}

For New User :

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;

Page 51: Bus Reservation Srs

using System.Data.SqlClient;

public partial class NewUser : System.Web.UI.Page{ public SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); public DataTable dt; SqlDataAdapter da; DataSet ds; protected void Page_Load(object sender, EventArgs e) { da = new SqlDataAdapter("select Name,username,password,MobileNo,secques,secans from User_info", con); ds = new DataSet(); da.Fill(ds, "User"); dt = ds.Tables["User"]; Label2.Text = ""; Label3.Text = ""; Label4.Text = ""; Label5.Text = ""; Label6.Text = ""; Label7.Text = ""; Label8.Text = ""; Label9.Text = ""; Label10.Text = ""; } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) {

Page 52: Bus Reservation Srs

if (TextBox1.Text == "") { Label2.Text = "Please Enter your Name"; return; } if ((TextBox1.Text.Contains("a"))|| (TextBox1.Text.Contains("b")) || (TextBox1.Text.Contains("c")) || (TextBox1.Text.Contains("d")) || (TextBox1.Text.Contains("e"))) { } else if((TextBox1.Text.Contains("f")) || (TextBox1.Text.Contains("g")) || (TextBox1.Text.Contains("h")) || (TextBox1.Text.Contains("i")) || (TextBox1.Text.Contains("j"))) { } else if((TextBox1.Text.Contains("k")) || (TextBox1.Text.Contains("l")) || (TextBox1.Text.Contains("m")) || (TextBox1.Text.Contains("n")) || (TextBox1.Text.Contains("o"))) { } else if((TextBox1.Text.Contains("p")) || (TextBox1.Text.Contains("q")) || (TextBox1.Text.Contains("r")) || (TextBox1.Text.Contains("s")) || (TextBox1.Text.Contains("t")))

Page 53: Bus Reservation Srs

{ } else if ((TextBox1.Text.Contains("u")) || (TextBox1.Text.Contains("v")) || (TextBox1.Text.Contains("w")) || (TextBox1.Text.Contains("x")) || (TextBox1.Text.Contains("y")) || (TextBox2.Text.Contains("y"))) { } else { Label2.Text = "Invalid Name"; return; } if (TextBox2.Text == "") { Label3.Text = "Please Enter your Email Id"; return; } if((((TextBox2.Text.IndexOf("@")) == -1) && ((TextBox2.Text.IndexOf(".")) == -1))) { Label3.Text="Invalid Email ID"; return; } if (TextBox3.Text == "") { Label4.Text = "Please Enter the password"; return; }

Page 54: Bus Reservation Srs

if (TextBox4.Text.Length < 6) { Label4.Text = "Minimum length of the password must be 6 characters"; return; } if (TextBox4.Text != TextBox3.Text) { Label5.Text = "Password not matched"; return; } if (TextBox5.Text == "") { Label6.Text = "Please Enter the MobileNo."; return; } int l = TextBox5.Text.Length; if ((l != 10)) { Label6.Text = "Invalid Mobile No., not use 0 in front"; return; } /* if (((TextBox5.Text.IndexOf("1")) == -1) || ((TextBox5.Text.IndexOf("2")) == -1) || ((TextBox5.Text.IndexOf("3")) == -1) || ((TextBox5.Text.IndexOf("4")) == -1) || ((TextBox5.Text.IndexOf("5")) == -1) || ((TextBox5.Text.IndexOf("6")) == -1) || ((TextBox5.Text.IndexOf("7")) == -1) || ((TextBox5.Text.IndexOf("8")) == -1) ||

Page 55: Bus Reservation Srs

((TextBox5.Text.IndexOf("9")) == -1) || ((TextBox5.Text.IndexOf("0")) == -1)) { Label6.Text = "Invalid Mobile No."; return; }*/ if (DropDownList1.SelectedIndex == 0) { Label3.Text = "Please Enter the Security Question"; return; } if (TextBox7.Text == "") { Label8.Text = "Please Enter the Security Answer"; return; } DataRow dr = dt.NewRow(); dr[0] = TextBox1.Text; dr[1] = TextBox2.Text; dr[2] = TextBox3.Text; dr[3] = TextBox5.Text; dr[4] = DropDownList1.Text; dr[5] = TextBox7.Text; dt.Rows.Add(dr); SqlCommandBuilder scb = new SqlCommandBuilder(da); da.Update(ds.Tables["User"]); TextBox1.Text = ""; TextBox2.Text = ""; TextBox5.Text = ""; DropDownList1.SelectedIndex = 0;

Page 56: Bus Reservation Srs

TextBox7.Text = ""; Label11.Text = "You are Successfully Registered"; } protected void LinkButton3_Click(object sender, EventArgs e) { string em1 = TextBox2.Text; for (int i = 0; i < dt.Rows.Count; i++) { string em2 = dt.Rows[i][1].ToString(); if (em1 == em2) { Label10.Text = "Not Available, try another one!!"; return; } else { Label9.Text = "Available, you Can use it"; return; } } }}

For Forget Password :

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;

Page 57: Bus Reservation Srs

using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class ForgetPassword : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); DataTable dt; protected void Page_Load(object sender, EventArgs e) { Label7.Visible = false; SqlDataAdapter da = new SqlDataAdapter("select name,username,password,secques,secans from user_info", con); DataSet ds = new DataSet(); da.Fill(ds, "user1"); dt = ds.Tables["user1"]; Label4.Visible=false; Label5.Visible=false; TextBox2.Visible=false; TextBox3.Visible=false; ImageButton2.Visible = false; Label6.Visible = false; Label6.Text = "";

Page 58: Bus Reservation Srs

ImageButton1.Visible = true; } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { int flag = 0; string em1 = TextBox1.Text.ToString(); for (int i = 0; i < dt.Rows.Count; i++) { string em2 = dt.Rows[i][1].ToString(); if (em1 == em2) { Label4.Visible = true; Label5.Visible = true; TextBox2.Visible = true; TextBox3.Visible = true; ImageButton1.Visible = false; TextBox2.Text = dt.Rows[i][3].ToString(); ImageButton2.Visible = true; flag = 1; break; } else flag = 0; } if (flag == 0) { Label7.Visible = true; Label7.Text = "Wrong Email ID"; TextBox1.Text = ""; return;

Page 59: Bus Reservation Srs

} }

protected void ImageButton2_Click(object sender, ImageClickEventArgs e) { int flag=0; string em1 = TextBox1.Text.ToString(); string sec1 = TextBox3.Text.ToString(); for (int i = 0; i < dt.Rows.Count; i++) { string em2 = dt.Rows[i][1].ToString(); string sec2 = dt.Rows[i][4].ToString(); if ((em1 == em2) && (sec1 == sec2)) { Label4.Visible = false; Label5.Visible = false; TextBox2.Visible = false; TextBox3.Visible = false; ImageButton2.Visible = false; Label6.Visible = true; Label6.Text = "Your Password Is : " + dt.Rows[i][2].ToString(); flag=1; TextBox2.Text = ""; TextBox3.Text = ""; break; } else flag = 0; }

Page 60: Bus Reservation Srs

if (flag == 0) { Label7.Visible = true; Label7.Text = "Wrong Answer"; TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; return; } }}

For Change Password :

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class ChangePassword : System.Web.UI.Page{

Page 61: Bus Reservation Srs

SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); DataTable dt; protected void Page_Load(object sender, EventArgs e) { if (Session["un"] == null) { Response.Redirect("Login.aspx"); } } protected void Button1_Click(object sender, EventArgs e) { if (TextBox1.Text == "") { Label3.Text = "This Field cannot be left blank"; return; } SqlCommand cmd1 = new SqlCommand("select password from user_info where username = @USER", con); cmd1.Parameters.Add("@USER", SqlDbType.VarChar); cmd1.Parameters["@USER"].Value = Session["un"].ToString(); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); if (dr.Read()) { if (TextBox1.Text != dr.GetValue(0).ToString()) { Label3.Text = "Invalid password";

Page 62: Bus Reservation Srs

con.Close(); return; } } con.Close(); if (TextBox2.Text == "") { Label4.Text = "This Field cannot be left blank"; return; } if (TextBox2.Text == "") { Label5.Text = "This Field cannot be left blank"; return; } if (TextBox2.Text != TextBox3.Text) { Label5.Text = "Password doen't match"; return; } SqlCommand cmd = new SqlCommand("update user_info set password= @P where username=@r", con); cmd.Parameters.Add("@r", SqlDbType.VarChar); cmd.Parameters.Add("@P", SqlDbType.VarChar); cmd.Parameters["@P"].Value = TextBox2.Text; cmd.Parameters["@r"].Value = Session["un"].ToString();

con.Open(); cmd.ExecuteNonQuery(); con.Close();

Page 63: Bus Reservation Srs

}}

For Cancel Ticket :

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class CancelTicket : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); DataTable dt; protected void Page_Load(object sender, EventArgs e) {

} protected void Button2_Click(object sender, EventArgs e) {

Page 64: Bus Reservation Srs

Response.Redirect("Home.aspx"); } protected void Button1_Click(object sender, EventArgs e) { string avai="",bsno=""; int i=0; SqlCommand cmd = new SqlCommand("update Passenger_info set date='Cancelled', time='Cancelled',seatnum= null,totalseat=null,status='cancelled' where PNR=@r", con); cmd.Parameters.Add("@r", SqlDbType.VarChar); cmd.Parameters["@r"].Value = Session["PNR"].ToString(); Label3.Text = "Your ticket is Cancelled";

con.Open(); cmd.ExecuteNonQuery(); con.Close(); string pnr=Session["PNR"].ToString(); cmd = new SqlCommand("select bsno from passenger_info where pnr = @r", con); cmd.Parameters.Add("@r", SqlDbType.VarChar); cmd.Parameters["@r"].Value = Session["PNR"].ToString(); SqlDataReader dr; con.Open(); dr = cmd.ExecuteReader(); while (dr.Read()) { bsno = dr.GetValue(0).ToString();

Page 65: Bus Reservation Srs

i++; } con.Close(); cmd = new SqlCommand("select availableseat from status where busno = @BS", con); cmd.Parameters.Add("@BS", SqlDbType.VarChar); cmd.Parameters["@BS"].Value = bsno; con.Open(); dr = cmd.ExecuteReader(); if (dr.Read()) { avai = dr.GetValue(0).ToString(); } con.Close();

int av = int.Parse(avai); av = av + i; avai = av.ToString(); cmd = new SqlCommand("update status set availableseat = '" + avai + "' where busno=@BS", con); cmd.Parameters.Add("@BS", SqlDbType.VarChar); cmd.Parameters["@BS"].Value = bsno; con.Open(); cmd.ExecuteNonQuery(); con.Close(); }}

For Enter PNR Page :

using System;

Page 66: Bus Reservation Srs

using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class EnterPNR : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); DataTable dt; protected void Page_Load(object sender, EventArgs e) { if (Session["un"] == null) { Response.Redirect("Login.aspx"); return; } Label16.Visible = false; SqlDataAdapter da = new SqlDataAdapter("select pnr,p_nme,P_ph,P_to,P_from,date,time,totalseat,seatnum,amount,status from passenger_info", con); DataSet ds = new DataSet();

Page 67: Bus Reservation Srs

da.Fill(ds, "user1"); dt = ds.Tables["user1"]; } protected void Button3_Click(object sender, EventArgs e) { int f = 0; string em1 = TextBox1.Text; for (int i = 0; i < dt.Rows.Count; i++) { string em2 = dt.Rows[i][0].ToString(); if (em1 == em2) { Session["PNR"] = em2; Label3.Text = dt.Rows[i][0].ToString(); Label4.Text = dt.Rows[i][1].ToString(); Label11.Text = dt.Rows[i][2].ToString(); Label12.Text = dt.Rows[i][3].ToString(); Label5.Text = dt.Rows[i][4].ToString(); Label6.Text = dt.Rows[i][5].ToString(); Label10.Text = dt.Rows[i][6].ToString(); Label14.Text = dt.Rows[i][7].ToString(); if (dt.Rows[i][7].ToString() == null) { Label16.Text = "Your Ticket Is Already Cancelled"; return; } if (dt.Rows[i][7].ToString() == "1") Label7.Text = dt.Rows[i][8].ToString(); if (dt.Rows[i][7].ToString() == "2") {

Page 68: Bus Reservation Srs

string r = dt.Rows[i][8].ToString(); int n = int.Parse(r); n = n + 1; n.ToString(); Label7.Text = dt.Rows[i][8].ToString() + "," + n; } if (dt.Rows[i][7].ToString() == "3") { string r = dt.Rows[i][8].ToString(); int n = int.Parse(r); n = n + 1; n.ToString(); int n1 = int.Parse(r); n1 = n1 + 2; n1.ToString(); Label7.Text = dt.Rows[i][8].ToString() + "," + n + "," + n1; } if (dt.Rows[i][7].ToString() == "1") Label15.Text = dt.Rows[i][9].ToString(); if (dt.Rows[i][7].ToString() == "2") { string r = dt.Rows[i][9].ToString(); int n = int.Parse(r); n = n * 2; r = n.ToString(); Label15.Text = r; } if (dt.Rows[i][7].ToString() == "3") { string r = dt.Rows[i][8].ToString();

Page 69: Bus Reservation Srs

int n = int.Parse(r); n = n * 3; r = n.ToString(); Label15.Text = r; } if (dt.Rows[i][10].ToString().ToLower().Trim() == "cancelled") { Label16.Text = "Your Ticket Is Already Cancelled"; return; } f = 0; break; } else { f = 1; } } if (f == 1) { Label16.Text = "Invalid PNR Number"; return; } } protected void Button1_Click(object sender, EventArgs e) { Response.Redirect("PrintTicket.aspx"); } protected void Button2_Click(object sender, EventArgs e)

Page 70: Bus Reservation Srs

{ Response.Redirect("CancelTicket.aspx"); }}

For Status Page :

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class Status : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); SqlDataAdapter da; DataSet ds, ds1; DataTable dt; SqlCommand cmd1; protected void Page_Load(object sender, EventArgs e)

Page 71: Bus Reservation Srs

{ GridView1.SelectedIndex = -1; string date = DateTime.Today.ToShortDateString(); da = new SqlDataAdapter("select travels,busno,source,destination,date from bus_detail where date = '" + date + "'", con); ds = new DataSet(); da.Fill(ds, "detail"); dt = ds.Tables["detail"]; Session["ds"] = ds; if (dt.Rows.Count == 0) { Label4.Text = "Oops! No Service Available for your search"; GridView1.DataSource = null; GridView1.Visible = false; GridView1.DataBind(); return; } else { GridView1.Visible = true; Label4.Text = ""; GridView1.DataSource = ((DataSet)Session["ds"]).Tables["detail"]; GridView1.DataBind(); } }

protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)

Page 72: Bus Reservation Srs

{

} protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { int index = GridView1.SelectedIndex; string time = DateTime.Now.ToLocalTime().ToShortTimeString(); if (index != -1) { GridViewRow row = GridView1.Rows[index]; Label l; l = (Label)row.FindControl("Label1"); string busno = l.Text.Trim(); SqlCommand cmd1 = new SqlCommand("select time from bus_detail where busno=@bno", con); cmd1.Parameters.Add("@bno", SqlDbType.VarChar); cmd1.Parameters["@bno"].Value = busno; SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); if (dr.Read()) { Label4.Text = dr.GetValue(0).ToString(); } con.Close(); } else { Label4.Text = "";

Page 73: Bus Reservation Srs

} GridView1.SelectedIndex = -1; }}

For Administrator Home Page :

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class HomeForAdmin : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); DataSet ds; SqlDataAdapter da; DataTable dt; protected void Page_Load(object sender, EventArgs e) {

Page 74: Bus Reservation Srs

if (Session["un"] == null) { Response.Redirect("Login.aspx"); } else { Session["un"] = "Administrator"; da = new SqlDataAdapter("select busno from Bus_detail", con); ds = new DataSet(); da.Fill(ds, "Bus1"); dt = ds.Tables["Bus1"]; int l = dt.Rows.Count; Label3.Text = l.ToString(); string date = DateTime.Today.ToShortDateString(); da = new SqlDataAdapter("select date from Bus_detail where date = '" + date + "'", con); ds = new DataSet(); da.Fill(ds, "Bus4"); dt = ds.Tables["Bus4"]; l = dt.Rows.Count; Label5.Text = l.ToString(); da = new SqlDataAdapter("select username from user_info", con); ds = new DataSet(); da.Fill(ds, "Bus2"); dt = ds.Tables["Bus2"]; l = dt.Rows.Count; Label2.Text = l.ToString(); da = new SqlDataAdapter("select email from feedback_list", con);

Page 75: Bus Reservation Srs

ds = new DataSet(); da.Fill(ds, "Bus3"); dt = ds.Tables["Bus3"]; l = dt.Rows.Count; Label4.Text = l.ToString(); } }}

For Add Bus Page :

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class AddBus : System.Web.UI.Page{ static int i = -1; SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False");

Page 76: Bus Reservation Srs

protected void Page_Load(object sender, EventArgs e) { TextBox1.Focus(); } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { if (TextBox1.Text == "" || TextBox2.Text == "" || TextBox3.Text == "" || TextBox4.Text == "" || TextBox6.Text == "" || TextBox7.Text == "" || TextBox8.Text == "" || TextBox5.Text == "" || TextBox9.Text == "") { Label2.Text = "PLEASE ENTER ALL THE DETAILS"; return; } SqlCommand cmd2 = new SqlCommand("select busno from bus_detail", con); SqlDataReader dr; con.Open(); dr = cmd2.ExecuteReader(); bool flag = false; while (dr.Read()) { if (dr.GetValue(0).ToString() == TextBox2.Text) { flag = true; break; }

}

Page 77: Bus Reservation Srs

con.Close(); if (flag == false) { string date=DateTime.Now.ToShortDateString(); //for bus details SqlCommand cmd1 = new SqlCommand("insert into bus_detail (travels,busno,source,destination,date,time,category,amount,kilometers,mo,tu,we,th,fr,sa,su) values(@T,@V,@S,@D,@DT,@DR,@C,@F,@K,@MO,@TU,@WE,@TH,@FR,@SA,@SU)", con); cmd1.Parameters.Add("@T", SqlDbType.VarChar); cmd1.Parameters.Add("@V", SqlDbType.VarChar); cmd1.Parameters.Add("@S", SqlDbType.VarChar); cmd1.Parameters.Add("@D", SqlDbType.VarChar); cmd1.Parameters.Add("@DT", SqlDbType.VarChar); cmd1.Parameters.Add("@DR", SqlDbType.VarChar); cmd1.Parameters.Add("@C", SqlDbType.VarChar); cmd1.Parameters.Add("@F", SqlDbType.Int); cmd1.Parameters.Add("@K", SqlDbType.Int); cmd1.Parameters.Add("@MO", SqlDbType.VarChar); cmd1.Parameters.Add("@TU", SqlDbType.VarChar); cmd1.Parameters.Add("@WE", SqlDbType.VarChar); cmd1.Parameters.Add("@TH", SqlDbType.VarChar); cmd1.Parameters.Add("@FR", SqlDbType.VarChar); cmd1.Parameters.Add("@SA", SqlDbType.VarChar); cmd1.Parameters.Add("@SU", SqlDbType.VarChar);

cmd1.Parameters["@T"].Value = TextBox1.Text.ToUpper();

Page 78: Bus Reservation Srs

cmd1.Parameters["@V"].Value = TextBox2.Text.ToUpper(); cmd1.Parameters["@S"].Value = TextBox3.Text.ToUpper(); cmd1.Parameters["@D"].Value = TextBox4.Text.ToUpper(); cmd1.Parameters["@DT"].Value = date; cmd1.Parameters["@DR"].Value = TextBox5.Text.ToUpper(); cmd1.Parameters["@C"].Value = TextBox6.Text; cmd1.Parameters["@F"].Value = float.Parse(TextBox7.Text); cmd1.Parameters["@K"].Value = int.Parse(TextBox8.Text); if (CheckBox1.Checked == true) { cmd1.Parameters["@MO"].Value = "Y"; } else { cmd1.Parameters["@MO"].Value = "N"; } if (CheckBox2.Checked == true) { cmd1.Parameters["@TU"].Value = "Y"; } else { cmd1.Parameters["@TU"].Value = "N"; } if (CheckBox3.Checked == true)

Page 79: Bus Reservation Srs

{ cmd1.Parameters["@WE"].Value = "Y"; } else { cmd1.Parameters["@WE"].Value = "N"; } if (CheckBox4.Checked == true) { cmd1.Parameters["@TH"].Value = "Y"; } else { cmd1.Parameters["@TH"].Value = "N"; } if (CheckBox5.Checked == true) { cmd1.Parameters["@FR"].Value = "Y"; } else { cmd1.Parameters["@FR"].Value = "N"; } if (CheckBox6.Checked == true) { cmd1.Parameters["@SA"].Value = "Y"; } else { cmd1.Parameters["@SA"].Value = "N"; }

Page 80: Bus Reservation Srs

if (CheckBox7.Checked == true) { cmd1.Parameters["@SU"].Value = "Y"; } else { cmd1.Parameters["@SU"].Value = "N"; } con.Open(); int n = cmd1.ExecuteNonQuery(); con.Close();

//for bus status SqlCommand cmd3 = new SqlCommand("insert into status (busno,source,category,totalseat,availableseat) values(@V,@S,@C,@TO,@AV)", con); cmd3.Parameters.Add("@V", SqlDbType.VarChar); cmd3.Parameters.Add("@S", SqlDbType.VarChar); cmd3.Parameters.Add("@C", SqlDbType.VarChar); cmd3.Parameters.Add("@TO", SqlDbType.Int); cmd3.Parameters.Add("@AV", SqlDbType.Int); cmd3.Parameters["@V"].Value = TextBox2.Text.ToUpper(); cmd3.Parameters["@S"].Value = TextBox3.Text.ToUpper(); cmd3.Parameters["@C"].Value = TextBox6.Text; cmd3.Parameters["@TO"].Value = int.Parse(TextBox9.Text); cmd3.Parameters["@AV"].Value = int.Parse(TextBox9.Text); con.Open();

Page 81: Bus Reservation Srs

int n1 = cmd3.ExecuteNonQuery(); Label2.Text = n1 + "Rows Inserted"; con.Close(); TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; TextBox5.Text = ""; TextBox6.Text = ""; TextBox7.Text = ""; TextBox8.Text = ""; TextBox9.Text = ""; CheckBox1.Checked = false; CheckBox2.Checked = false; CheckBox3.Checked = false; CheckBox4.Checked = false; CheckBox5.Checked = false; CheckBox6.Checked = false; CheckBox7.Checked = false; } else { Label2.Text = "DUPLICATE BUS ID";

} } protected void LinkButton3_Click(object sender, EventArgs e) { Response.Redirect("HomeForAdmin.aspx"); }

Page 82: Bus Reservation Srs

protected void Button1_Click(object sender, EventArgs e) { Session["image"] = i++; string filename = FileUpload1.FileName; FileUpload1.SaveAs(Server.MapPath("~/Images/Bus Images/") + filename); Label3.Text = "Upload status: File uploaded!"; }}

For Delete Bus :

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class DeleteBus : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False");

Page 83: Bus Reservation Srs

SqlDataAdapter da; DataSet ds; DataTable dt; SqlCommand cmd1; protected void Page_Load(object sender, EventArgs e) { GridView1.SelectedIndex = -1; Label6.Text = ""; Label7.Text = ""; Label8.Text = ""; Label3.Text = ""; Label4.Text = ""; Label5.Text = ""; } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { GridView1.Visible = false; DropDownList2.Items.Clear(); string s = DropDownList1.SelectedValue.ToString(); Label2.Text = DropDownList1.SelectedValue.ToString(); DropDownList2.Items.Add("Select " + Label2.Text); if (s == "Bus Number") { cmd1 = new SqlCommand("select busno from bus_detail", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); while (dr.Read())

Page 84: Bus Reservation Srs

{ DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } if (s == "Travels") { cmd1 = new SqlCommand("select distinct travels from bus_detail", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); while (dr.Read()) { DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } if (s == "Source") { cmd1 = new SqlCommand("select distinct source from bus_detail", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); while (dr.Read()) { DropDownList2.Items.Add(dr.GetValue(0).ToString()); }

Page 85: Bus Reservation Srs

con.Close(); } if (s == "Destination") { cmd1 = new SqlCommand("select distinct destination from bus_detail", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); while (dr.Read()) { DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } if (s == "Time") { cmd1 = new SqlCommand("select distinct time from bus_detail", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); while (dr.Read()) { DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } if (s == "Category") {

Page 86: Bus Reservation Srs

cmd1 = new SqlCommand("select distinct category from bus_detail", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); while (dr.Read()) { DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } if (s == "Weekdays") { DropDownList2.Items.Add("Monday"); DropDownList2.Items.Add("Tuesday"); DropDownList2.Items.Add("Wednesday"); DropDownList2.Items.Add("Thursday"); DropDownList2.Items.Add("Friday"); DropDownList2.Items.Add("Saturday"); DropDownList2.Items.Add("Sunday"); } } protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { string s = DropDownList1.SelectedValue.ToString(); string s1; if (s == "Bus Number") { GridView1.Visible = true;

Page 87: Bus Reservation Srs

s1 = DropDownList2.SelectedItem.ToString(); da = new SqlDataAdapter("select busno from bus_detail where busno='" + s1 + "'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s == "Travels") { GridView1.Visible = true; s1 = DropDownList2.SelectedItem.ToString(); da = new SqlDataAdapter("select busno from bus_detail where travels='" + s1 + "'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s == "Source") { GridView1.Visible = true; s1 = DropDownList2.SelectedItem.ToString(); da = new SqlDataAdapter("select busno from bus_detail where source='" + s1 + "'", con); ds = new DataSet(); da.Fill(ds, "bus1");

Page 88: Bus Reservation Srs

Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s == "Destination") { GridView1.Visible = true; s1 = DropDownList2.SelectedItem.ToString(); da = new SqlDataAdapter("select busno from bus_detail where destination='" + s1 + "'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s == "Time") { GridView1.Visible = true; s1 = DropDownList2.SelectedItem.ToString(); da = new SqlDataAdapter("select busno from bus_detail where time='" + s1 + "'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); }

Page 89: Bus Reservation Srs

if (s == "Category") { GridView1.Visible = true; s1 = DropDownList2.SelectedItem.ToString(); da = new SqlDataAdapter("select busno from bus_detail where category='" + s1 + "'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s == "Weekdays") { s1 = DropDownList2.SelectedItem.ToString(); if (s1 == "Monday") { GridView1.Visible = true; da = new SqlDataAdapter("select busno from bus_detail where Mo='Y'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s1 == "Tuesday") { GridView1.Visible = true;

Page 90: Bus Reservation Srs

da = new SqlDataAdapter("select busno from bus_detail where Tu='Y'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s1 == "Wednesday") { GridView1.Visible = true; da = new SqlDataAdapter("select busno from bus_detail where We='Y'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s1 == "Thursday") { GridView1.Visible = true; da = new SqlDataAdapter("select busno from bus_detail where Th='Y'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0];

Page 91: Bus Reservation Srs

GridView1.DataBind(); } if (s1 == "Friday") { GridView1.Visible = true; da = new SqlDataAdapter("select busno from bus_detail where Fr='Y'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s1 == "Saturday") { GridView1.Visible = true; da = new SqlDataAdapter("select busno from bus_detail where Sa='Y'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s1 == "Sunday") { GridView1.Visible = true; da = new SqlDataAdapter("select busno from bus_detail where Su='Y'", con);

Page 92: Bus Reservation Srs

ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } } } protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { int index = GridView1.SelectedIndex; if (index != -1) { Label6.Text = "Bus Number :"; Label7.Text = "Total Seat :"; Label8.Text = "Available Seat :"; GridViewRow row = GridView1.Rows[index]; Label l; l = (Label)row.FindControl("Label1"); string busno = l.Text.Trim(); Label3.Text = busno; SqlCommand cmd1 = new SqlCommand("select busno,totalseat,availableseat from status where busno=@bno", con); cmd1.Parameters.Add("@bno", SqlDbType.VarChar); cmd1.Parameters["@bno"].Value = busno; SqlDataReader dr; con.Open();

Page 93: Bus Reservation Srs

dr = cmd1.ExecuteReader(); if (dr.Read()) { Label3.Text = dr.GetValue(0).ToString(); Label4.Text = dr.GetValue(1).ToString(); Label5.Text = dr.GetValue(2).ToString(); } con.Close(); } else { Label6.Text = ""; Label7.Text = ""; Label8.Text = ""; Label3.Text = ""; Label4.Text = ""; Label5.Text = ""; } } protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { SqlDataAdapter da1; int index = e.RowIndex; dt = ((DataSet)Session["ds"]).Tables[0]; dt.Rows[index].Delete(); da1 = (SqlDataAdapter)Session["da"]; SqlCommandBuilder scb = new SqlCommandBuilder(da1); da1.Update(dt); string s = DropDownList1.SelectedValue.ToString();

Page 94: Bus Reservation Srs

string s1; if (s == "Bus Number") { GridView1.Visible = true; s1 = DropDownList2.SelectedItem.ToString(); da = new SqlDataAdapter("select busno from bus_detail where busno='" + s1 + "'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s == "Travels") { GridView1.Visible = true; s1 = DropDownList2.SelectedItem.ToString(); da = new SqlDataAdapter("select busno from bus_detail where travels='" + s1 + "'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s == "Source") { GridView1.Visible = true; s1 = DropDownList2.SelectedItem.ToString();

Page 95: Bus Reservation Srs

da = new SqlDataAdapter("select busno from bus_detail where source='" + s1 + "'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s == "Destination") { GridView1.Visible = true; s1 = DropDownList2.SelectedItem.ToString(); da = new SqlDataAdapter("select busno from bus_detail where destination='" + s1 + "'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s == "Time") { GridView1.Visible = true; s1 = DropDownList2.SelectedItem.ToString(); da = new SqlDataAdapter("select busno from bus_detail where time='" + s1 + "'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds;

Page 96: Bus Reservation Srs

Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s == "Category") { GridView1.Visible = true; s1 = DropDownList2.SelectedItem.ToString(); da = new SqlDataAdapter("select busno from bus_detail where category='" + s1 + "'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s == "Weekdays") { s1 = DropDownList2.SelectedItem.ToString(); if (s1 == "Monday") { GridView1.Visible = true; da = new SqlDataAdapter("select busno from bus_detail where Mo='Y'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind();

Page 97: Bus Reservation Srs

} if (s1 == "Tuesday") { GridView1.Visible = true; da = new SqlDataAdapter("select busno from bus_detail where Tu='Y'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s1 == "Wednesday") { GridView1.Visible = true; da = new SqlDataAdapter("select busno from bus_detail where We='Y'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s1 == "Thursday") { GridView1.Visible = true; da = new SqlDataAdapter("select busno from bus_detail where Th='Y'", con); ds = new DataSet();

Page 98: Bus Reservation Srs

da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s1 == "Friday") { GridView1.Visible = true; da = new SqlDataAdapter("select busno from bus_detail where Fr='Y'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s1 == "Saturday") { GridView1.Visible = true; da = new SqlDataAdapter("select busno from bus_detail where Sa='Y'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s1 == "Sunday")

Page 99: Bus Reservation Srs

{ GridView1.Visible = true; da = new SqlDataAdapter("select busno from bus_detail where Su='Y'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } } } protected void LinkButton3_Click(object sender, EventArgs e) { Response.Redirect("HomeForAdmin.aspx"); }}

For Update Bus :

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;

Page 100: Bus Reservation Srs

using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class UpdateBus : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); SqlDataAdapter da; DataSet ds; DataTable dt; SqlCommand cmd1; protected void Page_Load(object sender, EventArgs e) { GridView1.SelectedIndex = -1; } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { GridView1.Visible = false; DropDownList2.Items.Clear(); string s = DropDownList1.SelectedValue.ToString(); Label3.Text = DropDownList1.SelectedValue.ToString(); DropDownList2.Items.Add("Select " + Label3.Text); if (s == "Bus Number") { cmd1 = new SqlCommand("select busno from bus_detail", con);

Page 101: Bus Reservation Srs

SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); while (dr.Read()) { DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } if (s == "Travels") { cmd1 = new SqlCommand("select distinct travels from bus_detail", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); while (dr.Read()) { DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } if (s == "Source") { cmd1 = new SqlCommand("select distinct source from bus_detail", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); while (dr.Read())

Page 102: Bus Reservation Srs

{ DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } if (s == "Destination") { cmd1 = new SqlCommand("select distinct destination from bus_detail", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); while (dr.Read()) { DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } if (s == "Time") { cmd1 = new SqlCommand("select distinct time from bus_detail", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); while (dr.Read()) { DropDownList2.Items.Add(dr.GetValue(0).ToString()); }

Page 103: Bus Reservation Srs

con.Close(); } if (s == "Category") { cmd1 = new SqlCommand("select distinct category from bus_detail", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); while (dr.Read()) { DropDownList2.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } if (s == "Weekdays") { DropDownList2.Items.Add("Monday"); DropDownList2.Items.Add("Tuesday"); DropDownList2.Items.Add("Wednesday"); DropDownList2.Items.Add("Thursday"); DropDownList2.Items.Add("Friday"); DropDownList2.Items.Add("Saturday"); DropDownList2.Items.Add("Sunday"); } } protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { Get_Data();

Page 104: Bus Reservation Srs

} protected void Get_Data() { string s = DropDownList1.SelectedValue.ToString(); string s1; if (s == "Bus Number") { GridView1.Visible = true; s1 = DropDownList2.SelectedItem.ToString(); da = new SqlDataAdapter("select travels,busno,source,destination,time,amount from bus_detail where busno='" + s1 + "'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; Load_Data(); } if (s == "Travels") { GridView1.Visible = true; s1 = DropDownList2.SelectedItem.ToString(); da = new SqlDataAdapter("select travels,busno,source,destination,time,amount from bus_detail where travels='" + s1 + "'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; Load_Data(); }

Page 105: Bus Reservation Srs

if (s == "Source") { GridView1.Visible = true; s1 = DropDownList2.SelectedItem.ToString(); da = new SqlDataAdapter("select travels,busno,source,destination,time,amount from bus_detail where source='" + s1 + "'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; Load_Data(); } if (s == "Destination") { GridView1.Visible = true; s1 = DropDownList2.SelectedItem.ToString(); da = new SqlDataAdapter("select travels,busno,source,destination,time,amount from bus_detail where destination='" + s1 + "'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; Load_Data(); } if (s == "Time") { GridView1.Visible = true; s1 = DropDownList2.SelectedItem.ToString();

Page 106: Bus Reservation Srs

da = new SqlDataAdapter("select travels,busno,source,destination,time,amount from bus_detail where time='" + s1 + "'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; Load_Data(); } if (s == "Category") { GridView1.Visible = true; s1 = DropDownList2.SelectedItem.ToString(); da = new SqlDataAdapter("select travels,busno,source,destination,time,amount from bus_detail where category='" + s1 + "'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; Load_Data(); } if (s == "Weekdays") { s1 = DropDownList2.SelectedItem.ToString(); if (s1 == "Monday") { GridView1.Visible = true; da = new SqlDataAdapter("select travels,busno,source,destination,time,amount from bus_detail where Mo='Y'", con);

Page 107: Bus Reservation Srs

ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; Load_Data(); } if (s1 == "Tuesday") { GridView1.Visible = true; da = new SqlDataAdapter("select travels,busno,source,destination,time,amount from bus_detail where Tu='Y'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s1 == "Wednesday") { GridView1.Visible = true; da = new SqlDataAdapter("select travels,busno,source,destination,time,amount from bus_detail where We='Y'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind();

Page 108: Bus Reservation Srs

} if (s1 == "Thursday") { GridView1.Visible = true; da = new SqlDataAdapter("select travels,busno,source,destination,time,amount from bus_detail where Th='Y'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } if (s1 == "Friday") { GridView1.Visible = true; da = new SqlDataAdapter("select travels,busno,source,destination,time,amount from bus_detail where Fr='Y'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; Load_Data(); } if (s1 == "Saturday") { GridView1.Visible = true;

Page 109: Bus Reservation Srs

da = new SqlDataAdapter("select travels,busno,source,destination,time,amount from bus_detail where Sa='Y'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; Load_Data(); } if (s1 == "Sunday") { GridView1.Visible = true; da = new SqlDataAdapter("select travels,busno,source,destination,time,amount from bus_detail where Su='Y'", con); ds = new DataSet(); da.Fill(ds, "bus1"); Session["ds"] = ds; Session["da"] = da; Load_Data(); } } } protected void Load_Data() { GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) {

Page 110: Bus Reservation Srs

GridView1.EditIndex = e.NewEditIndex; GridView1.DataSource = ((DataSet)Session["ds"]).Tables[0]; GridView1.DataBind(); }

protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { GridView1.EditIndex = -1; GridView1.DataSource = ((DataSet)Session["ds"]).Tables[0]; GridView1.DataBind(); }

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { int index = e.RowIndex; GridViewRow row = GridView1.Rows[index]; TextBox t1; t1 = (TextBox)(row.FindControl("TextBox1")); string s1 = t1.Text; TextBox t2; t2 = (TextBox)(row.FindControl("TextBox3")); string s2 = t2.Text; TextBox t3; t3 = (TextBox)(row.FindControl("TextBox4")); string s3 = t3.Text; TextBox t4; t4 = (TextBox)(row.FindControl("TextBox5"));

Page 111: Bus Reservation Srs

string s4 = t4.Text; TextBox t5; t5 = (TextBox)(row.FindControl("TextBox6")); float p = float.Parse(t5.Text);

dt = ((DataSet)Session["ds"]).Tables[0]; dt.Rows[index][0] = s1.ToUpper(); dt.Rows[index][2] = s2.ToUpper(); dt.Rows[index][3] = s3.ToUpper(); dt.Rows[index][4] = s4.ToUpper(); dt.Rows[index][5] = p;

SqlDataAdapter da1; da1 = (SqlDataAdapter)Session["da"]; SqlCommandBuilder scb = new SqlCommandBuilder(da1); da1.Update(dt); Get_Data(); GridView1.EditIndex = -1; Load_Data(); } protected void LinkButton3_Click(object sender, EventArgs e) { Response.Redirect("HomeForAdmin.aspx"); }}

For Bus List Page :

using System;

Page 112: Bus Reservation Srs

using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class BusLists : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); if (Session["un"] != "Administrator") { Response.Redirect("Login.aspx"); } else { SqlDataAdapter da = new SqlDataAdapter("select travels,busno,source,destination,time,category,amount,mo,tu,we,th,fr,sa,su from Bus_Detail", con); DataSet ds = new DataSet(); da.Fill(ds, "Bus1");

Page 113: Bus Reservation Srs

DataTable dt = ds.Tables["Bus1"]; GridView1.DataSource = ds.Tables["Bus1"]; GridView1.DataBind(); } }}

For Today’s Bus :

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class TodayBus : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); SqlDataAdapter da; DataSet ds, ds1; DataTable dt;

Page 114: Bus Reservation Srs

protected void Page_Load(object sender, EventArgs e) { GridView1.SelectedIndex = -1; string date = DateTime.Today.ToShortDateString(); da = new SqlDataAdapter("select travels,busno,source,destination,time,category,amount from bus_detail where date = '" + date + "'", con); ds = new DataSet(); da.Fill(ds, "detail"); dt = ds.Tables["detail"]; Session["ds"] = ds; if (dt.Rows.Count == 0) { Label3.Text = "Oops! No Service Available for your search"; GridView1.DataSource = null; GridView1.Visible = false; GridView1.DataBind(); return; } else { GridView1.Visible = true; Label3.Text = ""; GridView1.DataSource = ((DataSet)Session["ds"]).Tables["detail"]; GridView1.DataBind(); } }}

Page 115: Bus Reservation Srs

For Search User Page :

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class SearchUser : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); SqlDataAdapter da; DataSet ds, ds1; DataTable dt; SqlCommand cmd1; protected void Page_Load(object sender, EventArgs e) { GridView1.Visible = false; if (IsPostBack == false) {

Page 116: Bus Reservation Srs

cmd1 = new SqlCommand("select distinct name from User_info", con); SqlDataReader dr; con.Open(); dr = cmd1.ExecuteReader(); while (dr.Read()) { DropDownList1.Items.Add(dr.GetValue(0).ToString()); } con.Close(); } } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { GridView1.Visible = true; string name=DropDownList1.SelectedValue.ToString(); if (DropDownList1.SelectedIndex == 1) { da = new SqlDataAdapter("select name,username,mobileno,secques,secans from user_info ", con); } else { da = new SqlDataAdapter("select name,username,mobileno,secques,secans from user_info where name = '" + name + "'", con); } ds = new DataSet();

Page 117: Bus Reservation Srs

da.Fill(ds, "detail"); dt = ds.Tables["detail"]; GridView1.DataSource = ds.Tables["detail"]; GridView1.DataBind(); }}

For Feedback List :

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class FeedbackList : System.Web.UI.Page{ SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); protected void Page_Load(object sender, EventArgs e) { if (Session["un"] != "Administrator")

Page 118: Bus Reservation Srs

{ Response.Redirect("Login.aspx"); } else { SqlDataAdapter da = new SqlDataAdapter("select name,email,phone,subject,comment from feedback_list", con); DataSet ds = new DataSet(); da.Fill(ds, "Feed"); DataTable dt = ds.Tables["Feed"]; GridView1.DataSource = ds.Tables["Feed"]; GridView1.DataBind(); } }}

For About Us :

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;

Page 119: Bus Reservation Srs

using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;

public partial class AboutUs : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { }}

For Contact Us Page :

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;

public partial class ContactUs : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) {

Page 120: Bus Reservation Srs

}}

For Feedback Page :

using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;

public partial class Feedback : System.Web.UI.Page{

SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=Final;Integrated Security=True;Pooling=False"); DataTable dt; SqlDataAdapter da; DataSet ds; protected void Page_Load(object sender, EventArgs e) {

Page 121: Bus Reservation Srs

da = new SqlDataAdapter("select Name,email,phone,subject,comment from Feedback_list", con); ds = new DataSet(); da.Fill(ds, "User"); dt = ds.Tables["User"]; Label2.Text = ""; Label3.Text = ""; Label4.Text = ""; } protected void Button1_Click(object sender, EventArgs e) { if (TextBox1.Text == "") { Label2.Text = "Enter Your Name"; return; } if (TextBox2.Text == "") { Label3.Text = "Enter Your EmailId"; return; } if (TextBox3.Text == "") { Label4.Text = "Enter your phone Number"; return; } DataRow dr = dt.NewRow(); dr[0] = TextBox1.Text; dr[1] = TextBox2.Text; dr[2] = TextBox3.Text;

Page 122: Bus Reservation Srs

dr[3] = TextBox4.Text; dr[4] = TextBox5.Text; dt.Rows.Add(dr); SqlCommandBuilder scb = new SqlCommandBuilder(da); da.Update(ds.Tables["User"]); TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; TextBox5.Text = ""; Label5.Text = "Thank You For Your Feedback, we will contact you soon"; }}

Page 123: Bus Reservation Srs

Home Page

Search Page

Todays Bus

Log-In

Log-In

One can search for buses filling the required fields.

Displays the buses running on the particular day.

Page 124: Bus Reservation Srs

Register

Passenger Info

Allows users to log in.

Page 125: Bus Reservation Srs

Payment Mode

Ticket

A new user can enter his details & register.

After booking the tickets one needs to fill in this.

Page 126: Bus Reservation Srs

Change Passwd

Feedback Form

Allows user to choose different payment modes.

Generated Ticket for the user.

Page 127: Bus Reservation Srs

A user can change his password.

A user can provide is feedback through this.

Page 128: Bus Reservation Srs

Cancel Ticket

Admin Home

One Can cancel the ticket using this.

Administrator Home Page.

Page 129: Bus Reservation Srs

Add Bus

Delete Bus

Administrator can add a bus.

Administrator can delete a bus.

Page 130: Bus Reservation Srs

Bus List

Update Bus

Status

User Info

Administrator can view all the bus details.

Administrator can update bus details.

Page 131: Bus Reservation Srs

Feedback List

About Us

Administrator can view the status of buses running.

Administrator can view details of the Users.

Page 132: Bus Reservation Srs

FAQ

Contact Us

Administrator can view all the feedbacks received.

Page about the website.

Page 133: Bus Reservation Srs

Frequently Asked Questions

Page 134: Bus Reservation Srs

This software provides online bus reservation facility and generates ticket for any user who books a seat. It maintains a record of all the users, buses and administrator.

There are provisions of improvement like

. Adding options for bus hire.

Adding Agents.

Select Seat option.

Having different depature time for a bus running on

different days of a week.

Option for generating report containing average no.

of bookings per week or per month.

Page 135: Bus Reservation Srs

Reference Books:-

Websites:-

Learning C# 2005 By Jesse Liberty,Brian Mac Donald. Programming ASP.NET By Jesse Liberty, Dan Hurwitz.

www.w3school.com www.dotnetspider.com www.google.com