<%
'商易仿淘宝4.0(多用户)
'ACCESS版演示网站：http://www.ftaobao.com(商易仿淘宝商城)
'SQL版演示网站：http://sql.ftaobao.com
'电话：0571-56907100
'QQ：1147100
%>
<%qx=4%>
<!--#include file="top.asp"-->
<!--#include file="check.asp"-->
<!--#include file="../include/conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../include/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<br><div align="center">
  <table width="550" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#efefef">
    
    <tr align="center" valign="middle" bgcolor="#f7f7f7">
      <td width="25%" height="25" bgcolor="#FFFFFF"><a href="add-lb.asp?action=Add">[新增大类别]</a></td>
      <td width="25%" height="25" bgcolor="#FFFFFF"><a href="he.asp">[合并或移动大类别]</a></td>
      <td width="27%" nowrap bgcolor="#FFFFFF"><a href="?x=cp">[重新计算类别产品数量]</a></td>
    </tr>
  </table>
  <br>
<%
Select case request("x")
case "px"
if shopnet("lbid")<>"" then
px= conn.execute("select px from lb where lbid="&shopnet("lbid")&"")(0)
if shopnet("px")="shang" and px<255 then
conn.execute("Update lb set px=px+1 where lbid="&shopnet("lbid")&"")
elseif shopnet("px")="xia" and px>0 then
conn.execute("Update lb set px=px-1 where lbid="&shopnet("lbid")&"")
end if
Response.Write("<script>alert(""修改类别排序成功"");location.href=""?"";</script>")
elseif shopnet("xlbid")<>"" then
px= conn.execute("select px from xlb where xlbid="&shopnet("xlbid")&"")(0)
if shopnet("px")="shang" and px<255 then
conn.execute("Update xlb set px=px+1 where xlbid="&shopnet("xlbid")&"")
elseif shopnet("px")="xia" and px>0 then
conn.execute("Update xlb set px=px-1 where xlbid="&shopnet("xlbid")&"")
end if
Response.Write("<script>alert(""修改类别排序成功"");location.href=""?"";</script>")
end if
case "cang"
if shopnet("lbid")<>"" then
if shopnet("cang")="yes" then
conn.execute("Update lb set cang=1 where lbid="&shopnet("lbid")&"")
elseif shopnet("cang")="no" then
conn.execute("Update lb set cang=0 where lbid="&shopnet("lbid")&"")
end if
Response.Write("<script>alert(""修改类别隐藏显示成功"");location.href=""?"";</script>")
elseif shopnet("xlbid")<>"" then
if shopnet("cang")="yes" then
conn.execute("Update xlb set cang=1 where xlbid="&shopnet("xlbid")&"")
elseif shopnet("cang")="no" then
conn.execute("Update xlb set cang=0 where xlbid="&shopnet("xlbid")&"")
end if
Response.Write("<script>alert(""修改类别隐藏显示成功"");location.href=""?"";</script>")
end if
case "cp"
set rs = conn.execute("select lbid from lb order by lbid desc")
do while not rs.eof
cp_s=conn.execute("select count(id) from chanpin where lbid="&rs(0)&" and cang=0 and tui=0")(0)
conn.execute("Update lb set cp="&cp_s&" where lbid="&rs(0)&"")
rs.movenext
loop
rs.close
set rs = conn.execute("select xlbid,lbid from xlb order by xlbid desc")
do while not rs.eof
cp_s=conn.execute("select count(id) from chanpin where xlbid="&rs(0)&" and lbid="&rs(1)&" and cang=0 and tui=0")(0)
conn.execute("Update xlb set cp="&cp_s&" where xlbid="&rs(0)&"")
rs.movenext
loop
rs.close
set rs = conn.execute("select lbid,xlbid,slbid from slb order by slbid desc")
do while not rs.eof
cp_s=conn.execute("select count(id) from chanpin where lbid="&rs(0)&" and xlbid="&rs(1)&" and slbid="&rs(2)&" and cang=0 and tui=0")(0)
conn.execute("Update slb set cp="&cp_s&" where slbid="&rs(2)&"")
rs.movenext
loop
rs.close
Response.Write("<br><br>重新计算类别产品数量成功。。。<meta http-equiv=refresh content=4;url=?>")
Response.end
End Select 

sql2 = "select * from lb order by px desc,lbid"
set rs2 = conn.execute(sql2)
if rs2.eof then
response.write("<br>当前没有任何分类！<br><a href=""add-lb.asp?action=Add""><font color=red>新增大类别</font></a><br>")
end if

%>
</div>
<SCRIPT LANGUAGE=javascript>
var tt='start';
var ii='start';
function turnit(ss,bb) {

  if (ss.style.display=="none") {
    if(tt!='start') tt.style.display="none";
    if(ii!='start') ii.src="";
    ss.style.display="";
    tt=ss;
    ii=bb;
    bb.src="";
  }
  else {
    ss.style.display="none"; 
    bb.src="";
  }
}
</SCRIPT>
<table cellspacing="1" cellpadding="4" class="tableborder" align="center">
<tr>
  <td bgcolor="#ffffff" align="center" background="images/admin_bg_4.gif" height="25" colspan="2"><span style="color: #FFFFFF; font-weight: bold">类别管理</span></td>
</tr>
<%do while not rs2.Eof%>
  <tr> 
    <td width="280" height="18" bgcolor="#FFFFFF" vAlign=middle  id=tag<%=rs2("lbid")%> 
    style='CURSOR: hand' onclick=turnit(Content<%=rs2("lbid")%>,tag<%=rs2("lbid")%>);  language=JScript>&nbsp;→<%=rs2("lbname")%> (<%=rs2("cp")%>)</td>
    <td width="300" height="18" align="center" bgcolor="#FFFFFF"><%if rs2("px")=0 then
Response.Write("<a href=?x=px&lbid="&rs2("lbid")&"&px=shang>↑</a> <font color=#999999>↓</font>")
elseif rs2("px")=255 then
Response.Write("<font color=#999999>↓</font> <a href=?x=px&lbid="&rs2("lbid")&"&px=xia>↓</a>")
else
Response.Write("<a href=?x=px&lbid="&rs2("lbid")&"&px=shang>↑</a> <a href=?x=px&lbid="&rs2("lbid")&"&px=xia>↓</a>")
end if%> | <%if rs2("cang")=0 then Response.Write("<a href=?x=cang&lbid="&rs2("lbid")&"&cang=yes>首页不隐藏</a>") else Response.Write("<a href=?x=cang&lbid="&rs2("lbid")&"&cang=no><font color=red>首页不显示</font></a>")%> | <a href="#" OnClick="Javascript:window.open('edit-lb.asp?action=Aedit&id=<%=rs2("lbid")%>','','width=350,height=100,top=10,left=180')">编辑</a> 
      | <a href="javascript:ConfirmDele(<%=rs2("lbid")%>)">删除</a> 
    | <a href="#" OnClick="Javascript:window.open('add-lb.asp?action=Ndd&lbid=<%=rs2("lbid")%>','','width=350,height=100,top=10,left=180')">新增二类别</a>    </td>
  </tr>
  <tr> 
    <td height="18" colspan="2" vAlign=center bgcolor="#FFFFFF" id=Content<%=rs2("lbid")%> style='DISPLAY: none'><%sql1 = "select * from xlb where lbid="&rs2("lbid")&" order by px desc,xlbid"
            set rs1 = conn.execute(sql1)
            do while not rs1.EOF%>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="1">
  <tr> 
    <td height="18" width="50">&nbsp;</td>
          <td height="18" bgcolor="#FFFFFF" vAlign=middle  id=tag<%=rs2("lbid")%> 
    style='CURSOR: hand' onclick=turnit(Content<%=rs2("lbid")%>,tag<%=rs2("lbid")%>);  language=JScript>&nbsp;→&nbsp;<%=rs1("xlbname")%> (<%=rs1("cp")%>)</td>
    <td width="300" height="18" align="center" nowrap bgcolor="#f7f7f7"><%if rs1("px")=0 then
Response.Write("<a href=?x=px&xlbid="&rs1("xlbid")&"&px=shang>↑</a> <font color=#999999>↓</font>")
elseif rs1("px")=255 then
Response.Write("<font color=#999999>↓</font> <a href=?x=px&xlbid="&rs1("xlbid")&"&px=xia>↓</a>")
else
Response.Write("<a href=?x=px&xlbid="&rs1("xlbid")&"&px=shang>↑</a> <a href=?x=px&xlbid="&rs1("xlbid")&"&px=xia>↓</a>")
end if%> | <%if rs1("cang")=0 then Response.Write("<a href=?x=cang&xlbid="&rs1("xlbid")&"&cang=yes>首页不隐藏</a>") else Response.Write("<a href=?x=cang&xlbid="&rs1("xlbid")&"&cang=no><font color=red>首页不显示</font></a>")%> 
      | <a href="#" OnClick="Javascript:window.open('edit-lb.asp?action=Nedit&id=<%=rs1("xlbid")%>','','width=350,height=100,top=10,left=180')">编辑</a> 
      | <a href="javascript:ConfirmDele1(<%=rs1("xlbid")%>)">删除</a> | <a href="#" onClick="Javascript:window.open('add-lb.asp?action=sdd&lbid=<%=rs1("lbid")%>&xlbid=<%=rs1("xlbid")%>','','width=350,height=100,top=10,left=180')">新增三类别</a> </td>
  </tr>
</table>
<%
            sql3 = "select * from slb where lbid="&rs2("lbid")&" and xlbid="&rs1("xlbid")&" order by slbid"
            set rs3 = conn.execute(sql3)
            do while not rs3.EOF 
            %>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#efefef">
  <tr>
    <td width="27%" height="18" bgcolor="#FFFFFF">&nbsp;</td>
    <td height="18" bgcolor="#FFFFFF" width="300">&nbsp;→&nbsp;<%=rs3("slbname")%> (<%=rs3("cp")%>)</td>
    <td width="100" height="18" align="center" bgcolor="#FFFFFF"> <a href="#" OnClick="Javascript:window.open('edit-lb.asp?action=sedit&id=<%=rs3("slbid")%>','','width=350,height=100,top=10,left=180')">编辑</a> | <a href="javascript:ConfirmDele2(<%=rs3("slbid")%>)">删除</a> </td>
  </tr>
</table>
<%rs3.MoveNext
loop
rs3.Close
'rs3=nothing%>
<%rs1.MoveNext
loop
rs1.Close
set rs1=nothing%>
<%rs2.MoveNext 
Loop
rs2.Close
set rs2=nothing
conn.close
set conn=nothing%>
 </td> </tr><tr><td bgcolor="#ffffff" align="center" height="21" colspan="2"></td>
 </tr> 
</table>

<script language="JavaScript">
function ConfirmDele(unid)     
   {     
      if(confirm("\n您确认删除吗？"))     
      {     
        location.href="del-leibie.asp?action=lbdel&id="+unid;
      }        
   } 
function ConfirmDele1(unid)     
   {     
      if(confirm("\n您确认删除吗？"))     
      {     
        location.href="del-leibie.asp?action=xlbdel&id="+unid;
      }        
   } 
function ConfirmDele2(unid)     
   {     
      if(confirm("\n您确认删除吗？"))     
      {     
        location.href="del-leibie.asp?action=slbdel&id="+unid;
      }        
   } 
</script>
<table width="650" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="40" align="center" valign="middle">备注：点击大类别可以查看该类别下的小分类，排序会影响类别的排列顺序，首页隐藏会隐藏该类别不显示。</td>
  </tr>
</table>
</body>
</html>
