<!--#include file="tgzcm_Conn.asp"-->
<!--#include file="tgzcm_Check.asp"-->
<!--#include file="../tgzcm.Cache/tgzcm.Admin.asp"-->
<%
dim action,id,reurl,Title,data_lastdate,Content,News_Color,allid
reurl=Request.ServerVariables("Http_Referer")'来源地址
If reurl="" Then reurl="tgzcm_News.asp"
action=Trim(Request.QueryString("action"))
id=Clng(Request.QueryString("id"))
allid=tgzcm_replace(Trim(Request.Form("allid")))'批量影片ID
Title=Left(tgzcm_replace(request.form("Title")),255)'新闻标题
data_lastdate=Cint(request.form("data_lastdate"))'是否更新时间,0,1
Content=Trim(request.form("Content"))'影片简介
News_Color=tgzcm_replace(request.form("News_Color")) '标题颜色

Sub News_Add '作用:入库新的新闻信息
    If Title=""  Then 
	    Call tgzcm_err_c("新闻名称不能为空！")
	    Response.End
    ElseIf Content=""  Then
	    Call tgzcm_err_c("新闻内容不能为空！")
	    Response.End	
    End if
	Set rs = Server.CreateObject("adodb.recordset")
	sql = " select * from tgzcm_News "
	rs.Open sql, Conn, 1, 3
	rs.AddNew
	rs("title")=Title
	rs("Content")=Content
	rs("Color")=News_Color
	rs("datetimes")=now()
	rs.update
	rs.Close
	Set rs=nothing
	Call tgzcm_err_b("新闻增加成功！","tgzcm_News.asp")

End sub

Sub News_Edit '作用:编辑新闻信息
    If Title=""  Then 
	    Call tgzcm_err_c("新闻名称不能为空！")
	    Response.End
    ElseIf Content=""  Then
	    Call tgzcm_err_c("新闻内容不能为空！")
	    Response.End	
    End if
    Set rs = Server.CreateObject("adodb.recordset")
	sql = " select * from tgzcm_News where id="&id&" "
	rs.Open sql, Conn, 1, 3
	If Not (rs.bof And rs.eof) Then 
		rs("title")=Title
	    rs("Content")=Content
	    rs("Color")=News_Color
		If data_lastdate=1 Then
		rs("datetimes")=now()
		End If
		rs.update
	End if
	rs.Close
	set rs=nothing
	Call tgzcm_err_b("新闻修改成功！","tgzcm_News.asp")
End Sub

Sub News_Del '作用:删除新闻信息 
    If allid<>"" then '批量删除新闻信息
	ad=Split(allid,",")
	  for bd=0 to Ubound(ad)
	    conn.execute(" delete from tgzcm_News where id="&ad(bd)&" ")'删除新闻信息
	  next
	  Response.Redirect(reurl)
	Elseif id>0 Then
      conn.execute(" delete from tgzcm_News where id="&id&" ")'删除新闻信息
	  Response.Redirect(reurl)
	Else
	  Call tgzcm_err_b("TgzcmCms错误:"&Err.Number&" ！","tgzcm_News.asp") 
	End if  
End Sub

%>

<%
If action="add" then 
    Call News_Add
ElseIf action="edit" then 
    Call News_Edit
ElseIf action="del" then 
    Call News_Del		
Else
   Call tgzcm_err_c("请检查你提交的参数是否正确！")
   Response.End
End if
%>
