<!--#include file="../inc/conn1.asp"-->
<%
'添加新闻内容
if request.form("action")="add" then
	news_name=request.form("news_name")
	sort_id=request.form("sort_id")
	news_content=request.form("content")
	news_date=date()
	
	set rs=server.createobject("adodb.recordset")
	sql="select * from news"
	rs.open sql,conn,1,3
	
				rs.addnew
				if news_name="" then
				response.Write("<script language='javascript'>alert('新闻标题必须填写！');window.location.href='news_admin.asp?action=add';</script>")	
				response.end 
				else
				rs("news_name")=news_name
				end if
				
				rs("sort_id")=sort_id
				rs("news_date")=news_date
				
				if news_content="" then
				response.Write("<script language='javascript'>alert('新闻内容必须填写！');window.location.href='news_admin.asp?action=add';</script>")	
				response.end 
				else
				rs("news_content")=news_content
				end if
				
				rs.update
				response.Write("<script language='javascript'>alert('新闻内容添加成功！');window.location.href='news_list.asp';</script>")	
	rs.close
	set rs=nothing
	
	
'修改新闻内容
elseif request.form("action")="edit" then
	news_id=request.form("news_id")
	news_name=request.form("news_name")
	sort_id=request.form("sort_id")
	news_content=request.form("content")
	news_date=date()
	
	set rs=server.createobject("adodb.recordset")
	sql="select * from news where news_id="&news_id&""
	rs.open sql,conn,1,3
	
				if news_name="" then
				response.Write("<script language='javascript'>alert('新闻标题必须填写！');window.location.href='news_list.asp';</script>")	
				response.end 
				else
				rs("news_name")=news_name
				end if
				
				rs("sort_id")=sort_id
				rs("news_date")=news_date
				
				if news_content="" then
				response.Write("<script language='javascript'>alert('新闻内容必须填写！');window.location.href='news_list.asp';</script>")	
				response.end 
				else
				rs("news_content")=news_content
				end if
				
				rs.update
				response.Write("<script language='javascript'>alert('新闻内容修改成功！');window.location.href='news_list.asp';</script>")	
	rs.close
	set rs=nothing
end if
	conn.close
	set conn=nothing
%>