<!--#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")

'//添加新数据
select case action
case "add"
set rs=server.CreateObject("adodb.recordset")
rs.open "select top 1 * from com_china where LevelID=1 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")=1
rs("name")=trim(request("name2"))
rs("parentid")=int(request("id"))
rs.Update
rs.Close
set rs=nothing
response.redirect "Addr_nclass.asp?id="&id&"&anclass="&anclass&"&tid=0"

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

'//删除数据
case "del"
id=request.QueryString("id")
conn.execute ("delete from com_china where id="&request.QueryString("nid"))
conn.execute ("delete from com_china where parentid="&request.QueryString("nid"))
response.redirect "Addr_nclass.asp?id="&id&"&anclass="&anclass&"&tid="&tid&""
end select
%>
<%
dim id,ClassNamecn,paixu
id=request.QueryString("id")
tid=request("tid")

action=request.QueryString("action")
select case action
case "cn1"
 call editbook("showin=0")
case "cn2"
 call editbook("showin=1")
end select

function editbook(b_name)
aid=request.QueryString("aid")
conn.execute("update com_china set "&b_name&" where id="&aid)
'response.Write "<script>location='?"&canshu2&"'</script->"
End Function
%>
<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 LevelID=0 and parentid=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 id="" then
response.Write ""
else
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from com_china where parentid="&id&" and LevelID=1 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_nclass.asp?action=edit&nid=<%=rs("id")%>&tid=<%=tid%>">

<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_nclass.asp?nid=<%=int(rs("id"))%>&tid=<%=tid%>&action=del&id=<%=request.QueryString("id")%>" onClick="return confirm('此删除操作，会删除此分类下的所有资料！您确定进行删除操作吗？')">删除</a></li>
</div>

</form>
<%
rs.movenext
wend
paixu=rs.RecordCount
rs.close
set rs=nothing
end if
end if
%>
<form name="formadd" method="post" action="Addr_nclass.asp?action=add&anclass=<%=request.QueryString("ClassNamecn")%>&tid=<%=tid%>">
<div class="tableAll titlebgcolor">
  <li style="width:30px;">&nbsp;</li>
 <li style="width:700px">添加小分类(注意：小类名称不要含有非法字符)&nbsp;
   <select name="select2" 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 LevelID=0 and parentid=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>
<%
if id="" 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"-->