-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtimetable.jsp
129 lines (119 loc) · 3.63 KB
/
timetable.jsp
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.Random" %>
<%@ include file="top.jsp" %>
<%@ include file="dbconfig.jsp" %>
<link rel="stylesheet" href="css/table.css">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<!-- / College Timetable -->
<%
class Course {
String c_name;
String t_where;
String p_name;
String color;
public Course(String c_name, String t_where, String p_name) {
this.c_name = c_name;
this.t_where = t_where;
this.p_name = p_name;
this.color = color_select();
}
String color_select() {
Random random = new Random();
String result = null;
result = "color" + (random.nextInt(5) + 1);
return result;
}
}
Course[][] cour = new Course[8][5];
if (session_id == null) { %>
<script>
alert("로그인이 필요합니다.");
location.href = "login.jsp";
</script>
<% } else {
Statement stmt = null;
String sql = null;
stmt = myConn.createStatement();
if (session_identity == "student") {
sql = "select c.c_name, t.t_where, t.t_day, t.t_time, p.p_name"
+ " from course c, enroll e, teach t, professor p"
+ " where e.C_ID=c.C_ID and e.C_ID_NO=c.C_ID_NO and e.s_id = " + session_id
+ " and e.e_semester = DATE2ENROLLSEMESTER(SYSDATE) and e.e_year = DATE2ENROLLYEAR(SYSDATE)"
+ " and t.C_ID = e.c_id and t.C_ID_NO = e.c_id_no and p.p_id = t.p_id";
} else {
sql = "select c.c_name, t.t_where, t.t_day, t.t_time"
+ " from course c, teach t"
+ " where t.t_semester = DATE2ENROLLSEMESTER(SYSDATE) and t.t_year = DATE2ENROLLYEAR(SYSDATE)"
+ " and t.C_ID = c.c_id and t.C_ID_NO = c.c_id_no and t.p_id = " + session_id;
}
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
String c_name = rs.getString(1);
String t_where = rs.getString(2);
int t_day = rs.getInt(3);
int t_time = rs.getInt(4) - 1;
String p_name = "";
if (session_identity == "student") {
p_name = rs.getString(5);
}
if (t_day == 1)
cour[t_time][0] = cour[t_time][2] = new Course(c_name, t_where, p_name);
else if (t_day == 2)
cour[t_time][1] = cour[t_time][3] = new Course(c_name, t_where, p_name);
else
cour[t_time][4] = cour[t_time + 1][4] = new Course(c_name, t_where, p_name);
%>
<%
}
%>
<div id="containerwrap">
<div id="container">
<div class="section_title">
<h1>
<span>시간표</span>
</h1>
</div>
<div class='tab'>
<center>
<table border='0' cellpadding='0' cellspacing='0'>
<tr class='days'>
<th></th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
</tr>
<% for (int i = 0; i < 8; i++) {%>
<tr>
<td class='time'><%=i + 1 %>
</td>
<%
for (int j = 0; j < 5; j++) {
if (cour[i][j] != null) {
%>
<td class='mouseon <%=cour[i][j].color %>'
data-tooltip='<%= cour[i][j].p_name %>'><%=cour[i][j].c_name %><br/>
<%=cour[i][j].t_where %>
</td>
<% } else {%>
<td></td>
<%
}
}
%>
</tr>
<%} %>
</table>
</center>
</div>
<% } %>
</div>
</div>
<%@ include file="footer.jsp" %>