<!--#include file="conn.asp"-->
<!--#include file="inc/cook2.asp"-->
<!--#include file="inc/dimflag.asp"-->
<!--#include file="top.asp"-->
<%
id=request.QueryString("id")
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=0 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("name")=request("name2")
rs("parentid")=0
rs.Update
rs.Close
set rs=nothing
response.Redirect "Addr_anclass.asp?tid=0"

'//修改数据
case "edit"
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from com_china where id="&id,conn,1,3
rs("name")=trim(request("name"))
rs.Update
rs.Close
set rs=nothing
response.Redirect "Addr_anclass.asp?tid=0"

'//删除数据
case "del"
conn.execute ("delete from com_china where id="&id)
conn.execute ("delete from com_china where parentid="&id)
response.Redirect "Addr_anclass.asp?tid=0"
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>
</div>

<div class="tableAll titlebgcolor">
  <li style="width:30px;">&nbsp;</li>
 <li style="width:150px;">分类</li>
 <li style="width:80px;">操作</li>
</div>
<%
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
dim paixu
if rs.EOF and rs.BOF then
response.write conn_eof
paixu=0
else
while not rs.EOF
%>
<form name="form<%=rs("id")%>" method="post" action="Addr_anclass.asp?action=edit&id=<%=int(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"))%>"></li>
 <li style="width:80px;"><a href="javascript:form<%=rs("id")%>.submit();">修改</a> <a href="Addr_anclass.asp?id=<%=int(rs("id"))%>&action=del&tid=<%=tid%>" onClick="return confirm('此操作会删除此大类下包含的小分类和产品！您确定进行删除操作吗？')">删除</a></li>
 </div>
</form>
<%
rs.MoveNext
wend
paixu=rs.RecordCount
end if
%>
<div class="tableAll titlebgcolor">
  <li style="width:30px;">&nbsp;</li>
 <li style="width:700px">添加大类(注意：各项名称不能含有非法字符)</li>
</div>
<form name="formadd" method="post" action="Addr_anclass.asp?action=add&tid=<%=tid%>">
 <div class="tableAll trbgcolor">
  <li style="width:30px;">&nbsp;</li>
 <li style="width:150px;"><input name="name2" id="name2" type="text"></li>
 <li style="width:80px;"><a href="javascript:formadd.submit();">添加</a></li>
 </div>


 <div class="tableAll trbgcolor">
  <li style="width:20%;"></li>
  <li style="width:10%;"></li>
 </div>
</form>
</div>
<!--#include file="footer.asp"-->