managenotice.asp

来自「一套完整的学生课程管理系统」· ASP 代码 · 共 139 行

ASP
139
字号
<!-- #include file="utility/check.asp" -->

<%
	'****************************************
	'目的:			处理公告信息
	'开始时间:		2005-6-4 9:24
	'最后修改时间:	2005-6-4 9:24
	'编写人:		某某某
	'****************************************
	
	'定义相关变量
	dim actionType			'操作类型
	dim noticeID
	dim sql				
	dim rs
	
	actionType = Request.QueryString("actionType")
	
	'参数是否完整
	if(actionType = "") then
		Alert("参数丢失,拒绝操作!")
		Goback()
		Response.end
	end if
	
	'判断操作类型并执行对应操作
	Select case (actionType)
		case "add": 	
			addNotice()				'添加公告信息
		case "delete":	
			deleteNotice()			'删除公告信息
		case "change":
			changeNotice()			'修改公告内容
	end Select
	
	'添加新的公告信息
	Sub addNotice()
		dim noticeTitle				'标题
		dim noticeContent			'内容
		dim noticeFor				'发布对象
		dim noticeTeacherID			'发布人编号
		
		noticeTitle = Trim(Request.Form("noticeTitle"))
		noticeContent = HtmlEncode2(Trim(Request.Form("noticeContent")))
		noticeFor = Request.Form("noticeFor")
		noticeTeacherID = Session("userID")
		
		'判断信息完整性
		if(noticeTitle = "") then
			Alert("标题不能为空,拒绝操作!")
			GoBack()
			Response.End
		elseif(noticeContent = "") then
			Alert("内容不能为空,拒绝操作!")
			GoBack()
			Response.End	
		'下面这段检查代码一旦执行即表示系统受到恶意攻击
		elseif(noticeFor <> "教师" and noticeFor <> "学生") then
			Alert("参数非法,操作被拒绝")
			GoBack()
			Response.End	
		end if
		
		'添加公告到数据库
		sql = "insert into notice(nTitle,nContent,tID,nFor) values ('"
		sql = sql & noticeTitle & "','"
		sql = sql & noticeContent & "',"
		sql = sql & noticeTeacherID & ",'"
		sql = sql & noticeFor & "')"
		ExecuteNonQuery(sql)
		Alert("公告发布成功,请继续其他操作!")
		Go("welcome.htm")
	end Sub
	
	'删除指定ID的公告信息
	Sub deleteNotice()
		noticeID = Request.QueryString("nID")
		sql = "delete from notice where ID = " & noticeID
		'下面的代码可以确保用户有足够的权限删除对应公告
		if(Session("userFlag") <> "管理员") then
			sql = sql & " and tID = " & Session("userID")
		end if	
		ExecuteNonQuery(sql)
		Alert("公告删除成功,请继续其他操作")
		Go("listNotice.asp")
	end Sub
	
	'修改指定ID的公告信息
	Sub changeNotice()
		dim noticeTitle				'标题
		dim noticeContent			'内容
		dim noticeFor				'发布对象
		dim noticeTeacherName		'修改人姓名
		
		noticeID = Request.QueryString("nID")
		noticeTitle = Trim(Request.Form("noticeTitle"))
		noticeContent = HtmlEncode2(Trim(Request.Form("noticeContent")))
		noticeFor = Request.Form("noticeFor")
		noticeTeacherName = Session("userName")
		
		'参数是否完整
		if(noticeID = "") then
			Alert("参数丢失,操作失败!")
			GoBack()
			Response.end
		end if
		
		'判断信息完整性
		if(noticeTitle = "") then
			Alert("标题不能为空,拒绝操作!")
			GoBack()
			Response.End
		elseif(noticeContent = "") then
			Alert("内容不能为空,拒绝操作!")
			GoBack()
			Response.End	
		'下面这段检查代码一旦执行即表示系统受到恶意攻击
		elseif(noticeFor <> "教师" and noticeFor <> "学生") then
			Alert("参数非法,操作被拒绝")
			GoBack()
			Response.End	
		end if
		
		'在内容后添加信息表示此信息被修改过
		noticeContent = noticeContent & "<br><font color=red>"
		noticeContent = noticecontent & noticeTeacherName & "于"
		noticeContent = noticeContent & Date() & " " & Time()
		noticeContent = noticeContent & "编辑此公告</font>"
		
		sql = "update notice set nTitle = '" & noticeTitle & "',"
		sql = sql & "nContent = '" & noticeContent & "',"
		sql = sql & "nFor = '" & noticeFor & "' "
		sql = sql & "where ID = " & noticeID
		ExecuteNonQuery(sql)
		Alert("修改操作已经成功执行,请执行其他操作")
		Go("listNotice.asp")
	end Sub
	
%>

⌨️ 快捷键说明

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