温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:在线订票系统源码(毕业设计)
当前文件路径:TicketOnline/QuarterStatistics.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
public partial class QuarterStatistics : System.Web.UI.Page 14
{ 15
public string str; 16
protected void Page_Load(object sender, EventArgs e) 17
{ 18
19
} 20
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 21
{ 22
Checkidmonth1(); 23
Checkidmonth2(); 24
if (Label1.Text != "" || Label2.Text != "") 25
{ 26
decimal str1 = Convert.ToDecimal(this.Label1.Text); 27
decimal str2 = Convert.ToDecimal(this.Label2.Text); 28
this.Label3.Text = Convert.ToString(str2 + str1); 29
} 30
31
} 32
private void YudingMoney() 33
{ 34
if (DropDownList1.SelectedItem.Text == "第一季度") 35
{ 36
str = "select sum(Omoney) from OrderTicket where ObuyTime between '2007-01-01' and '2007-03-31'"; 37
38
39
40
} 41
else if (DropDownList1.SelectedItem.Text == "第二季度") 42
{ 43
str = "select sum(Omoney) from OrderTicket where ObuyTime between '2007-04-01 'and '2007-06-30'"; 44
} 45
else if (DropDownList1.SelectedItem.Text == "第三季度") 46
{ 47
str = "select sum(Omoney) from OrderTicket where ObuyTime between '2007-07-01' and '2007-09-30'"; 48
} 49
else if (DropDownList1.SelectedItem.Text == "第四季度") 50
{ 51
str = "select sum(Omoney) from OrderTicket where ObuyTime between '2007-10-01' and '2007-12-31'"; 52
53
} 54
//所有预定车票季度的收入 55
int month = this.DropDownList1.SelectedIndex + 1; 56
SqlConnection con = db.ceratcon(); 57
con.Open(); 58
SqlCommand cmd = new SqlCommand(str,con); 59
cmd.CommandText = str; 60
decimal summoney = Convert.ToDecimal(cmd.ExecuteScalar()); 61
this.Label1.Text = Convert.ToString(summoney); 62
63
con.Close(); 64
65
66
} 67
private void Money() 68
{ 69
if (DropDownList1.SelectedItem.Text == "第一季度") 70
{ 71
str = "select sum(Smoney) from SealTicket where Stime between '2007-01-01' and '2007-03-31'"; 72
73
74
75
} 76
else if (DropDownList1.SelectedItem.Text == "第二季度") 77
{ 78
str = "select sum(Smoney) from SealTicket where Stime between '2007-04-01 'and '2007-06-30'"; 79
} 80
else if (DropDownList1.SelectedItem.Text == "第三季度") 81
{ 82
str = "select sum(Smoney) from SealTicket where Stime between '2007-07-01' and '2007-09-30'"; 83
} 84
else if (DropDownList1.SelectedItem.Text == "第四季度") 85
{ 86
str = "select sum(Smoney) from SealTicket where Stime between '2007-10-01' and '2007-12-31'"; 87
88
} 89
//所有出售车票季度的收入 90
91
SqlConnection con = db.ceratcon(); 92
con.Open(); 93
SqlCommand cmd = new SqlCommand(); 94
cmd.Connection = (SqlConnection)con; 95
cmd.CommandText = str; 96
decimal summoney = Convert.ToDecimal(cmd.ExecuteScalar()); 97
this.Label2.Text = Convert.ToString(summoney); 98
99
100
101
102
} 103
104
private void Checkidmonth1() 105
{ 106
//检索出售的车票表中是否存在所选择月份信息 107
if (DropDownList1.SelectedItem.Text == "第一季度") 108
{ 109
str = "select Stime from SealTicket where Stime between '2007-01-01' and '2007-03-31'"; 110
111
112
113
} 114
else if (DropDownList1.SelectedItem.Text == "第二季度") 115
{ 116
str = "select Stime from SealTicket where Stime between '2007-04-01 'and '2007-06-30'"; 117
} 118
else if (DropDownList1.SelectedItem.Text == "第三季度") 119
{ 120
str = "select Stime from SealTicket where Stime between '2007-07-01' and '2007-09-30'"; 121
} 122
else if (DropDownList1.SelectedItem.Text == "第四季度") 123
{ 124
str = "select Stime from SealTicket where Stime between '2007-10-01' and '2007-12-31'"; 125
126
} 127
SqlConnection con = db.ceratcon(); 128
con.Open(); 129
SqlCommand cmd = new SqlCommand(); 130
cmd.Connection = (SqlConnection)con; 131
cmd.CommandText = str; 132
SqlDataReader sdr = cmd.ExecuteReader(); 133
if (sdr.Read()) 134
{ 135
Money(); 136
} 137
138
else 139
{ 140
141
Response.Write("<script language='javascript'>alert('该季度没有数据');location.href='QuarterStatistics.aspx'</script>"); 142
} 143
144
} 145
146
private void Checkidmonth2() 147
{ 148
149
//检索预售的车票表中是否存在所选择季度的信息 150
if (DropDownList1.SelectedItem.Text == "第一季度") 151
{ 152
str = "select ObuyTime from OrderTicket where ObuyTime between '2007-01-01' and '2007-03-31'"; 153
154
155
156
} 157
else if (DropDownList1.SelectedItem.Text == "第二季度") 158
{ 159
str = "select ObuyTime from OrderTicket where ObuyTime between '2007-04-01 'and '2007-06-30'"; 160
} 161
else if (DropDownList1.SelectedItem.Text == "第三季度") 162
{ 163
str = "select ObuyTime from OrderTicket where ObuyTime between '2007-07-01' and '2007-09-30'"; 164
} 165
else if (DropDownList1.SelectedItem.Text == "第四季度") 166
{ 167
str = "select ObuyTime from OrderTicket where ObuyTime between '2007-10-01' and '2007-12-31'"; 168
169
} 170
SqlConnection con = db.ceratcon(); 171
con.Open(); 172
SqlCommand cmd = new SqlCommand(); 173
cmd.Connection = (SqlConnection)con; 174
cmd.CommandText = str; 175
SqlDataReader sdr = cmd.ExecuteReader(); 176
if (sdr.Read()) 177
{ 178
YudingMoney(); 179
} 180
181
else 182
{ 183
184
Response.Write("<script language='javascript'>alert('该季度没有数据');location.href='QuarterStatistics.aspx'</script>"); 185
} 186
187
} 188
189
} 190





}
}