<% data_path="../../" 'ACC连接数据库路径，对SQL无效 %>
<!--#include file="../../conn/conn.asp"-->
<!--#include file="../../inc/safe.asp"-->
 <!--#include file="../checkrole.asp"-->
<%

  call checkuser("cp")

if issession=0 then
gsid=Replace_Text(request.Cookies("Yxmemberid"))
else
gsid=session("id")
end if  
  Response.Buffer = true
  Response.ExpiresAbsolute=now()-1
  Response.Expires=0
  Response.CacheControl="no-cache"
  
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 Websen_productclass_1 where gsid="&gsid&" and SmallClassName='"&SmallClassName&"' and BigClassID="&BigClassID
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")=gsid
rs("BigClassID")=BigClassID
rs("SmallClassName")=SmallClassName
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing

	Content="<center>恭喜您，该产品系列名称已经添加成功<br><br><input name='' type='button' value='返回上一页' onclick='javascript:history.go(-1)'></center>"

Call Operation(Content,1)
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 Websen_productclass_1 where SmallClassID="&SmallClassID&" and gsid="&gsid&"")
Set Rs=Server.CreateObject("Adodb.Recordset")
	SqlFile="select * from Websen_productshow where SmallClassID="&SmallClassID&" and gsid="&gsid&""
Rs.Open SqlFile,Conn,1,3

if not(rs.eof and rs.bof) then
	do while not rs.eof
		 ttid=rs("id")
		 sortid=rs("sortid")
		 typeid=rs("typeid")
		 typeid_2=rs("typeid_2")
			 
			FileName=HOPE_InstallDir&"productshow/offerdetail/"&sortid&"-"&typeid&"-"&typeid_2&"-"&ttid&".html"
			Call FileDel(FileName) 
			conn.execute("delete from Websen_productshow where SmallClassID="&SmallClassID&" and gsid="&gsid&"")
	rs.movenext
		if Rs.Eof then Exit do 
	loop

End if

rs.close
set rs=nothing
conn.close
set conn=nothing

	Content="<center>恭喜您，该产品系列已经删除成功<br><br><input name='' type='button' value='返回上一页' onclick='javascript:history.go(-1)'></center>"
	Call Operation(Content,1)
end if 

if cmd="up" then
if Chkrequest(request("SmallClassID")) then
SmallClassID=request("SmallClassID")
BigClassID=request("BigClassID")
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 Websen_productclass_1 where gsid="&gsid&" and SmallClassName='"&SmallClassName&"' and BigClassID="&BigClassID&" 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 Websen_productclass_1 where SmallClassID="&SmallClassID&" and gsid="&gsid&""
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
	Content="<center>恭喜您，该产品系列名称已经修改成功<br><br><input name='' type='button' value='返回上一页' onclick='javascript:history.go(-1)'></center>"

	Call Operation(Content,1)
end if
end if
%>