date2 = Request.QueryString("d2") & "." & Request.QueryString("m2") & "." &
Request.QueryString("y2")
Week = Request.QueryString("week")
Sem = Request.QueryString("Sem")
If Week="This" then today=WeekDay(now-1)
For k=1 to 7 If today=k then
date1=DateValue(now-k+1) date2=DateValue(now+6-k)
End If Next date1SQL=month(date1) &"/"& day(date1) &"/"& year(date1) date2SQL=month(date2) &"/"& day(date2) &"/"& year(date2)
End If
If Week="Next" then today=WeekDay(now-1)
For k=1 to 7 If today=k then
date1=DateValue(now-k+8) date2=DateValue(now+13-k)
End If Next date1SQL=month(date1) &"/"& day(date1) &"/"& year(date1) date2SQL=month(date2) &"/"& day(date2) &"/"& year(date2) End If
If Week="Semestr" then date1=Left(Sem,10) date2=Right(Sem,10)
date1SQL=month(date1) &"/"& day(date1) &"/"& year(date1)
date2SQL=month(date2) &"/"& day(date2) &"/"& year(date2) End If
If Week="User" then
If IsDate(date1)=false or IsDate(date2)=false then Response.Redirect("form.asp") End If
Response.Write group & " с " & FormatDateTime(date1) & " по " & FormatDateTime(date2)
%>
</title>
<link rel="stylesheet" type="text/css" href="rsp.css"> </head>
<body>
<a href="form.asp">Новый запрос</a>
<%
Dim Conn, RS, strSQL, i, j, g, x, y, s, p
Dim DateMas(),WDayMas(),WLesMas(),WTeachMas()
strProvider = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=D:\СГАУ\текущие предметы\ИТ\Курсовой проект\kp\db1.mdb;" Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open strProvider
Set RS = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT занятия.ID_pair, группы.platoon_name, дисциплины.short_name, виды_занятий.short_name, дни_занятий.Data, преподаватели.SurName, преподаватели.Name, преподаватели.Patronymic, расписание.ID_classroom1, расписание.ID_classroom2 FROM дисциплины INNER JOIN (дни_занятий INNER JOIN (темплан_шапка INNER JOIN ((виды_занятий INNER JOIN темпланы ON виды_занятий.ID_lesson_class = темпланы.ID_lesson_class) INNER JOIN ((занятия INNER JOIN (расписание LEFT JOIN преподаватели ON расписание.ID_teacher1 = преподаватели.ID_teacher) ON занятия.ID_pair_data =
расписание.ID_pair_data) INNER JOIN (группы INNER JOIN группы_распис ON группы.ID_platoon = группы_распис.ID_platoon) ON расписание.ID_sheduler = группы_распис.ID_sheduler) ON темпланы.ID_plan_lesson = расписание.ID_plan_lesson) ON темплан_шапка.ID_subj_header = темпланы.ID_subj_header) ON дни_занятий.ID_data = занятия.ID_data) ON дисциплины.ID_sceinse = темплан_шапка.ID_sceinse WHERE (((группы.platoon_name)="""&group&""") AND ((дни_занятий.Data)>=#"&date1SQL&"# And
(дни_занятий.Data)<=#"&date2SQL&"#)) ORDER BY дни_занятий.Data;"
RS.Open strSQL, Conn
If RS.EOF then
Response.Write "<h3>Извините, по Вашему запросу ничего не найдено. Попробуйте изменить период</h3>"
Else
Response.Write "<a
href=""raspprint.asp?group="&group&"&Week="&week&"&d1="&day(date1)&"&m1="&month(date1) &"&y1="&year(date1)&"&d2="&day(date2)&"&m2="&month(date2)&"&y2="&year(date2)&""">Вер сия для печати</a><p>"
Response.Write "<b>Расписание занятий группы "& group & " с " & FormatDateTime(date1,2) & " по " & FormatDateTime(date2,2) & "</b>"%>
<table border="1" cellpadding="0" bordercolor="#0066FF" cellspacing="0"> <tbody align="center">
<%
for i=1 to 6
p=1
RS.MoveFirst
Do While Not RS.EOF
if p < RS.Fields("ID_pair") then p = RS.Fields("ID_pair")
RS.MoveNext
Loop
Response.Write "<tr>"
Response.Write "<th rowspan="&p+1&" class=""weekday"">" & WeekdayName(i,false,2) & "</th>" Response.Write "<th> </th>"
if weekday(date1,2)>i then Response.Write "<th rowspan=""6""></th>"
x=0
ReDim DateMas(0)
For g=DateValue(date1) to DateValue(date2) if weekday(g,2)=i then
Response.Write "<th class=""date"">" & Day(g) & "." & Month(g) & "." & Right(year(g),2) & "</th>"
ReDim Preserve DateMas(x+1)
DateMas(x)=g x=x+1
End If
Next
For j=1 to p
Response.Write "<tr>"
Response.Write "<th class=""pare"">" & j & " пара" & "</th>"
ReDim WDayMas(0)
ReDim WLesMas(0) ReDim WTeachMas(0) y=0
RS.MoveFirst
Do While Not RS.EOF
If weekday(RS.Fields("Data"),2)=i and RS.Fields("ID_pair")=j then
ReDim Preserve WDayMas(y+1)
ReDim Preserve WLesMas(y+1) ReDim Preserve WTeachMas(y+1)
WTeachMas(y)=RS.Fields("Surname")+"
"+Left(RS.Fields("Name"),1)+"."+Left(RS.Fields("Patronymic"),1) WDayMas(y)=RS.Fields("Data")
WLesMas(y)="<b>" +
RS.Fields("дисциплины.short_name")+"</b>"+"/"+RS.Fields("виды_занятий.short_name") if IsNull(RS.Fields("ID_classroom1"))=false then WLesMas(y)=WLesMas(y) +" (<i>"+
RS.Fields("ID_classroom1") +"</i>)" if IsNull(RS.Fields("ID_classroom2"))=false then WLesMas(y)=WLesMas(y) +"/(<i>"+
RS.Fields("ID_classroom2") +"</i>)" y=y+1
End If
RS.MoveNext
Loop
a=0 s=0
Do while a<=y-1
If WDayMas(a) = WDayMas(a+1) then
Do while WDayMas(a)<>DateMas(s) Response.Write "<td> </td>" s=s+1 Loop
Response.Write "<td class=""cell"" title=""Преподаватели:
"&WTeachMas(a)&"/"&WTeachMas(a+1)&""">"& WLesMas(a) & " + " & WLesMas(a+1) &"</td>" a=a+1
Else
Do while WDayMas(a)<>DateMas(s)
Response.Write "<td> </td>" s=s+1 Loop
Response.Write "<td class=""cell"" title=""Преподаватель: "&WTeachMas(a)&""">"& WLesMas(a) &"</td>"
End If s=s+1 a=a+1
Loop
Response.Write "</tr>" Next 'следующая пара
Next 'следующий день недели
End If 'проверка наличия записей
RS.Close
Set RS = Nothing
Conn.Close
Set Conn = Nothing
%>
</tbody>
</table>
</body>
</html>
Код файла raspprint.asp
<%@ Language=VBScript %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> <%
Dim group,date1,date2,v,w,k 'Определение переменных group = Request.QueryString("group")
date1SQL =Request.QueryString("m1") & "/" & Request.QueryString("d1") & "/" & Request.QueryString("y1")
date2SQL = Request.QueryString("m2") & "/" & Request.QueryString("d2") & "/" & Request.QueryString("y2")
date1 =Request.QueryString("d1") & "." & Request.QueryString("m1") & "." & Request.QueryString("y1")
date2 = Request.QueryString("d2") & "." & Request.QueryString("m2") & "." &
Request.QueryString("y2")
Week = Request.QueryString("week")
If Week="This" then today=WeekDay(now-1,2)
For k=1 to 7 If today=k then
date1=DateValue(now-k+1) date2=DateValue(now+6-k)
End If Next date1SQL=month(date1) &"/"& day(date1) &"/"& year(date1) date2SQL=month(date2) &"/"& day(date2) &"/"& year(date2)
End If
If Week="Next" then today=WeekDay(now-1,2)
For k=1 to 7 If today=k then
date1=DateValue(now-k+8) date2=DateValue(now+13-k)
End If Next date1SQL=month(date1) &"/"& day(date1) &"/"& year(date1) date2SQL=month(date2) &"/"& day(date2) &"/"& year(date2) End If
If Week="User" then
If IsDate(date1)=false or IsDate(date2)=false then Response.Redirect("form.asp") End If
Response.Write group & " с " & FormatDateTime(date1,2) & " по " & FormatDateTime(date2,2) %>
(версия для печати)
</title>
</head>
<body alink="#3333FF" vlink="#3333FF" link="#3333FF">
<a href="form.asp">Новый запрос</a>
<a href="rasp.asp?group=<%Response.Write(group)%>&Week=User&d1=<%Response.Write(day(date1)) %>&m1=<%Response.Write(month(date1))%>&y1=<%Response.Write(year(date1))%>&d2=<%Respo nse.Write(day(date2))%>&m2=<%Response.Write(month(date2))%>&y2=<%Response.Write(year(date 2))%>">Назад</a>
<p><%
Dim Conn, RS, strSQL, i, j, g, x, y, s, p
Dim DateMas(),WDayMas(),WLesMas(),TeachMas()
strProvider = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=D:\СГАУ\текущие предметы\ИТ\Курсовой проект\kp\db1.mdb;" Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open strProvider
Set RS = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT занятия.ID_pair, группы.platoon_name, дисциплины.short_name, виды_занятий.short_name, дни_занятий.Data, преподаватели.SurName, преподаватели.Name, преподаватели.Patronymic, расписание.ID_classroom1, расписание.ID_classroom2 FROM дисциплины INNER JOIN (дни_занятий INNER JOIN (темплан_шапка INNER JOIN ((виды_занятий INNER JOIN темпланы ON виды_занятий.ID_lesson_class = темпланы.ID_lesson_class) INNER JOIN ((занятия INNER JOIN (расписание LEFT JOIN преподаватели ON расписание.ID_teacher1 = преподаватели.ID_teacher) ON занятия.ID_pair_data =
расписание.ID_pair_data) INNER JOIN (группы INNER JOIN группы_распис ON группы.ID_platoon = группы_распис.ID_platoon) ON расписание.ID_sheduler = группы_распис.ID_sheduler) ON темпланы.ID_plan_lesson = расписание.ID_plan_lesson) ON темплан_шапка.ID_subj_header = темпланы.ID_subj_header) ON дни_занятий.ID_data = занятия.ID_data) ON дисциплины.ID_sceinse = темплан_шапка.ID_sceinse WHERE (((группы.platoon_name)="""&group&""") AND ((дни_занятий.Data)>=#"&date1SQL&"# And (дни_занятий.Data)<=#"&date2SQL&"#)) ORDER BY дни_занятий.Data;"
RS.Open strSQL, Conn
Response.Write "<b>Расписание занятий группы "& group & " с " & FormatDateTime(date1,2) & " по
" & FormatDateTime(date2,2) & "</b>"%>
<table border="1" cellpadding="0" bordercolor="#000000" cellspacing="0">
<tbody align="center" valign="middle" style="font-size:12px">
<%
for i=1 to 6
p=1
RS.MoveFirst
Do While Not RS.EOF
if p < RS.Fields("ID_pair") then p = RS.Fields("ID_pair")
RS.MoveNext
Loop
Response.Write "<tr>"
Response.Write "<th rowspan="&p+1&" bgcolor=""#FFFFFF"">" & WeekdayName(i,false,2) & "</th>"
Response.Write "<th> </th>"
if weekday(date1,2)>i then Response.Write "<th rowspan=""6""></th>"
x=0
ReDim DateMas(0)
For g=DateValue(date1) to DateValue(date2) if weekday(g,2)=i then
Response.Write "<th bgcolor=""#FFFFFF"">" & Day(g) & "." & Month(g) & "." & Right(year(g),2) & "</th>"
ReDim Preserve DateMas(x+1)
DateMas(x)=g x=x+1
End If
Next
For j=1 to p
Response.Write "<tr>"
Response.Write "<th bgcolor=""#FFFFFF"">" & j & " пара" & "</th>"
ReDim WDayMas(0)
ReDim WLesMas(0) ReDim WTeachMas(0) y=0
RS.MoveFirst
Do While Not RS.EOF
If weekday(RS.Fields("Data"),2)=i and RS.Fields("ID_pair")=j then
ReDim Preserve WDayMas(y+1)
ReDim Preserve WLesMas(y+1) ReDim Preserve WTeachMas(y+1)
WTeachMas(y)=RS.Fields("Surname")
WDayMas(y)=RS.Fields("Data")
WLesMas(y)="<b>" +
RS.Fields("дисциплины.short_name")+"</b>"+"/"+RS.Fields("виды_занятий.short_name") if IsNull(RS.Fields("ID_classroom1"))=false then WLesMas(y)=WLesMas(y) +" (<i>"+
RS.Fields("ID_classroom1") +"</i>)" if IsNull(RS.Fields("ID_classroom2"))=false then WLesMas(y)=WLesMas(y) +"/(<i>"+
RS.Fields("ID_classroom2") +"</i>)" y=y+1
End If
RS.MoveNext Loop a=0
s=0
Do while a<=y-1
If WDayMas(a) = WDayMas(a+1) then
Do while WDayMas(a)<>DateMas(s) Response.Write "<td> </td>" s=s+1 Loop
Response.Write "<td>"& WLesMas(a) & " + " & WLesMas(a+1) & " " & WTeachMas(a) & "</td>" a=a+1
Else
Do while WDayMas(a)<>DateMas(s)
Response.Write "<td> </td>" s=s+1 Loop
Response.Write "<td>"& WLesMas(a) & " " & WTeachMas(a) & "</td>"
End If s=s+1 a=a+1
Loop
Response.Write "</tr>" Next 'следующая пара
Next 'следующий день недели
RS.Close
Set RS = Nothing
Conn.Close
Set Conn = Nothing %>
</tbody>
</table>
</body>
</html>
Код файла rsp.css
.cell {background-color:#BFDFFF;}
.weekday {background-color:#6FB7FF; text-transform:capitalize;}
.date {background-color:#6FB7FF;}
.pare {background-color:#6FB7FF;}
table {background-color: #E1F0FF;}
tbody {font-size:12px; font-family:"Times New Roman", Times, serif; vertical-align:middle;} a:link {color: #3333FF; } a:active {color:#3333FF; } a:visited {color: #3333FF;}