<!--#include file="../../../inc/cms_admin.asp" -->
<%
dim AdID,AdName,AdClass,AdImg,AdLink,AdWidth,AdHeight,AdStime,AdEtime,AdOnOff,AdContent,AddTime,LID,AdStyle
dim sql,table,col,colval,idval,id

dim act : act=getForm("act","get")
dim stype : stype=getForm("stype","get")
dim postion : postion=getForm("postion","get")
table=getForm("table","both")
col=getForm("col","both")
colval=getForm("colval","both")
idval=getForm("idval","both")
AdID=getForm("AdID","both")

Select case act	
	case "setad"	:	dbconn("update  [dbpre]ad set adonoff="&colval&"  where  AdID="&AdID&"")	
	case "getcity"	:	getcity
	case "edit"		:	editad
	case "add"		: 	addtad
	case "del"		:	dbconn("delete from [dbpre]ad  where AdID in ("&idval&")")
	case "saveid"	:	saveid
	case "ok"	 	: 	script("{parent.layer.msg('成功保存',{icon: 1})}")
End Select

Sub saveid
	dim colid		:	colid=getForm("colid","both")
	dim colname		:	colname=getForm("colname","both")
	dim colval		:	colval=getForm("colval","both")
	dim sql1 		:	sql1="update [dbpre]ad Set "&colname&"='"&colval&"' Where AdID="&colid
	dim sql2 		:	sql2="update [dbpre]ad Set "&colname&"="&colval&" Where AdID="&colid	
	dbconn(sql1)	:	if err then dbconn(sql2)
End Sub

Sub addtad
	 AdName=getForm("AdName","post")
	 AdClass=getForm("AdClass","post")
	 AdImg=getForm("AdImg","post")
	 AdLink=getForm("AdLink","post")
	 AdWidth=getForm("AdWidth","post")	
	 AdHeight=getForm("AdHeight","post")	
	 AdStime=getForm("AdStime","post")
	 AdEtime=getForm("AdEtime","post")	
	 AdOnOff=getcheck(getForm("AdOnOff","post"))
	 AdContent=getForm("AdContent","post")	
	 LID=zset.lid	
	 AdStyle =""
	  if isnul(AdStime) then AdStime=now()
	 if isnul(AdName) then back "名称不能为空"	
	 if isnul(AdClass) then back "样式不能为空"	   
	  if isnul(AdEtime) then back "结束时间不能为空"	
	  
	sql="insert into [dbpre]ad(AdName,AdClass,AdImg,AdLink,AdWidth,AdHeight,AdStime,AdEtime,AdOnOff,AdContent,AddTime,AdStyle,LID) values ('"&AdName&"','"&AdClass&"','"&AdImg&"','"&AdLink&"','"&AdWidth&"','"&AdHeight&"','"&AdStime&"','"&AdEtime&"',"&AdOnOff&",'"&AdContent&"','"&AddTime&"','"&AdStyle&"',"&LID&")"
	 dbconn(sql)
	layertrue("添加成功")
End Sub

Sub editad
	 AdName=getForm("AdName","post")
	 AdClass=getForm("AdClass","post")
	 AdImg=getForm("AdImg","post")
	 AdLink=getForm("AdLink","post")
	 AdWidth=getForm("AdWidth","post")	
	 AdHeight=getForm("AdHeight","post")	
	 AdStime=getForm("AdStime","post")
	 AdEtime=getForm("AdEtime","post")	
	 AdOnOff=getcheck(getForm("AdOnOff","post"))
	 AdContent=getForm("AdContent","post")	
	 LID=zset.lid	
	 AdStyle =""
	 if isnul(AdStime) then AdStime=now()
	 if isnul(AdName) then back "名称不能为空"	
	 if isnul(AdClass) then back "样式不能为空"	   
	  if isnul(AdEtime) then back "结束时间不能为空"	 
	  
	 dbconn("update  [dbpre]ad set AdName='"&AdName&"', AdClass='"&AdClass&"',AdImg='"&AdImg&"',AdLink='"&AdLink&"',AdWidth='"&AdWidth&"',AdHeight='"&AdHeight&"',AdStime='"&AdStime&"',AdEtime='"&AdEtime&"',AdContent='"&AdContent&"',AdOnOff="&AdOnOff&",LID="&LID&",AdStyle='"&AdStyle&"' where  AdID="&AdID&"")	
	layertrue("修改成功")
End Sub


Sub getad
dim rs,id
	if not isnul(AdID) then	
		sql ="select * from [dbpre]ad where AdID="&AdID
		set rs = conn.exec(sql,"r1")		
	else
		alertgo "没有这条记录","-1"
	end if 
	
	if rs.eof then 
			alertgo "没有这条记录","-1"
		else
			AdID=rs("AdID")
			AdName=rs("AdName")
			AdClass=rs("AdClass")
			AdImg=rs("AdImg")
			AdLink=rs("AdLink")
			AdWidth=rs("AdWidth")
			AdHeight=rs("AdHeight")
			AdStime=rs("AdStime")
			AdEtime=rs("AdEtime")
			AdOnOff=rs("AdOnOff")
			AdContent=rs("AdContent")
			AddTime=rs("AddTime")
			AdStyle=rs("AdStyle")
		end if
	rs.close : set rs=nothing
End Sub


%>