<!--#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 Tuser 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 sno from Tuser where sno='" & trim(Request.Form("sno")) & "'")
     if not (rsCheck.bof and rsCheck.eof) then
      response.write "<script language='javascript'>alert('帐号" & trim(Request.Form("sno")) & " 已存在，请检查！');history.back(-1);</script>"
      response.end
     end if
   set rsCheck=nothing
   sql="select * from Tuser" 
   rs.open sql,conn,3,3
   rs.addnew 
else
   sql="select * from Tuser where id="&id&"" 
   rs.open sql,conn,1,2
end if
rs("sno")=Request("sno")
rs("sname")=Request("sname")
rs("sex")=Request("sex")
rs("sclass")=Request("sclass")
rs("Pws")=Request("Pws")
 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 type=text/JavaScript>
function check()
{

  if (document.add.sno.value=="")
     {
      alert("请填写帐号！")
      document.add.sno.focus()
      document.add.sno.select()
      return
     } 
	 
  if (document.add.Pws.value=="")
     {
      alert("请填写密码！")
      document.add.Pws.focus()
      document.add.Pws.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="Tuser.asp">
        <tr bgcolor="#F2FDFF" align="center">
          <td colspan="2"  class="optiontitle">添加帐号</td>
        </tr>
        <tr bgcolor="#FFFFFF">
          <td width="10%" align="right">学号：</td>
          <td><input name="sno" type="text" id="sno"></td>
        </tr>
		<tr  bgcolor='#FFFFFF'>
		  <td align='right' bgcolor="#FFFFFF"> 姓名：</td>
		  <td align='left'><input name="sname" type="text" id="sname"></td>
		</tr>
		<tr  bgcolor='#FFFFFF'>
		  <td align='right' bgcolor="#FFFFFF"> 性别：</td>
		  <td align='left'><input type="radio" name="sex" value="男" >男  <input type="radio" name="sex" value="女">女</td>
		</tr>
		<tr  bgcolor='#FFFFFF'>
		  <td align='right' bgcolor="#FFFFFF"> 班级：</td>
		  <td align='left'><input name="sclass" type="text" id="sclass"></td>
		</tr>
		<tr  bgcolor='#FFFFFF'>
		  <td align='right' bgcolor="#FFFFFF"> 密码：</td>
		  <td align='left'><input name="Pws" type="text" id="Pws"></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 bgcolor="#F2FDFF">
          <td colspan="7" class="optiontitle" align="center">帐号列表</td>
        </tr>
        <tr align="center" bgcolor="#ebf0f7">
		  <td width="15%">选中</td>
          <td>学号</td>
          <td>姓名</td>
          <td>性别</td>
          <td>班级</td>
          <td>密码</td>
          <td width="15%">执行操作</td>
        </tr>
<%
set rs=server.createobject("adodb.recordset") 
sql="select * from Tuser" 
rs.open sql,conn,1,1
do while not rs.eof
%>
       <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><%=rs("sno")%></td>
          <td><%=rs("sname")%></td>
		  <td><%=rs("sex")%></td>
          <td><%=rs("sclass")%></td>
          <td><%=rs("pws")%></td>
          <td>
          <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")%>')">删除</a>          </td>
        </tr>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
        <tr align="right" bgcolor="#ebf0f7">
          <td>
		  	<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>
          <td colspan="6"><a href="Tuser.asp?action=add">添加帐号</a>  <a href="buy/1-1.jpg">批量添加[商]</a></td>
        </tr>
        </form>
      </table> 
<%
end if
if action="edit" then
set rs=server.createobject("adodb.recordset") 
sql="select * from Tuser 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="Tuser.asp">
		<tr bgcolor="#F2FDFF">
		  <td colspan=2 class="optiontitle" align="center">修改帐号</td>
		</tr>
		<tr bgcolor="#F2FDFF">
          <td width="10%" align="right">学号：</td>
          <td><input name="sno" type="text" id="sno" value="<%=rs("sno")%>"></td>
        </tr>
		<tr  bgcolor='#FFFFFF'>
		  <td align='right' bgcolor="#FFFFFF"> 姓名：</td>
		  <td align='left'><input name="sname" type="text" id="sname" value="<%=rs("sname")%>"></td>
		</tr>
		<tr  bgcolor='#FFFFFF'>
		  <td align='right' bgcolor="#FFFFFF"> 性别：</td>
		  <td align='left'><input type="radio" name="sex" value="男" <% if rs("sex")="男" then response.Write("checked") end if%>>男
		  <input type="radio" name="sex" value="女" <% if rs("sex")="女" then response.Write("checked") end if%>>女</td>
		</tr>
		<tr  bgcolor='#FFFFFF'>
		  <td align='right' bgcolor="#FFFFFF"> 班级：</td>
		  <td align='left'><input name="sclass" type="text" id="sclass" value="<%=rs("sclass")%>"></td>
		</tr>
		<tr  bgcolor='#FFFFFF'>
		  <td align='right' bgcolor="#FFFFFF"> 密码：</td>
		  <td align='left'><input name="Pws" type="text" id="Pws" value="<%=rs("Pws")%>"></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)"> <input name="id" type="hidden" id="id" value="<%=rs("id")%>">		 </td>
	   </tr>
  	 </form>
  	</table>
<%
end if
end if
%>
    </td>
  </tr>
</table>
</body>
</html>