 <% 
	data_path="../../" 'ACC连接数据库路径，对SQL无效
	numid="no"
	dir="no" 
  %>
  <!--#include file="../../conn/conn.asp"-->
<!--#include file="../../inc/filesystem.asp"-->
<!--#include file="../../inc/safe.asp"-->
  <!--#include file="../rolecheck.asp"-->

<%
	delbtn=replace_text(request("delbtn"))
	idlist=replace_text(request("userid"))
	checkbtn=replace_text(request("checkbtn"))
	action=replace_text(request("action"))
	exd=replace_text(request("exd"))
	tuibtn=replace_text(request("tuibtn"))
	tuiflag=replace_text(request("tuiflag"))
    idlist=Trim(idlist)
 '--执行删除操作 -----------------------------------------------------------------------------------
   if delbtn<>"" then
    if instr(idlist,",")>0 then
  	 idArr=split(idlist,",")
 		for i = 0 to ubound(idArr)
              call delUserFile(idArr(i))	
 	          call deleteannounce(idArr(i))  
 		next
	 else
             call delUserFile(idlist)	
			 call deleteannounce(idlist) 
 	 end if
	 response.Redirect(request.ServerVariables("HTTP_REFERER"))
   end if
 '--执行审核操作 ----------------------------------------------------------------------------------
 if checkbtn<>"" then
 valf=action
  if instr(idlist,",")>0 then
  	 idArr=split(idlist,",")
	 for i = 0 to ubound(idArr)
	  call Emails(valf,idArr(i))
	 next
	 else
	  call Emails(valf,idlist)	
	 end if  
 end if
 '------------------------------------------------------------------------------------发送油箱
     if checkbtn<>"" then
	 if action<>"" then
	 valf=action 
	else
	valf=1
	 end if
   	 if instr(idlist,",")>0 then
  	 idArr=split(idlist,",")
 		for i = 0 to ubound(idArr)
            call updateflag(valf,idArr(i),exd)	
  		next
	 else
            call updateflag(valf,idlist,exd)  
  	 end if
	 response.Redirect(request.ServerVariables("HTTP_REFERER"))
   end if
  '----------------------------------------------------------------------------------------------
   '--推荐设置---------------------------------------------------------------------------------------
   if tuibtn<>"" then 
     if tuiflag="" then
	 tuiflag=1
	 end if	 
	  if instr(idlist,",")>0 then
  	  idArr=split(idlist,",")
 		for i = 0 to ubound(idArr)
              call tuijian(idArr(i),tuiflag)	
  		next
	 else
              call tuijian(idlist,tuiflag)	
  	 end if
     response.Redirect(request.ServerVariables("HTTP_REFERER"))
    end if
   
   '--------------------------------------------------------------------------------------
   
     
 '1.=================================删除会员生成文件与会员生成的相关文件====start=============================
 sub delUserFile(id) 
  	  '删除会员相关的文件生成文件	---------------------------start-----------------------------------------------	
				Set Rsfile=Conn.Execute("Select ID,[User],Flag From Websen_corporation Where ID="&id&"")
					if not Rsfile.Eof Then 
						'【未审核会员:删除生成的单文件页面,】
							FName=Rsfile("User")&".Html"
							FileName=HOPE_InstallDir&"PtCom/"&FName
							Call FileDel(FileName)
						'【已审核的会员:删除生成的会员模板:/Vipcom/,】
							FoldFile=HOPE_InstallDir&"VipCom/"&Rsfile("User")&"/"
 							Call FSO_Del(FoldFile)
					end if
 					Rsfile.Close
					Set Rsfile=Nothing
	  '删除文件生成文件	---------------------------end -----------------------------------------------	
	  
	 '【公共:删除生成的产品信息信息文件:/productshow/,】-------------start -------------------------
		Set RsPro=Conn.Execute("Select ID, GsID,sortid,typeid,typeid_2,cpmc From Websen_productshow Where GsID="&id&"")
			IF NOt RsPro.Eof Then 
				Do WHile Not RsPro.Eof
					ttid=RsPro("id")
					sortid=RsPro("sortid")
					typeid=RsPro("typeid")
					typeid_2=RsPro("typeid_2")
					showname=RsPro("cpmc")
					ProFile=HOPE_InstallDir&"productshow/offerdetail/"&sortid&"-"&typeid&"-"&typeid_2&"-"&ttid&".html"
					Call FileDel(ProFile)
				RsPro.MOveNExt
					if RsPro.Eof then exit do
				loop
			End if
			RsPro.CloSe
			Set RsPro=nothing
 	 '【公共:删除生成的产品信息信息文件:/productshow/,】-------------end  -------------------------
	 
	 '【公共:删除生成的展会信息文件:service/expo/detail,】-----------------start-----------------
			Set RsExpo=Conn.Execute("Select id,gsid,picture From Websen_expo Where gsid="&id&"") 
			if NOt RsExpo.Eof Then 
				do while not RsExpo.Eof
					ttid=RsExpo("id")
					picture=RsExpo("picture")
 					ExpoFile=HOPE_InstallDir&"service/expo/detail/"&ttid&".html"
					Call FileDel(ExpoFile)'删除文件
					ExpoPic=HOPE_InstallDir&"UploadFile/"&picture&"/"
					if picture<>"nopicture.gif" then
					Call FileDel(ExpoPic)'删除图片
					end if
					RsExpo.MOveNExt
					 if RsExpo.Eof Then exit do
				loop
			End if
 			RsExpo.Close
			Set RsExpo=Nothing
	 '【公共:删除生成的展会信息文件:service/expo/detail,】----------end ------------------
	 
	 '【公共:删除生成的供求信息文件Websen_Info】-----------------------start-------------------
	SqltridInfo="select Info_ID, sortid,typeid,typeid_2,showname,dateandtime,period,type  from Websen_Info where  gsid="&id&""
	Set RstridInfo=Conn.Execute(SqltridInfo)
	
	  IF Not RstridInfo.Eof Then 
	  	do while not RstridInfo.Eof
			 ttid=RstridInfo("Info_ID")
			 sortid=RstridInfo("sortid")
			 typeid=RstridInfo("typeid")
			 typeid_2=RstridInfo("typeid_2")
			 showname=RstridInfo("showname")
			 dateandtime=RstridInfo("dateandtime")
			 period=RstridInfo("period")
 				FileTrideinfo=HOPE_InstallDir&"tradeinfo/offerdetail/"&sortid&"-"&typeid&"-"&typeid_2&"-"&ttid&".html"
				Call FileDel(FileTrideinfo) '删除供应信息
 				FileTrideinfo=HOPE_InstallDir&"seller/offerdetail/"&sortid&"-"&typeid&"-"&typeid_2&"-"&ttid&".html"
				Call FileDel(FileTrideinfo) '删除供应信息
 			RstridInfo.MOVeNExt
				if RstridInfo.Eof Then exit do
		loop
	  End if
	RstridInfo.CLose
	Set RstridInfo=nothing
	'【公共:删除生成的供求信息文件Websen_Info】-----------------------end-------------------
end sub
'=================================删除会员生成文件与会员生成的相关文件=====end ============================
 
 
 	
'2.----删除数据表信息过程--------------start------------------------------------------------------------- 
sub deleteannounce(id)
     theuser="a"
	 sqldel="select * from Websen_corporation where id="&cstr(id)
	 set DelRs=server.CreateObject("adodb.recordset")
	 DelRs.open sqldel,conn,1,3
	 if not DelRs.eof then
 	 theuser=DelRs("user")
	 DelRs.close
	 end if 
		'从会员关系表中删除这个公司的信息------------------------------------------------------------
		conn.execute("delete from [Websen_memberRelation] where [user]='"&theuser&"' or secuser='"&theuser&"'")
		'----------------------------------------------------------------------------------------------
		
		conn.execute("delete from [Websen_bizre] where gsid="&cstr(id)&"")	'删除企业证书 
		 
		conn.execute("delete from [Websen_expo] where gsid="&cstr(id)&"")	'删除展会信息
		
		'从客户反馈表中删除这个公司的信息--------------------------------------------
		conn.execute("delete from [Websen_book] where bookid="&cstr(id)&" or gsid="&cstr(id)&"")
		'---------------------------------------------------------------------------- 
		
		'从评论表中删除这个公司的信息-----------------------------------------------
		conn.execute("delete from [Websen_trustadv] where bprid="&cstr(id)&" or pjrid="&cstr(id)&"")   
		'---------------------------------------------------------------------------- 
		
		conn.execute("delete from [Websen_work] where gsid="&cstr(id)&"")'从招聘表中删除这个公司的信息  
				
	    conn.execute("delete from [Websen_productclass] where gsid="&cstr(id)&"")'从产品分类中删除这个公司的信息 
	  
 	    conn.execute("delete from [Websen_productclass_1] where gsid="&cstr(id)&"")'从产品二级分类中删除这个公司的信息	
	 
  		conn.execute("delete from [Websen_productshow] where gsid="&cstr(id)&"")'从产品信息中删除这个公司的信息  
			 
	    conn.execute("delete from [Websen_wt] where gsid="&cstr(id)&"")'从委托代理表中删除这个公司的信息  
		  
		conn.execute("delete from [Websen_emailorder] where gsid="&cstr(id)&"")'从邮件订阅表中删除这个公司的信息 
		 
		'从发信中删除这个公司的信息 -----------------------------------------------------------------  
		conn.execute("delete from [Websen_getprice] where mycid="&cstr(id)&" or sendcid="&cstr(id)&"")   
		'------------------------------------------------------------------------------------------
		
		 '从询价表1中删除这个公司的信息	--------------------------------------------------------------	
		conn.execute("delete from [Websen_getprice1] where mycid="&cstr(id)&" or sendcid="&cstr(id)&"")  
		'------------------------------------------------------------------------------------- 

		conn.execute("delete from [Websen_Info] where gsid="&cstr(id)&"")'从供求信息中删除这个公司的信息   
		 
		conn.execute("delete from [Websen_files] where userid="&cstr(id)&"") '删除这个公司的上传图片信息   
		
	    conn.execute("delete from [Websen_corporation] where id="&cstr(id)&"")'最后，从公司库中删除  
	 
	if err.Number<>0 then
	 err.clear
	response.write "删 除 失 败 !<br><a href='#' onclick='javascript:history.back(-1);'>返回</a>"
 	end if
end sub
 '-删除数据表信息过程--------------end -----------------------------------------------------------------------
 
   
'-审核操作 -------------------------------------------------------------------------
  sub updateflag(valf,id,exd) 
 
  
      if exd="" then 
	   exd=0
 	   end if
     
     if valf=1 then
	 set rsd=server.CreateObject("adodb.recordset")
	 sqld="select * from Websen_corporation where id="&id
	 rsd.open sqld,conn,1,3
	 Email=rsd("Email")
	 flag=rsd("flag")
	 if not rsd.eof then 
	 if rsd("BeginDate")<>"" then
 	 startdate=rsd("BeginDate")
	 else
	 startdate=date()
 	 end if
	 rsd.close
	 end if
	 enddate=dateadd("m",12,date())
     conn.execute "update Websen_corporation  set flag=1,BeginDate='"&startdate&"',EndDate='"&enddate&"',Exd="&exd&" where id="&id
 	 else
   conn.execute "update Websen_corporation  set flag=0 where id="&id
	 end if
  end sub
 '-----------------------------------------------------------------------
 '发邮件
 sub Emails(valf,id)
 fromname=SystemEmail
if instr(fromname,"@") then
	mailusername=left(fromname,instr(fromname,"@")-1)
else
	mailusername = fromname
end if
 sql1="select top 1 * from Websen_worldec_config"
Set rs1= Server.CreateObject("ADODB.Recordset") 
rs1.open sql1,conn,1,3
Notices=rs1("Notices")
Notice=rs1("Notice")
rs1.close
sql="select * from websen_worldec_Temp "
Set rs= Server.CreateObject("ADODB.Recordset") 
rs.open sql,conn,1,3
Audit=rs("Audit")
Unaudited=rs("Unaudited")
rs.close
 sqld="select * from Websen_corporation where id="&id
 Set rsd= Server.CreateObject("ADODB.Recordset") 
	 rsd.open sqld,conn,1,3
	 Email=rsd("Email")
rsd.close
   if valf="0" then 
	 call SendMail(Email,Notices,Unaudited,mailusername,HOPE_MailPwd,SMTPServer,SystemEmail)
	 else
	  call SendMail(Email,Notice,Audit,mailusername,HOPE_MailPwd,SMTPServer,SystemEmail)
	 end if
 end sub
 
 '推荐设置-------------------------------------------------------------------------
 sub tuijian(id,tuiflag)
    set rst=server.CreateObject("adodb.recordset")
	sqlt="select  * from Websen_corporation where id="&id
	rst.open sqlt,conn,1,3
	if not rst.eof then 
	rst("Uflag")=tuiflag
	rst.update
	rst.close
	end if
 end sub
 '-----------------------------------------------------------------------------
 
 %>