<!--#include file="../here99login/0.asp"-->
<!--#include file="../conn/zkconn.asp"-->
 <%
   	dim page,i,idlist
	page=request("page")

  	if not isempty(request("selAnnounce")) then
     		idlist=request("selAnnounce")
     		if instr(idlist,",")>0 then
			dim idarr
			idArr=split(idlist)
			dim id
		for i = 0 to ubound(idarr)
	       		id=clng(idarr(i))
	       		call deleteannounce(id)
		next
     		else
			call deleteannounce(clng(idlist))
     		end if
  	end if 
   	dim sql
   	dim rs
%>
             <%
  sub deleteannounce(id)
    dim rs,sql,fso,image
	
	Set rs= Server.CreateObject("ADODB.Recordset")
   sql="select * from chanpin where cpid="&cstr(id)
   rs.open sql,conn,1,1
   if rs("st") <> "image/no.gif" Then
   image=rs("st")
    end if
	If image <> "" Then
   image = server.mappath(image)
    End If
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
	If fso.FileExists(image) Then
	fso.DeleteFile (image),true
	else
	Response.Write "图片文件不存在无法删除！"
	end if
	Set fso = nothing
	
    set rs=server.createobject("adodb.recordset")
    sql="delete from chanpin where cpid="&cstr(id)
    conn.execute sql
    if err.Number<>0 then
	err.clear
	response.write "<script>alert(""操作失败！"");location.href=""guanli.asp?page="&page&""";</script>"
    else
        Response.Write "<script>alert(""操作成功！"");location.href=""guanli.asp?page="&page&""";</script>"
    end if
  End sub
rs.close
set rs=nothing
%>