managemessage.asp

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

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

<%
	'****************************************
	'目的:			处理用户短信息
	'开始时间:		2005-5-30
	'最后修改时间:	2005-5-30
	'编写人:		某某某
	'****************************************
		
	'首先检查是否有权限
	'也就是用户是否通过审核
	CheckFlag(1)
	
	dim actionType
	dim sql
	dim rs
	
	actionType = Request.QueryString("actionType")
	
	Select case (actionType)
		case "add": 	addMessage()		'添加信息
		case "delete":	deleteMessage()		'删除信息
	end Select
	
	'添加新的信息到数据库
	Sub addMessage()
	
		'定义相关变量并用Form中的值填充
		dim msgTitle
		dim msgFrom
		dim msgTo
		dim msgContent
		
		msgTitle = Trim(Request.Form("msgTitle"))
		msgFrom = Session("userID")
		msgTo = Trim(Request.Form("msgTo"))
		msgContent = HtmlEncode2(Trim(Request.Form("msgContent")))
		
		'判断信息是否填充完整
		if(msgTitle = "" or msgTo = "" or msgContent ="") then
			Alert("请填写所有空白后再提交!")
			GoBack()
			Response.end
		end if
		
		'学生自己不能给自己发送短信
		if(msgTo = msgFrom) then
			Alert("对不起,您不能给自己发送信息!")
			GoBack()
			Response.end
		end if
		
		'判断信息发送对象是否存在
		sql = "select count(*) from student,teacher where student.ID = '"
		sql = sql & msgTo & "'"
		set rs = ExecuteQuery(sql)
		if(rs(0) < 1) then
			Alert("请填写正确的收信人!\n收信人应该为学生学号!")
			GoBack()
			rs.close()
			set rs = nothing
			Response.end
		end if
		
		'所有判断都通过以后添加信息到数据库中
		sql = "insert into message(msgFrom,msgTo,msgContent,msgTitle) values ('"
		sql = sql & msgFrom & "','"
		sql = sql & msgTo & "','"
		sql = sql & msgContent & "','"
		sql = sql & msgTitle & "')"
		ExecuteNonQuery(sql)
		
		Alert("您的信息已经发送成功!")
		Go("welcome.htm")
	end Sub
	
	'删除指定ID的消息
	Sub deleteMessage()
		dim msgID
		msgID = Request.QueryString("msgID")
		
		'判断用户是否有权限删除信息
		sql = "select msgTo from message where ID = " & msgID
		set rs = ExecuteQuery(sql)
		if(rs(0) <> Session("userID")) then
			Alert("该信息不存在或者您没有权限删除该信息!")
			GoBack()
			rs.close()
			set rs = nothing
			Response.end
		end if
		
		'删除信息
		sql = "delete from message where ID = " & msgID
		ExecuteNonQuery(sql)
		Alert("该信息已被删除")
		Go("listReceivedMessage.asp")
	end Sub
	

%>

⌨️ 快捷键说明

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