⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vote_save.asp

📁 这是我根据动网新闻核心自行设计的校园新闻系统
💻 ASP
字号:
<!-- #include file="../inc/const.asp" -->
<%
pagename="votesave"
pageadmin=1
%>

<!-- #include file="../inc/conn.asp" -->
<!-- #include file="../inc/function.asp" -->
<!-- #include file="../inc/vote_function.asp" -->
<!-- #include file="../inc/sql.asp" -->

<%
dim action
dim votetitle
dim votedetail
dim returnvalues
dim style
dim votecount
action=FormatText(request("action"))

select case action
	case "add"
		votetitle=FormatText(request("votetitle"))
		votedetail=FormatText(request("votedetail"))
		style=FormatText(request("style"))
		if votetitle=empty or votedetail=empty then
			response.write "<script>alert('投票和选择项不能为空');history.back();</script>"
			call connclose
			response.end
		end if
		votedetail=GetSplit(votedetail)
		'开始事务
		conn.BeginTrans
			'插入标题
			returnvalues=InsertSql("vote_vote","votetitle,style,userid","'"&votetitle&"','"&style&"','"&userid&"'")
			
			'插入选择项
			for i=0 to ubound(votedetail)
				call InsertSql("vote_details","voteid,votedetail",returnvalues&",'"&votedetail(i)&"'")
			next
		if err then
			conn.RollBackTrans
			'response.write err.description
			call showerror("添加投票操作失败.")
		else
			conn.CommitTrans
			call showsuccess("投票添加成功","add_vote.asp")
		end if

'*******************************************修改
	case "mod"
		votetitle=FormatText(request("votetitle"))
		votedetail=FormatText(request("votedetail"))
		votecount=FormatText(request("votecount"))
		style=FormatText(request("style"))
		if votetitle=empty or votedetail=empty then
			response.write "<script>alert('投票和选择项不能为空');history.back();</script>"
			call connclose
			response.end
		end if
		votedetail=GetSplit(votedetail)
		votecount=GetSplit(votecount)
		'开始事务
		conn.BeginTrans
			'更新标题
			call UpdateSql("vote_vote","votetitle,style","'"&votetitle&"','"&style&"'","id="&FormatText(request("id")))

			'删除旧的选择项
			call DeleteSql("vote_details","voteid="&FormatText(request("id")))
			'插入选择项
			for i=0 to ubound(votedetail)
				call InsertSql("vote_details","voteid,votedetail,votecount",FormatText(request("id"))&",'"&votedetail(i)&"',"&votecount(i)&"")
			next
		if err then
			conn.RollBackTrans
			'response.write err.description
			call showerror("更新投票操作失败.")
		else
			conn.CommitTrans
			call showsuccess("投票更新成功","vote_list.asp")
		end if

'*****************************************删除
	case "del"
		conn.BeginTrans
		call DeleteSql("vote_vote","id="&FormatText(request("id")))
		call DeleteSql("vote_details","voteid="&FormatText(request("id")))
		if err then
			conn.RollBackTrans
			'response.write err.description
			call showerror("删除投票操作失败.")
		else
			conn.CommitTrans
			call showsuccess("投票删除成功","vote_list.asp")
		end if
end select
call connclose		
		
%>

⌨️ 快捷键说明

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