温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:在线订票系统源码(毕业设计)
当前文件路径:TicketOnline/ReturningTicket.aspx.cs

1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
using System.Data.SqlClient; 12
13
14
public partial class ReturningTicket : System.Web.UI.Page 15
{ 16
public int time; 17
protected void Page_Load(object sender, EventArgs e) 18
{ 19
20
} 21
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 22
{ 23
this.Label1.Text = "你的车票类型是:" + this.DropDownList1.SelectedItem.Text; 24
25
} 26
private void LookTicket1() 27
{//预定车票查询 28
29
30
31
int id = Convert.ToInt32(this.TextBox1.Text); 32
33
SqlConnection con = db.ceratcon(); 34
con.Open(); 35
SqlCommand cmd = new SqlCommand("select * from OrderTicket where Oid='"+id+"'", con); 36
cmd.Parameters.Add("@Oid", SqlDbType.Int); 37
cmd.Parameters["@Oid"].Value = id; 38
SqlDataReader sdr = cmd.ExecuteReader(); 39
if(sdr.Read()) 40
{ 41
this.Label2.Text = sdr["Omoney"].ToString(); 42
this.Label3.Text = sdr["OTicketype"].ToString(); 43
Label4.Text = sdr["OCar"].ToString(); 44
Label5.Text = sdr["Ousetime"].ToString(); 45
txtyudingtime.Text = sdr["ObuyTime"].ToString(); 46
47
} 48
con.Close(); 49
50
51
} 52
private void LookTicket2() 53
{//非预定车票查询 54
55
56
int id = Convert.ToInt32(this.TextBox1.Text); 57
SqlConnection con = db.ceratcon(); 58
con.Open(); 59
SqlCommand cmd = new SqlCommand("select * from SealTicket where Sid='" + id + "'", con); 60
cmd.Parameters.Add("@Sid", SqlDbType.Int); 61
cmd.Parameters["@Sid"].Value = id; 62
SqlDataReader sdr = cmd.ExecuteReader(); 63
if (sdr.Read()) 64
{ 65
this.Label2.Text = sdr["Smoney"].ToString(); 66
this.Label3.Text = sdr["SticketType"].ToString(); 67
Label4.Text = sdr["SCar"].ToString(); 68
Label5.Text = sdr["Stime"].ToString(); 69
70
71
} 72
con.Close(); 73
74
75
} 76
private void Checkid2() 77
{ 78
//检索输入的车票号码是否在预定的数据库中存在 79
int id = Convert.ToInt32(this.TextBox1.Text); 80
SqlConnection con = db.ceratcon(); 81
con.Open(); 82
SqlCommand cmd = new SqlCommand("select * from OrderTicket where Oid='" + id + "'", con); 83
SqlDataReader sdr = cmd.ExecuteReader(); 84
if (sdr.Read()) 85
{ 86
Session["id"] = sdr["Oid"].ToString();//管理员名称保存到session 87
88
89
90
} 91
92
else 93
{ 94
95
Response.Write("<script language='javascript'>alert('该车票不存在');location.href='ReturningTicket.aspx'</script>"); 96
} 97
98
} 99
private void Checkid1() 100
{ 101
//检索输入的车票号码是否在非预定的数据库中存在 102
int id = Convert.ToInt32(this.TextBox1.Text); 103
SqlConnection con = db.ceratcon(); 104
con.Open(); 105
SqlCommand cmd = new SqlCommand("select * from SealTicket where Sid='" + id + "'", con); 106
SqlDataReader sdr = cmd.ExecuteReader(); 107
if (sdr.Read()) 108
{ 109
Session["id"] = sdr["Sid"].ToString();//管理员名称保存到session 110
111
112
113
} 114
115
else 116
{ 117
118
Response.Write("<script language='javascript'>alert('该车票不存在');location.href='ReturningTicket.aspx'</script>"); 119
} 120
121
} 122
123
protected void LinkButton1_Click(object sender, EventArgs e) 124
{//查询车票 125
Time();//判断当前时间是否可以退票 126
if (DateTime.Now.Hour > time) 127
{ 128
if (this.DropDownList1.SelectedItem.Text == "非预定的票") 129
{ 130
if (this.TextBox1.Text != "") 131
{ 132
Checkid1(); 133
LookTicket2(); 134
135
136
} 137
else 138
{ 139
Response.Write("<script language='javascript'>alert('请输入车票号码!')</script>"); 140
141
} 142
} 143
else if (this.DropDownList1.SelectedItem.Text == "预定的票") 144
{ 145
if (this.TextBox1.Text != "") 146
{ 147
Checkid2(); 148
LookTicket1(); 149
150
} 151
else 152
{ 153
Response.Write("<script language='javascript'>alert('请输入车票号码!')</script>"); 154
155
} 156
157
158
} 159
} 160
else 161
{ 162
Response.Write("<script language='javascript'>alert('当前时间不能退票');location.href='ReturningTicket.aspx'</script>"); 163
164
} 165
} 166
protected void Linktuipiao_Click(object sender, EventArgs e) 167
{//退票按钮单击事件 168
if (this.DropDownList1.SelectedItem.Text == "非预定的票") 169
{ 170
DeleteTicker2(); 171
} 172
else if (this.DropDownList1.SelectedItem.Text == "预定的票") 173
{ 174
DeleteTicker1(); 175
176
} 177
} 178
public void Time()//判断退票时间根据设置的时间进行卖票过程 179
{ 180
SqlConnection con = db.ceratcon(); 181
con.Open(); 182
SqlCommand cmd = new SqlCommand("select SystuipiaoTime from System", con);//从数据库中选择设置时间 183
time = Convert.ToInt32(cmd.ExecuteScalar()); 184
185
con.Close(); 186
187
} 188
private void DeleteTicker1() 189
{ 190
//删除预定的票 191
SqlConnection con = db.ceratcon(); 192
con.Open(); 193
SqlCommand cmd = new SqlCommand(" delete OrderTicket where Oid=@Oid", con); 194
cmd.Parameters.Add("@Oid", SqlDbType.Int); 195
cmd.Parameters["@Oid"].Value = Convert.ToInt32(this.TextBox1.Text); 196
cmd.ExecuteNonQuery(); 197
con.Close(); 198
Response.Write("<script language='javascript'>alert('退票成功');location.href='ReturningTicket.aspx'</script>"); 199
200
201
} 202
private void DeleteTicker2() 203
{ 204
//删除预定的票 205
SqlConnection con = db.ceratcon(); 206
con.Open(); 207
SqlCommand cmd = new SqlCommand(" delete SealTicket where Sid=@Sid", con); 208
cmd.Parameters.Add("@Sid", SqlDbType.Int); 209
cmd.Parameters["@Sid"].Value = Convert.ToInt32(this.TextBox1.Text); 210
cmd.ExecuteNonQuery(); 211
con.Close(); 212
Response.Write("<script language='javascript'>alert('退票成功');location.href='ReturningTicket.aspx'</script>"); 213
214
215
} 216
} 217





}
}