www.gusucode.com > 25175 学生成绩管理查询系统码程序 > INC/functions.asp

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!-- #include file="../config.asp" -->
<!-- #include file="../conn.asp" -->
<%
Session.CodePage=936
Response.charset = "gb2312"
dim xq,lj,bj,kc,xq_id
If request("action")="usermenus" then
	usermenus="<ul>"
	usermenus=usermenus & "<li><a href=""user_manager.asp"" title=""首 页""><span>首 页</span></a></li>"
	usermenus=usermenus & "<li><a href=""?action=post"" title=""最新公告""><span>最新公告</span></a></li>"
	usermenus=usermenus & "<li><a href=""?action=guest"" title=""系统留言""><span>系统留言</span></a></li>"
	If session("xh")<>"" Then 
		usermenus=usermenus & "<li><a href=""?action="" title=""成绩查询""><span>成绩查询</span></a></li>"
		usermenus=usermenus & "<li><a href=""?action=info_edit"" title=""资料修改""><span>资料修改</span></a></li>"
		usermenus=usermenus & "<li><a href=""?action=logout"" title=""退  出""><span>退  出</span></a></li>"
	End If
	usermenus=usermenus & "</ul>"
	response.write usermenus
End If
If request("action")="logins" then
	If session("xh")<>"" Then 
		response.write "当前学号:<font color=red>"&session("xh")&"</font><br>"
		response.write "<hr size=1 color=#07396D style=filter:alpha(opacity=10,finishopacity=100,style=1,startX=100,startY=100,finishX=0,finishY=0);width:100%;><br>"
		response.write "姓名:"&session("xm")
		response.write "<br>年级:"&session("lj")
		response.write "<br>班级:"&session("bj")
		response.write "<br /><br /><br /><br /><br /><br /><br /><br />"
	else
		response.write "<form action=checklogin.asp method=post name=form1 style=margin:0px>"
		response.write "学号:"
		response.write "<input name=xh type=text size=17 onKeyDown=javascript:return check_isnum() class=smallInput><br>"
		response.write "密码:"
		response.write "<input name=mm type=password class=smallInput size=17 style=float: left><br>"
		response.write "<input name=kind type=hidden size=5 value=student><input type=image src=images/login_botton_01.gif name=Submit value=登陆>&nbsp;"
		response.write "<img src=images/login_botton_03.gif onClick=javascript:window.location.href = 'register.asp?action=reg'>&nbsp;"
		response.write "<img src=images/login_botton_05.gif onClick=javascript:window.location.href = 'register.asp?action=getpass'><br>"
		response.write "</form>"
	End If 
End If









function usermenu()
	usermenu="<ul>"
	usermenu=usermenu & "<li><a href=""user_manager.asp"" title=""首 页""><span>首 页</span></a></li>"
	usermenu=usermenu & "<li><a href=""?action=post"" title=""最新公告""><span>最新公告</span></a></li>"
	usermenu=usermenu & "<li><a href=""?action=guest"" title=""系统留言""><span>系统留言</span></a></li>"
	If session("xh")<>"" Then 
		usermenu=usermenu & "<li><a href=""?action="" title=""成绩查询""><span>成绩查询</span></a></li>"
		usermenu=usermenu & "<li><a href=""?action=info_edit"" title=""资料修改""><span>资料修改</span></a></li>"
		usermenu=usermenu & "<li><a href=""?action=logout"" title=""退  出""><span>退  出</span></a></li>"
	End If
	usermenu=usermenu & "</ul>"
end Function 

function userinfo_title()
	If session("xh")<>"" Then 
		userinfo_title="学号信息"
	else
		userinfo_title="学生登陆"
	End If
End Function 

function userinfo()
	If session("xh")<>"" Then 
		userinfo= "当前学号:<font color=red>"&session("xh")&"</font><br>"
		userinfo=userinfo & "<hr size=1 color=#07396D style=filter:alpha(opacity=10,finishopacity=100,style=1,startX=100,startY=100,finishX=0,finishY=0);width:100%;><br>"
		userinfo=userinfo & "姓名:"&session("xm")
		userinfo=userinfo & "<br>年级:"&session("lj")
		userinfo=userinfo & "<br>班级:"&session("bj")
		userinfo=userinfo & "<br /><br /><br /><br /><br /><br /><br /><br />"
	else
		userinfo=userinfo & "<form action=checklogin.asp method=post name=form1 style=margin:0px>"
		userinfo=userinfo & "学号:"
		userinfo=userinfo & "<input name=xh type=text size=17 onKeyDown=javascript:return check_isnum() class=smallInput><br>"
		userinfo=userinfo & "密码:"
		userinfo=userinfo & "<input name=mm type=password class=smallInput size=17 style=float: left><br>"
		userinfo=userinfo & "<input name=kind type=hidden size=5 value=student><input type=image src=images/login_botton_01.gif name=Submit value=登陆>&nbsp;"
		userinfo=userinfo & "<img src=images/login_botton_03.gif onClick=javascript:window.location.href = 'register.asp?action=reg'>&nbsp;"
		userinfo=userinfo & "<img src=images/login_botton_05.gif onClick=javascript:window.location.href = 'register.asp?action=getpass'><br>"
		userinfo=userinfo & "</form>"
	End If 
end Function 

function maintop_title(infos)
	select case infos
	Case "cj"
		If session("xh")<>"" Then 
			maintop_title="成绩信息"
		else
			maintop_title ="提示"
		End If 
	Case "post"
		maintop_title="公告信息"
	Case "guest"
		maintop_title="系统留言"
	case else
		
	End Select
end Function 

function maintop(infos)
	select case infos
	Case "cj"
	tbs="ico_service_login.gif"
	tbsinfo1="成绩查询"
	tbsinfo2="查询你的成绩,统计各科名次及总平成绩。"
	Case "post"
	tbs="ico_service_bonus.gif"
	tbsinfo1="最新公告"
	tbsinfo2="查阅的最新公布的信息"
	Case "guest"
	tbs="ico_service_feedback.gif"
	tbsinfo1="在线留言"
	tbsinfo2="提交你的问题给系统管理员。"
	case else
	End Select
	maintop="<table ><tr><td><img src="""&SystemFolder&"images/"&tbs&""" border=0></td><td><b>"&tbsinfo1&"</b><br>"&tbsinfo2&"</td></tr></table>"
end Function 

function errorinfo(infos)
select case infos
	Case "cj"
	tbs="ico_service_login.gif"
	tbsinfo1=xq
	tbsinfo2="当前学期还没有你的成绩。"
	case else
	tbsinfo1="您还未登录学生成绩查询系统"
	tbsinfo2="未登录状态下您无法查阅你的成绩,请在左侧面板处登录。"
	End Select
	errorinfo="<br><div id=""errors"">"&tbsinfo1&"<br>"& tbsinfo2&"</div>"
end Function 


function maininfo(infos)
	select case infos
	Case "cj"
	If session("xh")<>"" Then 
	maininfo=cjinfo
	else
	maininfo=errorinfo("")
	maininfo=maininfo&"<BR><script  language='JavaScript'  src=user_manager.asp?action=post_js&number=10&count=20&dates=0></script>"
	End If 
	Case "post"
	maininfo=postinfo
	Case "guest"
	maininfo=guestinfo
	case else

	End Select
end Function 

Function cjinfo()
If Request.Querystring("xq_id")="" Then 
		set rsxq=server.createobject("adodb.recordset")
		sqlxq="select id,xq from xqb order by xq desc"
		rsxq.Open sqlxq,conn,1,2
		xq_id=rsxq(0)
		xq=rsxq(1)
	Else
		xq_id=CLng(Request.Querystring("xq_id")) 
		set rsxq=server.createobject("adodb.recordset")
		sqlxq="select xq from xqb where id="&xq_id
		rsxq.Open sqlxq,conn,1,2
		xq=rsxq(0)
	End If 
	rsxq.close
	Set rsxq=Nothing 
	set rscj=server.createobject("adodb.recordset")
	sqlcj="select * from cj_"&session("lj")&",ljb,bjb,kcb where ljb.id=ljb_id and bjb.id=ljbj_id and kcb.id=kcb_id and xq_id="&xq_id&" and lj='"&session("lj")&"' and bj='"&session("bj")&"' and xh='"&session("xh")&"'"
	rscj.Open sqlcj,conn,1,2

	If Not rscj.eof Then 
		cjinfo="<br><table width=350  border=0 cellspacing=0 cellpadding=0>"
		cjinfo=cjinfo & "<tr><td colspan=3><b>"&xq&"</b></td></tr>"
		cjinfo=cjinfo & "<tr><td colspan=3><hr size=1 style=""COLOR: #000;border-style:dotted;width:100%""></td></tr>"
		cjinfo=cjinfo & "<tr>"
		cjinfo=cjinfo & "<td>课程</td>"
		cjinfo=cjinfo & "<td width=""40%"">成绩</td>"
		cjinfo=cjinfo & "<td>名次</td><tr>"
		Do While Not rscj.eof
			cjinfo=cjinfo & "<tr><td>"&rscj("kc")&"</td>"
			cjinfo=cjinfo & "<td>"
			cj=rscj("cj")
			If cj="" Then 
				response.write "--"
			ElseIf cj>-1 Then 
				If cj<60 Then 
					cjinfo=cjinfo & "<font color=#FF0000>"&cj&"</font>"
				Else 
					cjinfo=cjinfo & cj
				End If 
			End If
			lx=rscj("lx")
			If lx<>"" Then 	
				cjinfo=cjinfo & "("&lx&")"
			End If 
			cjinfo=cjinfo & "</td><td>"
			If rscj("mc")<0 Then
				cjinfo=cjinfo & "--"
			Else
			cjinfo=cjinfo & rscj("mc")
			End If 
			cjinfo=cjinfo & "</td></tr>"
			rscj.movenext
		Loop
			rscj.close
		Set rscj=Nothing 

		set rsmc=server.createobject("adodb.recordset")
		sqlmc="select * from cj_mc,bjb,ljb where xh='"&session("user")&"' and lj='"&session("lj")&"' and bj='"&session("bj")&"' and ljb.id=ljb_id and bjb.id=ljbj_id and xq_id="&xq_id
		rsmc.Open sqlmc,conn,1,1
		If Not rsmc.eof Then 
			cjinfo=cjinfo & "<tr>"
			cjinfo=cjinfo & "<td colspan=3>平均分:"&rsmc("pjf")&"&nbsp;&nbsp;总分:"&rsmc("zf")&"&nbsp;&nbsp;总分排名:"&rsmc("zfmc")
			cjinfo=cjinfo & "</td></tr>"
		End If 
		cjinfo=cjinfo & "</table>"
	Else
		cjinfo=errorinfo("cj")
	End If 
	cjinfo=cjinfo &select_xq
end Function 

Function select_xq()
	select_xq="<div id=""xq_select"" style=""width:350;""><br><br><hr size=1 style=""COLOR: #000;border-style:dotted;width:100%"">(查询其它成绩)考试类别列表:"
	select_xq=select_xq & "<select onchange=""location=this.options[this.selectedIndex].value"">"
	set rs1=server.createobject("adodb.recordset")
	sql1="select distinct id,xq from xqb order by xq desc"
	rs1.Open sql1,conn,1,1
	do while not rs1.eof
		select_xq=select_xq & "<option value=""user_manager.asp?xq_id="&rs1(0)&""""
		If xq_id=rs1(0) Then select_xq=select_xq & " selected "
		select_xq=select_xq & "size=""10"">"&rs1(1)&"</option>"
		rs1.movenext
	loop
	rs1.Close
	set rs1=Nothing 
	select_xq=select_xq & "</select></div>"					
end Function

Function post_js(number,count,dates)
	If number="" Then number=10
	If dates="" Then dates=10
	If count="" Then count=100
	set rs=conn.execute("SELECT top "&number&" * FROM cj_post order by data desc")
	if rs.eof and rs.bof then
	 post_js= "document.write('没有');"
	else  
		do while not rs.eof
			dates0=""
			If dates<>"0" Then dates0="("&rs("data")&")"
			post_js=post_js& "document.write('·<A href=\"""&cj_SystemFolder&"user_manager.asp?action=post&id="&rs("id")&"#post_title_"&rs("id")&"\"" title=\"""&trim(replace(rs("title"),"<br>",""))&"\"">"&left(trim(replace(rs("title"),"<br>","")),count)&"</A>"&dates0&"<br>');" & vbCrLf
		rs.movenext 
		Loop
	End If
	Rs.Close
	set Rs=Nothing
end Function

Function postinfo()
	page = CLng(request("page"))                            '利用CLng函数把page值转换为Long型
	sql="select * from cj_post order by id desc"
	rs.Open sql,conn,1,1
	if not (rs.EOF or rs.BOF) Then
		rs.MoveFirst
		rs.PageSize = 20  '每页显示的条数
		If page < 1 Then page = 1 
		If page > rs.PageCount Then page = rs.PageCount  
		rs.AbsolutePage = page
		postinfo=postinfo&"<BR>"
		For ipage = 1 To rs.PageSize
		styles="style=""display:none;"""
		If Int(request.querystring("id"))=rs("id") Then styles=""
			postinfo=postinfo&"<div id=""post_title_"&rs("id")&""">["&FormatDateTime(rs("data"),vbshortdate)&"]&nbsp;<a href=""javascript:void(0);"" onClick=""shows_post('"&rs("id")&"')"">·"&rs("title")&"</a><br>" & vbCrLf
			postinfo=postinfo&"<div id=""post_"&rs("id")&""" "&styles&">"&Replace(Replace(rs("content"),Chr(10),"<BR>"),Chr(13),"<BR>")&"</div>" & vbCrLf
			postinfo=postinfo&"<hr size=1 style=""COLOR: #000;border-style:dotted;width:100%"">" & vbCrLf
		rs.MoveNext      
			If rs.EOF Then Exit For   
		Next
	End If
postinfo=postinfo&"<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf
postinfo=postinfo&"function shows_post(objID)" & vbCrLf
postinfo=postinfo&"{" & vbCrLf
 postinfo=postinfo&"if (document.getElementById('post_'+objID).style.display == ""none"") {" & vbCrLf
postinfo=postinfo&"document.getElementById('post_'+objID).style.display = """";" & vbCrLf
postinfo=postinfo&"}else{" & vbCrLf
postinfo=postinfo&"document.getElementById('post_'+objID).style.display = ""none"";" & vbCrLf
postinfo=postinfo&"}}" & vbCrLf
postinfo=postinfo&"</SCRIPT>" & vbCrLf
postinfo=postinfo&pageinfo(page,rs.PageCount,"user_manager.asp?action=post",rs.recordCount,"信息","post")
end Function


Function pageinfo(page,allpage,action,allcount,infos,infos1)
	pageinfo="<table border=0 cellpadding=0 cellspacing=0>"
	pageinfo=pageinfo& "<tr>" & vbCrLf
	pageinfo=pageinfo& "<form onSubmit=return test(); method=get action="""&action&""">" & vbCrLf
	pageinfo=pageinfo& "<td width=220>" & vbCrLf
	If page = 1 Then 
		pageinfo=pageinfo& "<font class='white'>第一页 上一页</font> " & vbCrLf
	End If
	If page <> 1 Then 
		pageinfo=pageinfo& "<a href="&action&"&page=1 class='yellow'>第一页</a> " & vbCrLf
		pageinfo=pageinfo& "<a href="&action&"&page="&(page - 1)&"  class='yellow'>上一页</a> " & vbCrLf
	End If
	If page <> allpage Then 
		pageinfo=pageinfo& "<a href="&action&"&page="&(page + 1)&"  class='yellow'>下一页</a> " & vbCrLf
		pageinfo=pageinfo& "<a href="&action&"&page="&allpage&" class='yellow'>最后一页</a> " & vbCrLf
	End If 
	If page = allpage Then 
		pageinfo=pageinfo& "<font class='white'>下一页 最后一页</font> " & vbCrLf
	End If
	pageinfo=pageinfo& "</td>" & vbCrLf
	pageinfo=pageinfo& "<td>GOTO页数:" & vbCrLf
	pageinfo=pageinfo& "<input type=hidden name=action value="&infos1&">" & vbCrLf
	pageinfo=pageinfo& "<input type=text size=2 maxlength=4 name=page></td>" & vbCrLf
	pageinfo=pageinfo& "</form>" & vbCrLf
	pageinfo=pageinfo& "</tr><tr>" & vbCrLf
	pageinfo=pageinfo& "<td class=white colspan=2 height=25 >" & vbCrLf
	pageinfo=pageinfo& "共有"&allcount&"条"&infos&"&nbsp;&nbsp;当前页次:"&page&"/"&allpage
	pageinfo=pageinfo& "</td></tr></table>" & vbCrLf
end Function
%>