<!-- #include file="../conn.asp" -->
<%call chksunzom()%>
<%
lx=requestA("lx")
id=replace(request("id")," ","")
if id="" then Response.Write "<script language='javascript'>alert('请选择删除选项！');history.back();</script>":Response.end

id=split(id,",")
mxid=requestA("mxid")
gid=requestA("gid")
dat=requestA("dat")
select case lx
case "zd"
mxbiao=cdatx("mxdat","SZ_mx","where id="&mxid&"")
for i=0 to UBound(id)
call FieldDel()
rznr=rznr&","&id(i)
next
conn.execute("insert into rizi(username,class,address,rznr) values('"&nowuser&"','删除字段','"&userip&"','"&rznr&"')")
call xxts(request.ServerVariables("HTTP_REFERER"))

case "mx"
for i=0 to UBound(id)
call mxDel()
rznr=rznr&","&id(i)
next
conn.execute("insert into rizi(username,class,address,rznr) values('"&nowuser&"','删除模型表','"&userip&"','"&rznr&"')")
call xxts(request.ServerVariables("HTTP_REFERER"))

case "heshi"
mxbiao=cdatx("mxdat","SZ_mx","where id="&mxid&"")
for i=0 to UBound(id)
she1=chk0(cdatx("zdsh",mxbiao,"where id="&id(i)&""))
if she1=1 then she2=0 else she2=1
sql="update "&mxbiao&" set zdsh="&she2&" where id="&id(i)&""
conn.execute(sql)
rznr=rznr&","&mxbiao&"-"&id(i)
next
conn.execute("insert into rizi(username,class,address,rznr) values('"&nowuser&"','审核数据','"&userip&"','"&rznr&"')")
call xxts(request.ServerVariables("HTTP_REFERER"))

case "hz"
for i=0 to UBound(id)
sql="delete from "&dat&" where id="&id(i)&""
conn.execute(sql)
rznr=rznr&","&dat&"-"&id(i)
next
conn.execute("insert into rizi(username,class,address,rznr) values('"&nowuser&"','删除汇总数据','"&userip&"','"&rznr&"')")
call xxts(request.ServerVariables("HTTP_REFERER"))

case "bb"
dat="SZ_bb"
for i=0 to UBound(id)
sql="delete from "&dat&" where id="&id(i)&""
conn.execute(sql)
rznr=rznr&","&dat&"-"&id(i)
next
conn.execute("insert into rizi(username,class,address,rznr) values('"&nowuser&"','删除报表菜单','"&userip&"','"&rznr&"')")
call xxts(request.ServerVariables("HTTP_REFERER"))

case "xxdel"
mxbiao=cdatx("mxdat","SZ_mx","where id="&mxid&"")
for i=0 to UBound(id)
sql="delete from "&mxbiao&" where id="&id(i)&""
conn.execute(sql)
rznr=rznr&","&mxbiao&"-"&id(i)
next
conn.execute("insert into rizi(username,class,address,rznr) values('"&nowuser&"','删除表数据','"&userip&"','"&rznr&"')")
call xxts("hzyw1.asp?id="&mxid&"&cid=1&gid="&gid&"")

case "cd"
for i=0 to UBound(id)
sql="delete from SZ_cd where id=" & id(i)
conn.execute(sql)
sql="delete from SZ_cd where cla1=" & id(i)
conn.execute(sql)
rznr=rznr&","&id(i)
next
conn.execute("insert into rizi(username,class,address,rznr) values('"&nowuser&"','删除菜单','"&userip&"','"&rznr&"')")
call xxts("cd.asp?page="&request("page")&"")

case else
Response.Write "<script language='javascript'>alert('请选择删除选项！');history.back();</script>" 
end select

Sub mxDel()
Set RSObj=Server.CreateObject("ADODB.RECORDSET")
RSObj.Open "Select * From SZ_mx Where bid="&id(i)&" or id="&id(i)&"",Conn,1,3
if Not RSObj.Eof then
do while not RSObj.eof
mxbiao=RSObj("mxdat"):idaa=RSObj("id")


Set RS1bj=Server.CreateObject("ADODB.RECORDSET")
RS1bj.Open "Select * From SZ_mx Where bid="&idaa&"",Conn,1,3
if Not RS1bj.Eof then
do while not RS1bj.eof
mxbiaoaa=RS1bj("mxdat"):idbb=RS1bj("id")
If left(mxbiaoaa,3)="MX_" Then
if CheckTable(mxbiaoaa)=1 then  Conn.Execute("Drop table "& mxbiaoaa &" ")
End If
sql="delete from SZ_zd where ChannelID="&idbb&"":conn.execute(sql)
sql="delete from SZ_mx where id="&idbb&"":conn.execute(sql)	  
RS1bj.movenext
loop
end if
RS1bj.Close:Set RS1bj=Nothing


If left(mxbiao,3)="MX_" Then
if CheckTable(mxbiao)=1 then  Conn.Execute("Drop table "& mxbiao &" ")
End If

sql="delete from SZ_zd where ChannelID="&idaa&"":conn.execute(sql)
		
sql="delete from SZ_mx where id="&idaa&"":conn.execute(sql)
			  
RSObj.movenext
loop
end if
RSObj.Close:Set RSObj=Nothing
End Sub

Sub FieldDel()
			Dim RSObj:Set RSObj=Server.CreateObject("ADODB.RECORDSET")
			RSObj.Open "Select FieldName,FieldType,ShowUnit From SZ_zd Where  id="&id(i)&"",Conn,1,3
			if Not RSObj.Eof then
			  'If left(Lcase(RSObj(0)),3)="ZD_" Then
			  if CheckFields (""&mxbiao&"",""&RSObj(0)&"")=1 then
			      Conn.Execute("Alter Table "& mxbiao &" Drop "& RSObj(0) &"")
				  If RSObj("ShowUnit")="1" Then Conn.Execute("Alter Table "& mxbiao &" Drop "& RSObj(0) &"_Unit")
			  end if
			  'End If
			end if
			RSObj.Close:Set RSObj=Nothing
sql="delete from SZ_zd where id=" & id(i)
conn.execute(sql)
End Sub

Sub xxts(xurl)
if lx="heshi" then tsxx="审核" else tsxx="删除"
Response.Write "<script language='javascript'>alert('"&tsxx&"成功!');window.location.href='"&xurl&"';</script>":Response.end
end sub
%>

