-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexchange2.aspx.cs
69 lines (66 loc) · 2.34 KB
/
exchange2.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class exchange2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Interaction.redirIfNotLoggedIn();
if (!(Interaction.LoggedInUser is Agent))
{
Interaction.redirUnauthorize();
}
if (!Page.IsPostBack)
{
Ticket t1 = (Ticket)Session["firstExchange"];
Ticket t2 = (Ticket)Session["secondExchange"];
if (t1 == null || t2 == null)
{
Response.Write("need two tickets to exchange");
Response.End();
}
updateTicketDisplay(t1, t2);
}
}
protected void exchangeBtn_Click(object sender, EventArgs e)
{
if (!(Interaction.LoggedInUser is Agent))
{
Interaction.redirUnauthorize();
}
if (!Page.IsValid) return;
Agent a = (Agent)Interaction.LoggedInUser;
try
{
Ticket first = (Ticket)Session["firstExchange"];
Ticket second = (Ticket)Session["secondExchange"];
a.exchangeFlight(first.TheUser, second.TheUser);
Interaction.setSuccessMessage(Literal1, "exchange successful");
updateTicketDisplay(first, second);
}
catch (Exception ex)
{
Interaction.setFailureMessage(Literal1, ex.Message);
}
}
private void updateTicketDisplay(Ticket t1,Ticket t2)
{
ticketNo.Text = t1.TicketNumber + "";
userName.Text = t1.TheUser.UserName;
flightNo.Text = t1.TheFlight.FlightNumber + "";
ori.Text = t1.TheFlight.Origin;
dst.Text = t1.TheFlight.Destination;
deptdt.Text = t1.TheFlight.DepartureDateTime.ToString();
arrivdt.Text = t1.TheFlight.ArrivalDateTime.ToString();
ticketNo0.Text = t2.TicketNumber + "";
userName0.Text = t2.TheUser.UserName;
flightNo0.Text = t2.TheFlight.FlightNumber + "";
ori0.Text = t2.TheFlight.Origin;
dst0.Text = t2.TheFlight.Destination;
deptdt0.Text = t2.TheFlight.DepartureDateTime.ToString();
arrivdt0.Text = t2.TheFlight.ArrivalDateTime.ToString();
}
}