<!--#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"))
msg = ""
MenuCode = replace(objUpload.form("MenuCode")&"","'","''")
TypeID = replace(objUpload.form("TypeID")&"","'","''")
Title = replace(objUpload.form("Title")&"","'","''")
ViceTitle = replace(objUpload.form("ViceTitle")&"","'","''")
AddUserName = replace(objUpload.form("AddUserName")&"","'","''")
IsStop = replace(objUpload.form("IsStop")&"","'","''")
Content = Replace(objUpload.form("Info")&"","'","''")
if TypeID&""="" then TypeID=0
if ListType&""="" then ListType=1
if IsStop&""="" then IsStop=0
if MenuCode&""="" then
	ErrorInfo "请选择栏目类型！"
elseif Title&""="" then
	ErrorInfo "请输入标题！"
elseif Content&""="" then
	ErrorInfo "请输入内容！"
end if

SmallPicture = ""
BigPicture = ""
strPath = "/uppic/" & MenuCode
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 fso = nothing
set file = objUpload.file("SmallPicture")
if file.FileSize>10 then
	fileName = file.FileName
	fileType = mid(fileName,instrrev(fileName,".")+1,len(fileName))
	SmallPicture = strPath & "/S_" & strFileName & "." & fileType
	file.SaveAs server.mappath(SmallPicture)
end if
set file = objUpload.file("BigPicture")
if file.FileSize>10 then
	fileName = file.FileName
	fileType = mid(fileName,instrrev(fileName,".")+1,len(fileName))
	BigPicture = strPath & "/B_"  & strFileName & "." & fileType
	file.SaveAs server.mappath(BigPicture)
end if
set file = nothing
set objUpload = nothing
if id&""="" or id&""="0" then
	conn.execute "insert into [Content](MenuCode,TypeID,Title,ViceTitle,SmallPicture,BigPicture,Content,AddUserName,IsStop) values('" & MenuCode & "'," & TypeID & ",'" & Title & "','" & ViceTitle & "','" & SmallPicture & "','" & BigPicture & "','" & Content & "','" & AddUserName & "'," & IsStop & ")"
	CloseConnection()
	Response.Write "<script language='javascript'>alert('添加成功！');if(confirm('你还要继续添加吗？'))window.location.href='AddContent.asp';else window.location.href='ManageContent.asp';</script>"
else
	strsql = "update [Content] set MenuCode='" & MenuCode & "',TypeID=" & TypeID & ",Title='" & Title & "',ViceTitle='" & ViceTitle & "',"
	if SmallPicture&""<>"" then strsql = strsql & "SmallPicture='" & SmallPicture & "',"
	if BigPicture&""<>"" then strsql = strsql & "BigPicture='" & BigPicture & "',"
	strsql = strsql & "AddUserName='" & AddUserName & "',Content='" & Content & "',IsStop=" & IsStop & " where id=" & id
	conn.execute strsql
	CloseConnection()
	Response.Write "<script language='javascript'>alert('修改成功！');window.opener.location.reload();window.close();</script>"
end if
%>