<!--#include file="top.asp"-->
<%if userflag2=0 then
response.redirect"ok.asp?action=flag"
end if%>
<%page=request("page")
if page="" then page=1

scatitle=request("scatitle")
if userflag33<>1 then
sca=code_jk(request("scas"))
else
For i = 1 To Request.Form("scas").Count 
	sca = sca & Request.Form("scas")(i) 
Next
end if
key=request("key")
scasort=request("scasort")
ypxxone_id=request("ypxxone_id")
ypxxtwo_id=request("ypxxtwo_id")
addone_id=request("addone_id")
addtwo_id=request("addtwo_id")
yp_id=session("id")
key1=cityscakey
ldate=CInt(request("ldate"))

if request("action")="del" then
page=request("page")
if page="" then page=1
conn.execute("delete from dlxf_sca where dlxf_id=" & request("id")&" and dlxf_yp_id="&session("id")&"")
conn.execute("delete from dlxf_leaveword where dlxf_book_sort=3 and dlxf_book_table=" & request("id")&" and dlxf_book_ypid="&session("id")&"")
Response.Redirect "ok.asp?url=sca.asp?page="&page

elseif request("action")="add" then
'====================================
if scatitle="" then
errstyle="·请输入完整的商机标题！"
scripterr
end if
if sca="" or len(sca)<20 then
errstyle="·请输入不少于20个字符的商机内容！"
scripterr
end if
if ypxxone_id<>"" and ypxxtwo_id="" then
errstyle="·如果您选择了行业大类，那么其小类必须选择！"
scripterr
end if
if addone_id<>"" and addtwo_id="" then
errstyle="·如果您选择了省，那么其地区必须选择！"
scripterr
end if

begindate=now()
lastdate=now()+ldate

set rs=Server.CreateObject("Adodb.Recordset")
sql="select * from dlxf_yp where dlxf_id="&yp_id
rs.open sql,conn,1,1
ypxxone_id_=rs("dlxf_ypxxone_id")
ypxxtwo_id_=rs("dlxf_ypxxtwo_id")
addone_id_=rs("dlxf_addone_id")
addtwo_id_=rs("dlxf_addtwo_id")
rs.close

if ypxxone_id="" then
ypxxone_id=ypxxone_id_
ypxxtwo_id=ypxxtwo_id_
end if
if addone_id="" then
addone_id=addone_id_
addtwo_id=addtwo_id_
end if

set rs=Server.CreateObject("Adodb.Recordset")
sql="select * from dlxf_sca where dlxf_yp_id="& session("id")
rs.open sql,conn,1,3

if userflag2<>0 then
if rs.recordcount >= cint(userflag2) then
errstyle="·您是"&vipshow&"，只能上传最多 "&userflag2&" 条商贸机会！"
scripterr
end if
else
errstyle="·对不起，此功能已对"&vipshow&"关闭！"
scripterr
end if

rs.addnew
rs("dlxf_scatitle")=scatitle
rs("dlxf_sca")=sca
rs("dlxf_key")=key
rs("dlxf_key1")=key1
rs("dlxf_yp_id")=yp_id
rs("dlxf_scasort")=scasort
rs("dlxf_begindate")=begindate
rs("dlxf_lastdate")=lastdate
rs("dlxf_ypxxone_id")=ypxxone_id
rs("dlxf_ypxxtwo_id")=ypxxtwo_id
rs("dlxf_addone_id")=addone_id
rs("dlxf_addtwo_id")=addtwo_id
rs.update
rs.close
set rs=nothing

if cityscakey=1 then
response.redirect"ok.asp?url=sca_add.asp"
elseif cityscakey=0 then
response.redirect"ok.asp?url=sca_add.asp&key=yes"
end if

elseif request("action")="edit" then
if scatitle="" then
errstyle="·请输入完整的商机标题！"
scripterr
end if
if sca="" or len(sca)<20 then
errstyle="·请输入不少于20个字符的商机内容！"
scripterr
end if
if ypxxone_id<>"" and ypxxtwo_id="" then
errstyle="·如果您选择了行业大类，那么其小类必须选择！"
scripterr
end if
if addone_id<>"" and addtwo_id="" then
errstyle="·如果您选择了省，那么其地区必须选择！"
scripterr
end if

begindate=request("begindate")
lastdate=cdate(begindate)+ldate

ypxxone_id_=request("ypxxone_id_")
ypxxtwo_id_=request("ypxxtwo_id_")
addone_id_=request("addone_id_")
addtwo_id_=request("addtwo_id_")

if ypxxone_id="" then
ypxxone_id=ypxxone_id_
ypxxtwo_id=ypxxtwo_id_
end if
if addone_id="" then
addone_id=addone_id_
addtwo_id=addtwo_id_
end if

set rs=Server.CreateObject("Adodb.Recordset")
sql="select * from dlxf_sca where dlxf_id="&request("id")&" and dlxf_yp_id="&session("id")
rs.open sql,conn,1,3

if userflag2=0 then
errstyle="·对不起，此功能已对"&vipshow&"关闭！"
scripterr
end if

rs("dlxf_scatitle")=scatitle
rs("dlxf_sca")=sca
rs("dlxf_key")=key
rs("dlxf_key1")=key1
rs("dlxf_yp_id")=yp_id
rs("dlxf_scasort")=scasort
rs("dlxf_lastdate")=lastdate
rs("dlxf_ypxxone_id")=ypxxone_id
rs("dlxf_ypxxtwo_id")=ypxxtwo_id
rs("dlxf_addone_id")=addone_id
rs("dlxf_addtwo_id")=addtwo_id

rs.update
rs.close
set rs=nothing
if cityscakey=1 then
response.redirect"ok.asp?url=sca.asp&page="&page
elseif cityscakey=0 then
response.redirect"ok.asp?url=sca.asp&page="&page&"&key=yes"
end if

elseif request("action")="key" then
set rs=Server.CreateObject("Adodb.Recordset")
sql="select * from dlxf_sca where dlxf_id="&request("id")&" and dlxf_yp_id="&session("id")
rs.open sql,conn,1,3

rs("dlxf_key")=request("zt")
rs.update
rs.close
set rs=nothing
response.redirect"ok.asp?url=sca.asp?page="&page
end if
%>