📄 regclass.asp
字号:
<!--#INCLUDE FILE="setup.asp" -->
<!--#INCLUDE FILE="char.asp" -->
<!--#INCLUDE FILE="checkuser.asp" -->
<!--#INCLUDE FILE="theme.asp" -->
<!--#INCLUDE FILE="email.asp" -->
<%locat="班级注册"
call top(1,1)
if membername="" then
errmsg=errmsg+"<br>"+"<li>您还没有<a href=login.asp>登录</a>。"
call error("Information",errmsg)
else
dim classname,enyear
select case request("action")
case "Join"
dim scID
call joinclass()
case "Create"
call createclass()
case "passwordjoin"
call chkclspwd()
case "exitpass"
call exitpass()
case else
call selclsform()
end select
end if
sub joinclass()
dim rs,sql
sql="select classcount from [student] where userid='"&membername&"'"
set rs=conn.execute(sql)
if not rs.eof and rs(0)>=maxjoinclass then
errmsg=errmsg+"<br>"+"<li>对不起!每个用户只能注册"&maxjoinclass&"个班级!"
call error("Information",errmsg)
exit sub
end if
scID=clng(request("scID"))
sql="select classid from [class] where classid="&scID
set rs=conn.execute(sql)
if rs.eof and rs.bof then
errmsg=errmsg+"<br>"+"<li>"+"您选择的班级不存在!"
call error("Information",errmsg)
exit sub
end if
sql="select openlevel from [class] where classid="&scID
set rs=conn.execute(sql)
openlevel=rs(0)
if SysAdmin then openlevel=0
select case openlevel
case 0
call add2class()
case 1
call pswform()
case 2
call waitpass()
case 3
errmsg=errmsg+"<br><li>班级管理员已经锁定了这个班级,禁止其他用户加入!"
call error("Information",errmsg)
end select
end sub
sub createclass()
dim rs,sql
if chkpost=false then
ErrMsg=ErrMsg+"<Br>"+"<li>您提交的数据不合法,请不要从同学录外部提交信息。"
call error("Critical",errmsg)
exit sub
end if
sql="select classcount from [student] where userid='"&membername&"'"
set rs=conn.execute(sql)
if not rs.eof and rs(0)>=maxjoinclass then
errmsg=errmsg+"<br>"+"<li>对不起!每个用户只能注册"&maxjoinclass&"个班级!"
call error("Information",errmsg)
exit sub
end if
classname=trim(checkstr(request.form("classname")))
if classname="" then
errmsg=errmsg+"<br>"+"<li>"+"请输入您要创建的班级名称!"
founderr=true
elseif strlength(classname)<5 or strlength(classname)>28 then
errmsg=errmsg+"<br>"+"<li>"+"请输入班级名称5-28个字符!"
founderr=true
else
sql="select classid from [class] where classname='"&classname&"'"
set rs=conn.execute(sql)
if not (rs.eof and rs.bof) then
errmsg=errmsg+"<br>"+"<li>"+"您输入的班级名已经存在,请在直接在班级列表中选择或重新输入其他班级名!"
founderr=true
end if
set rs=nothing
end if
enyear=trim(request.form("enyear"))
thisyear=cint(year(date()))
startyear=thisyear-50
if not isinteger(enyear) or not (cint(enyear)>=startyear and cint(enyear)<=thisyear ) then
errmsg=errmsg+"<br>"+"<li>"+"您输入的入学年份不正确!"
founderr=true
end if
if founderr=true then
call error("Exclamation",errmsg)
exit sub
end if
sql="insert into [class] (classname,studcount,enyear,regdate,"&_
"creator,visitcount) values('"&classname&"',1,'"&_
enyear&"',date(),'"&membername&"',0)"
conn.execute(sql)
sql = "select top 1 classid from [class] order by classid desc"
set rs=conn.execute(sql)
ncid=rs(0)
sql="update [config] set classes=classes+1"
conn.execute(sql)
sql="update [student] set classcount=classcount+1,point=point+"&pJoinClass&" where userid='"&membername&"'"
conn.execute(sql)
sql="insert into joinclass (userid,classid,visitcount,jointime,lastvisit,degree,"&_
"isauditing) values('"&membername&"',"&ncid&",0,now(),now(),1,false)"
conn.execute(sql)
set rs=nothing
rURL="myclass.asp?classid="&ncid
rtitle="创建班级成功"
rmsg="您已经成功的创建了班级:<font color=brown>"&htmlencode(classname)&"</font>,并成为该班级的成员。<br>"&_
"<ul><li><a href=myclass.asp?classid="&ncid&"><font color="&TableContentcolor&">进入班级页面</font></a>"&_
"</li></ul>"
redirect 3,rurl,rtitle,rmsg
end sub
sub exitpass()
dim sql,rs
pclassid=request.querystring("classid")
if pclassid<>"" then pclassid=clng(pclassid)
sql="select isauditing from joinclass where userid='"&membername&"' and classid="&pclassid
set rs=conn.execute(sql)
if rs.eof and rs.bof then
errmsg=errmsg+"<br>"+"<li>你没有向班级管理员提出申请加入这个班级!"
founderr=true
elseif rs(0)=false then
errmsg=errmsg+"<br>"+"<li>你已经通过班级管理员的审核并成为这个班级的正式成员了!"
founderr=true
end if
set rs=nothing
if founderr=true then
call error("Information",errmsg)
else
sql="update [student] set classcount=classcount-1 where userid='"&membername&"'"
conn.execute(sql)
sql="delete from [joinclass] where isauditing=true and classid="&pclassid&" and userid='"&membername&"'"
conn.execute(sql)
stitle="退出审核"
smsg="你已经成功的退出班级管理员的审核状态!"
call success(stitle,smsg)
end if
end sub
sub selclsform()
dim enyearRs
dim enyear
%>
<!--#INCLUDE FILE="script/popup.inc" -->
<table border="0" width="700" cellspacing="0" cellpadding="0" bgcolor="<%=tablebordercolor%>" align=center>
<tr align="left" bgcolor=<%=tablebodycolor1%>>
<td width=100% align=center>
<BR>
<form name="selsc" action="RegClass.asp" method="POST" onsubmit="return submitonce(this)">
<input type=hidden name=action value=Join>
<TABLE width=95% align=center>
<TR><TD align=left> 1.你的班级是下面班级列表中的哪一个?</TD>
</TR></TABLE>
<table border="0" width="95%" bgcolor=<%=tablebordercolor%> cellspacing="1" cellpadding="4">
<tr bgcolor=<%=tabletitlecolor%>>
<th align="center" width=8%>选择</th>
<th align="center" width=35%>班 级 名 称</th>
<th align="center" width=10%>人 数</th>
<th align="center" width=23%>管 理 员</th>
<th align="center" width=12%>开放等级</th>
<th align="center" width=12%>
<%
set enyearRs=conn.execute("select max(enyear),min(enyear) from [class]")
if (enyearRs.eof and enyearRs.bof) or classes<=20 then
response.write "入学年份"
else
response.write "<select name=enyear size=1 onchange=""location.href='RegClass.asp?enyear='+options[this.selectedIndex].value"">"
response.write "<option value=''>入学年份</option>"
for i=enyearRs(1) to enyearRs(0)
response.write "<option value="&i
if cstr(i)=request("enyear") then response.write " selected"
response.write "> "&i&" </option>"
next
response.write "</select>"
end if
set enyearRs=nothing
response.write "</th></tr>"
enyear=request("enyear")
if enyear="" then wherecond="" else wherecond="where enyear='"&cint(enyear)&"' "
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select classid,classname,admin1,admin2,studcount,openlevel,enyear from [class] "&wherecond&"order by enyear,regdate desc"
rs.Open sql,conn,1,1
rs.pagesize=20
maxpages=cint(rs.pagecount)
if isInteger(request("page")) then
currentpage=cint(request("page"))
else
CurrentPage=1
end if
if rs.EOF and rs.bof then
response.write "<tr bgcolor="&tablebodycolor2&"><td colspan=6 height=30>目前还没有任何班级!</td></tr>"
else
if currentpage>maxpages then currentpage=maxpages
rs.absolutepage=CurrentPage
total=0
do until rs.EOF or total=20
%>
<tr bgcolor=<%=tablebodycolor2%>><td align=center>
<input type="Radio" name="scId" value="<%=rs(0)%>"></td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -