<!--#INCLUDE FILE="conn.asp" -->
<!--#INCLUDE FILE="Class_Checkuser.asp" -->
<!--#INCLUDE FILE="Class_Top.asp" -->
<%locat="学校管理"

if membername="" Then
  	ErrMsg=ErrMsg+"<br>"+"<li>您还没有<a href=Class_Login.asp><font color=red>登录或注册校友录</font></a>。"
	Call top(1,1)
	Call Error("Information",ErrMsg)
	
Else
	Dim ClsID,Degree,ClassName
	Dim rs2
	clsid=Request("ClassID")
	joinstatus=chkjoinclass(ClsID)
	if joinstatus<>"" Then
		Call top(1,1)
		Call Error("Exclamation",joinstatus)
	Else
		Select Case Request("Action")
		Case "Delete"
			act="删除学校成员"
			Call top(3,1)
			Call DelMember()
		Case "Deposal"
			act="免除同学职务"
			Call top(3,1)
			Call Deposal()
		Case "Appoint"
			act="任命同学职务"
			Call top(3,1)
			Call Appoint()
		Case "通过审核"
			act="审核同学加入本校"
			Call top(3,1)
			Call PassJoin()
		Case "禁止加入"
			act="禁止待审同学加入本校"
			Call top(3,1)
			Call RefuseJoin()
		Case Else
			act="人事管理"
			Call top(3,1)
			Call ClassmateList()
		End Select
	End if
End if


Sub Appoint()

	Dim AptID
	Dim mbstatus

	AptID=Request.form("id")
	'Cmt=cint(Request.form("Cmt"))
    Cmt=8 '管理员
	if AptID="" Then
		ErrMsg=ErrMsg+"<li>操作失败，请选择相关同学进行操作！"
		FoundErr=True
	'ElseIf Cmt<2 or Cmt>8 Then
	'	ErrMsg=ErrMsg+"<li>非法操作，不存在的职务！"
	'	FoundErr=True
	ElseIf not sysadmin Then
		ErrMsg=ErrMsg+"<li>操作失败，您没有执行此项操作的权限！"
		FoundErr=True
	'ElseIf not sysadmin and Degree=7 and Cmt=8 Then
	'	ErrMsg=ErrMsg+"<li>操作失败，副管理员无权任命正管理员！"
	'	FoundErr=True
	End if

	if FoundErr Then
		Call Error("Exclamation",ErrMsg)
		Exit Sub
	End if

	AptID=Clng(AptID)
	mbstatus=ChkMember(AptID)
	if mbstatus=0 Then
		ErrMsg=ErrMsg+"<li>操作失败，您要任命职务的同学不是本校成员！"
		FoundErr=True
	ElseIf mbstatus>1 Then
		ErrMsg=ErrMsg+"<li>操作失败，您所选的同学已经是本校的"&Grade(mbstatus,False)&"，不能重复担任职务！"
		FoundErr=True
	End if


	if FoundErr Then
		Call Error("Exclamation",ErrMsg)
		Exit Sub
	End if

	DoAppoint="update student Set point=point+"&Round(PointSet(12)*Cmt/8)&" where studid="&AptID
	Conn.Execute(DoAppoint)

	Set Rs=Conn.Execute("Select userid from student where studid="&AptID)

	DoAppoint="update joinclass Set degree="&Cmt&" where classid="&ClsID&" and userid='"&Rs(0)&"'"
	Conn.Execute(DoAppoint)
    
    Set Rs2=Conn.Execute("Select Top 2 userid From joinclass Where degree=8 And classid="&ClsID&" Order By visitcount Desc")
    If not Rs2.Eof Then
		Conn.Execute("update class Set admin1='"&Rs2(0)&"' where classid="&ClsID)
	Rs2.movenext
	If not Rs2.Eof Then Conn.Execute("update class Set admin2='"&Rs2(0)&"' where classid="&ClsID)
    End if
	Set Rs2=nothing

	'write log
	IP=Request.ServerVariables("REMOTE_ADDR") 
	body="任命"&getrealname(Rs(0))&"为本校的"&Grade(Cmt,False)
	sql="insert into log(userid,content,classid,ip)"&_
		" values('"&membername&"','"&body&"',"&ClsID&",'"&IP&"')"
	Conn.Execute(sql)

	'send message
	title="恭喜你成为"&ClassName&"的"&Grade(Cmt,False)&"！"
	'if Degree=7 or Degree=8 Then
	'	body=ClassName&"的学校管理员"&getrealname(membername)&"任命你为本校的"&Grade(Cmt,False)&_
	'	",请经常访问这个您的学校，并正确行使你的管理权限来管理好这个学校！"
	'Else
		body="系统管理员任命你为"&ClassName&"的"&Grade(Cmt,False)&_
		",请经常访问这个您的学校，并正确行使你的管理权限来管理好这个学校！"
	'End if
	sql="insert into message(incept,sender,title,content,sendtime,flag,issend,delS)"&_
		" values('"&Rs(0)&"','"&StrVar(1)&"','"&title&"','"&body&"',getdate(),0,1,2)"
	Conn.Execute(sql)

	Set Rs=Nothing


	rURL="Class_Admin_Member.asp?ClassID="&ClsID
	rTitle="任命职务"
	rMsg="你已经成功将所选同学任命为本校的"&Grade(Cmt,False)&"！<br><ul>"&_
		"<li><a href=""Class_index.asp?ClassID="&ClsID&""">返回"&htmlencode(ClassName)&"首页</a></li>"&_
		"<li><a href=""Class_Admin_index.asp?ClassID="&ClsID&"&Action=Main"">返回学校管理</a></li>"&_
		"<li><a href="""&rURL&""">继续成员管理</a></li></ul>"
	Redirect 3,rURL,rTitle,rMsg

End Sub



Sub deposal()

	Dim DepID
	Dim mbstatus

	DepID=Request.form("id")
	if DepID="" Then
		ErrMsg=ErrMsg+"<li>操作失败，请选择相关同学进行操作！"
		FoundErr=True
	ElseIf not sysadmin Then
		ErrMsg=ErrMsg+"<li>操作失败，您没有执行此项操作的权限！"
		FoundErr=True
	End if

	if FoundErr Then
		Call Error("Exclamation",ErrMsg)
		Exit Sub
	End if

	DepID=Clng(DepID)

	mbstatus=ChkMember(DepID)
	if mbstatus=0 Then
		ErrMsg=ErrMsg+"<li>操作失败，您要免除职务的同学不是本校成员！"
		FoundErr=True
	ElseIf mbstatus=1 Then
		ErrMsg=ErrMsg+"<li>操作失败，您所选的同学没有职务可以免除！"
		FoundErr=True
'	ElseIf mbstatus=Degree Then
'		ErrMsg=ErrMsg+"<li>操作失败，您不能对自己执行此项操作，请使用辞职功能！"
'		FoundErr=True
	ElseIf not sysadmin Then
		ErrMsg=ErrMsg+"<li>操作失败，您不是系统管理员，无权执行此项操作！"
		FoundErr=True
	End if

	if FoundErr Then
		Call Error("Exclamation",ErrMsg)
		Exit Sub
	End if


	DoResign="update student Set point=point+"&Round(PointSet(13)*mbstatus/8)&" where studid="&DepID
	Conn.Execute(DoResign)

	Set Rs=Conn.Execute("Select userid from student where studid="&DepID)

	DoResign="update joinclass Set degree=1 where classid="&ClsID&" and userid='"&Rs(0)&"'"
	Conn.Execute(DoResign)


  Set Rs2=Conn.Execute("Select Top 2 userid From joinclass Where degree=8 And classid="&ClsID&" Order By visitcount Desc")
  If Rs2.Eof Then
     Conn.Execute("update class Set admin1=null where classid="&ClsID)
     Conn.Execute("update class Set admin2=null where classid="&ClsID)
  Else
		Conn.Execute("update class Set admin1='"&Rs2(0)&"' where classid="&ClsID)
	Rs2.movenext
	If not Rs2.Eof Then
	Conn.Execute("update class Set admin2='"&Rs2(0)&"' where classid="&ClsID)
	else
	Conn.Execute("update class Set admin2=null where classid="&ClsID)
    End if
 End if
	Set Rs2=nothing

	'write log
	IP=Request.ServerVariables("REMOTE_ADDR") 
	body="免除"&getrealname(Rs(0))&"在本校的"&Grade(mbstatus,False)&"职务"
	sql="insert into log(userid,content,classid,ip)"&_
		" values('"&membername&"','"&body&"',"&ClsID&",'"&IP&"')"
	Conn.Execute(sql)

	'send message
	title="你在"&ClassName&"的"&Grade(mbstatus,False)&"职务被免除！"
	'if Degree=7 or Degree=8 Then
	'	body="很抱歉，由于某种原因，"&ClassName&"的管理员免除了您在该校的"&_
	'		Grade(Cmt,False)&"职务,您如果有什么问题，请与该校的管理员联系！"
	'Else
		body="很抱歉，由于某种原因，系统管理员免除了您在"&ClassName&"的"&_
			Grade(mbstatus,False)&"职务,您如果有什么问题，请与管理员联系！"
	'End if
	sql="insert into message(incept,sender,title,content,sendtime,flag,issend,delS) values('"&Rs(0)&"','"&StrVar(1)&"','"&title&"','"&body&"',getdate(),0,1,2)"
	Conn.Execute(sql)

	Set Rs=Nothing

	rURL="Class_Admin_Member.asp?ClassID="&ClsID
	rTitle="免除职务"
	rMsg="你已经成功将所选同学的"&Grade(mbstatus,False)&"职务免除！<br><ul>"&_
		"<li><a href=""Class_index.asp?ClassID="&ClsID&""">返回"&htmlencode(ClassName)&"首页</a></li>"&_
		"<li><a href=""Class_Admin_index.asp?ClassID="&ClsID&"&Action=Main"">返回学校管理</a></li>"&_
		"<li><a href="""&rURL&""">继续成员管理</a></li></ul>"
	Redirect 3,rURL,rTitle,rMsg

End Sub



Sub ClassmateList()

	Dim studcount
	Dim Rs,sql

	Response.Write "<br><br>"&_
		"<script language=JavaScript src=inc/mgrcls.js></script>"&_
		"<form action=Class_Admin_Member.asp?ClassID="&ClsID&" method=post name=classmate onsubmit=""return chkradio();"">"&_
		"<table align=center cellpadding=5 cellspacing=1 border=0 width=650 Class=TableBorder>"&_
		"<TR align=middle Class=DarkTableBody>"
	if Degree=1 and not sysadmin Then
		Response.Write "<Td height=24 colspan=6>"
	Else
		Response.Write "<Td height=24 colspan=7>"
	End if
	Response.Write "<b>学校成员管理</b></Td></TR>"&_
		"<tr><th align=center>序号</th><th align=center>用&nbsp;户&nbsp;名</th><th align=center>姓&nbsp;&nbsp;名</th>"&_
		"<th align=center>身&nbsp;&nbsp;份</th><th align=center>访问次数</th><th align=center>最近访问时间</th>"
	if Degree>1 or sysadmin Then
		Response.Write "<th align=center>选择</th>"
	End if
	Response.Write "</tr>"

	sql="Select S.studid,S.Userid,S.realname,J.visitcount,J.lastvisit,J.degree from "&_
		"student S inner join joinclass J on S.userid=J.userid where J.classid="&ClsID&_
		" and J.isauditing=0 order by J.degree desc,J.visitcount desc,J.lastVisit desc"
	Set Rs=Conn.Execute(sql)
	studcount=1
	do until Rs.eof
		Response.Write "<TR height=10 Class=LightTableBody>"&_
		"<TD align=center>"&studcount&"</TD><TD align=center>"&htmlencode(Rs(1))&"</TD><TD>&nbsp;&nbsp;"
		if membername<>Rs(1) Then
			Response.Write "<a href=""Class_Userinfo.asp?Name="&Rs(1)&_
				"&Action=showdetail"" target=_blank>"&htmlencode(Rs(2))&"</a>"
		Else
			Response.Write "<font color=blue>"&htmlencode(Rs(2))&"</font>"
		End if
		Response.Write "</TD><TD align=center>"&Grade(Rs(5),True)&"</TD><td align=center>"&Rs(3)&"</td>"&_
		"<td>&nbsp;&nbsp;"&Rs(4)&"</td>"

		if Degree>1 or sysadmin Then
			Response.Write "<TD align=center><input type=Radio name=id value="&Rs(0)
			if membername=Rs(1) or not sysadmin and (Degree<7 and Rs(5)>1 or Degree=7 and Rs(5)=8) Then Response.Write " disabled"
			Response.Write "></td>"
		End if
		Response.Write "</tr>"
		Rs.movenext
		studcount=studcount+1
	loop
	Set Rs=Nothing

	if Degree>7 or sysadmin Then
		Response.Write "<TR align=middle Class=DarkTableBody>"&_
			"<TD height=24 colspan=7 align=right valign=top>"&_
			"<input type=radio name=Action id=ac1 value=Delete""><label for=ac1>赶出学校</label>&nbsp;"

		if sysadmin Then
			Response.Write "<input type=radio name=Action id=ac3 value=Deposal><label for=ac3>免去职务</label>&nbsp;"&_
				"<input type=radio name=Action id=ac4 value=Appoint><label for=ac4>任命为管理员</label>"
		End if

		Response.Write "&nbsp;<INPUT TYPE=submit value=执行(E) style=""width:40pt;height:22"" accesskey=e class=button></TD></TR>"

	End if
	Response.Write "</TABLE></form>"

	Call Auditinglist()

End Sub




Sub Auditinglist()

	dim i
	dim sql,rs
	Dim NoOne

	Response.Write "<BR><form action=Class_Admin_Member.asp?ClassID="&ClsID&" method=post>"&_
	"<table align=center cellpadding=5 cellspacing=1 border=0 width=650 Class=TableBorder>"&_
	"<TR><Th>管理未审核的同学</Th></TR>"

	sql="Select S.userid,S.studid,S.realname from student S inner join joinclass J "&_
		"on S.userid=J.userid where J.classid="&ClsID&" and J.isauditing=1"
	Set Rs=Conn.Execute(sql)

	if Rs.eof and Rs.bof Then
		Response.Write "<tr height=50 Class=LightTableBody>"&_
		"<td><font color=brown>没有未审核的同学:(</font></td></tr>"
		NoOne=true
	Else
		Response.Write "<TR  height=10 Class=LightTableBody><td>"&_
		"<table width=""100%"" border=0>"
		i=1
		do until rs.eof
			if i mod 4 =1 then response.write "<tr>"
			if Degree>1 or sysadmin Then
				Response.Write "<td width=""25%""><input type=checkbox name=wid value="&Rs(1)&">"
			End if
			response.write Rs(2)&"("&htmlencode(Rs(0))&")</TD>"
			if i mod 4=0 then Response.Write "</TR>"
			Rs.movenext
			i=i+1
		loop
		response.write "</table></td></tr>"
	End if

	if Degree>1 or sysadmin Then
		Response.Write "<TR align=middle Class=DarkTableBody>"&_
			"<TD align=right><input type=submit name=Action value=""通过审核"""
		if NoOne then response.write " disabled"
		response.write " class=button>"&_
		"&nbsp;&nbsp;<input type=submit name=Action value=""禁止加入"""
		if NoOne then response.write " disabled"
		response.write " class=button></TD></TR>"
	End if

	Response.Write "</TABLE></form>"

End Sub



Sub DelMember()

	Dim delid,mbstatus,sql,Rs,UserRs
	Dim ErrMsg,FoundErr

	delid=Request.form("id")

	if delid="" Then
		ErrMsg=ErrMsg+"<li>操作失败，请选择相关同学进行操作！"
		Call Error("Exclamation",ErrMsg)
		Exit Sub
	End if

	delid=Clng(delid)

	mbstatus=ChkMember(delid)
	if mbstatus=0 Then
		ErrMsg=ErrMsg+"<li>操作失败，该同学不是本校成员！"
		FoundErr=True
	Else
		if not sysadmin Then
			if ChkRights(1)=False Then		
				ErrMsg=ErrMsg+"<li>操作失败，您不是管理员，没有此项操作的权限！"
				FoundErr=True
			ElseIf mbstatus=8 and Degree=8 Then
				ErrMsg=ErrMsg+"<li>操作失败，管理员无权对管理员执行此项操作！"
				FoundErr=True		
			End if
		End if
	End if

	if FoundErr Then
		Call Error("Exclamation",ErrMsg)
		Exit Sub
	End if

	sql="update class Set studcount=studcount-1 where classid="&ClsID
	Conn.Execute(sql)

	sql="update student Set classcount=classcount-1,point=point+"&PointSet(11)&" where studid="&delid
	Conn.Execute(sql)

	Set UserRs=Conn.Execute("Select userid from student where studid="&delid)

	sql="delete from joinclass where classid="&ClsID&" and userid='"&UserRs(0)&"'"
	Conn.Execute(sql)

	if mbstatus>1 Then
		ResignPoint=Round(PointSet(13)*mbstatus/8)
		sql="update student Set point=point+"&ResignPoint&" where studid="&delid
		Conn.Execute(sql)


		if mbstatus=8 Then
		    Set Rs2=Conn.Execute("Select Top 2 userid From joinclass Where degree=8 And classid="&ClsID&" Order By visitcount Desc")
  If Rs2.Eof Then
     Conn.Execute("update class Set admin1=null where classid="&ClsID)
     Conn.Execute("update class Set admin2=null where classid="&ClsID)
  Else
		Conn.Execute("update class Set admin1='"&Rs2(0)&"' where classid="&ClsID)
	Rs2.movenext
	If not Rs2.Eof Then
	Conn.Execute("update class Set admin2='"&Rs2(0)&"' where classid="&ClsID)
	else
	Conn.Execute("update class Set admin2=null where classid="&ClsID)
    End if
 End if
	Set Rs2=nothing
		
	End if

		if Degree=9 Then

			Set Rs=Conn.Execute("Select openlevel,studcount from class where classid="&ClsID)
			'如果学校内已经没有成员，而且加入学校需要审核，则需要把未通过审核同学加进来
			if Rs(0)=2 and Rs(1)=0 Then
				Conn.Execute("update student Set point=point+"&PointSet(10)&" where userid"&_
					" in (Select userid from joinclass where isauditing=1 and classid="&ClsID&")")
				Set WaitNum=Conn.Execute("Select count(userid) from joinclass where isauditing=1 and classid="&ClsID)
				Conn.Execute("update class Set studcount=studcount+"&WaitNum(0)&" where classid="&ClsID)
				Set WaitNum=Nothing
				Conn.Execute("update joinclass Set isauditing=0,jointime=getdate(),lastvisit=getdate() "&_
					"where isauditing=1 and classid="&ClsID)
			End if
			Set Rs=Nothing

			'如果学校内已经没有成员，而且已经限制加入学校，则需要把学校属性修改
			sql="update class Set openlevel=0,classpwd=null where studcount=0 and openlevel>0 and classid="&ClsID
			Conn.Execute(sql)

		End if

	End if

	'write log
	IP=Request.ServerVariables("REMOTE_ADDR") 
	body="把"&getrealname(UserRs(0))&"的从本校成员列表中除名！"
	sql="insert into log(userid,content,classid,ip)"&_
		" values('"&membername&"','"&body&"',"&ClsID&",'"&IP&"')"
	Conn.Execute(sql)

	'send message
	title="你被赶出了"&ClassName&"！"
    if Degree=9 or sysadmin and ChkRights(1)=False Then
		body="很抱歉，由于某种原因，系统管理员把你赶出了"&ClassName&",您如果有什么问题，可与管理员联系！"
	Else
		body="很抱歉，由于某种原因，"&ClassName&"的管理员把你赶出了这个学校,您如果有什么问题，可与该校的管理员联系！"
	End if
	sql="insert into message(incept,sender,title,content,sendtime,flag,issend,delS) values('"&UserRs(0)&"','"&StrVar(1)&"','"&title&"','"&body&"',getdate(),0,1,2)"
	Conn.Execute(sql)

	Set UserRs=Nothing


	rURL="Class_Admin_Member.asp?ClassID="&ClsID
	rTitle="成员管理"
	rMsg="你已经成功将所选成员从本校删除！<br><ul>"&_
		"<li><a href=""Class_index.asp?ClassID="&ClsID&""">返回"&htmlencode(ClassName)&"首页</a></li>"&_
		"<li><a href=""Class_Admin_index.asp?ClassID="&ClsID&"&Action=Main"">返回学校管理</a></li>"&_
		"<li><a href="""&rURL&""">继续成员管理</a></li></ul>"
	Redirect 3,rURL,rTitle,rMsg

End Sub




Sub  RefuseJoin()

	Dim passid,idlist,SucNum,NameList
	passid=Request.form("wid")

    if passid="" Then
		ErrMsg=ErrMsg+"<li>"+"请选择要禁止加入的同学。"
		FoundErr=True
	ElseIf not sysadmin And ChkRights(1)=False Then
		ErrMsg=ErrMsg+"<li>"+"对不起，您没有此项操作的权限！"
		FoundErr=True
	End if

	if FoundErr Then
		Call Error("Information",ErrMsg)
		Exit Sub
	End if

	idlist=Split(passid,",")
	SucNum=0
	NameList=""
	for i= 0 to ubound(idlist)
		if ChkAuditing(Clng(idlist(i)))=True Then
			Conn.Execute("update student Set classcount=classcount-1 where studid="&Clng(idlist(i)))

			Set UserRs=Conn.Execute("Select userid from student where studid="&Clng(idlist(i)))
			
			Conn.Execute("delete from joinclass where classid="&ClsID&" and userid='"&UserRs(0)&"'")
			
			'send message
			body=ClassName&"的管理员已经审核了您的注册请求，但不允许你加入这个学校，如果你有什么问题，可与该校的管理员联系！"
			sql="insert into message(incept,sender,title,content,sendtime,flag,issend,delS) values('"&UserRs(0)&"','"&StrVar(1)&"','注册学校失败！','"&body&"',getdate(),0,1,2)"
			Conn.Execute(sql)

			SucNum=SucNum+1
			NameList=NameList&getrealname(UserRs(0))&","

			Set UserRs=Nothing
	End if
	next


	'write log
	if SucNum<>0 Then
		NameList=left(NameList,len(NameList)-1)
		IP=Request.ServerVariables("REMOTE_ADDR") 
		body="审核待审核同学，"&NameList&"等"&SucNum&"位同学被禁止加入本校"
		sql="insert into log(userid,content,classid,ip)"&_
			" values('"&membername&"','"&body&"',"&ClsID&",'"&IP&"')"
		Conn.Execute(sql)
	End if

	rURL="Class_Admin_Member.asp?ClassID="&ClsID
	rTitle="审核学校成员"
	rMsg="有"&SucNum&"位同学被您禁止加入你们学校！<br><ul>"&_
		"<li><a href=""Class_index.asp?ClassID="&ClsID&""">返回"&htmlencode(ClassName)&"首页</a></li>"&_
		"<li><a href=""Class_Admin_index.asp?ClassID="&ClsID&"&Action=Main"">返回学校管理</a></li>"&_
		"<li><a href="""&rURL&""">继续成员管理</a></li></ul>"
	Redirect 3,rURL,rTitle,rMsg

End Sub


Sub  PassJoin()

	Dim passid,idlist,SucNum,NameList
	passid=Request.form("wid")

	if passid="" Then
		ErrMsg=ErrMsg+"<li>"+"请选择要通过审核的同学。"
		FoundErr=True
	ElseIf not sysadmin And ChkRights(1)=False Then
		ErrMsg=ErrMsg+"<li>"+"对不起，您没有此项操作的权限！"
		FoundErr=True
	End if

	if FoundErr Then
		Call Error("Information",ErrMsg)
		Exit Sub
	End if

	idlist=Split(passid,",")
	SucNum=0
	NameList=""
	for i= 0 to ubound(idlist)
		if ChkAuditing(Clng(idlist(i)))=True Then
			Conn.Execute("update class Set studcount=studcount+1 where classid="&ClsID)
			Conn.Execute("update student Set point=point+"&PointSet(10)&" where studid="&Clng(idlist(i)))

			Set UserRs=Conn.Execute("Select userid from student where studid="&Clng(idlist(i)))

			Conn.Execute("update joinclass Set isauditing=0,jointime=getdate(),lastvisit=getdate() "&_
			"where isauditing=1 and classid="&ClsID&" and userid='"&UserRs(0)&"'")

			'send message
			body=ClassName&"的管理员已经审核了您的注册请求，现在你已经成为该校的成员，请进入学校页面访问这个学校！"
			sql="insert into message(incept,sender,title,content,sendtime,flag,issend,delS) 										values('"&UserRs(0)&"','"&StrVar(1)&"','注册学校成功！','"&body&"',getdate(),0,1,2)"
			Conn.Execute(sql)

			SucNum=SucNum+1
			NameList=NameList&getrealname(UserRs(0))&","

			Set UserRs=Nothing
		End if
	next


	'write log
	if SucNum<>0 Then
		NameList=left(NameList,len(NameList)-1)
		IP=Request.ServerVariables("REMOTE_ADDR") 
		body="审核待审核同学，"&NameList&"等"&SucNum&"位同学通过审核加入到本校成员列表中"
		sql="insert into log(userid,content,classid,ip)"&_
			" values('"&membername&"','"&body&"',"&ClsID&",'"&IP&"')"
		Conn.Execute(sql)
	End if


	rURL="Class_Admin_Member.asp?ClassID="&ClsID
	rTitle="审核学校成员"
	rMsg="有"&SucNum&"位同学通过您的审核并加入到你们学校！<br><ul>"&_
		"<li><a href=""Class_index.asp?ClassID="&ClsID&""">返回"&htmlencode(ClassName)&"首页</a></li>"&_
		"<li><a href=""Class_Admin_index.asp?ClassID="&ClsID&"&Action=Main"">返回学校管理</a></li>"&_
		"<li><a href="""&rURL&""">继续成员管理</a></li></ul>"
	Redirect 3,rURL,rTitle,rMsg

End Sub


Function ChkMember(byval memberid)

	Dim tmpRs,tmpsql
	tmpsql="Select degree from joinclass where classid="&ClsID&_
	" and isauditing=0 and userid=(Select userid from student where studid="&memberid&")"

	Set tmpRs=Conn.Execute(tmpsql)
	if tmpRs.eof and tmpRs.bof Then
		chkmember=0
	Else
		chkmember=tmpRs(0)
	End if
	Set tmpRs=Nothing

End Function


Function ChkAuditing(byval memberid)

	Dim tmpRs,tmpsql
	tmpsql="Select isauditing from joinclass where classid="&ClsID&_
	" and isauditing=1 and userid=(Select userid from student where studid="&memberid&")"
	Set tmpRs=Conn.Execute(tmpsql)
	ChkAuditing=not (tmpRs.eof and tmpRs.bof)

End Function


function GetRealname(byval username)
	Dim rSQL,rRs
	GetRealname=""
	if isnull(username) or username="" then exit function
	rSQL = "select realname from student where userid='"&username&"'"
	set rRs=conn.execute(rSQL)
	if not (rRs.eof and rRs.bof) then
		GetRealname=rRs(0)
	else
		GetRealname=""
	end if
	Set rRs=Nothing
end function


%>
<!--#INCLUDE FILE="inc/grade.asp" -->
<%Call footer%>

