<!--#include file="conn.asp"-->
<!--#include file="inc/cook2.asp"-->
<!--#include file="inc/dimflag.asp"-->
<!--#include file="top.asp"-->
<%
id=request("id")
anclass=request.QueryString("anclass")
action=request.QueryString("action")
tid=request("tid")
nid=request("nid")
sid=request("sid")
'//添加新数据
select case action
case "add"
set rs=server.CreateObject("adodb.recordset")
rs.open "select top 1 * from com_china where LevelID=2 order by id desc",conn,1,3
lestid=rs("id")
rs.Close
set rs=nothing

set rs=server.CreateObject("adodb.recordset")
rs.open "select * from com_china",conn,1,3
rs.AddNew
rs("id")=lestid+1
rs("LevelID")=2
rs("name")=trim(request("name2"))
rs("parentid")=int(request("nid"))
rs.Update
rs.Close
set rs=nothing
response.redirect "Addr_snclass.asp?id="&id&"&anclass="&anclass&"&tid="&tid&"&nid="&nid&""

'//修改数据
case "edit"
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from com_china where id="&request.QueryString("sid"),conn,1,3
rs("name")=trim(request("name"))
rs("LevelID")=2
rs.update
rs.close
set rs=nothing
response.redirect "Addr_snclass.asp?id="&id&"&anclass="&anclass&"&tid="&tid&"&nid="&nid&""

'//删除数据
case "del"
id=request.QueryString("id")
conn.execute ("delete from com_china where id="&request.QueryString("sid"))
response.redirect "Addr_snclass.asp?id="&id&"&anclass="&anclass&"&tid="&tid&"&nid="&nid&""
end select
%>
<div id="container">
<div class="top_but">
 <li class="left"></li>
 <li><a href="#"><img src="images/but_1.gif" alt="添加" ></a></li>
 <li><img src="images/but_8.gif" alt="刷新" style="cursor:hand" onClick="window.location.reload(true);"></li>
 <li><img src="images/but_9.gif" alt="打印" style="cursor:hand;" onClick="window.print() "/></li>
 <li class="right"><select name="select" onChange="var jmpURL=this.options[this.selectedIndex].value ; if(jmpURL!='') {window.location=jmpURL;} else {this.selectedIndex=0 ;}" >
          <option >选择大类</option>
          <%set rs=server.createobject("adodb.recordset")
		rs.Open "select * from com_china where parentid=0 and LevelID=0 order by id asc",conn,1,1
		while not rs.eof %>
          <option value="?id=<%=rs("id")%>&tid=<%=tid%>" <%if rs("id")=cint(request.QueryString("id")) then %>selected<%end if%>>
		  <%=rs("name")%>
		  </option>
          <%rs.movenext
		wend
		rs.close
		set rs=nothing
		%>
        </select></li>
</div>

<div class="tableAll titlebgcolor">
  <li style="width:30px;">&nbsp;</li>
 <li style="width:150px;"><%=language_cn%>小分类</li>

 <li style="width:80px;">操作</li>
</div>

<%
if nid="" then
response.Write ""
else
if id="" then
response.Write ""
else
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from com_china where parentid="&nid&" order by id asc",conn,1,1
if rs.EOF and rs.BOF then
response.Write "还没有小分类"
paixu=0
else
%>
<%while not rs.EOF%>
<form name="form<%=rs("id")%>" method="post" action="Addr_snclass.asp?action=edit&id=<%=rs("parentid")%>&tid=<%=tid%>&nid=<%=nid%>&sid=<%=rs("id")%>">

<div class="tableAll trbgcolor">
  <li style="width:30px;">&nbsp;</li>
 <li style="width:150px;">
   <input name="name" type="text" value="<%=trim(rs("name"))%>">
   <input name="id" type="hidden" value="<%=request.QueryString("id")%>" id="Hidden1"></li>
 <li style="width:80px;"><a href="javascript:form<%=rs("id")%>.submit();">修改</a>
          <a href="Addr_snclass.asp?nid=<%=nid%>&tid=<%=tid%>&action=del&id=<%=request.QueryString("id")%>&sid=<%=rs("id")%>" onClick="return confirm('此删除操作，会删除此分类下的所有资料！您确定进行删除操作吗？')">删除</a></li>
</div>

</form>
<%
rs.movenext
wend
paixu=rs.RecordCount
rs.close
set rs=nothing
end if
end if
end if
%>
<form name="formadd" method="post" action="Addr_snclass.asp?action=add&anclass=<%=request.QueryString("name")%>&tid=<%=tid%>&nid=<%=nid%>">
<div class="tableAll titlebgcolor">
  <li style="width:30px;">&nbsp;</li>
 <li style="width:700px">添加小分类(注意：小类名称不要含有非法字符)&nbsp;<select name="select" onChange="var jmpURL=this.options[this.selectedIndex].value ; if(jmpURL!='') {window.location=jmpURL;} else {this.selectedIndex=0 ;}" >
          <option >选择一级分类</option>
          <%set rs=server.createobject("adodb.recordset")
		rs.Open "select * from com_china where parentid=0 and LevelID=0 order by id asc",conn,1,1
		while not rs.eof %>
          <option value="?id=<%=rs("id")%>&tid=<%=tid%>" <%if rs("id")=cint(request.QueryString("id")) then %>selected<%end if%>>
		  <%=rs("name")%>
		  </option>
          <%rs.movenext
		wend
		rs.close
		set rs=nothing
		%>
        </select>
		&nbsp;&nbsp;
		<select name="select" onChange="var jmpURL=this.options[this.selectedIndex].value ; if(jmpURL!='') {window.location=jmpURL;} else {this.selectedIndex=0 ;}" >
          <option >选择二级分类</option>
          <%
		  if id<>"" then
		  set rs=server.createobject("adodb.recordset")
		rs.Open "select * from com_china where LevelID=1 and parentid="&id&" order by id asc",conn,1,1
		while not rs.eof %>
          <option value="?id=<%=rs("parentid")%>&cid=<%=rs("parentid")%>&tid=<%=tid%>&nid=<%=rs("id")%>" <%if rs("id")=cint(request.QueryString("nid")) then %>selected<%end if%>>
		  <%=rs("name")%>
		  </option>
          <%rs.movenext
		wend
		rs.close
		set rs=nothing
		end if
		%>
        </select></li>
</div>
<%
if nid="" then
response.Write ""
else
%>
<div class="tableAll trbgcolor">
  <li style="width:30px;">&nbsp;</li>
 <li style="width:150px;"><input name="name2" type="text"> <input name="id" type="hidden" value="<%=request.QueryString("id")%>"></li>
 <li style="width:80px;"><a href="javascript:formadd.submit();">添加</a></li>
</div>
<%end if%>
</form>
</div>
<!--#include file="footer.asp"-->