www.pudn.com > Xiao5u_Exam_v2011627.rar > Blank.asp, change:2011-06-25,size:7104b


<!--#include file="inc/right.asp"-->  
<!--#include file="inc/conn.asp"--> 
<script language=JavaScript> 
<!-- 
function DoEmpty(params) 
{ 
if (confirm("真的要删除这条记录吗?删除后此记录里的所有内容都将被删除并且无法恢复!")) 
window.location = params ; 
} 
//--> 
</script> 
 
<% 
IF Request("wor")="del" Then 
sql="delete from Blank where id="&Request("id") 
Conn.execute(sql) 
Response.Redirect "?action=list" 
End IF 
%> 
 
<% 
action=Request("action") 
id=Request("id") 
if action="yes" Then 
 set rs=server.createobject("adodb.recordset")  
if id="" then 
   set rsCheck = conn.execute("select Topic from Blank where Topic='" & trim(Request.Form("Topic")) & "'") 
     if not (rsCheck.bof and rsCheck.eof) then 
      response.write "<script language='javascript'>alert('题目 " & trim(Request.Form("Topic")) & " 已存在,请检查!');history.back(-1);</script>" 
      response.end 
     end if 
   set rsCheck=nothing 
   sql="select * from Blank"  
   rs.open sql,conn,3,3 
   rs.addnew 		'添加记录到数据表末端  
else 
   sql="select * from Blank where id="&id&""  
   rs.open sql,conn,1,2 
end if 
rs("Topic")=Request("Topic") 
rs("Right")=Request("Right") 
 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 LANGUAGE="JavaScript"> 
function check() 
{ 
  if (document.add.Topic.value=="") 
     { 
      alert("请填写题目内容!") 
      document.add.Topic.focus() 
      document.add.Topic.select() 
      return 
     } 
	 	  
  if (document.add.Right.value=="") 
     { 
      alert("请填写正确答案!") 
      document.add.Right.focus() 
      document.add.Right.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="Blank.asp"> 
        <tr align="center" bgcolor="#F2FDFF"> 
          <td colspan="2"  class="optiontitle">添加题目</td> 
        </tr> 
        <tr align="center" bgcolor="#F2FDFF"> 
          <td width="10%" align="right">题目内容:</td> 
          <td align="left"><textarea name="Topic" cols="60" rows="5" id="Topic" ></textarea></td> 
        </tr> 
		<tr align='center' bgcolor='#FFFFFF'> 
		  <td align='right' bgcolor="#FFFFFF"> 答案:</td> 
		  <td align='left'>	<input name="Right" type="text" id="Right" size="60"> 
		  对于多个填空项,答案用顿号或空格间隔开。</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="location.href='Blank.asp?action=list'"></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="4"  class="optiontitle">题目列表</td> 
        </tr> 
        <tr align="center"> 
          <td align="center"  bgcolor="#ebf0f7" width="5%">序号</td> 
          <td align="center"  bgcolor="#ebf0f7" width="75%">题目标题</td> 
          <td align="center"  bgcolor="#ebf0f7" width="20%">执行操作</td> 
        </tr> 
		 
<% 
sql="select * from Blank 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 '利用for next 循环依次读出记录 
%> 
        <tr align='center' bgcolor='#FFFFFF' onmouseover='this.style.background="#ebf0f7"' onmouseout='this.style.background="#FFFFFF"'> 
		  <td width="5%"><%=rs("id")%></td> 
          <td align='left' ><%=rs("Topic")%></td> 
          <td align='center' ><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 align="center" bgcolor="#ebf0f7"> 
          <td colspan="4"> 总共:<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="4">对不起!目前数据库中还没有添加题目!</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 Blank where id="&Request("id") 
rs.open sql,conn,1,1 
if not rs.eof Then 
%> 
<br> 
	  <table width="96%"  border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#aec3de"> 
       <form name="add" method="post" action="Blank.asp"> 
		<tr align="center" bgcolor="#F2FDFF"> 
		  <td colspan=2  class="optiontitle">修改题目</td> 
		</tr> 
		<tr align="center" bgcolor="#F2FDFF"> 
		  <td width="10%" align="right">题目内容:</td> 
		  <td align="left"><textarea name="Topic" cols="60" rows="5" id="Topic"><%=rs("Topic")%></textarea></td> 
		</tr> 
	    <tr align='center' bgcolor='#FFFFFF'> 
		  <td align='right' bgcolor="#FFFFFF"> 答案:</td> 
		  <td align='left'><input name="Right" type="text" id="Right" value="<%=rs("right")%>" size="60"></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="location.href='Blank.asp?action=list'"> 
		  <input name="id" type="hidden" id="id" value="<%=rs("id")%>"> 
		  </td> 
		</tr> 
  		</FORM> 
  	</table> 
<% 
end if 
end if 
%>     
    </td> 
  </tr> 
</table> 
</body> 
</html>