
<!--#include file="../inc/Conn.asp"-->
<!--#include file="Inc/Admin.Asp"-->
<!--#include file="../Inc/Ubbcode.asp"-->
<!--#include file="Inc/Function.asp"-->
<%
dim rs,sql
dim ID
dim Title,Content,User,Action
dim ok,AddDatee,Hits
FoundErr=false

StrTitle="信息"

ID=Request.Form("ID")
Title=Trim(request.form("Title"))
User=Trim(request.form("User"))
UpdateTime=trim(request.form("UpdateTime"))
Hits=trim(request.form("Hits"))
Action=trim(request("Action"))

DefaultPicUrl=trim(request.form("DefaultPicUrl"))
Downurl=trim(request.form("Downurl"))

if Title="" then
	founderr=true
	errmsg="<li>"&StrTitle&"标题不能为空</li>"
end if

if founderr=false then	
	if UpdateTime<>"" and IsDate(UpdateTime)=true then
		UpdateTime=CDate(UpdateTime)
	else
		UpdateTime=now()
	end if
	
	if Hits<>"" then
		Hits=CLng(Hits)
	else
		Hits=0
	end if
	
	set rs=server.createobject("adodb.recordset")
	select case Action
	  case "Add"	
		sql="select * from Dream_Banner where (id is null)" 
		rs.open sql,conn,1,3
		rs.addnew
		call SaveData()		
		rs.update	
		rs.close
		set rs=nothing
		response.redirect "Banner_Manage.asp"
	 case "Modify"	
  		if ID<>"" then
			sql="select * from Dream_Banner where id="&ID
			rs.open sql,conn,1,3
			if not (rs.bof and rs.eof) then
			    
				call SaveData()				
				rs.update
				rs.close
				set rs=nothing
	            response.redirect "Banner_Manage.asp"
 			else
				founderr=true
				errmsg=errmsg+"<li>找不到此"&StrTitle&"，可能已经被删除。</li>"
				call WriteErrMsg()
			end if
		else
			founderr=true
			errmsg=errmsg+"<li>不能确定ID的值</li>"
			call WriteErrMsg()
		end if
	 Case else
		founderr=true
		errmsg=errmsg+"<li>没有选定参数</li>"
		call WriteErrMsg()
	end select
	call CloseConn()
else
	WriteErrMsg
end if
%>

<%
sub SaveData()  
  rs("Dream_Title")=Title
  rs("Dream_User")=User
  rs("Dream_UpdateTime")=UpdateTime
  rs("Dream_Hits")=Hits
  rs("Dream_DefaultPicUrl")=DefaultPicUrl
  rs("Dream_DownUrl")=Downurl   
end sub
%>