<!-- #include file="conn.asp" -->
<!-- #include file="cookies.asp" -->
<%
select case request("action")
case "del_type"
call del_type
case "del_type_son"
call del_type_son
case "del_brand"
call del_brand
case "mod_type"
call mod_type
case "mod_type_son"
call mod_type_son
case "mod_brand"
call mod_brand
case "up_index_True"
call up_index(0)
case "up_index_False"
call up_index(1)
end select

'修改一个分类
sub mod_type
sql="update type set type_name='"&request.form("type_name")&"',xu="&request.form("type_xu")&" where type_id="&request.form("type_id")
conn.execute(sql)
end sub
'修改一个二级分类
sub mod_type_son
sql="update type_son set type_son_name='"&request.form("type_son_name")&"',xu="&request.form("type_son_xu")&" where type_son_id="&request.form("type_son_id")
conn.execute(sql)
end sub
'修改一个类型
sub mod_brand
sql="update brand set brand_name='"&request.form("brand_name")&"',xu="&request.form("brand_xu")&" where brand_id="&request.form("brand_id")
conn.execute(sql)
end sub
'删除一个分类
sub del_type
sql="delete from type where type_id="&request.QueryString("type_id")
conn.execute(sql)
sql1="delete from type_son where type_id="&request.QueryString("type_id")
conn.execute(sql1)
sql2="delete from brand where type_id="&request.QueryString("type_id")
conn.execute(sql2)
sql3="delete from products where type_id="&request.QueryString("type_id")
conn.execute(sql3)
sql4="delete from offer where type_id="&request.QueryString("type_id")
conn.execute(sql4)
end sub
'删除一个二级分类
sub del_type_son
sql1="delete from type_son where type_son_id="&request.QueryString("type_son_id")
conn.execute(sql1)
sql2="delete from brand where type_son_id="&request.QueryString("type_son_id")
conn.execute(sql2)
sql3="delete from products where type_son_id="&request.QueryString("type_son_id")
conn.execute(sql3)
sql4="delete from offer where type_id="&request.QueryString("type_id")
conn.execute(sql4)
end sub
'删除一个类型
sub del_brand
sql1="delete from brand where brand_id="&request.QueryString("brand_id")
conn.execute(sql1)
sql2="delete from products where brand_id="&request.QueryString("brand_id")
conn.execute(sql2)
sql3="delete from offer where type_id="&request.QueryString("type_id")
conn.execute(sql3)
end sub
'修改一个二级分类
sub up_index(up)
sql="update type_son set index="&up&" where type_son_id="&request.QueryString("type_son_id")
conn.execute(sql)
end sub
%>
<html>
<head>
<title>管理分类</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<SCRIPT language=vbscript> 
  Option Explicit
  Function ClickHands(y)                 
     Dim mShow
     Dim imgID
         Set mShow = Document.All(y & "_show")           
         ''Set imgID = Document.All(y & "_img")                     
            If mShow.style.display = "none" Then          
               mShow.style.display = ""
               ''imgID.src = "../images/-.gif"  
             Else
               mShow.style.display = "none"
               ''imgID.src = "../images/+.gif"     
            End If                                         
  End function   
</SCRIPT>

<body bgcolor="#FFFFFF" text="#000000" background="blue.gif">
<div align="center">
    <p style="color:#FF0000; font-size:12px">警告：当删除一个分类时，将同时删除该分类下的所有 <strong>商品</strong> 及其 <strong>报价</strong> ！</p>
  <%
  set rs1=server.createobject("adodb.recordset")
  sql1="select * from type order by xu"
  rs1.open sql1,conn,1,1
if rs1.eof and rs1.bof then 
 response.write "还没有任何分类，您需要新增一个分类"
 response.end
end if
  rs1.movefirst
  for i=10001 to rs1.recordcount + 10000
  %> 
  <table width="96%" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFCC">
    <tr bgcolor="#FFCC33"><form name="form1<%=i%>" method="post" action=""> 
      <td width="70%" height="30">&nbsp;&nbsp;&nbsp;&nbsp;<IMG id=<%=i%>_img src="../images/+.gif" align=absMiddle style="CURSOR: hand" onclick=vbscript:ClickHands(<%=i%>)>
          <input name="type_name" type="text" value="<%=rs1("type_name")%>" style="width:150px">
		  <input name="type_xu" type="text" value="<%=rs1("xu")%>" size="3">
		  <input name="type_id" type="hidden" value="<%=rs1("type_id")%>">
		  <input name="action" type="hidden" value="mod_type">
		  <span style="width:47%;CURSOR: hand" onclick=vbscript:ClickHands(<%=i%>)></span>
</td>
      <td width="30%">&nbsp;<input type="submit" name="Submit" value="修改">
	  <input onclick="window.location.href='?action=del_type&type_id='+document.form1<%=i%>.type_id.value" type=button name=Button value="删除"></td>
    </form></tr>
	<tr bgcolor="#FDFEF5"> 
	<td colspan="2">
<!---显示二级分类------------------------------------------------------->
<DIV id=<%=i%>_show style="DISPLAY: none; WIDTH: 100%; POSITION: relative; TOP: 0px">
	<%
  set rs2=server.createobject("adodb.recordset")
  sql2="select * from type_son where type_id="&rs1("type_id")&" order by xu"
  rs2.open sql2,conn,3,3
  do while not rs2.eof
  t=t+1%>
  <table width="100%" border="0" cellpadding="5" cellspacing="1">
    <tr bgcolor="#FEF49C" onmouseover=javascript:this.bgColor="#E9CD5C" onmouseout=javascript:this.bgColor="#FEF49C"> 
      <form name="form2<%=t%>" method="post" action="">
	  <td width="70%">
	  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<IMG id=<%=i%>_img src="../images/+.gif" align=absMiddle style="CURSOR: hand" onclick=vbscript:ClickHands(<%=t%>)> 
	  <input name="type_son_name" type="text" value="<%=rs2("type_son_name")%>" style="width:130px">
	  <input name="type_son_xu" type="text" value="<%=rs2("xu")%>" size="3">
		  <input name="type_son_id" type="hidden" value="<%=rs2("type_son_id")%>">
		  <input name="action" type="hidden" value="mod_type_son">
		  <span style="width:48%;CURSOR: hand" onclick=vbscript:ClickHands(<%=t%>)></span></td>
      <td width="30%" align="center"><input type="submit" name="Submit" value="修改">
	  <input onclick="window.location.href='?action=del_type_son&type_son_id='+document.form2<%=t%>.type_son_id.value" type=button name=Button value="删除">
	  <input onclick="window.location.href='?action=up_index_<%=rs2("index")%>&type_son_id='+document.form2<%=t%>.type_son_id.value" type=button name=Button value=<%if rs2("index")=true then Response.Write("'从首页取消' style='color:#FF0000'") else Response.Write("'设置到首页'") end if%>>
	  </td>
    </form></tr>
  </table>
<DIV id=<%=t%>_show style="DISPLAY: none; WIDTH: 100%; POSITION: relative; TOP: 0px">
<!----开始显示类型------------------------------------------------------->
<table width="100%"  border="0" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">
<%
set rs3=server.createobject("adodb.recordset")
sql3="select * from brand where type_son_id="&rs2("type_son_id")&" order by xu"
rs3.open sql3,conn,1,1 
While (NOT rs3.EOF)
b=b+1
%>
  <tr bgcolor="#ffffff" onmouseover=javascript:this.bgColor="#f7f7f7" onmouseout=javascript:this.bgColor="#ffffff">
    <form name="form3<%=b%>" method="post" action=""><td width="70%">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="brand_name" type="text" value="<%=(rs3.Fields.Item("brand_name").Value)%>" size="30">
<input name="brand_xu" type="text" value="<%=(rs3.Fields.Item("xu").Value)%>" size="3">
		  <input name="brand_id" type="hidden" value="<%=(rs3.Fields.Item("brand_id").Value)%>">
		  <input name="action" type="hidden" value="mod_brand"></td>
    <td width="30%">&nbsp;<input type="submit" name="Submit" value="修改">
	  <input onclick="window.location.href='?action=del_brand&brand_id='+document.form3<%=b%>.brand_id.value" type=button name=Button value="删除"></td>
  </form></tr>
<%
rs3.MoveNext()
Wend
rs3.close
set rs3=nothing
%>
</table>
</DIV>
<!----类型结束------------------------------------------------------->
<%rs2.movenext
  loop
  rs2.close
  set rs2=nothing
  %></div></td>
    </tr>
  </table><%rs1.movenext
  next
  rs1.close
  set rs1=nothing
  %>
</div>
</body>
</html>
