<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Chk_Admin.asp"-->

<%Sub AddBigClass()
	sql="select count(*) from ws_bigclass_news where ws_bigclassname='"&ws_bigclassname&"'"
	call CreateRS(sql,1,1)
	if rs(0)>0 then
		CloseRS()
		response.Write("<script>alert('该大类已存在！');history.go(-1);</script>")
		response.end
	else
		CloseRS()

		conn.execute("insert into ws_bigclass_news (ws_bigclassname) values('"&ws_bigclassname&"')")

	end if
End Sub

Sub AddSmallClass()
    sql="select count(*) from Ws_smallclass_news where ws_bigclassname='"&ws_bigclassname&"' and ws_smallclassname='"&ws_smallclassname&"'"
	call CreateRS(sql,1,1)
	if rs(0)>0 then
	    CloseRS()
		response.Write("<script>alert('该小类已存在！');history.go(-1);</script>")
		response.end
	else
		CloseRS()

		conn.execute("insert into Ws_smallclass_news (ws_bigclassname,ws_smallclassname) values('"&ws_bigclassname&"','"&ws_smallclassname&"')")

	end if
End Sub

Sub UpdateBigClass()
   sql="select count(*) from ws_bigclass_news where ws_bigclassname='"&ws_bigclassname&"' and id <>"&id

   call CreateRS(sql,1,1)
   if rs(0)>0 then
	   CloseRS()
	   response.write("<script>alert('大类名称重复！');history.go(-1);</script>")
	   response.end
   else
	   CloseRS()

	   conn.execute("update ws_bigclass_news set ws_bigclassname='"&ws_bigclassname&"' where id="&id)
	   conn.execute("update Ws_smallclass_news set ws_bigclassname='"&ws_bigclassname&"' where ws_bigclassname='"&FristName&"'")
	   conn.execute("update ws_news set ws_bigclassname='"&ws_bigclassname&"' where ws_bigclassname='"&FristName&"'")

   end if
End Sub

Sub UpdateSmallClass()
   sql="select count(*) from Ws_smallclass_news where ws_smallclassname='"&ws_smallclassname&"' and ws_bigclassname='"&ws_bigclassname&"' and id <>"&id
   call CreateRS(sql,1,1)
   if rs(0)>0 then
      CloseRS()
	  response.Write("<script>alert('小类名称重复！！请重新输入！');history.go(-1);</script>")
	  response.end
   else
       CloseRS()

	   conn.execute("update Ws_smallclass_news set ws_smallclassname='"&ws_smallclassname&"' where id="&id&" and ws_bigclassname='"&ws_bigclassname&"'")
	   conn.execute("update ws_news set ws_smallclassname='"&ws_smallclassname&"' where ws_smallclassname='"&FristName&"'")

   end if
End Sub
%>

<%if request.Form("action")="addBig" then
    ws_bigclassname=trim( request.Form("ws_bigclassname"))
	AddBigClass()
	response.Write("<script>alert('添加大类成功！');this.location='News_Class.asp';</script>")
	response.end
end if

if request.form("action")="addsmall" then
    ws_bigclassname=trim(request.Form("ws_bigclassname"))
	ws_smallclassname=trim(request.Form("ws_smallclassname"))
	AddSmallClass()
	response.Write("<script>alert('添加小类成功！');this.location='News_Class.asp';</script>")
	response.end	
end if

if request.form("action")="editsmall" then
    id=request.form("id")
    ws_bigclassname=trim(request.Form("ws_bigclassname"))
	ws_smallclassname=trim(request.Form("ws_smallclassname"))
	FristName=trim(request.form("FristName"))
	UpdateSmallClass()
	response.Write("<script>alert('小类修改成功！');this.location='News_Class.asp';</script>")
	response.end	
end if

if request.form("action")="editBig" then
    id=request.form("id")
    ws_bigclassname=trim(request.Form("ws_bigclassname"))
	FristName=trim(request.form("FristName"))
	UpdateBigClass()
	response.Write("<script>alert('大类修改成功！');this.location='News_Class.asp';</script>")
	response.end	
end if

if request.querystring("method")="delbig" then
	ws_bigclassname=request.querystring("ws_bigclassname")
	conn.execute("delete from ws_news where ws_bigclassname='"&ws_bigclassname&"'")
	conn.execute("delete from Ws_smallclass_news where ws_bigclassname='"&ws_bigclassname&"'")
	conn.execute("delete from ws_bigclass_news where ws_bigclassname='"&ws_bigclassname&"'")
	response.Write("<script>alert('大类删除成功！');this.location='News_Class.asp';</script>")
	response.end	
end if

if request.querystring("method")="Delsmall" then
    ws_bigclassname=request.querystring("ws_bigclassname")
	ws_smallclassname=trim(request("ws_smallclassname"))
	conn.execute("delete from ws_news where ws_smallclassname='"&ws_smallclassname&"' and ws_bigclassname='"&ws_bigclassname&"'")
	conn.execute("delete from Ws_smallclass_news where ws_smallclassname='"&ws_smallclassname&"' and ws_bigclassname='"&ws_bigclassname&"'")
	response.Write("<script>alert('小类删除成功！');this.location='News_Class.asp';</script>")
	response.end	
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<link rel="StyleSheet" href="images/style.css" type="text/css">
</head>

<body>
<table width="98%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="30"><div align="center" class="navtline">产品类别管理</div></td>
  </tr>
  <tr>
    <td height="22">
	<%select case request.QueryString("method")
	case "addsmall"%>
	<form action="" method="post">
      <table width="60%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="30" colspan="2" class="navtline"><div align="center">添加小类</div></td>
        </tr>
        <tr>
          <td width="40%" height="22"><div align="right">类别名称：</div></td>
          <td><div align="left">
              <input name="ws_smallclassname" type="text" class="tittab" id="ws_smallclassname">
          </div></td>
        </tr>
        <tr>
          <td height="22"><input name="action" type="hidden" value="addsmall">
            &nbsp;
            <input name="ws_bigclassname" type="hidden" id="ws_bigclassname" value="<%=request.querystring("ws_bigclassname")%>"></td>
          <td><input name="Submit" type="submit" class="navtab" value="提交">
              <input name="Submit2" type="reset" class="navtab" value="重置"></td>
        </tr>
      </table>
	  </form><%case "editsmall"%>
	<form action="" method="post">
      <table width="60%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="30" colspan="2" class="navtline"><div align="center">小类信息修改</div></td>
        </tr>
        <tr>
          <td width="40%" height="22"><div align="right">类别名称：</div></td>
          <td><div align="left">
              <input name="ws_smallclassname" type="text" class="tittab" id="ws_smallclassname" value="<%=request.querystring("ws_smallclassname")%>">
          </div></td>
        </tr>
        <tr>
          <td height="22"><input name="action" type="hidden" id="action" value="editsmall">
            &nbsp;
            <input name="ws_bigclassname" type="hidden" id="ws_bigclassname" value="<%=request.querystring("ws_bigclassname")%>">
            <input name="id" type="hidden" id="id" value="<%=request.querystring("id")%>">
            <input name="FristName" type="hidden" id="FristName" value="<%=request.querystring("ws_smallclassname")%>"></td>
          <td><input name="Submit4" type="submit" class="navtab" value="提交">
              <input name="Submit23" type="reset" class="navtab" value="重置"></td>
        </tr>
      </table>
	  </form><%case "addbig"%>
	<form action="" method="post">
        <table width="60%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="30" colspan="2" class="navtline"><div align="center">添加大类</div></td>
          </tr>
          <tr>
            <td width="40%" height="22"><div align="right">类别名称：</div></td>
            <td><div align="left">
                <input name="ws_bigclassname" type="text" class="tittab" id="ws_bigclassname">
            </div></td>
          </tr>
          <tr>
            <td height="22"><input name="action" type="hidden" id="action" value="addBig"></td>
            <td><input name="Submit3" type="submit" class="navtab" value="提交">
                <input name="Submit22" type="reset" class="navtab" value="重置"></td>
          </tr>
        </table>
      </form><%case "editbig"%>
      <form action="" method="post">
        <table width="60%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="30" colspan="2" class="navtline"><div align="center">大类信息修改</div></td>
          </tr>
          <tr>
            <td width="40%" height="22"><div align="right">类别名称：</div></td>
            <td><div align="left">
                <input name="ws_bigclassname" type="text" class="tittab" id="ws_bigclassname" value="<%=request.querystring("ws_bigclassname")%>">
            </div></td>
          </tr>
          <tr>
            <td height="22"><input name="action" type="hidden" id="action" value="editBig">
            <input name="id" type="hidden" id="id" value="<%=request.querystring("id")%>">
            <input name="FristName" type="hidden" id="FristName" value="<%=request.querystring("ws_bigclassname")%>"></td>
            <td><input name="Submit32" type="submit" class="navtab" value="提交">
                <input name="Submit222" type="reset" class="navtab" value="重置"></td>
          </tr>
        </table>
      </form><%end select%></td>
  </tr>
  <tr>
    <td height="22"><table width="60%" border="0" align="center" cellpadding="0" cellspacing="2">
      <tr>
        <td colspan="2"><div align="right" class="b"><a href="News_Class.asp?method=addbig">添加产品大类</a></div></td>
        </tr>
      <tr>
        <td width="40%" class="navtab"><div align="center">栏目名称</div></td>
        <td class="navtab"><div align="center">操作选项</div></td>
      </tr>
	  <%sql="select * from ws_bigclass_news"
	  call CreateRS(sql,3,3)
	  if not (rs.eof and rs.bof) then
	  do while not rs.eof%>
      <tr>
        <td bgcolor="#ECF7FF"><%=rs("ws_bigclassname")%></td>
        <td bgcolor="#ECF7FF"><div align="right"> <span class="b"><a href="News_Class.asp?method=addsmall&ws_bigclassname=<%=rs("ws_bigclassname")%>">添加二级分类</a></span> <a href="News_Class.asp?method=editbig&ws_bigclassname=<%=rs("ws_bigclassname")%>&id=<%=rs("id")%>">修改</a> | <a href="News_Class.asp?method=delbig&ws_bigclassname=<%=rs("ws_bigclassname")%>">删除</a></div></td>
      </tr>
	  <%sql1="select * from Ws_smallclass_news where ws_bigclassname='"&rs("ws_bigclassname")&"'"
	  set rs1=server.CreateObject("adodb.recordset")
	  rs1.open sql1,conn,1,1
	  if not(rs1.eof and rs1.bof) then
	  do while not rs1.eof%>
	  <tr>
        <td bgcolor="#FEFFF0"> &nbsp;&nbsp;|--<%=rs1("ws_smallclassname")%></td>
        <td bgcolor="#FEFFF0"><div align="right"> <a href="News_Class.asp?method=editsmall&ws_smallclassname=<%=rs1("ws_smallclassname")%>&id=<%=rs1("id")%>&ws_bigclassname=<%=rs1("ws_bigclassname")%>">修改</a> | <a href="News_Class.asp?method=Delsmall&ws_smallclassname=<%=rs1("ws_smallclassname")%>&ws_bigclassname=<%=rs1("ws_bigclassname")%>">删除</a></div></td>
      </tr>
	  
	  <%rs1.movenext:loop	    
	  end if
	  rs1.close
	  set rs1=nothing%>
	  
	  <%rs.movenext:loop
	  end if
	  CloseRS()%>
    </table></td>
  </tr>
</table>
</body>
</html>
