<!--#include file="inc/right.asp"--> 
<!--#include file="inc/conn.asp"-->
<%
if Request("wor")="del" then
id=request("id")
idArr=split(id,",")
for i=0 to ubound(idArr)
sql="delete from Info where id="&trim(idArr(i))
conn.execute(sql)
next
end if
%>
<%
action=Request("action")
id=Request("id")
if action="yes" Then
 set rs=server.createobject("adodb.recordset") 
    set rsCheck = conn.execute("select xx1,xx3,xx4,sh from Info where xx1=#"&trim(Request.Form("xx1"))&"# and xx3='"&trim(Request.Form("xx3"))&"' and xx4='"&trim(Request.Form("xx4"))&"' and sh='已审核'  ")
     if not (rsCheck.bof and rsCheck.eof) then
      response.write "<script language='javascript'>alert('此教室 " & trim(Request.Form("xx1")) & " 已预约，请检查！');history.back(-1);</script>"
      response.end
     end if
   set rsCheck=nothing
if id="" then
   sql="select * from Info" 
   rs.open sql,conn,3,3
   rs.addnew
else
   sql="select * from Info where id="&id&"" 
   rs.open sql,conn,1,2
end if
for i=1 to 8
rs("xx"&i)=Request("xx"&i)
next
rs("sh")=Request("sh")
rs("addtime")=Request("addtime")
rs("adduser")=session("admin_name")
 rs.update
 rs.close
set rs=nothing
 Response.Redirect "?action=list"
end if
%>
<html>
<head>
<title>校无忧管理系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/main.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="images/setdate.js"></script>
<script language=JavaScript type=text/JavaScript>
function CheckAll(form)
{for (var i=0;i<form.elements.length;i++){
var e = form.elements[i];
if (e.name != 'chkall') e.checked = form.chkall.checked;
}
}
</script>
<script language=JavaScript>
<!--
function DoEmpty(params)
{
if (confirm("真的要删除这条记录吗？删除后此记录里的所有内容都将被删除并且无法恢复！"))
window.location = params ;
}

function check()
{

  if (document.add.xx1.value=="")
     {
      alert("请填写预定时间！")
      document.add.xx1.focus()
      document.add.xx1.select()
      return
     }
	 
  if (document.add.xx2.value=="")
     {
      alert("请填写星期！")
      document.add.xx2.focus()
      document.add.xx2.select()
      return
     }
	 
  if (document.add.xx3.value=="")
     {
      alert("请填写预定课时！")
      document.add.xx3.focus()
      document.add.xx3.select()
      return
     }
	 
  
  if (document.add.xx5.value=="")
     {
      alert("请填写主讲内容！")
      document.add.xx5.focus()
      document.add.xx5.select()
      return
     }
	 
  if (document.add.xx6.value=="")
     {
      alert("请填写主讲人！")
      document.add.xx6.focus()
      document.add.xx6.select()
      return
     }
	 
  if (document.add.xx7.value=="")
     {
      alert("请填写联系电话！")
      document.add.xx7.focus()
      document.add.xx7.select()
      return
     }
	 	 
     document.add.submit()
}

-->
</script>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td bgcolor="#FFFFFF">
	<%if action="add" then%><BR>
        <table width="96%"  border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#aec3de">
        <form name="add" method="post" action="Info.asp">
        <tr align="center" bgcolor="#F2FDFF">
          <td colspan="2"  class="optiontitle"> 添加预约信息 </td>
        </tr>	
		<tr bgcolor='#FFFFFF'>
          <td width="10%" align="right">预定时间：</td>
		  <td><input name="xx1" type="text" id="xx1" onKeyDown="next()" onClick="fPopCalendar(event,this,this)" onFocus="this.select()" readonly="readonly"> </td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'>星　　期：</td>
          <td><SELECT name='xx2' id="xx2">
		  <option value="星期一">星期一</option>
		  <option value="星期二">星期二</option>
		  <option value="星期三">星期三</option>
		  <option value="星期四">星期四</option>
		  <option value="星期五">星期五</option>
		  <option value="星期六">星期六</option>
		  <option value="星期日">星期日</option>
		  </SELECT></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'>预定课时：</td>
		  <td><SELECT name='xx3' id="xx3">
		  <option value="第1节">第1节</option>
		  <option value="第2节">第2节</option>
		  <option value="第3节">第3节</option>
		  <option value="第4节">第4节</option>
		  <option value="第5节">第5节</option>
		  <option value="第6节">第6节</option>
		  <option value="第7节">第7节</option>
		  <option value="第8节">第8节</option>
		  </SELECT></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'>预定教室：</td>
          <td><%
Set rsSclass = Server.CreateObject("ADODB.Recordset")
rsSclass.open "select * from Sclass",Conn,1,2
%>
		  <SELECT name='xx4' id="xx4">
		  <%
		  do while not rsSclass.eof
		  %>
		  <option value="<%=rsSclass("title")%>"><%=rsSclass("title")%></option>
          <%
			rsSclass.movenext
			loop
			set rsSclass=nothing
		  %>
		  </SELECT></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'> 主讲内容：</td>
		  <td><input name="xx5" type="text" id="xx5" size="60" /></td>
		</tr>	
		<tr bgcolor='#FFFFFF'>
		  <td align='right'>主讲人：</td>
		  <td><input name="xx6" type="text" id="xx6"></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'>联系电话：</td>
		  <td><input name="xx7" type="text" id="xx7"></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'>备注说明：</td>
		  <td  ><textarea name="xx8" cols="53" rows="3" id="xx8"></textarea></td>
		</tr>
	    <tr bgcolor='#FFFFFF'>
		  <td align='right' >申请时间：</td>
		  <td ><input name="addtime" type="text" id="addtime" value="<%=now()%>" readonly></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'> 预约状态：</td>
          <td>
           <select name="sh" id="sh">
		   <option value="待审核">待审核</option>
		   <option value="已审核">已审核</option>
            </select></td>
		</tr>
        <tr align="center" bgcolor="#ebf0f7">
          <td colspan="2" >
		    <input TYPE="hidden" name="action" value="yes">
            <input type="button" name="Submit" value="提交" onClick="check()">
          	<input type="button" name="Submit2" value="返回" onClick="history.back(-1)"></td>
        </tr>
		</FORM>
      </table> 
<%end if%>
<br>
<%if action="list" then%>
      <table width="96%"  border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#aec3de">
        <tr align="center" bgcolor="#F2FDFF">
          <td colspan="11"  class="optiontitle">预约信息</td>
        </tr>
        <tr align="center" bgcolor="#ffffff">
          <td colspan="11" align="left">
<%
ClassName=trim(request("ClassName"))
dim sqlClass,rsClass
sqlClass="select * from Sclass order by id asc"
Set rsClass= Server.CreateObject("ADODB.Recordset")
rsClass.open sqlClass,conn,1,1
if rsClass.eof then 
	response.Write("还没有任何教室，请先添加教室。")
end if
do while not rsClass.eof
	if rsClass("title")=ClassName then
		response.Write("<a href='?action=list&ClassName=" & rsClass("title") & "'><font color='blue'>" & rsClass("title") & "</font></a> | ")		
	else
		response.Write("<a href='?action=list&ClassName=" & rsClass("title") & "'>" & rsClass("title") & "</a> | ")
	end if
	rsClass.movenext
loop
rsClass.close
set rsClass=nothing
%>
		  </td>
        </tr>
<%
TN=trim(request("TN"))
%>
         <form name="search" method="post" action="info.asp?action=list">
        <tr align="center" bgcolor="#F2FDFF">
          <td colspan="11"  >
            <input name="TN" type="radio" value="" <%if TN="" then response.Write("checked") end if%> onClick="javascript:this.form.submit();">所有信息
	        <input type="radio" name="TN" value="待审核" <%if TN="待审核" then response.Write("checked") end if%> onClick="javascript:this.form.submit();">待审核
	        <input type="radio" name="TN" value="已审核" <%if TN="已审核" then response.Write("checked") end if%> onClick="javascript:this.form.submit();">已审核
		  </td>
        </tr>
		</form>
        <tr align="center" bgcolor="#ebf0f7">
		  <td width="50">选中</td>
          <td>预定时间</td>
          <td>星期</td>
          <td>预定课时</td>
          <td>预定教室</td>
          <td>主讲内容</td>
          <td>主讲人</td>
          <td>联系电话</td>
          <td>申请时间</td>
          <td>预约状态</td>
          <td width="20%">执行操作</td>
        </tr>	
		<form name="del" action="" method="post">
<%
 sql="select * from Info where 5=5"
 if ClassName<>"" then 
	sql=sql & " and xx4='" & ClassName & "' "
 end if
 if TN<>"" then
	sql=sql & " and sh='"&TN&"' "
 end if
 sql=sql & " order by id desc"
 set rs=server.createobject("adodb.recordset") 
 rs.open sql,conn,1,1
 if not rs.eof then
 proCount=rs.recordcount
	rs.PageSize=20
     if not IsEmpty(Request("ToPage")) then
	    ToPage=CInt(Request("ToPage"))
		if ToPage>rs.PageCount then
		   rs.AbsolutePage=rs.PageCount
		   intCurPage=rs.PageCount
		elseif ToPage<=0 then
		   rs.AbsolutePage=1
		   intCurPage=1
		else
		   rs.AbsolutePage=ToPage
		   intCurPage=ToPage
		end if
	 else
		rs.AbsolutePage=1
		intCurPage=1
	 end if
	 intCurPage=CInt(intCurPage)
	 For i = 1 to rs.PageSize
	 if rs.eof then     
	 Exit For 
	 end if
%>
        <tr align='center' bgcolor='#FFFFFF' onmouseover='this.style.background="#F2FDFF"' onmouseout='this.style.background="#FFFFFF"'>
          <td><input type="checkbox" name="id" value="<%=rs("id")%>"></td>
          <td><%=rs("xx1")%></td>
		  <td><%=rs("xx2")%></td>
          <td><%=rs("xx3")%></td>
		  <td><%=rs("xx4")%></td>
		  <td><%=rs("xx5")%></td>
		  <td><%=rs("xx6")%></td>
		  <td><%=rs("xx7")%></td>
		  <td><%=rs("addtime")%></td>
		  <td>
		  <%if rs("sh")="待审核" then
		  c="red"
		  elseif rs("sh")="已审核" then 
		  c="blue"
		  else c="black"
		  end if%><font color="<%=c%>"><%=rs("sh")%></font></td>
          <td><IMG src="images/view.gif" align="absmiddle"><a href="?action=view&id=<%=rs("id")%>">查看</a> | <IMG src="images/edit.gif" align="absmiddle"><a href="?action=edit&id=<%=rs("id")%>">修改</a> | <IMG src="images/drop.gif" align="absmiddle"><a href="javascript:DoEmpty('?wor=del&id=<%=rs("id")%>&action=list&ToPage=<%=intCurPage%>')">删除</a></td>
        </tr>
<%
rs.movenext 
next
%>
		<tr bgcolor="#ffffff">
		  <td colspan="11"  >&nbsp;&nbsp;
		   <input name="chkall" type="checkbox" id="chkall" value="select" onclick=CheckAll(this.form)> 全选
		   <input name="wor" type="hidden" id="wor" value="del" />
		   <input type="submit" name="Submit3" value="删除所选" onClick="{if(confirm('确定要删除记录吗？删除后将被无法恢复！')){return true;}return false;}" />
		  </td>
		</tr>
		</form>
        <tr align="center" bgcolor="#ebf0f7">
          <td colspan="11"  > 总共：<font color="#ff0000"><%=rs.PageCount%></font>页, <font color="#ff0000"><%=proCount%></font>条预约信息, 当前页：<font color="#ff0000"><%=intCurPage%> </font><%if intCurPage<>1 then%><a href="?action=list&TN=<%=TN%>">首页</a> | <a href="?action=list&TN=<%=TN%>&ToPage=<%=intCurPage-1%>">上一页</a> | <% end if
if intCurPage<>rs.PageCount then %><a href="?action=list&TN=<%=TN%>&ToPage=<%=intCurPage+1%>">下一页</a> | <a href="?action=list&TN=<%=TN%>&ToPage=<%=rs.PageCount%>"> 最后页</a><% end if%></span></td>
        </tr>
<%
else
%>
        <tr align="center" bgcolor="#ffffff">
          <td colspan="11"  >对不起！目前数据库中还没有添加预约信息！</td>
        </tr>
<%
rs.close
set rs=nothing
end if
%>
      </table>
<br>
<%end if%>
<%if action="edit" then
set rs=server.createobject("adodb.recordset") 
sql="select * from Info where id="&Request("id")
rs.open sql,conn,1,1
if not rs.eof Then
%>
	  <table width="96%"  border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#aec3de">
       <form name="add" method="post" action="Info.asp">
		<tr align="center" bgcolor="#F2FDFF">
		  <td colspan=2  class="optiontitle"> 修改预约信息 </td>
		</tr>
		<tr bgcolor='#FFFFFF'>
          <td width="10%" align="right">预定时间：</td>
		  <td><input name="xx1" type="text" id="xx1"  value="<%=rs("xx1")%>" onKeyDown="next()" onClick="fPopCalendar(event,this,this)" onFocus="this.select()" readonly="readonly"> </td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'>星　　期：</td>
          <td><SELECT name='xx2' id="xx2">
		  <option value="星期一" <%if rs("xx2")="星期一" then response.write("Selected")%>>星期一</option>
		  <option value="星期二" <%if rs("xx2")="星期二" then response.write("Selected")%>>星期二</option>
		  <option value="星期三" <%if rs("xx2")="星期三" then response.write("Selected")%>>星期三</option>
		  <option value="星期四" <%if rs("xx2")="星期四" then response.write("Selected")%>>星期四</option>
		  <option value="星期五" <%if rs("xx2")="星期五" then response.write("Selected")%>>星期五</option>
		  <option value="星期六" <%if rs("xx2")="星期六" then response.write("Selected")%>>星期六</option>
		  <option value="星期日" <%if rs("xx2")="星期日" then response.write("Selected")%>>星期日</option>
		  </SELECT></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'>预定课时：</td>
          <td><SELECT name='xx3' id="xx3">
		  <option value="第1节" <%if rs("xx3")="第1节" then response.write("Selected")%>>第1节</option>
		  <option value="第2节" <%if rs("xx3")="第2节" then response.write("Selected")%>>第2节</option>
		  <option value="第3节" <%if rs("xx3")="第3节" then response.write("Selected")%>>第3节</option>
		  <option value="第4节" <%if rs("xx3")="第4节" then response.write("Selected")%>>第4节</option>
		  <option value="第5节" <%if rs("xx3")="第5节" then response.write("Selected")%>>第5节</option>
		  <option value="第6节" <%if rs("xx3")="第6节" then response.write("Selected")%>>第6节</option>
		  <option value="第7节" <%if rs("xx3")="第7节" then response.write("Selected")%>>第7节</option>
		  <option value="第8节" <%if rs("xx3")="第8节" then response.write("Selected")%>>第8节</option>
		  </SELECT></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'>预定教室：</td>
          <td><%
Set rsSclass = Server.CreateObject("ADODB.Recordset")
rsSclass.open "select * from Sclass",Conn,1,2
%>
		  <SELECT name='xx4' id="xx4">
		  <%
		  do while not rsSclass.eof
		  %>
		  <option value="<%=rsSclass("title")%>" <%if rs("xx4")=rsSclass("title") then response.write("Selected")%>><%=rsSclass("title")%></option>
          <%
			rsSclass.movenext
			loop
			set rsSclass=nothing
		  %>
		  </SELECT></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'> 主讲内容：</td>
		  <td><input name="xx5" type="text" id="xx5" size="60" value="<%=rs("xx5")%>"/></td>
		</tr>	
		<tr bgcolor='#FFFFFF'>
		  <td align='right'>主讲人：</td>
		  <td><input name="xx6" type="text" id="xx6" value="<%=rs("xx6")%>"></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'>联系电话：</td>
		  <td><input name="xx7" type="text" id="xx7" value="<%=rs("xx7")%>"></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'>备注说明：</td>
		  <td  ><textarea name="xx8" cols="53" rows="3" id="xx8"><%=rs("xx8")%></textarea></td>
		</tr>
	    <tr bgcolor='#FFFFFF'>
		  <td align='right' >申请时间：</td>
		  <td ><input name="addtime" type="text" id="addtime" value="<%=rs("addtime")%>"></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'> 预约状态：</td>
          <td>
           <select name="sh" id="sh">
		   <option value="待审核" <%if rs("sh")="待审核" then response.write("Selected")%>>待审核</option>
		   <option value="已审核" <%if rs("sh")="已审核" then response.write("Selected")%>>已审核</option>
            </select></td>
		</tr>
		<tr align="center" bgcolor="#ebf0f7">
		  <td colspan="2">
		  <input type="hidden" name="action" value="yes">
          <input type="button" name="Submit2" value="提交" onClick="check()">
          <input type="button" name="Submit2" value="返回" onClick="history.back(-1)">
		  <input name="id" type="hidden" id="id" value="<%=rs("id")%>"></td>
		</tr>
  		</FORM>
  	</table>
<%
end if
end if
%>  
<%if action="view" then
set rs=server.createobject("adodb.recordset") 
sql="select * from Info where id="&Request("id")
rs.open sql,conn,1,1
if not rs.eof Then
%>
	  <table width="96%"  border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#aec3de">
		<tr align="center" bgcolor="#F2FDFF">
		  <td colspan=2  class="optiontitle"> 查看预约信息 </td>
		</tr>
		<tr bgcolor='#FFFFFF'>
          <td width="10%" align="right">预定时间：</td>
		  <td><%=rs("xx1")%></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'>星　　期：</td>
		  <td><%=rs("xx2")%></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'>预定课时：</td>
		  <td><%=rs("xx3")%></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'>预定教室：</td>
		  <td><%=rs("xx4")%></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'> 主讲内容：</td>
		  <td><%=rs("xx5")%></td>
		</tr>	
		<tr bgcolor='#FFFFFF'>
		  <td align='right'>主讲人：</td>
		  <td><%=rs("xx6")%></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'>联系电话：</td>
		  <td><%=rs("xx7")%></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'>备注说明：</td>
		  <td><%=rs("xx8")%></td>
		</tr>
	    <tr bgcolor='#FFFFFF'>
		  <td align='right' >申请时间：</td>
		  <td><%=rs("addtime")%></td>
		</tr>
		<tr bgcolor='#FFFFFF'>
		  <td align='right'> 预约状态：</td>
		  <td><%=rs("sh")%></td>
		</tr>
		<tr align="center" bgcolor="#ebf0f7">
		  <td colspan="2">
          <input type="button" name="Submit2" value="返回" onClick="history.back(-1)"></td>
		</tr>
  	</table>
<%
end if
end if
%> 
  
    </td>
  </tr>
</table>
</body>
</html>