📄 booking.asp
字号:
<!--#include file="include/sqlstr.asp"-->
<!--#include file="include/bgsub.asp"-->
<!--#include file="include/opendb.asp"-->
<!--#include file="include/checked.asp"-->
<%
today1=date()
today2=date()+1
'a1=datediff("h",today1,'2001-5-6 1:00:00')
'response.write a1
'-----------------------------------------
oabusyname=request.cookies("oabusyname")
oabusysuid=request.cookies("oabusysuid")
oabusyuserdept=request.cookies("oabusyuserdept")
oabusyuserlevel=request.cookies("oabusyuserlevel")
if oabusysuid="" then response.redirect "default.asp"
'--------------------------------------
'打开数据库
set conn=opendb()
'删除公用资源
if request("delz")<>"" then
sql="delete from equipment where id="&request("delz")&_
" delete from booking where equipment="&request("delz")
conn.execute sql
end if
'删除预约
if request("dely")<>"" then
sql="delete from booking where id="&request("dely")
conn.execute sql
end if
'删除过期的预约记录
set conn=opendb()
sql = "delete from booking where endtime<'" & date() & "'"
conn.Execute sql
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<link rel="stylesheet" href="css/css.css" type="text/css">
<script language="javascript1.2" src="js/openwin.js"></script>
<title>企业办公系统</title>
</head>
<body bgcolor="#ffffff">
<% call bghead() %>
<center>
<table>
<tr>
<form method=post action="addequipment.asp">
<td>
<input type="submit" value="增加">
</td>
</form>
<form method=post action="addbooking.asp">
<td>
<input type="submit" value="预约">
</td>
</form>
</tr>
</table>
今天资源占用情况图(<font color=red>红色</font>表示被占用时间段)
</center>
<%
call bgmid()
%>
<center>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<%
dim today1
'显示图表
'取到所有公用资源
set rs=server.createobject("adodb.recordset")
sql="select *,convert(varchar(10),getdate(),111) as today from equipment"
rs.open sql,conn,1
while not rs.eof and not rs.bof
'取得今天的日期
today1=rs("today")
'显示时间轴
%>
<tr>
<td width=90 align=center><a href="editequipment.asp?id=<%=rs("id")%>"><%=rs("equipment")%></a></td><td align=center>
<table border="0" cellspacing="0" cellpadding="0" width="100%" height="10">
<tr><td align=left>00:00</td><td align=center>12:00</td><td align=right>24:00</td></tr>
</table>
<%
'读出公用资源的今日所有预约数据
set rs1=server.createobject("adodb.recordset")
sql="select * from booking where endtime>convert(varchar(10),getdate(),111) and endtime<convert(varchar(10),getdate()+1,111) and equipment=" & rs("id") & " order by starttime"
rs1.open sql,conn,1
if rs1.eof or rs1.bof then
'当公用资源没有预约的情况,就显示一条灰线
%>
<table border="0" cellspacing="0" cellpadding="0" width="100%" height="15">
<tr><td bgcolor="#aaaaaa"></td></tr>
</table>
<% else '当有公用资源时,就在相应的位置显示对应的一块红色区域%>
<table border="0" cellspacing="0" cellpadding="0" width="100%" height="15">
<tr>
<%
'初始化前面没记录
a=0
while not rs1.eof and not rs1.bof
starttime=rs1("starttime")
endtime=rs1("endtime")
'起始时间
a1=hour(starttime)
if a1<a then a1=a
'结束时间
b1=datediff("h",today1,endtime)
if b1>24 then b1=24
'response.write "a1="&a1&":b1="&b1&":a="&a&":endtime="&endtime
'如果开始时间大于已处理的时间,就将此时间差处理为无色
if a1>a then
'计算色条长度
colorwidth=int((a1-a)/24*100)
'显示无色
%>
<td bgcolor="#aaaaaa" width="<%=colorwidth%>%" align=center><%=a1-a%></td>
<%
end if
'已被处理的时间
a=a1
'计算红色条长度
colorwidth=int((b1-a1)/24*100)
'显示红色块
%>
<td bgcolor="red" width="<%=colorwidth%>%" align=center><%=b1-a1%></td>
<%
a=b1
rs1.movenext
wend
'显示最后无色区
if a<24 then
colorwidth=int((24-a)/24*100)
%>
<td bgcolor="#aaaaaa" width="<%=colorwidth%>%" align=center><%=24-a%></td>
<%
end if
%>
</tr>
</table>
<%
end if
%>
</td>
</tr>
<%
rs.movenext
wend
%>
</table>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
<%
'在图表展示时已取得的所有公用资源的记录集回到第一条记录上
rs.movefirst
while not rs.eof and not rs.bof
%>
<tr>
<td>
<%
'当是此公用资源管理员时,可以在此直接删除此公用资源
if rs("controller")=oabusysuid then
response.Write "<a href='booking.asp?delz="&rs("id")&"' onclick=""javascript:return window.confirm('你确定要删除此公用资源和它的所有预约吗?');"">"
response.write "<img src=images/del.gif border=0></a> "
end if
%>
<b><a href="editequipment.asp?id=<%=rs("id")%>"><%=rs("equipment")%></a></b></td>
</tr>
<tr><td height=40>
<%
'读出全部预约记录
set rs1=server.createobject("adodb.recordset")
sql="select a.*,b.userdept,b.name from booking a left join a_userinf b on a.suid=b.suid where equipment=" & rs("id") & " order by starttime"
rs1.open sql,conn,1
while not rs1.eof and not rs1.bof
%>
<a href="editbooking.asp?id=<%=rs1("id")%>"><font color="#0000ff">[<%=rs1("starttime")%>----<%=rs1("endtime")%>]</font></a>
<%
'如果是用户自己发的预约,就显示为红色
if rs1("suid")=oabusysuid then response.Write "<font color=red>" %>
部门:<%=rs1("userdept")%> 预约者:<%=rs1("name")%>
<%
if oabusysuid=rs1("suid") then response.write "</font>"
'如果是用户自己发的预约,就可以删除
if rs1("suid")=oabusysuid then
response.Write " <a href='booking.asp?dely="&rs1("id")&"' onclick=""javascript:return window.confirm('你确定要删除此预约吗?');"">"
response.write "<img src=images/del.gif border=0></a> "
end if
response.write "<br><br>"
rs1.movenext
wend
rs.movenext
wend
%>
</table>
</center>
<%
call bgback()
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -