<!--#include file="conn.asp"-->
<!--#include file="../../inc/filter.asp"-->

<%
Rem 获得活动列表
sub get_huodong_list()
	dim list
	list=""

	set rs_list=Server.CreateObject("ADODB.RecordSet")
	rs_list.open "select * from [fksf_huodong]",conn,1,1
	for i=1 to rs_list.recordcount
%>
		<tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#cccccc'" style="padding: 0px 2px;">
			<td align="center"><%=rs_list("id")%></td>
			<td align="center"><a href="../huodong.asp?id=<%=rs_list("id")%>" target="_blank"><%=rs_list("huodongname")%></a></td>
			<td align="center"><%=rs_list("publishdate")%></td>
			<td align="center"><img src="../upfile/<%=rs_list("pic")%>"></td>
			<td align="center"><a href="huodong_update_form.asp?id=<%=rs_list("id")%>">修改</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="huodong_delete.asp?id=<%=rs_list("id")%>">删除</a></td></tr>
<%
		rs_list.movenext()
	next
	rs_list.close()
	set rs_list=nothing
	response.write(list)
end sub
%>

<%
Rem 活动管理入口
sub huodong_access()
	action=trim(request("action"))
	if(action="") then
		response.Write("<script language=javascript>")
		response.Write("alert('判断参数不能为空');")
		response.Write("window.location='main_body.asp';")
		response.Write("</script>")
	else
		if(ChkBadWord(action)<>0) then
			response.Write("<script language=javascript>")
			response.Write("alert('判断参数包含非法字符');")
			response.Write("window.location='main_body.asp';")
			response.Write("</script>")
		else
			if(action="update") then
				call huodong_update()'操作活动更新
			else
				if(action="insert") then
					call huodong_insert()'操作活动添加
				else
					if(action="delete") then
						call huodong_delete()'操作活动删除
					end if
				end if
			end if
		end if
	end if
end sub
%>

<%
Rem 操作活动更新
sub huodong_update()
	dim sContent1,i
	For i = 1 To Request.Form("content1").Count 
		sContent1 = sContent1 & Request.Form("content1")(i) 
	Next
	id=trim(request("id"))
	huodongname=trim(request("huodongname"))
	pic=trim(request("pic"))
	
	if(id="" or huodongname="" or pic="" or sContent1="") then
		response.Write("<script language=javascript>")
		response.Write("alert('参数不能为空');")
		response.Write("window.location='main_body.asp';")
		response.Write("</script>")
	else
		set rs_huodong=Server.CreateObject("ADODB.RecordSet")
		rs_huodong.open "select * from [fksf_huodong] where id="&id,conn,1,3
		if(rs_huodong.eof) then
			rs_huodong.close()
			set rs_huodong=nothing
			response.Write("<script language=javascript>")
			response.Write("alert('本系统中无该活动');")
			response.Write("window.location='main_body.asp';")
			response.Write("</script>")
		else
			rs_huodong("huodongname")=huodongname
			rs_huodong("pic")=pic
			rs_huodong("content")=sContent1
			rs_huodong("publishdate")=now()
			rs_huodong.update()
			rs_huodong.close()
			response.Write("<script language=javascript>")
			response.Write("alert('活动更新成功');")
			response.Write("window.location='main_body.asp';")
			response.Write("</script>")
		end if
	end if
end sub
%>

<%
Rem 操作活动添加
sub huodong_insert()
	dim sContent1,i
	For i = 1 To Request.Form("content1").Count 
		sContent1 = sContent1 & Request.Form("content1")(i) 
	Next
	huodongname=trim(request("huodongname"))
	pic=trim(request("pic"))
	
	if(huodongname="" or pic="" or sContent1="") then
		response.Write("<script language=javascript>")
		response.Write("alert('参数不能为空');")
		response.Write("window.location='main_body.asp'")
		response.Write("</script>")
	else
		set rs_huodong=Server.CreateObject("ADODB.RecordSet")
		rs_huodong.open "select * from [fksf_huodong] where huodongname='"&huodongname&"'",conn,1,3
		if(not rs_huodong.eof) then
			rs_huodong.close()
			set rs_huodong=nothing
			response.Write("<script language=javascript>")
			response.Write("alert('该活动已存在');")
			response.Write("window.location='main_body.asp';")
			response.Write("</script>")
		else
			rs_huodong.addnew()
			rs_huodong("huodongname")=huodongname
			rs_huodong("pic")=pic
			rs_huodong("content")=sContent1
			rs_huodong("publishdate")=now()
			rs_huodong.update()
			rs_huodong.close()
			response.Write("<script language=javascript>")
			response.Write("alert('活动添加成功');")
			response.Write("window.location='main_body.asp';")
			response.Write("</script>")
		end if
	end if
end sub
%>

<%
Rem 操作活动删除
sub huodong_delete()
	dim id
	id=trim(request("id"))
	
	if(id="") then
		response.Write("<script language=javascript>")
		response.Write("alert('参数不能为空');")
		response.Write("window.location='main_body.asp';")
		response.Write("</script>")
	else
		if(ChkBadWord(id)<>0) then
			response.Write("<script language=javascript>")
			response.Write("alert('参数包含非法字符');")
			response.Write("window.location='main_body.asp';")
			response.Write("</script>")
		else
			conn.execute("delete from [fksf_huodong] where id="&id)
			response.Write("<script language=javascript>")
			response.Write("alert('删除活动成功');")
			response.Write("window.location='main_body.asp';")
			response.Write("</script>")
		end if
	end if
end sub
%>