<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加商品类别</title>
<link type="text/css" rel="stylesheet" href="../Css/style.css" />
<script language="javascript" type="text/javascript" src="../jQuery/lib/jquery.js"></script>
<script language="javascript" type="text/javascript" src="../js/WebSite.js"></script>
<script language="javascript" type="text/javascript" src="../js/ChkForm.js"></script>
</head>
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/Function.asp"-->
<body>
<%
Call ChkLogin(session("WebAdminsUserName"))
Dim CateID,iCount
CateID=Request.QueryString("CateID")
Call ChkIsNumber(CateID,"参数类型错误!")
Call ConnectionDataBase(2)


Function SubCategory(ParentID,Sapce)
	StrSql="SELECT * FROM T_Class WHERE ParentID=" & ParentID & " ORDER BY SortID DESC,ID ASC"
	SetRs Rs1,StrSql,conn,1,1
	IF Not Rs1.EOF Then
	Do While Not Rs1.EOF
	iCount = iCount + 1
	ClassName = Sapce & Rs1("ClassName")
	ClassID = Rs1("ID")
	%>	
	<tr>
        <td align="center"><%=iCount%></td>
        <td align="left"><%=ClassName%></td>
        <td align="center">
        <a href="#" onclick="EditClass(<%=Rs1("ParentID")%>,<%=ClassID%>,'<%=Replace(ClassName,"&nbsp;","")%>',<%=Rs1("SortID")%>)">编辑</a>
        <a href="Delete.asp?action=DelClass&id=<%=ClassID%>" onclick="return Confirm('确定要删除该记录吗?删除后无法恢复');">删除</a>    </td>
  	</tr>
	<%
		TempClassName = TempClassName & ClassName & ","
		TempClassID = TempClassID & ClassID & ","
		Sapce = Sapce + "&nbsp;&nbsp;&nbsp;&nbsp;"
		Call SubCategory(Rs1("ID"),Sapce)
	Rs1.movenext
	Loop
	End IF
	IF Len(Sapce)>24 Then
		Sapce = Left(Sapce,Len(Sapce)-24)
	Else
		Sapce = "&nbsp;&nbsp;&nbsp;&nbsp;"
	End IF
	DisRs Rs1
End Function
%>
<div class="FloatLeft" style="width:67%;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th width="10%">序号</th>
    <th width="70%">类别名称</th>
    <th width="20%">操作</th>
  </tr>
  <%
	Sql="SELECT * FROM T_Class WHERE CateID=" & CateID & " AND ParentID=0 ORDER BY SortID DESC,ID ASC"
	SetRs Rs,Sql,conn,1,1
	IF Not Rs.EOF Then
	Do While Not Rs.EOF
	iCount = iCount + 1
	ClassName = Rs("ClassName")
	ClassID = Rs("ID")
  %>
  <tr>
    <td align="center"><%=iCount%></td>
    <td align="left"><%=ClassName%></td>
    <td align="center">
    <a href="#" onclick="EditClass(<%=Rs("ParentID")%>,<%=ClassID%>,'<%=ClassName%>',<%=Rs("SortID")%>)">编辑</a>
    <a href="Delete.asp?action=DelClass&id=<%=ClassID%>" onclick="return Confirm('确定要删除该记录吗?删除后无法恢复');">删除</a>    </td>
  </tr>
  <%
  	  TempClassName = TempClassName & ClassName & ","
	  TempClassID = TempClassID & ClassID & ","
	  Call SubCategory(Rs("ID"),"&nbsp;&nbsp;&nbsp;&nbsp;")
	  Rs.movenext
	Loop
	End IF
	DisRs Rs
  %>
</table>
</div>
<div class="FloatLeft" style="width:28%; margin-left:5px">
<form action="Submit.asp" method="post" name="frm" style="margion:0" onsubmit="return ChkClass()">
<input type="hidden" name="CateID" id="CateID" value="<%=CateID%>" />
<input type="hidden" name="ID" id="ID" value="0" />
<input type="hidden" name="action" id="action" value="AddCategory" />
<table width="100%" border="0" cellspacing="0" cellpadding="0">  
  <tr>
    <td width="33%" align="right">所属大类：</td>
    <td width="67%" align="left">
	    <select name="BigCategory" id="BigCategory">
	    <option value="0" selected>根目录</option>
        <%
		ArrClassName = Split(TempClassName,",")
		ArrClassID = Split(TempClassID,",")
		For i=0 To Ubound(ArrClassName)-1
		%>
		<option value="<%=ArrClassID(i)%>"><%=ArrClassName(i)%></option>
		<%
		Next
		%>
	    </select>
    </td>
  </tr>
  <tr>
    <td align="right">子类名称：</td>
    <td align="left"><input type="text" name="SubCategory" id="SubCategory" class="txt" /></td>
  </tr> 
  <tr>
    <td align="right">排序：</td>
    <td align="left"><input type="text" name="SortID" id="SortID" class="txt" value="99" style="width:30px" onkeyup="value=value.replace(/[^\d]/g,'');" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''));"/></td>
  </tr>   
  <tr>
    <td align="right">&nbsp;</td>
    <td align="left">    
    <input type="submit" value="提交" class="btn" />
    </td>
  </tr>  
</table>
</form>

</div>
</body>
</html>
