<!--#include file="conn.asp"-->
<!--#include file="../../inc/filter.asp"-->
<%
Rem 获得文章列表
sub get_article_list()
	dim list
	list=""
	classname=trim(request("classname"))
	
	if(classname="") then
		response.Write("<script language=javascript>")
		response.Write("alert('类别参数不能为空');")
		response.Write("window.location='main_body.asp';")
		response.Write("</script>")
	else
		if(ChkBadWord(classname)<>0) then
			response.Write("<script language=javascript>")
			response.Write("alert('类别参数包含非法字符');")
			response.Write("window.location='main_body.asp';")
			response.Write("</script>")
		else
			set rs_list=Server.CreateObject("ADODB.RecordSet")
			rs_list.open "select * from [fksf_news] where classname='"&classname&"'",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="../news.asp?id=<%=rs_list("id")%>" target="_blank"><%=rs_list("subject")%></a></td>
					<td align="center"><%=classname%></td>
					<td align="center"><%=rs_list("publishdate")%></td>
					<td align="center"><a href="article_update_form.asp?classname=<%=classname%>&id=<%=rs_list("id")%>">修改</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="article_delete.asp?classname=<%=classname%>&id=<%=rs_list("id")%>">删除</a></td></tr>
<%
				rs_list.movenext()
			next
			rs_list.close()
			set rs_list=nothing
		end if
	end if
	
	response.write(list)
end sub
%>

<%
Rem 文章管理入口
sub article_access()
	dim action
	action=trim(request("action"))
	
	if(action="") then
		response.Write("<script language=javascript>")
		response.Write("alert('判断参数不能为空');")
		response.Write("history.go(-1);")
		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 article_update()'操作文章更新
			else
				if(action="insert") then
					call article_insert()'操作文章添加
				else
					if(action="delete") then
						call article_delete()'操作文章删除
					end if
				end if
			end if
		end if
	end if
end sub
%>

<%
Rem 保存文章更新
sub article_update()
	dim sContent1,i,classname,subject,id
	For i = 1 To Request.Form("content1").Count 
		sContent1 = sContent1 & Request.Form("content1")(i) 
	Next
	classname=trim(request("classname"))
	subject=trim(request("title"))
	id=trim(request("id"))
	
	if(id="" or classname="" or subject="" or sContent1="") then
		response.Write("<script language=javascript>")
		response.Write("alert('参数不能为空');")
		response.Write("history.go(-1);")
		response.Write("</script>")
	else
		set rs_article=Server.CreateObject("ADODB.RecordSet")
		rs_article.open "select * from [fksf_news] where id="&id,conn,1,3
		if(rs_article.eof) then
			rs_article.close()
			set rs_article=nothing
			response.Write("<script language=javascript>")
			response.Write("alert('本系统无该文章');")
			response.Write("history.go(-1);")
			response.Write("</script>")
		else
			rs_article("classname")=classname
			rs_article("subject")=subject
			rs_article("content")=sContent1
			rs_article("publishdate")=now()
			rs_article.update()
			rs_article.close()
			set rs_article=nothing
			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 article_insert()
	dim sContent1,i,classname,subject
	For i = 1 To Request.Form("content1").Count 
		sContent1 = sContent1 & Request.Form("content1")(i) 
	Next
	classname=trim(request("classname"))
	subject=trim(request("title"))
	
	if(subject="" or classname="" or sContent1="") then
		response.Write("<script language=javascript>")
		response.Write("alert('参数不能为空');")
		response.Write("history.go(-1);")
		response.Write("</script>")
	else
		set rs_article=Server.CreateObject("ADODB.RecordSet")
		rs_article.open "select * from [fksf_news]",conn,1,3
		rs_article.addnew()
		rs_article("classname")=classname
		rs_article("subject")=subject
		rs_article("content")=sContent1
		rs_article("publishdate")=now()
		rs_article.update()
		rs_article.close()
		set rs_article=nothing
		response.Write("<script language=javascript>")
		response.Write("alert('新闻添加成功');")
		response.Write("window.location='main_body.asp';")
		response.Write("</script>")
	end if
end sub
%>

<%
Rem 删除文章
sub article_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_news] 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
%>