<!-- #include file="../conn.asp" -->
<!-- #include file="../const.asp" -->
<%call chksunzom()
chk=requestA("chk")
mxid=chk0(requestA("mxid"))
m1id=chk0(requestA("m1id"))
m2id=chk0(requestA("m2id"))

xxid=chk0(requestA("xxid"))
x1id=chk0(requestA("x1id"))
sid=chk0(requestA("sid"))
cid=chk0(requestA("cid"))
cdid=chk0(requestA("cdid"))

if chk0(x1id)>0 then x0id=x1id else x0id=xxid
if x0id=0 then x00id=mxid else x00id=x0id
if chk0(m1id)=0 then x00id=0
xur=requestA("xur")

if chk="ok" then
mxbiao=cdatx("mxdat","SZ_mx","where id="&mxid&"")
mxbbal=cdatx("bbal","SZ_mx","where id="&mxid&"")

sql="select * from SZ_zd where ChannelID="&mxid&" and ShowOnForm=1  and FieldName<>'zduser' order by OrderID desc,id asc"
set rsc2=conn.execute(sql)
if not rsc2.bof then
do while not rsc2.eof
id2=chk0(rsc2("id"))
bdname=rsc2("FieldName"):bdlx=rsc2("FieldType")

bdTitle=rsc2("Title"):bdmoren=rsc2("DefaultValue"):bdTips=rsc2("Tips"):bdbjqlx=rsc2("EditorType")
bdscok=rsc2("AllowFileExt"):bdscdx=rsc2("MaxFileSize"):bdOptions=rsc2("Options"):bdShowUnit=rsc2("ShowUnit"):bdUnitOptions=rsc2("UnitOptions")
bdbt=rsc2("MustFillTF"):bdWidth=rsc2("Width"):bdMaxLength=rsc2("MaxLength"):bdHeight=rsc2("Height"):zdkd=chk0(rsc2("zdkd"))
if requestA(""&bdname&"")<>"" and len(requestA(""&bdname&""))>=1 then
inst1=inst1&""&bdname&","
if bdlx=4 then bdname1=""&requestA(""&bdname&"")&"" else bdname1="'"&requestA(""&bdname&"")&"'" 
if bdname="zdsh" and bdname1<>"" then bdname1=1
inst2=inst2&""&bdname1&","
end if
rsc2.movenext
loop
end if
rsc2.close:set rsc2=nothing

if m2id>0 then m22id=m2id else m22id=m1id

if mxid>0 then inst1=inst1&"gid,g1id,":inst2=inst2&""&chk0(xxid)&","&chk0(m22id)&","

'Response.Write (""&inst1&"<br>"&inst2&""):Response.end

if xtuser=1 then  now00user=nowuserhao else  now00user=nowuser
sql="insert into "&mxbiao&"("&inst1&"tjsj,zduser) values("&inst2&"'"&now()&"','"&now00user&"')"

'Response.Write (""&sql&""):Response.end

conn.execute(sql)
xxid=cdatx("id",mxbiao,"order by id desc")
if instr(mxbbal,"t1an")>0 then tanlx=1 else tanlx=0
if instr(mxbbal,"f1an")>0 then
tsurl=""&xur&".asp?chk=edit&cdid="&cdid&"&mxid="&mxid&"&m1id="&m1id&"&m2id="&m2id&"&x1id="&x1id&"&xxid="&xxid&"&sid="&sid&""
elseif  instr(mxbbal,"f2an")>0 then
tsurl="hz.asp?cdid="&cdid&"&mxid="&mxid&"&m1id="&m1id&"&m2id="&m2id&"&x1id="&x1id&"&xxid="&xxid&"&sid="&sid&""
else
tsurl=""&request.ServerVariables("HTTP_REFERER")&""
end if
Response.Write ""&tsmsm("保存成功!",tanlx,tsurl)&""
Response.end

'Response.Write ("<Script> if (confirm('保存成功,点击继续！')) { location.href='"&xur&".asp?chk=edit&cdid="&cdid&"&mxid="&mxid&"&m1id="&m1id&"&m2id="&m2id&"&x1id="&x1id&"&xxid="&xxid&"&sid="&sid&"';} else{location.href='hz.asp?mxid="&mxid&"&cdid="&cdid&"&m1id="&m1id&"&xxid="&xxid&"&x1id="&x1id&"&sid="&sid&"';}</script>")
end if


if chk="editok" then
mxbiao=cdatx("mxdat","SZ_mx","where id="&mxid&"")
mxbbal=cdatx("bbal","SZ_mx","where id="&mxid&"")

sql="select * from SZ_zd where ChannelID="&mxid&" and ShowOnForm=1 order by OrderID desc,id asc"
set rsc2=conn.execute(sql)
if not rsc2.bof then
do while not rsc2.eof
id2=chk0(rsc2("id"))
bdname=rsc2("FieldName"):bdlx=rsc2("FieldType")

bdTitle=rsc2("Title"):bdmoren=rsc2("DefaultValue"):bdTips=rsc2("Tips"):bdbjqlx=rsc2("EditorType")
bdscok=rsc2("AllowFileExt"):bdscdx=rsc2("MaxFileSize"):bdOptions=rsc2("Options"):bdShowUnit=rsc2("ShowUnit"):bdUnitOptions=rsc2("UnitOptions")
bdbt=rsc2("MustFillTF"):bdWidth=rsc2("Width"):bdMaxLength=rsc2("MaxLength"):bdHeight=rsc2("Height"):zdkd=chk0(rsc2("zdkd"))
zwzd1=rsc2("zwzd1"):zwzd2=rsc2("zwzd2"):fuzhi=rsc2("fuzhi")
if len(requestA(""&bdname&""))>=0 and requestA(""&bdname&"")<>"" then
'if requestA(""&bdname&"")<>"" and len(requestA(""&bdname&""))>=0 then

if bdlx=4 or bdlx=12 then bdname1=""&chk0(requestA(""&bdname&""))&"" else bdname1="'"&requestA(""&bdname&"")&"'" 
if (bdlx=5 or bdlx=13) and requestA(""&bdname&"")="" then bdname1="null"

if bdname="zdsh" then
if bdname1<>"" and  bdname1<>"null" then bdname1=1 else  bdname1=0
end if

if instr(zwzd1,nowzw)>0  or isnull(zwzd1) or len(trim(zwzd1))<2 then  inst2=inst2&""&bdname&"="&bdname1&","

end if
bdlx=""
rsc2.movenext
loop
end if
rsc2.close:set rsc2=nothing
'sql="update "&mxbiao&" set "&inst2&"gid="&x00id&",g1id="&m2id&",tjsj=now() where id="&xxid&""
sql="update "&mxbiao&" set "&inst2&"tjsj=now() where id="&xxid&""

'Response.Write (""&sql&""):Response.end

conn.execute(sql)
conn.execute("insert into rizi(username,class,address,rznr) values('"&nowuser&"|"&nowuserhao&"','修改数据','"&userip&"','"&mxbiao&"-"&xxid&"')")
'Response.Write ("<Script> if (confirm('修改保存成功！')) { location.href='"&request.ServerVariables("HTTP_REFERER")&"';} else{location.href='"&xur&".asp?chk=edit&cdid="&cdid&"&mxid="&mxid&"&m1id="&m1id&"&m2id="&m2id&"&xxid="&xxid&"&x1id="&x1id&"&sid="&sid&"';}</script>")


if instr(mxbbal,"t1an")>0 then tanlx=1 else tanlx=0
if instr(mxbbal,"f1an")>0 then
tsurl=""&xur&".asp?chk=edit&cdid="&cdid&"&mxid="&mxid&"&m1id="&m1id&"&m2id="&m2id&"&x1id="&x1id&"&xxid="&xxid&"&sid="&sid&""
elseif  instr(mxbbal,"f2an")>0 then
tsurl="hz.asp?cdid="&cdid&"&mxid="&mxid&"&m1id="&m1id&"&m2id="&m2id&"&x1id="&x1id&"&xxid="&x1id&"&sid="&sid&""
else
tsurl=""&request.ServerVariables("HTTP_REFERER")&""
end if
Response.Write ""&tsmsm("修改成功!",tanlx,tsurl)&""
Response.end
end if
%>