<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<!--#include file="admin.asp"-->
<!--#include file="Inc/Function.asp"-->
<!--#include file="../Inc/Config.asp"-->
<%
dim ID,Action,sqlDel,rsDel,FoundErr,ErrMsg,ObjInstalled
ID=trim(request("ID"))
Action=Trim(Request("Action"))
FoundErr=False
ObjInstalled=IsObjInstalled("Scripting.FileSystemObject")

if ID="" or Action<>"Del" then
	FoundErr=True
	ErrMsg=ErrMsg & "<br><li>参数不足！</li>"
end if
if FoundErr=False then
	sqlDel="select * from News where ID in" & "("&ID&")"
	Set rsDel= Server.CreateObject("ADODB.Recordset")
	rsDel.open sqlDel,conn,1,1
	if not rsDel.eof then
	do while not rsDel.eof
	 if ObjInstalled=True and trim(rsDel("DefaultPicUrl"))<>"" and not isnull(rsDel("DefaultPicUrl")) then
			call DelFile("../",rsDel("DefaultPicUrl"))
	 end if
	rsDel.movenext
	if rsDel.eof then exit do
	loop
	end if
	rsDel.close
	set rsDel=nothing
	conn.execute("delete from News where ID in" & "("&ID&")")
end if

if FoundErr=False then
	call CloseConn()
	response.Redirect "News_Manage.asp"
else
	call CloseConn()
	call WriteErrMsg()
end if

	'=================================================
	'过程名：DelFile
	'作  用：删除文件
	'=================================================
	Private sub DelFile(FilePath,FileName)
		Dim fso, i
		Dim strFileName, strFilePath
		Dim strFolderName, strFolderPath
		'---- 删除文件
		If Trim(FileName) <> "" Then
			strFileName = Split(FileName, "|")
			If UBound(strFileName) <> -1 Then '删除文件
				Set fso = CreateObject("Scripting.FileSystemObject")
				For i = 0 To UBound(strFileName)
					strFilePath = Server.MapPath(FilePath & Trim(strFileName(i)))
					If fso.FileExists(strFilePath) Then
						fso.DeleteFile strFilePath, True
					End If
				Next
				Set fso = Nothing
			End If
		End If
	End sub
%>
