<!--#include virtual="inc/General.inc.asp"-->
<!--#include virtual="inc/uploadfile.inc"-->
<%
CheckManageUser()
dim objUpload
set objUpload = new Jeansecool_uploadClass
id = clng("0"&objUpload.form("idh"))
TypeCode = replace(objUpload.form("TypeCode"),"'","''")
LinkUrl = replace(objUpload.form("LinkUrl"),"'","''")
AltText = replace(objUpload.form("AltText"),"'","''")
AdOrder = replace(objUpload.form("AdOrder"),"'","''")
MenuCode = replace(objUpload.form("MenuCode"),"'","''")
if AdOrder&""="" then AdOrder = "1"
PicPath = ""
strPath = "/uppic/AD"
strFileName = year(now) & month(now) & day(now) & hour(now) & minute(now) & second(now)
set fso = server.createobject("scripting.filesystemobject")
if fso.FolderExists(server.mappath(strPath))=false then
	fso.CreateFolder server.mappath(strPath)
end if
set file = objUpload.file("PicPath")
if file.FileSize>10 then
	fileName = file.FileName
	fileType = mid(fileName,instrrev(fileName,".")+1,len(fileName))
	PicPath = strPath & "/" & strFileName & "." & fileType
	file.SaveAs server.mappath(PicPath)
	if id&""<>"" and id&""<>"0" then
		paths = GetSomeFieldByField("AD","id",id,"PicPath")
		if paths<>"" then
			if fso.FileExists(server.mappath(paths)) then
				fso.DeleteFile server.mappath(paths)
			end if
		end if
	end if
end if
set fso = nothing
set objUpload = nothing
if id&""="" or id&""="0" then
	conn.execute "insert into AD(TypeCode,MenuCode,PicPath,LinkUrl,AltText,AdOrder) values('" & TypeCode & "','','" & PicPath & "','" & LinkUrl & "','" & AltText & "'," & AdOrder & ")"
	CloseConnection()
	Response.Write "<script language='javascript'>alert('添加成功！');window.location.href='AD.asp';</script>"
else
	strsql = "update AD set TypeCode='" & TypeCode & "',MenuCode='" & MenuCode & "',LinkUrl='" & LinkUrl & "',AltText='" & AltText & "',AdOrder=" & AdOrder
	if PicPath&""<>"" then strsql = strsql & ",PicPath='" & PicPath & "'"
	strsql = strsql & " where id=" & id
	conn.execute strsql
	CloseConnection()
	Response.Write "<script language='javascript'>alert('修改成功！');window.location.href='AD.asp';</script>"
end if
%>