<!--#include file="config.asp" -->

<%
function changechr(str)
changechr=replace(replace(replace(replace(str,"<","&lt;"),">","&gt;"),chr(13),"<br>")," "," ")
changechr=replace(changechr,"'","‘")
changechr=replace(changechr,mid(" "" ",2,1),"&quot;")
end function

if request("action")="addone" then

pricename=changechr(trim(request.form("price")))
If pricename="" Then
response.write "<script>alert('请填写广告种类！');history.go(-1);</Script>"
Response.End 
end if

set adsrs=server.createobject("adodb.recordset")
adssql="select * from dlxf_price where dlxf_price='"& pricename &"'"
adsrs.open adssql,conn,1,3
if not adsrs.eof then
response.write "<script>alert('已经存在这个广告分类名称！');history.go(-1);</Script>"
Response.End 
else

set adsrs1=server.createobject("adodb.recordset")
adssql1="select * from dlxf_price"
adsrs1.open adssql1,conn,1,1
htc=adsrs1.recordcount
adsrs1.close
set adsrs1=nothing

adsrs.addnew
adsrs("dlxf_price")=pricename
adsrs("dlxf_priceID")=htc+1
adsrs.update
end if
adsrs.close
set adsrs=nothing
response.redirect "mana.asp"
'================================================================
elseif request("action")="oedit" then

ID=request("ID")
pricename=changechr(trim(request.form("pricename")))
If pricename="" Then
response.write "<script>alert('请填写广告种类！');history.go(-1);</Script>"
Response.End 
end if
'修改广告种类

set adsrs=server.createobject("adodb.recordset")
adssql="select * from dlxf_price where dlxf_priceID="&ID
adsrs.open adssql,conn,1,3
pricen=adsrs("dlxf_price")
adsrs("dlxf_price")=pricename
adsrs.update
adsrs.close

'修改广告位置

set adsrs=server.createobject("adodb.recordset")
adssql="select * from dlxf_place where dlxf_price='"&pricen&"'"
adsrs.open adssql,conn,1,3
do while not adsrs.eof
adsrs("dlxf_price")=pricename
adsrs.update
adsrs.movenext
loop
adsrs.close

'修改广告条数据

set adsrs=server.createobject("adodb.recordset")
adssql="select * from dlxf_ads where dlxf_price='"&pricen&"'"
adsrs.open adssql,conn,1,3
do while not adsrs.eof
adsrs("dlxf_price")=pricename
adsrs.update
adsrs.movenext
loop
adsrs.close
set adsrs=nothing
response.redirect "mana.asp"
'================================================================
elseif request("action")="odel" then
price=request("price")
button_value=trim(Request.Form("alert_button"))
if button_value="是" then
conn.Execute("DELETE FROM [dlxf_price] WHERE dlxf_price='"&price &"'")
conn.Execute("DELETE FROM [dlxf_place] WHERE dlxf_price='"&price&"'")
conn.Execute("DELETE FROM [dlxf_ads] WHERE dlxf_price='"&price&"'")
Response.Redirect "mana.asp"
end if
'================================================================
elseif request("action")="tadd" then
price=changechr(trim(request.form("price")))
place=changechr(trim(request.form("place")))
if IsNumeric(place)=false then
response.write "<script>alert('广告编号必须为数字！');history.go(-1);</Script>"
response.end
end if
isnumsic
placename=changechr(trim(request.form("placename")))
jg=changechr(trim(request.form("jg")))
jgg=changechr(trim(request.form("jgg")))
cc=changechr(trim(request.form("cc")))

If price="" or place="" or placename="" or jg="" or jgg="" or cc="" Then
response.write "<script>alert('请填写广告位置资料！');history.go(-1);</Script>"
Response.End 
end if

if instr(cc,"*")=0 then
response.write "<script>alert('广告尺寸格式为：宽*高\n\n宽和高中间请用 * 隔开');history.go(-1);</Script>"
Response.End 
end if

set adsrs=server.createobject("adodb.recordset")
adssql="select * from dlxf_place where dlxf_price='"& price &"' and dlxf_place="& place
adsrs.open adssql,conn,1,1
if not adsrs.eof then
response.write "<script>alert('此广告编号已存在！');history.go(-1);</Script>"
Response.End 
end if
adsrs.close

set adsrs=server.createobject("adodb.recordset")
adssql="select * from dlxf_price where dlxf_price='" & price & "'"
adsrs.open adssql,conn,1,1
id=adsrs("dlxf_priceid")
adsrs.close

set adsrs=server.createobject("adodb.recordset")
adssql="select * from dlxf_place"
adsrs.open adssql,conn,1,3
adsrs.addnew
adsrs("dlxf_place")=place
adsrs("dlxf_price")=price
adsrs("dlxf_priceid")=id
adsrs("dlxf_placename")=placename
adsrs("dlxf_jg")=jg
adsrs("dlxf_jgg")=jgg
adsrs("dlxf_cc")=cc
adsrs.update
adsrs.close
set adsrs=nothing
conn.close
set conn=nothing
response.redirect "Mana.asp"
'================================================================
elseif request("action")="tedit" then
ID=request("ID")
place=changechr(trim(request("place")))
if IsNumeric(place)=false then
response.write "<script>alert('广告编号必须为数字！');history.go(-1);</Script>"
response.end
end if
placename=changechr(trim(request("placename")))
jg=changechr(trim(request("jg")))
jgg=changechr(trim(request("jgg")))
cc=changechr(trim(request.form("cc")))

If place="" or placename="" or jg="" or jgg="" or id="" or cc="" Then
response.write "<script>alert('请填写广告位置资料！');history.go(-1);</Script>"
Response.End 
end if
'修改广告位

set adsrs=server.createobject("adodb.recordset")
adssql="select * from dlxf_place where dlxf_placeID="&ID
adsrs.open adssql,conn,1,3
placen=adsrs("dlxf_place")
adsrs("dlxf_place")=place
adsrs("dlxf_placename")=placename
adsrs("dlxf_jg")=jg
adsrs("dlxf_jgg")=jgg
adsrs("dlxf_cc")=cc
adsrs.update
adsrs.close

'修改广告数据库
set adsrs=server.createobject("adodb.recordset")
adssql="select * from dlxf_ads where dlxf_place="& placen &""
adsrs.open adssql,conn,1,3
do while not adsrs.eof
adsrs("dlxf_place")=place
adsrs.update
adsrs.movenext
loop
adsrs.close
set adsrs=nothing
conn.close
set conn=nothing

response.redirect "Mana.asp"
'================================================================
elseif request("action")="tdel" then
ID = Request("ID")
place=request("place")
priceid=request("priceid")

conn.Execute="DELETE FROM [dlxf_place] WHERE dlxf_placeid=" & id
conn.Execute="DELETE FROM [dlxf_ads] WHERE dlxf_place=" & place &" and dlxf_priceid="& priceid

Response.Redirect "Mana.asp"

'================================================================
end if
%>