-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfirmOrder.aspx.cs
152 lines (147 loc) · 6.5 KB
/
ConfirmOrder.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class ComfirmOrder : System.Web.UI.Page
{
private Dbc dbc = new Dbc();
protected static Table_Hotel hotel = new Table_Hotel();
protected static Table_Room room = new Table_Room();
protected static Table_HotelReservation reservation = new Table_HotelReservation();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
reservation = (Table_HotelReservation)Session["Reservation"];
if (reservation.Id != -1)
{
TextBox1.Text = reservation.name.Substring(0, reservation.name.IndexOf(".", 0));
TextBox2.Text = reservation.name.Substring(reservation.name.IndexOf(".", 0) + 1, reservation.name.Length - reservation.name.IndexOf(".", 0) - 1);
TextBox3.Text = reservation.PhoneNum.ToString();
TextBox5.Text = reservation.EmailAddress;
if (reservation.sex == "male")
DropDownList1.SelectedIndex = 0;
else
DropDownList1.SelectedIndex = 1;
}
//如果用户已经登陆则textbox1-5依次填入用户信息。
else if (Session["Customer"] != null)
{
Table_Customer customer = dbc.GetCustomer(Session["Customer"].ToString());
TextBox1.Text = customer.FirstName;
TextBox2.Text = customer.LastName;
TextBox3.Text = customer.PhoneNumber;
TextBox5.Text = customer.EmailAddress;
if (customer.Sex == "male")
DropDownList1.SelectedIndex = 0;
else
DropDownList1.SelectedIndex = 1;
TextBox1.Enabled = TextBox2.Enabled = TextBox3.Enabled = TextBox5.Enabled = false;
DropDownList1.Enabled = false;
}
//如果用户没有登陆,则textbook1-5为空
//加载右边订单信息
hotel = dbc.GetHotelById(reservation.HotelId);
room = dbc.GetRoomByHotelIdAndRoomType(reservation.HotelId, reservation.RoomType);
TimeSpan t=reservation.CheckOut-reservation.CheckIn;
//
Label10.Text = "$" + room.FullRate.ToString();
Label1.Text = t.Days.ToString();
Label2.Text = reservation.RoomNum.ToString();
Label3.Text = reservation.GuestNum.ToString();
Label4.Text = "$" + reservation.Value.ToString();
Label_cost.InnerText = "$" + reservation.Value.ToString();
Label5.Text = hotel.Name;
Label6.Text = hotel.Address;
Label7.Text = reservation.RoomType;
Label8.Text = reservation.CheckIn.ToString("yyyy/MM/dd");
Label9.Text = reservation.CheckOut.ToString("yyyy/MM/dd");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
//按下按钮清空联系人信息
TextBox1.Text = TextBox2.Text = TextBox3.Text = TextBox5.Text = String.Empty;
TextBox1.Enabled = TextBox2.Enabled = TextBox3.Enabled = TextBox5.Enabled = true;
DropDownList1.Enabled = true;
DropDownList1.SelectedIndex = 0;
}
protected void Button2_Click(object sender, EventArgs e)
{
if (Session["Customer"] != null)
{
if (TextBox1.Text == String.Empty || TextBox2.Text == String.Empty || TextBox3.Text == String.Empty || TextBox5.Text == String.Empty)
{
ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "updateScript", "alert('All fields must not be empty.')", true);
return;
}
try
{
reservation.name = TextBox1.Text +"."+ TextBox2.Text;
reservation.sex = DropDownList1.Text.ToString();
reservation.EmailAddress = TextBox5.Text.ToString();
reservation.PhoneNum = TextBox3.Text.ToString();
reservation.Customer = Session["Customer"].ToString();
Response.Redirect("PayMethod.aspx");
}
catch (Exception) { }
}
else
{
ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "updateScript", "alert('Login Required')", true);
return;
}
}
protected void Button3_Click(object sender, EventArgs e)
{
if (Session["Customer"] != null)
{
Table_Customer customer = dbc.GetCustomer(Session["Customer"].ToString());
TextBox1.Text = customer.FirstName;
TextBox2.Text = customer.LastName;
TextBox3.Text = customer.PhoneNumber;
TextBox5.Text = customer.EmailAddress;
if (customer.Sex == "male")
DropDownList1.SelectedIndex = 0;
else
DropDownList1.SelectedIndex = 1;
TextBox1.Enabled = TextBox2.Enabled = TextBox3.Enabled = TextBox5.Enabled = false;
DropDownList1.Enabled = false;
}
else
{
ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "updateScript", "alert('Login Required.')", true);
return;
}
}
protected void Button4_Click(object sender, EventArgs e)
{
if (Session["Customer"] != null)
{
if (TextBox1.Text == String.Empty || TextBox2.Text == String.Empty || TextBox3.Text == String.Empty || TextBox5.Text == String.Empty)
{
ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "updateScript", "alert('All fields must not be empty.')", true);
return;
}
try
{
reservation.name = TextBox1.Text + "." + TextBox2.Text;
reservation.sex = DropDownList1.Text.ToString();
reservation.PhoneNum = TextBox3.Text.ToString();
reservation.EmailAddress = TextBox5.Text.ToString();
reservation.Customer = Session["Customer"].ToString();
if (reservation.Id == -1)
dbc.AddHotelReservation(reservation);
Response.Redirect("Management.aspx");
}
catch (Exception) { }
}
else
{
ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "updateScript", "alert('Login Required')", true);
return;
}
}
}