-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollcall.cshtml
110 lines (110 loc) · 5.03 KB
/
rollcall.cshtml
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
@{
Layout = "~/_xuejiLayout.cshtml";
if (Session["name"] == null || Session["username"] == null)
{
Response.Redirect("~/#.cshtml");
}
var db = Database.Open("ctXueji");
var list="";
}
@if (Convert.ToInt16(Session["authority"]) == 2||Convert.ToInt16(Session["authority"]) == 4)
{
list = "select * from rollcall order by time_stamp DESC";//user_power="+Convert.ToInt16(Session["authority"])+"
}
else
{
list = "select * from rollcall where USER_NAME='"+Convert.ToString(Session["name"])+"' order by time_stamp DESC";//user_power="+Convert.ToInt16(Session["authority"])+"
}
<script>
$(document).ready(function () {
$('#table_id').DataTable(
{
// "paging": false,
"ordering": false
});
});
</script>
<table id="table_id" class="table table-striped table-bordered">
<thead>
<tr>
<th>班级</th>
<th>课程</th>
<th>出勤率(总数-缺勤=出勤)</th>
<th>时间</th>
<th>操作人</th>
</tr>
</thead>
<tbody>
@foreach (var row in db.Query(list))
{
<tr>
@{
var cid = row.classes_id;
var coid = row.courses_id;
var classList = "select *from classes where id=" + cid;
var classListRow = db.QuerySingle(classList);
var mid = classListRow.majors_id;
var majorsList = "select *from majors where id=" + mid;
var majorsListRow = db.QuerySingle(majorsList);
var coursesList = "select *from courses where id=" + coid;
var coursesListRow = db.QuerySingle(coursesList);
}
<td class="center">@classListRow.classes_year @majorsListRow.majors_name</td>
<td class="center">@coursesListRow.courses_name</td>
@{
var time = row.time_stamp;
var classes_id = row.classes_id;
var courses_id = row.courses_id;
// absents缺勤 presents出勤 totals总数 attendanceRate出勤率
float absents = 0;
float totals = 0;
float attendanceRate = 0;
float presents=0;
var cqlist = "select *from rollcall where classes_id=" + classes_id + " and courses_id = " + courses_id + " and time_stamp='" + time + "'";
var dic = row.sid_state;//合并后查询
foreach (var row4 in Functions.StringToDictionary(dic))
{
totals++;
if (row4.Value == 1 || row4.Value == 4)
{
continue;
}
else
{
absents++;
}
}
if (totals == 0)
{
<td class="centent"><span class="btn btn-success">100 %</span> <font>@totals-@absents=@presents</font></td>
}
else if (totals == absents)
{
<td class="centen"><span class="btn btn-warning">50 %</span> <font>@totals-@absents=@presents</font></td>
}
else
{
presents=totals - absents;
attendanceRate = presents / totals;
attendanceRate = attendanceRate * 100;
string attendanceStr=string.Format("{0:f2}", attendanceRate);
if (attendanceRate > 90)
{
<td class="centent"><span class="btn btn-success">@attendanceStr %</span> <font>@totals-@absents=@presents</font></td>
}
else if (attendanceRate > 75)
{
<td class="centent"><span class="btn btn-warning">@attendanceStr %</span> <font>@totals-@absents=@presents</font></td>
}
else
{
<td class="centen"><span class="btn btn-danger">@attendanceStr %</span> <font>@totals-@absents=@presents</font></td>
}
}
}
<td class="center"><a href="~/rollcall_history.cshtml?id=@row.id">@row.time_stamp</a></td>
<td class="center">@row.user_name</td>
</tr>
}
</tbody>
</table>