<!--#include file="../../conn/conn.asp"-->
<!--#include file="../../inc/safe.asp"-->
<!--#include file="../../inc/config.asp"-->
<%
  Response.Buffer = true
  Response.ExpiresAbsolute=now()-1
  Response.Expires=0
  Response.CacheControl="no-cache"
%>
<%
'if Not ChkPost then 
'response.redirect ("../../login/chklogin.asp?login=4")
'response.end
'end if

if session("flag")<>1 then 
response.Redirect("../../login/login1.asp")
response.end
end if
%>
<%
cmd=Replace_Text(request("cmd"))

if cmd="add" then
BigClassID=Replace_Text(request.form("BigClassID"))
SmallClassName=Replace_Text(request.form("SmallClassName"))
if BigClassID="" then
response.write"<SCRIPT language=JavaScript>alert('请选择产品大类！');"
response.write"this.location.href='addclass_1.asp';</SCRIPT>"
response.end
end if
if SmallClassName="" then
response.write"<SCRIPT language=JavaScript>alert('输入的内容不能为空！');"
response.write"this.location.href='addclass_1.asp';</SCRIPT>"
response.end
end if
set rs=server.createobject("adodb.recordset")
sql="select * from productclass_1 where gsid="&session("id")&" and SmallClassName='"&SmallClassName&"'"
rs.open sql,conn,1,3
if not (rs.eof and rs.bof) then
response.write"<SCRIPT language=JavaScript>alert('对不起，已存在此产品系列！');"
response.write"javascript:history.go(-1)</SCRIPT>"
response.end 
else
rs.addnew
rs("gsid")=session("id")
rs("BigClassID")=BigClassID
rs("SmallClassName")=SmallClassName
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
response.write"<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>"
response.write"<meta HTTP-EQUIV=refresh Content='1;url=addclass_1.asp'>"
response.write"<table border=0 cellspacing=0 width=100% cellpadding=0 height=418>"
response.write"<tr><td valign='middle' align='center'>"
response.write"<b>恭喜您，该产品系列名称已经添加成功！<a href='addclass_1.asp'>返回</a></b>"
response.write"</td></tr></table>"
end if
end if

if cmd="del" then
if Chkrequest(request("SmallClassID")) then
SmallClassID=request("SmallClassID")
else
response.write"<SCRIPT language=JavaScript>alert('提交的参数非法，请返回！');"
response.write"this.location.href='addclass_1.asp';</SCRIPT>"
response.end 
end if
conn.execute("delete from productclass_1 where SmallClassID="&SmallClassID&" and gsid="&session("id")&"")
set rs=conn.execute("select picture from productshow where SmallClassID="&SmallClassID&" and gsid="&session("id")&"")
if not(rs.eof and rs.bof) then
set fs=server.CreateObject("scripting.filesystemobject")
do while not rs.eof
filepath=newspic&rs("picture")
filepath=server.MapPath(filepath)
if fs.FileExists(filepath) and rs("picture")<>"nopicture.gif" then
     fs.DeleteFile filepath,true
end if
rs.movenext
loop
set fs=nothing
end if
rs.close
set rs=nothing
conn.execute("delete from productshow where SmallClassID="&SmallClassID&" and gsid="&session("id")&"")
conn.close
set conn=nothing
response.write"<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>"
response.write"<meta HTTP-EQUIV=refresh Content='1;url=addclass_1.asp'>"
response.write"<table border=0 cellspacing=0 width=100% cellpadding=0 height=418>"
response.write"<tr><td valign='middle' align='center'>"
response.write"<b>该产品系列已经删除成功！<a href='addclass_1.asp'>返回</a></b>"
response.write"</td></tr></table>"
end if 

if cmd="up" then
if Chkrequest(request("SmallClassID")) then
SmallClassID=request("SmallClassID")
else
response.write"<SCRIPT language=JavaScript>alert('提交的参数非法，请返回！');"
response.write"this.location.href='addclass_1.asp';</SCRIPT>"
response.end 
end if
SmallClassName=Replace_Text(request.form("SmallClassName"))
if SmallClassName="" then
response.write"<SCRIPT language=JavaScript>alert('输入的内容不能为空！');"
response.write"this.location.href='addclass_1.asp';</SCRIPT>"
response.end
end if
set rs1=server.createobject("adodb.recordset")
sql1="select * from productclass_1 where gsid="&session("id")&" and SmallClassName='"&SmallClassName&"' and SmallClassID<>"&SmallClassID&""
rs1.open sql1,conn,1,3
if not rs1.eof then
response.write"<SCRIPT language=JavaScript>alert('对不起，和已存在产品系列同名！');"
response.write"this.location.href='addclass_1.asp';</SCRIPT>"
response.end 
else
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from productclass_1 where SmallClassID="&SmallClassID&" and gsid="&session("id")&""
rs.open sql,conn,1,3
rs("SmallClassName")=SmallClassName
rs.update
rs.close
set rs=nothing
rs1.close
set rs1=nothing
conn.close
set conn=nothing
response.write"<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>"
response.write"<meta HTTP-EQUIV=refresh Content='1;url=addclass_1.asp'>"
response.write"<table border=0 cellspacing=0 width=100% cellpadding=0 height=418>"
response.write"<tr><td valign='middle' align='center'>"
response.write"<b>恭喜您，该产品系列名称已经修改成功！<a href='addclass_1.asp'>返回</a></b>"
response.write"</td></tr></table>"
end if
end if
%>