-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsearchandbook.aspx.cs
181 lines (175 loc) · 6.95 KB
/
searchandbook.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using System.Diagnostics;
public partial class mainmenu : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Interaction.redirIfNotLoggedIn();
if (!Page.IsPostBack) Session["flightEdit"] = null;
if (Request["removesuccess"] == "1")
{
Interaction.setSuccessMessage(Literal3, "flight removed");
}
else
{
Literal3.Text = "";
}
if (Request["editremove"] != "1")
{
editBtn.Visible = false;
removeBtn.Visible = false;
}
else if (!(Interaction.LoggedInUser is Admin))
{
Interaction.redirUnauthorize();
}
if (!(Interaction.LoggedInUser is Admin))
{
editBtn.Enabled = false;
removeBtn.Enabled = false;
}
//GridView1.DataSourceID = "";
deptDateTxt.Attributes.Add("readonly", "readonly");
arrivDateTxt.Attributes.Add("readonly", "readonly");
}
protected void bookBtn_Click(object sender, EventArgs e)
{
if (GridView1.SelectedIndex < 0)
{
selectValidate.IsValid = false;
return;
}
if (!Page.IsValid)
{
return;
}
else
{
GridViewRow row = GridView1.SelectedRow;
//Response.Write(string.Format("{0},{1},{2},{3},{4},{5}", row.Cells[0].Text, row.Cells[1].Text, row.Cells[2].Text, row.Cells[3].Text,
// row.Cells[4].Text,row.Cells[5].Text));
//GridViewRow h = GridView1.HeaderRow;
Flight f = new Flight(Convert.ToInt32(row.Cells[1].Text), row.Cells[2].Text,
row.Cells[3].Text, Convert.ToDateTime(row.Cells[4].Text), Convert.ToDateTime(row.Cells[5].Text));
try
{
Interaction.LoggedInUser.book(f);
Interaction.setSuccessMessage(Literal1, "Book Successful");
}
catch (Exception ex)
{
Interaction.setFailureMessage(Literal1, ex.Message);
}
GridView1.DataBind();
//Ticket t = new Ticket(Interaction.LoggedInUser, f);
}
}
//protected int getCellIndex(GridViewRow headerRow, String ColumnName)
//{
// for (int i = 0; i < headerRow.Cells.Count; i++)
// {
// if (headerRow.Cells[i].Text.ToLower().Equals(ColumnName.ToLower()))
// return i;
// }
// return -1;
//}
protected void searchBtn_Click(object sender, EventArgs e)
{
if (!Page.IsValid) return;
String DateTimeFormat = "MM/dd/yyyy";
DateTime deptdate = DateTime.ParseExact(deptDateTxt.Text, DateTimeFormat, DateTimeFormatInfo.InvariantInfo);
//DateTime deptdtime = new DateTime(deptdate.Year, deptdate.Month, deptdate.Day, Convert.ToInt32(hour1.SelectedValue) + Convert.ToInt32(ampm1.SelectedValue),
// Convert.ToInt32(minute1.SelectedValue), 0);
DateTime deptdate2=new DateTime();
if(CheckBox1.Checked) deptdate2 = DateTime.ParseExact(arrivDateTxt.Text, DateTimeFormat, DateTimeFormatInfo.InvariantInfo);
//DateTime arrivaldtime = new DateTime(arrivaldate.Year, arrivaldate.Month, arrivaldate.Day, Convert.ToInt32(hour2.SelectedValue) + Convert.ToInt32(ampm2.SelectedValue),
// Convert.ToInt32(minute2.SelectedValue), 0);
ObjectDataSource1.SelectParameters.Clear();
ObjectDataSource1.SelectParameters.Add("ori", originTxt.Text);
ObjectDataSource1.SelectParameters.Add("dst", destTxt.Text);
//ObjectDataSource1.SelectParameters.Add("deptdt", TypeCode.DateTime, deptdtime.ToString());
//ObjectDataSource1.SelectParameters.Add("arridt", TypeCode.DateTime, arrivaldtime.ToString());
ObjectDataSource1.SelectParameters.Add("deptdt", TypeCode.DateTime, deptdate.ToString());
if(CheckBox1.Checked) ObjectDataSource1.SelectParameters.Add("deptdt2", TypeCode.DateTime, deptdate2.ToString());
GridView1.DataSourceID = "ObjectDataSource1";
GridView1.DataBind();
if (GridView1.Rows.Count <= 0)
{
Interaction.setFailureMessage(Literal2, "no result found");
Panel2.Visible = false;
}
else
{
Panel2.Visible = true;
}
}
//protected void ObjectDataSource1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
//{
// User u = Interaction.LoggedInUser;
// e.InputParameters.Add("account", dealer.Account);
//}
protected void ObjectDataSource1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{
}
protected void ObjectDataSource1_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
{
e.ObjectInstance = Interaction.LoggedInUser;
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox1.Checked)
{
betweenPanel.Visible = true;
}
else
{
betweenPanel.Visible = false;
}
}
protected void editBtn_Click(object sender, EventArgs e)
{
if (GridView1.SelectedIndex < 0)
{
selectValidate.IsValid = false;
return;
}
if (!Page.IsValid)
{
return;
}
//GridView1.DataBind();
Session["flightEdit"]=new Flight(Convert.ToInt32(GridView1.SelectedRow.Cells[1].Text),GridView1.SelectedRow.Cells[2].Text,
GridView1.SelectedRow.Cells[3].Text, Convert.ToDateTime(GridView1.SelectedRow.Cells[4].Text), Convert.ToDateTime(GridView1.SelectedRow.Cells[5].Text));
Response.Redirect("editflight.aspx");
}
protected void removeBtn_Click(object sender, EventArgs e)
{
if (GridView1.SelectedIndex < 0)
{
selectValidate.IsValid = false;
return;
}
if (!Page.IsValid)
{
return;
}
Session["flightRemove"] = new Flight(Convert.ToInt32(GridView1.SelectedRow.Cells[1].Text), GridView1.SelectedRow.Cells[2].Text,
GridView1.SelectedRow.Cells[3].Text, Convert.ToDateTime(GridView1.SelectedRow.Cells[4].Text), Convert.ToDateTime(GridView1.SelectedRow.Cells[5].Text));
Response.Redirect("removeflight2.aspx");
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//if (GridView1.SelectedIndex<0) return;
//Debug.WriteLine(GridView1.SelectedIndex);
//Flight f = (Flight)GridView1.SelectedRow.DataItem;
//Session["flightEdit"] = f;
}
protected void ObjectDataSource1_ObjectCreated(object sender, ObjectDataSourceEventArgs e)
{
}
}