⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin_class.asp

📁 eayanQuery思燕大学成绩查询系统 版本 V1.6
💻 ASP
📖 第 1 页 / 共 2 页
字号:
response.write ("<td>班级名称</td> ")
response.write ("<td>所属辅导员</td>")
response.write ("<td>班级总人数</td>")
response.write ("<td>所属院系</td>")
response.write ("<td><font color=red>管理选项</font></td>")
response.write ("</tr>")
    if TeacherList_rs.bof or TeacherList_rs.eof then 
 	   response.Write("<br><font color=red>暂时没有记录.</font>")  
	   response.End()
    end If	  
    TeacherList_rs.absolutepage=epage
for i=0 to TeacherList_rs.pagesize-1
    if TeacherList_rs.bof or TeacherList_rs.eof then  exit for' 当数据库中的记录数小于for循环中的i的值时,退出for循环
response.write ("<tr bgcolor=#FFFFFF align=center>")
response.write ("<td>"&TeacherList_rs(0)&"</td>")
response.write ("<td>"&TeacherList_rs(1)&"</td>")
Dim teacher_id:teacher_id=TeacherList_rs("teacher_id")
call Show_Class_teacherid(teacher_id,0)'列表中显示辅导员所在院系的过程调用
response.write ("<td>"&TeacherList_rs(3)&"</td>")
Dim department_id:department_id=TeacherList_rs("department_id")
call Show_teacher_department(department_id,0)'列表中显示辅导员所在院系的过程调用
response.write ("<td><a href=Admin_class.asp?action=EditTeacher&department_id="&teacherList_rs(4)&"&Teacher_id="&teacherList_rs(0)&">编辑</a>"&_
"&nbsp;&nbsp;<a onClick=""return confirm('确定要删除这个班级么吗?如果确认删除,班级下面所对应的所有学生都将被删除。');"" href=Admin_class.asp?action=Dlel_teacher&teacher_id="&teacherList_rs(0)&" >删除</a></td>")
response.write ("</tr>")
 TeacherList_rs.movenext()
next
response.write ("</table>")
response.write ("<p align=center>")
 '若果是搜索结果列表,则需要改动此处的分页链接
 IF Is_SearchMode=1 then 
response.write ("说明: 每页显示<font color=red>15</font>条记录&nbsp;<a href=Admin_class.asp?action=ShowSearchResult&teacher_name="&SearchKey&"&page=0>首页</a>&nbsp;")
response.write ("<a href=Admin_class.asp?action=ShowSearchResult&teacher_name="&SearchKey&"&page="&epage-1&">前一页</a>&nbsp;")
response.write ("<a href=Admin_class.asp?action=ShowSearchResult&teacher_name="&SearchKey&"&page="&epage+1&">后一页</a>&nbsp;")
response.write ("<a href=Admin_class.asp?action=ShowSearchResult&teacher_name="&SearchKey&"&page="&TeacherList_rs.pagecount&">末页</a>")
 Else
response.write ("说明: 每页显示<font color=red>15</font>条记录&nbsp;<a href=Admin_class.asp?action=showlist&page=0>首页</a>&nbsp;")
response.write ("<a href=Admin_class.asp?action=showlist&page="&epage-1&">前一页</a>&nbsp;")
response.write ("<a href=Admin_class.asp?action=showlist&page="&epage+1&">后一页</a>&nbsp;")
response.write ("<a href=Admin_class.asp?action=showlist&page="&TeacherList_rs.pagecount&">末页</a>")
End IF
response.write ("<p align=center>现在是第<font color=red>"&epage&"</font>页一共有<font color=red>"&TeacherList_rs.pagecount&"</font>页</p>")
'******************分页代码结束***************************************** 
 TeacherList_rs.close
 Set TeacherList_rs=nothing
 Call CloseConn()
 Response.Write "</body>"
 Response.Write "</html>"
end sub
'负责处理添加院系数据的的过程********************************************
sub addTeacher()
    Dim Teacher_rs,Teacher_sql,Teacher_name,teacher_id,own_class_num,department_id,Edit_model,class_id
	    Edit_model=request.Form("Edit_model")
    Set Teacher_rs=server.CreateObject("adodb.recordset")
	Teacher_name=HtmlEncode(request.Form("Teacher_name"))
 	own_class_num=HtmlEncode(request.Form("own_class_num"))
 	department_id=HtmlEncode(request.Form("department_id"))
	teacher_id=HtmlEncode(request.Form("teacher_id"))
	class_id=HtmlEncode(request.Form("class_id"))
If Edit_model=1 then'如果Edit_model=1,则是编辑模式,而不是添加新纪录,此时无需检查是否存在相同的记录,而且要分别书写SQL语句
 Teacher_sql="select * from [class] where [class_id]='"&class_id&"'"
 	 '若果此时修改了密码,那么密码的长度一般应小于32位,则需要对新输入修改的密码进行md5加密;
	 'IF len(teacher_pass) < 32 then teacher_pass=md5(teacher_pass)
  Teacher_rs.open Teacher_sql,Initialize_Conn,1,3
   	 Teacher_rs("class_name")=Teacher_name  
	 Teacher_rs("teacher_id")=teacher_id
	 Teacher_rs("class_stu_num")=own_class_num
 	 Teacher_rs("department_id")=department_id
	 Teacher_rs.Update
  	 Teacher_rs.close
	 Set Teacher_rs=nothing
	 Call CloseConn()
	response.Write("<script>alert('编辑成功,按确定返回.');location.href='Admin_class.asp?action=showlist';</script>")
else 
    '下面的代码是添加新纪录***************  	
	Teacher_sql="select * from [class] where"&_
	 "[class_name]='"&HtmlEncode(request.Form("Teacher_name"))&"'"&_
	  "order by class_id desc"
   Teacher_rs.open Teacher_sql,Initialize_Conn,1,3
   if Teacher_rs.eof AND Teacher_rs.bof then
	 Teacher_rs.addnew
       '如果数目等于零,说明管理员没有填写对应的数目,则设置其数目为零,
 	   If own_class_num="" then own_class_num="0"
 	 Teacher_rs("class_name")=Teacher_name  
 	 Teacher_rs("class_stu_num")=own_class_num
 	 Teacher_rs("department_id")=department_id
 	 Teacher_rs("teacher_id")=teacher_id
	 Teacher_rs.Update
  	 Teacher_rs.close
	 Set Teacher_rs=nothing
	 Call CloseConn()
	response.Write("<script>alert('数据 成功添加.');location.href='Admin_class.asp?action=showlist';</script>")
   else
    Response.Write("<script>alert('对不起,您添加的名称已经存在.');location.href='"&request.ServerVariables("HTTP_REFERER")&"';</script>")
	Call CloseConn()
 end if	
end if	 
end sub
'显示 院系管理 管理页面的顶部 公共菜单****************************
sub showTeacherMenu()
response.Write("<div align=""center""><font color=""red"">【</font><a href=""admin_class.asp"">添加班级</a><font color=""red"">】</font>&nbsp;&nbsp;<font color=""red"">【</font><a href=""admin_class.asp?action=showlist"">班级管理</a><font color=""red"">】</font>&nbsp;&nbsp;<font color=""red"">【</font><a href=""admin_class.asp?Action=InputTeacher"">搜索班级</a><font color=""red"">】</font><hr width=""420""></div>")
end sub
'删除院系部门的过程调用********************************************
sub Dlel_teacher()
 Dim teacher_id,Del_teacher_sql
 'Call OpenConn()
  teacher_id=request.QueryString("teacher_id")
  'response.Write(teacher_id)
 Del_teacher_sql="delete from [class] where class_id='"&teacher_id&"'"
 Initialize_Conn.execute(Del_teacher_sql)
 Call CloseConn()
 Response.Write("<script>location.href='Admin_class.asp?action=showlist';</script>")

'response.Write("成功删除。")
end sub
'编辑 院系部门的过程调用********************************************
sub Edit_teacher()
   Call Main(1)
   Call CloseConn()
 end sub
'搜索教师的过程调用,显示页面************************************************************
Sub ShowSearchForm() 
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Admin_Teacher.asp管理 </title>
<link href="images/my_style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
<script language="javascript">	
function CheckMyForm() 
{
  if(theForm.teacher_name.value == '') {
    alert('请输入辅导员的名称!');
     theForm.teacher_name.focus();
    return false;
  }
}
//-->
</script>
</head>
<body onload="document.theForm.teacher_name.focus()" background="images/admin_MainBg.gif">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="22%" height="44">&nbsp;</td>
    <td width="28%">&nbsp;</td>
    <td width="28%">&nbsp;</td>
    <td width="22%">&nbsp;</td>
  </tr>
  <tr>
    <td height="28">&nbsp;</td>

    <td align="center" colspan="2"><%call showTeacherMenu()%></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="62">&nbsp;</td>
    <td align="center" colspan="2" rowspan="2">
   <form name="theForm" id="demo" onSubmit="return CheckMyForm()" method="post" action="Admin_class.asp?action=ShowSearchResult"> 
       <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="35"><div align="left">请您输入班级的名称或<font color=red>关键字</font>:&nbsp;&nbsp; 
                     <input value="" type="text" name="teacher_name" onkeyup="value=value.replace(/[ -~]/g,'')"/> &nbsp;&nbsp;                     <input type="submit" name="Submit" value="搜索"/> 
  		  </div></td>
        <td width="9%" rowspan="2">&nbsp;  </td>
      </tr>
      <tr>
        <td height="192">&nbsp; </td>
        </tr>
    </table>
	</form>	</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="129">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="153" colspan="4">&nbsp;</td>
  </tr>
</table>
</body>
</html>
 <%
 End Sub
'教师选择所在院系部门的过程调用******************************************************
Sub chooseTeacher(skip_id)
    'call OpenConn()
    Dim SelectDepartment_sql,SelectDepartment_rs
	SelectDepartment_sql="select [teacher_id],[teacher_name] from [teacher] order by [teacher_id] desc"
	Set SelectDepartment_rs=server.CreateObject("adodb.recordset")
	SelectDepartment_rs.open SelectDepartment_sql,Initialize_Conn,1,1 
 Do while not SelectDepartment_rs.eof
      '*********************
	  '如果传递过来的skip不等于0,此时需要跳过此id,不在客户端打印出来,防止下列列表中有重复选项
 	 IF SelectDepartment_rs(0)=skip_id then
	    SelectDepartment_rs.movenext() '当前记录集的id等于skip_id,则跳过;
	    if SelectDepartment_rs.eof then exit do '如果此时的skip_id已经是记录集中的最大id,则跳出Do while循环;
 	 End if 
 	 response.Write("<option value="&SelectDepartment_rs(0)&">"&SelectDepartment_rs(1)&"</option>")
	 SelectDepartment_rs.movenext()
 Loop
     SelectDepartment_rs.close
	 Set SelectDepartment_rs=nothing
	 'Call CloseConn()	
 End Sub
 '显示辅导员所在院系的过程调用************************
Sub Show_teacher_department(id,Show_OR_Edit)''show的意思是数据显示模式,当要显示辅导员列表时是show模式,出于要和显示列表中表格一致的考虑,此时要打印出<td></td>;
'当要修改辅导员的信息是,此时要显示的是edit模式,只需要根据call传递过来的department_id显示辅导员所在院系的汉字描述;
    Dim ShowSql,ShowRs
	Set ShowRs=server.CreateObject("adodb.recordset")
	 ShowSql="select department_name from [department] where department_id="&id&""
     ShowRs.open ShowSql,Initialize_Conn,1,1
  IF Show_OR_Edit=0 Then
	response.Write "<td>"&ShowRs("department_name")&"</td>"
   else 
	response.Write ShowRs("department_name")
  End if
 	ShowRs.close
	Set ShowRs=nothing
end sub
 '显示班级所对应的辅导员的过程调用************************
Sub Show_Class_teacherid(id,Show_OR_Edit)''show的意思是数据显示模式,当要显示辅导员列表时是show模式,出于要和显示列表中表格一致的考虑,此时要打印出<td></td>;
'当要修改辅导员的信息是,此时要显示的是edit模式,只需要根据call传递过来的department_id显示辅导员所在院系的汉字描述;
    Dim ShowSql_2,ShowRs_2
	Set ShowRs_2=server.CreateObject("adodb.recordset")
	 ShowSql_2="select teacher_name from [teacher] where teacher_id="&id&""
     ShowRs_2.open ShowSql_2,Initialize_Conn,1,1
  IF Show_OR_Edit=0 Then
	response.Write "<td>"&ShowRs_2("teacher_name")&"</td>"
   else 
	response.Write ShowRs_2("teacher_name")
  End if
 	ShowRs_2.close
	Set ShowRs_2=nothing
end sub

Sub chooseDepart(skip_id)
    'call OpenConn()
    Dim SelectDepartment_sql,SelectDepartment_rs
	SelectDepartment_sql="select [department_id],[department_name] from [department] order by [department_id] desc"
	Set SelectDepartment_rs=server.CreateObject("adodb.recordset")
	SelectDepartment_rs.open SelectDepartment_sql,Initialize_Conn,1,1 
 Do while not SelectDepartment_rs.eof
      '*********************
	  '如果传递过来的skip不等于0,此时需要跳过此id,不在客户端打印出来,防止下列列表中有重复选项
 	 IF SelectDepartment_rs(0)=skip_id then
	    SelectDepartment_rs.movenext() '当前记录集的id等于skip_id,则跳过;
	    if SelectDepartment_rs.eof then exit do '如果此时的skip_id已经是记录集中的最大id,则跳出Do while循环;
 	 End if 
 	 response.Write("<option value="&SelectDepartment_rs(0)&">"&SelectDepartment_rs(1)&"</option>")
	 SelectDepartment_rs.movenext()
 Loop
     SelectDepartment_rs.close
	 Set SelectDepartment_rs=nothing
	 'Call CloseConn()	
 End Sub
 
Sub TeacherListSub(id)
     Dim TeacherListSql,TeacherListRs
    TeacherListSql="select [teacher_id], [teacher_name] from [teacher] where [department_id]="&id&" order by [teacher_name] asc"
	Set TeacherListRs=Initialize_Conn.execute(TeacherListSql)
	    Do while not TeacherListRs.eof
	       response.Write "<option value="&TeacherListRs(0)&">"&TeacherListRs(1)&"<option>"
	       TeacherListRs.movenext
		Loop   
	TeacherListRs.close
	Set TeacherListRs=nothing
 End Sub
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -