温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:在线订票系统源码(毕业设计)
当前文件路径:TicketOnline/MonthStatistics.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 MonthStatistics : System.Web.UI.Page 14
{ 15
protected void Page_Load(object sender, EventArgs e) 16
{ 17
if (!IsPostBack) 18
{ 19
20
} 21
} 22
private void YudingMoney() 23
{ 24
//所有预定车票当月的收入 25
int month = this.DropDownList1.SelectedIndex + 1; 26
SqlConnection con = db.ceratcon(); 27
con.Open(); 28
SqlCommand cmd = new SqlCommand("select sum(Omoney) from OrderTicket where month(ObuyTime)='" + month + "'", con); 29
decimal summoney = Convert.ToDecimal(cmd.ExecuteScalar()); 30
this.Label1.Text = Convert.ToString(summoney); 31
32
con.Close(); 33
34
35
} 36
private void Money() 37
{ 38
//所有出售车票当月的收入 39
int month = this.DropDownList1.SelectedIndex + 1; 40
SqlConnection con = db.ceratcon(); 41
con.Open(); 42
SqlCommand cmd = new SqlCommand("select sum(Smoney) from SealTicket where month(Stime)='"+month+"'", con); 43
decimal summoney = Convert.ToDecimal(cmd.ExecuteScalar()); 44
this.Label2.Text = Convert.ToString(summoney); 45
46
47
} 48
49
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 50
{ 51
Checkidmonth1(); 52
Checkidmonth2(); 53
54
55
//计算总营业额 56
if (Label1.Text != "" || Label2.Text != "") 57
{ 58
decimal str1 = Convert.ToDecimal(this.Label1.Text); 59
decimal str2 = Convert.ToDecimal(this.Label2.Text); 60
this.Label3.Text = Convert.ToString(str2 + str1); 61
} 62
} 63
private void Checkidmonth1() 64
{ 65
//检索出售的车票表中是否存在所选择月份信息 66
int month = this.DropDownList1.SelectedIndex + 1; 67
SqlConnection con = db.ceratcon(); 68
con.Open(); 69
SqlCommand cmd = new SqlCommand("select * from SealTicket where month(Stime)='" + month + "'", con); 70
SqlDataReader sdr = cmd.ExecuteReader(); 71
if (sdr.Read()) 72
{ 73
Money(); 74
} 75
76
else 77
{ 78
79
Response.Write("<script language='javascript'>alert('该月份没有数据');location.href='MonthStatistics.aspx'</script>"); 80
} 81
82
} 83
84
private void Checkidmonth2() 85
{ 86
int month = this.DropDownList1.SelectedIndex + 1; 87
//检索预售的车票表中是否存在所选择月份信息 88
89
SqlConnection con = db.ceratcon(); 90
con.Open(); 91
SqlCommand cmd = new SqlCommand("select * from OrderTicket where month(ObuyTime)='" + month + "'", con); 92
SqlDataReader sdr = cmd.ExecuteReader(); 93
if (sdr.Read()) 94
{ 95
YudingMoney(); 96
} 97
98
else 99
{ 100
101
Response.Write("<script language='javascript'>alert('该月份没有数据');location.href='MonthStatistics.aspx'</script>"); 102
} 103
104
} 105
} 106





}
}