<!--#include file="connn.asp"-->
<!--#include file="cookies.asp"-->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
categoryid=Request("categoryid")
action=Request("action")
Dim ii
select case action
Case "edit"
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from FOX_category where categoryid = "&categoryid,conn,1,1
%>
<link href="images/fox.css" rel="stylesheet" type="text/css">
<style type=text/css>
BODY{
	margin:0px;
	FONT-SIZE: 12px;
	FONT-FAMILY: "宋体", "Verdana", "Arial", "Helvetica", "sans-serif";
	background-color: #CCCC99; 
	scrollbar-highlight-color: #CC9933; 
	scrollbar-arrow-color: #FFFFFF; 
	scrollbar-base-color: #CC9933
}
table { border:0px; }
td { font:normal 12px 宋体; }
img { vertical-align:bottom; border:0px; }
a { font:normal 12px 宋体; color:#111111; text-decoration:none; }
a:hover { color:#384780;text-decoration:underline; }
.sec_menu { border-left:2px solid #CC3300; border-right:2px solid #CC3300; border-bottom:2px solid #CC3300; overflow:hidden; background:#ffffff; }
.menu_title {background-color: #335EA8;color: white;font-size: 12px;font-weight:bold;height: 25; }
.menu_title span { position:relative; top:2px; left:8px; color:#FFFF00; font-weight:bold; }
.menu_title2 {background-color: #335EA8;color: white;font-size: 12px;font-weight:bold;height: 25; }
.menu_title2 span { position:relative; top:2px; left:8px; color:#FEFEFE; font-weight:bold; }
input,select,Textarea{
font-family:宋体,Verdana, Arial, Helvetica, sans-serif; font-size: 12px;}
</style>
<div align="center">
<table width="99%" border="0" cellspacing="1" bgcolor="#CC3300">
  <tr> 
    <td height="24" align="center"><span class="STYLE1"><span class="STYLE3">编辑分类</span></span></td>
  </tr>
  <tr> 
    <td bgcolor="#FFFFFF"><br>
	<table width="90%"  border="2" align="center" cellpadding="1" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#CCCCCC">
        </tr>
        <form name="form1" method="post" action="addfl.asp?action=editok">
		<input name="categoryid" type="hidden" value="<%= categoryid %>">
		<tr bgcolor="#FFFFFF"> 
            <td align="center"><b>分类名称</b></td>
            <td><input name="category" type="text" id="category" size="24" value="<%=trim(rs("category"))%>"></td>
          </tr>
		  <tr bgcolor="#FFFFFF"> 
            <td align="center"><b>所属分类</b></td>
            <td><select name="CID">  
<option value="0">一级分类</option>
			<%
sort(0)

ii=0
sub sort(selec)
	sql="select * from FOX_category where ParentID = "&selec&" order by categoryorder"
	Set Rs1=Conn.Execute(sql)
do while not rs1.eof
if selec=0 then
%>
<option value="<%=int(rs1("categoryid"))%>" <% if int(rs1("categoryid"))=rs("ParentID") Then Response.write("Selected") %>><%=rs1("category")%></option>
<%
else
%>
<option value="<%=int(rs1("categoryid"))%>" <% if int(rs1("categoryid"))=rs("ParentID") Then Response.write("Selected") %>><%=string(ii*2,"　")%><%=rs1("category")%></option>
<%
end if
ii=ii+1
	sort rs1("categoryid")
ii=ii-1
	rs1.movenext
	loop
	rs1.close
	Set Rs1 = Nothing
end sub

%></select></td>
          </tr>
		  <tr bgcolor="#FFFFFF">
		  <td align="center"><b>推荐分类</b></td>
		  <td><input name="first" type="checkbox" <% if rs("first")=1 Then Response.write("checked") %> value="1"></td>
		  </tr>
		  <tr bgcolor="#FFFFFF">
		  <td align="center"><b>显示分类</b></td>
		  <td><select name="hide">
		   <option value="0" <% if rs("hide")=0 Then Response.write("Selected") %>>显示</option>
           <option value="1" <% if rs("hide")=1 Then Response.write("Selected") %>>隐藏</option>
		  </select></td>
		  </tr>
		  <tr bgcolor="#FFFFFF">
		  <td align="center"><b>当前序号</b></td>
		  <td><input name="categoryOrder" type="text" class="input_sr" id="categoryOrder" value="<%=rs("categoryOrder")%>" size="3" /></td>
		  </tr>
		   <tr bgcolor="#FFFFFF">
		  <td></td>
		  <td><input type="submit" name="Submit3" value="提 交"></td>
		  </tr>
        </form>
      </table><br></td>
  </tr>
</table>
</div>
<%
case "add"

set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from FOX_category where categoryid = "&categoryid,conn,1,1
%>
<div align="center">
<table width="99%" border="0" cellspacing="1" bgcolor="#CC3300">
  <tr> 
    <td height="24" align="center"><span class="STYLE3"><b>添加下级分类</b></span></td>
  </tr>
    <td bgcolor="#FFFFFF">
	<br>
	<table width="90%" border="2" align="center" cellpadding="1" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#CCCCCC">
       
        <form name="form1" method="post" action="addfl.asp?action=addok">
		<tr bgcolor="#FFFFFF"> 
            <td align="center" background="images/topbg.gif" bgcolor="#F7F7F7"><strong>分类名称</strong></td>
            <td><input name="category" type="text" class="input_sr" id="category" size="24"></td>
          </tr>
		  <tr bgcolor="#FFFFFF"> 
            <td height="25" align="center" background="images/topbg.gif" bgcolor="#F7F7F7"><strong>所属分类</strong></td>
            <td><input name="CID" type="hidden" value="<%= categoryid %>">
			<%=trim(rs("category"))%></td>
          </tr>
		  <tr bgcolor="#FFFFFF">
		  <td align="center" background="images/topbg.gif" bgcolor="#F7F7F7"><strong>推荐分类</strong></td>
		  <td><input name="first" type="checkbox" value="1"></td>
		  </tr>
		  <tr bgcolor="#FFFFFF">
		  <td align="center" background="images/topbg.gif" bgcolor="#F7F7F7"><strong>显示分类</strong></td>
		  <td><select name="hide">
		   <option value="0">显示</option>
           <option value="1">隐藏</option>
		  </select></td>
		  </tr>
		  
		  <tr bgcolor="#FFFFFF">
		  <td align="center" background="images/topbg.gif" bgcolor="#F7F7F7"><strong>排列序号</strong></td>
		  <td><input name="categoryOrder" type="text" class="input_sr" id="categoryOrder" value="<%=rs("categoryOrder")%>" size="3" /></td>
		  </tr>
		  
		   <tr bgcolor="#FFFFFF">
		  <td background="images/topbg.gif" bgcolor="#F7F7F7"></td>
		  <td><input name="Submit3" type="submit" class="input_bot" value="提 交"></td>
		  </tr>
        </form>
      </table>
	<br></td>
  </tr>
</table>
</div>

<%
case "addcat" 
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from FOX_category",conn,1,3
rs.AddNew
rs("category")=trim(request.form("category"))
rs("categoryorder")=int(request.form("categoryorder"))
rs("ParentID")=0
rs("first")=1
rs("hide")=0
rs.Update
rs.Close
set rs=nothing
response.Redirect "shangjialb.asp"

case "addok" 
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from FOX_category",conn,1,3
rs.AddNew
rs("category")=trim(request.form("category"))
rs("intro")=trim(request.form("intro"))
rs("icon")=trim(request.form("icon"))
rs("meta")=trim(request.form("meta"))
rs("categoryorder")=int(request.form("categoryorder"))
rs("ParentID")=int(request.form("CID"))
rs("first")=int(request.form("first"))
rs("hide")=int(request.form("hide"))
rs.Update
rs.Close
set rs=nothing
response.Redirect "shangjialb.asp"

case "editok" 
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from FOX_category where categoryid = "&categoryid,conn,1,3
rs("category")=trim(request.form("category"))
rs("intro")=trim(request.form("intro"))
rs("icon")=trim(request.form("icon"))
rs("meta")=trim(request.form("meta"))
rs("categoryorder")=int(request.form("categoryorder"))
rs("ParentID")=int(request.form("CID"))
rs("first")=int(request.form("first"))
rs("hide")=int(request.form("hide"))
rs.Update
rs.Close
set rs=nothing
response.Redirect "shangjialb.asp"

case "delok"
set rs=server.CreateObject("adodb.recordset")
rs.open "select ParentID from FOX_category where ParentID="&categoryid,conn,1,1
If Not rs.eof then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('该分类有子分类，请先删除该分类的所有子分类！');history.go(-1);</script>"
response.End
else
conn.execute ("delete from FOX_category where categoryid="&categoryid)
conn.execute ("delete from FOX_xiao where categoryid="&categoryid)
response.Redirect "shangjialb.asp"
end if

end select
%></body></html>