<!--#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
%>
<script language=JavaScript>
<!--
function DoEmpty(params)
{
if (confirm("确定要删除这条记录吗？删除后此记录将被无法恢复！"))
window.location = params ;
}
//-->
</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>

<%
action=Request("action")
id=Request("id")
if action="yes" Then
 set rs=server.createobject("adodb.recordset") 
if id="" then
   set rsCheck = conn.execute("select title from Info where title='" & trim(Request.Form("title")) & "'")
     if not (rsCheck.bof and rsCheck.eof) then
      response.write "<script language='javascript'>alert('名称 " & trim(Request.Form("title")) & " 已存在，请检查！');history.back(-1);</script>"
      response.end
     end if
   set rsCheck=nothing
   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
 rs("title")=Request("title")
 For i = 2 to 6
  rs("xx"&i) = request.form("xx"&i)
 next
 rs("content")=Request("content")
 rs.update 	
 rs.close
set rs=nothing
 Response.Redirect "?action=list"
end if
%>
<html>
<head>
<title><%=sysConfig%></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/main.css" rel="stylesheet" type="text/css">
<script LANGUAGE="JavaScript">
function check()
{
  if (document.add.title.value=="")
     {
      alert("请填写课程名称！")
      document.add.title.focus()
      document.add.title.select()
      return
     }

  if (document.add.xx2.value=="")
     {
      alert("请填写课程人数！")
      document.add.xx2.focus()
      document.add.xx2.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='#F2FDFF'>
		  <td align='right'> 课程名称：</td>
		  <td align='left'><input name="title" type="text" id="title"></td>
		</tr>
		<tr align='center' bgcolor='#FFFFFF'>
		  <td align='right'>课程人数：</td>
		  <td align='left'><input name="xx2" type="text" id="xx2"></td>
		</tr>
		<tr align='center' bgcolor='#FFFFFF'>
		  <td align='right'>课程学分：</td>
		  <td align='left'><input name="xx3" type="text" id="xx3"></td>
		</tr>
		<tr align='center' bgcolor='#FFFFFF'>
		  <td align='right'>上课时间：</td>
		  <td align='left'><input name="xx4" type="text" id="xx4"></td>
		</tr>
		<tr align='center' bgcolor='#FFFFFF'>
		  <td align='right'>上课地点：</td>
		  <td align='left'><input name="xx5" type="text" id="xx5"></td>
		</tr>
		<tr align='center' bgcolor='#FFFFFF'>
		  <td align='right'>授课老师：</td>
		  <td align='left'><input name="xx6" type="text" id="xx6"></td>
		</tr>
        <tr align="center" bgcolor="#FFFFFF">
          <td width="10%" align="right">选课说明：</td>
          <td align="left"><textarea name="content" cols="50" rows="3" id="content"></textarea></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="9"  class="optiontitle">课程列表</td>
        </tr>
        <tr align="center" bgcolor="#ebf0f7">
		  <td width="15%">选中</td>
          <td width="5%">序号</td>
          <td>课程名称</td>
          <td>课程人数</td>
          <td>课程学分</td>
          <td>上课时间</td>
          <td>上课地点</td>
          <td>授课老师</td>
          <td width="20%">执行操作</td>
        </tr>
		
<%
sql="select * from Info order by id asc"
 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 
%>
       <form name="del" action="" method="post">
        <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 width="5%"><%=rs("id")%></td>
          <td><%=rs("title")%></td>
          <td><%=rs("xx2")%></td>
          <td><%=rs("xx3")%></td>
          <td><%=rs("xx4")%></td>
          <td><%=rs("xx5")%></td>
          <td><%=rs("xx6")%></td>
          <td align='center'><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="9">
		  	<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="9"> 总共：<font color="#ff0000"><%=rs.PageCount%></font>页，<font color="#ff0000"><%=proCount%></font>条记录，当前页：<font color="#ff0000"><%=intCurPage%> </font><%if intCurPage<>1 then%><a href="?action=list">首页</a> | <a href="?action=list&ToPage=<%=intCurPage-1%>">上一页</a> | <% end if
if intCurPage<>rs.PageCount then %><a href="?action=list&ToPage=<%=intCurPage+1%>">下一页</a> | <a href="?action=list&ToPage=<%=rs.PageCount%>"> 最后页</a><% end if%></span></td>
        </tr>
<%
else
%>
        <tr align="center" bgcolor="#ffffff">
          <td colspan="9">对不起！目前数据库中还没有添加课程内容！</td>
        </tr>
<%
rs.close
set rs=nothing
end if
%>
      </table>
	  <br>
<%end if%>
<%if action="edit" then
set rs=server.createobject("adodb.recordset") 
Tid=Request("id")
sql="select * from Info where id="&Tid
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='#F2FDFF'>
		  <td align='right'> 课程名称：</td>
		  <td align='left'><input name="title" type="text" id="title" value="<%=rs("title")%>" ></td>
		</tr>
		<tr align='center' bgcolor='#FFFFFF'>
		  <td align='right'>课程人数：</td>
		  <td align='left'><input name="xx2" type="text" id="xx2" value="<%=rs("xx2")%>"></td>
		</tr>
		<tr align='center' bgcolor='#FFFFFF'>
		  <td align='right'>课程学分：</td>
		  <td align='left'><input name="xx3" type="text" id="xx3" value="<%=rs("xx3")%>"></td>
		</tr>
		<tr align='center' bgcolor='#FFFFFF'>
		  <td align='right'>上课时间：</td>
		  <td align='left'><input name="xx4" type="text" id="xx4" value="<%=rs("xx4")%>"></td>
		</tr>
		<tr align='center' bgcolor='#FFFFFF'>
		  <td align='right'>上课地点：</td>
		  <td align='left'><input name="xx5" type="text" id="xx5" value="<%=rs("xx5")%>"></td>
		</tr>
		<tr align='center' bgcolor='#FFFFFF'>
		  <td align='right'>授课老师：</td>
		  <td align='left'><input name="xx6" type="text" id="xx6" value="<%=rs("xx6")%>"></td>
		</tr>
        <tr align="center" bgcolor="#FFFFFF">
          <td width="10%" align="right">选课说明：</td>
          <td align="left"><textarea name="content" cols="50" rows="3" id="content"><%=rs("content")%></textarea></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>
<%
rs.close
set rs=nothing
end if
end if
%>    

<%if action="view" then
set rs=server.createobject("adodb.recordset") 
Tid=Request("id")
sql="select * from Info where id="&Tid
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='#F2FDFF'>
		  <td align='right'> 课程名称：</td>
		  <td align='left'><%=rs("title")%></td>
		</tr>
		<tr align='center' bgcolor='#FFFFFF'>
		  <td align='right'>课程人数：</td>
		  <td align='left'><%=rs("xx2")%></td>
		</tr>
		<tr align='center' bgcolor='#FFFFFF'>
		  <td align='right'>课程学分：</td>
		  <td align='left'><%=rs("xx3")%></td>
		</tr>
		<tr align='center' bgcolor='#FFFFFF'>
		  <td align='right'>上课时间：</td>
		  <td align='left'><%=rs("xx4")%></td>
		</tr>
		<tr align='center' bgcolor='#FFFFFF'>
		  <td align='right'>上课地点：</td>
		  <td align='left'><%=rs("xx5")%></td>
		</tr>
		<tr align='center' bgcolor='#FFFFFF'>
		  <td align='right'>授课老师：</td>
		  <td align='left'><%=rs("xx6")%></td>
		</tr>
        <tr align="center" bgcolor="#FFFFFF">
          <td width="10%" align="right">选课说明：</td>
          <td align="left"><%=rs("content")%></td>
        </tr>	
		<tr align="center" bgcolor="#ebf0f7">
		  <td colspan="2">
          <input type="button" name="Submit2" value="返回" onClick="history.back(-1)">
		  </td>
		</tr>
  	</table>
<%
rs.close
set rs=nothing
end if
end if
%>    
    </td>
  </tr>
</table>
</body>
</html>