This repository has been archived by the owner on Feb 10, 2023. It is now read-only.
forked from pigsquare/StuAct
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTongji.aspx.cs
88 lines (80 loc) · 4.02 KB
/
Tongji.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
using System;
using System.Configuration;
using System.Data.SqlClient;
public partial class Tongji : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["role"] == null || Session["role"].ToString() != "teacher")
{
Response.Redirect("Index.aspx");
Session["login"] = "未登录教师用户!";
}
else
{
if (Session["name"] != null)
TeaName.InnerText = "欢迎您," + Session["name"].ToString() + "!";
string conf = ConfigurationManager.ConnectionStrings["ActManageConnectionString"].ConnectionString;
SqlConnection conn = new SqlConnection(conf);
string sql = "SELECT * FROM [Stu]";
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader dr = cmd.ExecuteReader();
TableAvg.InnerHtml = "<table class='table table-striped table-bordered table-hover'><tr><th>学号</th><th>姓名</th><th>平均分</th></tr>";
while (dr.Read())
{
string sid = dr.GetString(0);
string sname = dr.GetString(1);
string sql2 = "SELECT avg(score) FROM [Detail] WHERE stu_id='" + sid + "'";
SqlCommand cmd2 = new SqlCommand(sql2, conn);
SqlDataReader dr2 = cmd2.ExecuteReader();
if (dr2.Read())
{
string sc = "没有成绩记录";
if (!dr2.IsDBNull(0))
sc = dr2.GetInt32(0).ToString();
TableAvg.InnerHtml += "<tr><td>"+sid+ "</td><td>" + sname + "</td><td>" + sc+ "</td></tr>";
}
dr2.Close();
}
TableAvg.InnerHtml += "</table>";
dr.Close();
conn.Close();
}
}
protected void Logout(object sender, EventArgs e)
{
Session.Abandon();
Response.Redirect("Index.aspx");
}
protected void Button2_Click(object sender, EventArgs e)
{
string sql = "SELECT * FROM [Detail] INNER JOIN Act ON Detail.act_id=Act.act_id WHERE [stu_id]='" + DropDownList1.SelectedValue + "' ORDER BY Act.[act_id]";
string conf = ConfigurationManager.ConnectionStrings["ActManageConnectionString"].ConnectionString;
SqlConnection conn = new SqlConnection(conf);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader dr = cmd.ExecuteReader();
TableStu.InnerHtml = "<table class='table table-striped table-bordered table-hover'><tr><th>作业序号</th><th>作业类型</th><th>作业名称</th><th>分数</th><th>备注</th></tr>";
while (dr.Read())
{
TableStu.InnerHtml += "<tr><td>" + dr.GetInt32(1).ToString() + "</td><td>" + dr.GetString(6) + "</td><td>" + dr.GetString(7) + "</td><td>" + dr.GetInt32(3).ToString() + "</td><td>" + dr.GetString(4) + "</td></tr>";
}
TableStu.InnerHtml += "</table>";
}
protected void Button3_Click(object sender, EventArgs e)
{
string sql = "SELECT * FROM [Detail] INNER JOIN Stu ON Detail.stu_id=Stu.stu_id WHERE [act_id]='" + DropDownList2.SelectedValue + "' ORDER BY [Stu].[stu_id]";
string conf = ConfigurationManager.ConnectionStrings["ActManageConnectionString"].ConnectionString;
SqlConnection conn = new SqlConnection(conf);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader dr = cmd.ExecuteReader();
TableAct.InnerHtml = "<table class='table table-striped table-bordered table-hover'><tr><th>学号</th><th>姓名</th><th>分数</th><th>备注</th></tr>";
while (dr.Read())
{
TableAct.InnerHtml += "<tr><td>" + dr.GetString(2) + "</td><td>" + dr.GetString(6) + "</td><td>" + dr.GetInt32(3).ToString() + "</td><td>" + dr.GetString(4) + "</td></tr>";
}
TableAct.InnerHtml += "</table>";
}
}