-
Notifications
You must be signed in to change notification settings - Fork 0
/
SeatDetails.aspx.cs
98 lines (92 loc) · 4.66 KB
/
SeatDetails.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace BusBookingProject
{
public partial class SeatDetails : System.Web.UI.Page
{
#region Global Variable
SqlConnection connString = new SqlConnection(ConfigurationManager.ConnectionStrings["OnlineBusBookingConnectionString"].ToString());
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
lblForm.Text = Convert.ToString(Request.QueryString["Origin"]);
lblTo.Text = Convert.ToString(Request.QueryString["Destination"]);
DateTime dtNEw =DateTime.ParseExact(Convert.ToString(Request.QueryString["TravelDate"]),"dd/MM/yyyy",null);
lbldate.Text = String.Format("{0:ddd,d MMM,yyyy}", dtNEw);
bingBoardigPoints();
string bookedSeatNo = "";
DataTable dt = getBookedSeat();
foreach(DataRow dr in dt.Rows)
{
bookedSeatNo+= Convert.ToString(dr["SeatNo"])+",";
}
Page.ClientScript.RegisterStartupScript(this.GetType(), "paramFN1", "getSeatLayout('" + Convert.ToInt32(Request.QueryString["Row"]) + "','" + Convert.ToInt32(Request.QueryString["Column"]) + "','" + bookedSeatNo + "','" + Convert.ToDecimal(Request.QueryString["Fare"]) + "');", true);
}
}
private void bingBoardigPoints()
{
DataTable dsGetData = new DataTable();
SqlCommand sqlCmd = new SqlCommand();
if (connString.State == ConnectionState.Closed)
{
connString.Open();
}
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.Parameters.AddWithValue("@BusID", Convert.ToInt32(Request.QueryString["BusID"]));
sqlCmd.CommandText = "ispGetBoardingPoints";
sqlCmd.Connection = connString;
SqlDataAdapter sda = new SqlDataAdapter(sqlCmd);
sda.Fill(dsGetData);
if(dsGetData.Rows.Count>0)
{
dsGetData.Columns.Add(new DataColumn("Value", System.Type.GetType("System.String"), "PlaceName + ' - ' + PlaceTime"));
ddlBoardingpoints.DataSource = dsGetData;
ddlBoardingpoints.DataTextField = "Value";
ddlBoardingpoints.DataValueField = "StandId";
ddlBoardingpoints.DataBind();
}
ddlBoardingpoints.Items.Insert(0, new ListItem("Select Boarding Points", "0"));
}
private DataTable getBookedSeat()
{
DataTable dt = new DataTable();
SqlCommand sqlCmd = new SqlCommand();
if (connString.State == ConnectionState.Closed)
{
connString.Open();
}
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.Parameters.AddWithValue("@BusID", Convert.ToInt32(Request.QueryString["BusID"]));
sqlCmd.Parameters.AddWithValue("@TravelDate", Convert.ToString(Request.QueryString["TravelDate"]));
sqlCmd.CommandText = "ispGetBookedSeatNo";
sqlCmd.Connection = connString;
SqlDataAdapter sda = new SqlDataAdapter(sqlCmd);
sda.Fill(dt);
return dt;
}
protected void btnPayment_Click(object sender, EventArgs e)
{
lblSelectedSeat.Text = Request.Form[hdnSeatNo.UniqueID];
lblPerSeat.Text = Request.Form[hdnFare.UniqueID];
if(Session["UserID"]!=null)
{
Response.Redirect("PassengerDetailsInfo.aspx?BusID=" + Request.QueryString["BusID"] + "&SeatNo=" + lblSelectedSeat.Text + "&TravelDate=" + Request.QueryString["TravelDate"] +
"&Origin=" + Request.QueryString["Origin"] + "&Destination=" + Request.QueryString["Destination"] + "&BoardingID=" + ddlBoardingpoints.SelectedValue + "&Fare=" + lblPerSeat.Text);
}
else
{
Response.Redirect("Login.aspx?BusID=" + Request.QueryString["BusID"] + "&SeatNo=" + lblSelectedSeat.Text + "&TravelDate=" + Request.QueryString["TravelDate"] +
"&Origin=" + Request.QueryString["Origin"] + "&Destination=" + Request.QueryString["Destination"] + "&BoardingID=" + ddlBoardingpoints.SelectedValue + "&Fare=" + lblPerSeat.Text);
}
}
}
}