<!--#include file="conn.asp"-->
<!--#include file="admin.asp"-->
<%
title=request("title")
'TitleColor=request("TitleColor")
BigClassName=request("BigClassName")
SmallClassName=request("SmallClassName")
wailink=request("wailink")
author=request("author")
from=request("from")
pic=request("pic")
'tuijian=request("tuijian")
'guding=request("guding")
'FileName1=request("FileName1")
FileName2=request("FileName2")
'AutoCutStr=int(request("AutoCutStr"))
'KeyWords=request("KeyWords")

set rsbig=server.createobject("adodb.recordset")
sqlbig="select count (*) as bigClassNum from SmallClass_New where BigClassName='"&BigClassName&"'"
rsbig.open sqlbig,conn,1,1
bigClassNum2=rsbig("bigClassNum")

set rsbig2=server.createobject("adodb.recordset")
sqlbig2="select * from SmallClass_New where BigClassName='"&BigClassName&"' and SmallClassName='"&SmallClassName&"'"
rsbig2.open sqlbig2,conn,1,1
conclass2=rsbig2("conclass")

if (bigClassNum2>0) and (SmallClassName="") then

response.write"<Script>alert('“"&BigClassName&"”栏目下还有二级栏目，您必须选择一个二级栏目方可添加。');history.back();</Script>"

else
	
	set rsClassNum=server.createobject("adodb.recordset")
	sqlClassNum="select count (*) as ClassNum from News where BigClassName='"&BigClassName&"' and  SmallClassName='"&SmallClassName&"'"
	rsClassNum.open sqlClassNum,conn,1,1
	ClassNum2=rsClassNum("ClassNum")
		if (conclass2="简介类") and ClassNum2>0 then
		response.write"<Script>alert('“"&BigClassName&"”－“"&SmallClassName&"”栏目为简介类栏目，只能有一条信息，而数据库中已经有一条信息了，您只能在“管理全部信息”中找到该条信息然后修改，或者删除该信息后重新在该栏目中添加一条信息。');history.back();</Script>"
		else
			set rs=server.createobject("adodb.recordset")
			sql="select * from NEWS where (id is null)"
			rs.open sql,conn,1,3
			rs.addnew
			rs("title")=title
			
			rs("BigClassName")=BigClassName
			rs("SmallClassName")=SmallClassName
			rs("author")=author
			rs("from")=from
				if pic="" then rs("pic")="No" 
				if pic<>"" then rs("pic")=pic
				if wailink="" then rs("wailink")="No"
				if FileName2="" then rs("FileName2")="Null" 
				if FileName2<>"" then rs("FileName2")=FileName2
				
			Dim strNewsContent
			For i = 1 To Request.Form("newscontent").Count 
			strNewsContent = strNewsContent & Request.Form("newscontent")(i) 
			Next 
			rs("content")=strNewsContent
			rs("content")="作品名称："&title&"&nbsp;&nbsp;&nbsp;作者："&from&"<br>"&strNewsContent&"<p><img src='../../"&filename2&"'>"
			rs.update
			rs.close
			set rs=nothing
			conn.close  
			set conn=nothing
			response.write "<script language='javascript'>" & chr(13)
					response.write "alert('信息提交成功！');" & Chr(13)
					response.write "window.document.location.href='manage_news.asp?bigclassname="&bigclassname&"';"&Chr(13)
					response.write "</script>" & Chr(13)
			Response.End
		end if
	rsClassNum.close
	
end if
rsbig2.close
rsbig.close
%>