<!--#include file="../include/DBConn.asp"-->
<!--#include file="BenbenInc/Functions.asp"-->
<%
Dim num,xmsg,rs,tempNUM
Call DBConnBegin()
num=request("num")
'#######################APC_添加一级分类#########################
if request("apc_l1")<>"" then
Set Rs = Server.CreateObject("ADODB.RecordSet")
  rs.open "select * from News_Sort",conn,1,3

  rs.addnew
    rs("Sname")=request("apc_l1")
	rs("Stype")=0
  rs.update
  rs.close
  set rs=nothing
  xmsg="<font color=red>添加分类 " & request("apc_l1") & " 成功！</font>"
end if

'#######################APC_添加二级分类#########################
if request("apc_level2")<>"" then
Set Rs = Server.CreateObject("ADODB.RecordSet")
  rs.open "select * from News_Sort",conn,1,3
  rs.addnew
    rs("Sname")=request("apc_level2")
	rs("Stype")=1
	rs("Spid")=request("apc_lparent")
  rs.update
  rs.close
  xmsg="<font color=red>添加二级分类 " & request("apc_level2") & " 成功！</font>"
  num=3
end if

'##################### 动作函数区 ###############################
if request("action")<>"" then
  if request("action")="editLM" then
	Set Rs = Server.CreateObject("ADODB.RecordSet")
     rs.open "select * from News_Sort where Sid="&int(request("apc_l44")),conn,1,3
     if not rs.eof then
        rs("Sname")=request("apc_l11")
        rs.update
     end if
     rs.close
     xmsg="<font color=red>修改分类 " & request("apc_l11") & " 成功！</font>"
     num=2
  end if
    if request("action")="editLM2" then
		Set Rs = Server.CreateObject("ADODB.RecordSet")
     rs.open "select * from News_Sort where Sid="&int(request("apc_l222")),conn,1,3
     if not rs.eof then
        rs("Sname")=request("apc_l111")
        rs.update
     end if
     rs.close
     xmsg="<font color=red>修改二级分类 " & request("apc_l111") & " 成功！</font>"
     num=4
  end if
  if request("action")="dLM" then
     conn.execute("delete from News_Sort where Spid="&int(request("lid"))&" or Sid="&int(request("lid")))
     xmsg="<font color=red>删除分类 " & request("delname") & " 成功！</font>"
     num=2
  end if
  if request("action")="dLM2" then
     conn.execute("delete from News_Sort where Sid="&int(request("lid")))
     xmsg="<font color=red>删除二级分类 " & request("delname") & " 成功！</font>"
     num=4
  end if
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>==栏目管理==</title>
<link href="BenbenInc/css.css" rel="stylesheet" type="text/css">
<link href="../stylecss/style.css" rel="stylesheet" type="text/css">
<script language=vbscript>
Function CheckForm(s)
	CheckForm=true
	A=""
	execute("A=document.xform."&s&".value")
	if A="" then CheckForm=false
	if CheckForm=false then
		Msgbox "请填写类别名称!",16,"提示"
	end if
End Function
</script>
<style type="text/css">
<!--
.style4 {color: #0066FF}
.style5 {color: #333333}
.style6 {color: #000000}
-->
</style>
</head>

<body leftmargin="0" topmargin="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="30" class="Title_bg">新闻栏目管理</td>
  </tr>
</table>
<table width="600" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#DAEFFF" style="margin-top:18px;">
    <tr> 
      <td width="486"><span class="style4"> <span class="t34 style5">4</span> <b>栏目管理菜单 </b></span></td>
    </tr>
    <tr align="center" bordercolor="#f4f5f6"> 
      <td height="30" bordercolor="#f4f5f6" bgcolor="#FFFFFF"><span class="t34">4</span> <a href="?num=1">添加栏目分类</a> 
        <span class="t34">4</span> <a href="?num=2">管理栏目分类</a><span class="t34"> 
        4</span> <a href="?num=3">添加二级栏目</a> <span class="t34">4</span> <a href="?num=4">管理二级栏目</a></td>
    </tr>
</table>
<br>
<%
'*************************************************************************************
select case num
case 1
%>
<table width="600" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#DAEFFF">
  <form method=post name=xform  onsubmit="javascript:return CheckForm('apc_l1');">
  <tr> 
      <td colspan="2"><span class="style4"> <span class="t34 style5">4</span> <b>添加栏目分类 </b></span>
		<% if xmsg<>"" then response.write xmsg %>		
		</font></td>
  </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="60" height="30"><NOBR>分类名称： </td>
      <td width="426"> 
        <input name="apc_l1" type="text" id="apc_l1" size="25">
      <font color="#FF0000">*</font><font color="#999999">最长为五十个字符.</font></td>
  </tr>
    <tr align="center" bgcolor="#FFFFFF"> 
      <td height="40" colspan="2"> 
        <input name="Submit" type="submit" class="sub_Add" value="添加">
      　
      <input name="Submit2" type="reset" class="sub_Add" value="重置"></td>
  </tr></form>
</table>
<% case 2 
Set Rs = Server.CreateObject("ADODB.RecordSet")
rs.open "select * from News_Sort where Stype=0 and Stid=0 order by Sid asc",conn,1,1
%>
<table width="600" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#DAEFFF">
  <tr> 
    <td colspan="2"><span class="style4"> <span class="t34 style5">4</span> <b>管理栏目分类 </b></span>
      <% if xmsg<>"" then response.write xmsg %>
    </font></td>
  </tr>
  <tr bgcolor="#F4F5F6"> 
    <td width="367" height="19" bgcolor="#F4F5F6"><font color="#FFFFFF"><NOBR></font><span class="t34 style5">4</span><span class="style5"> 
      分类名称</span></td>
    <td width="119" align="center"><span class="style6"> 操作</span></td>
  </tr>
  <%
if rs.eof then
%>
  <tr bgcolor="#FFFFFF"> 
    <td height="25" colspan="2">没有数据！</td>
  </tr>
  <% else 
n=1
do while not rs.eof
%>
  <tr bgcolor="#FFFFFF"> 
    <td height="25"><%=rs("Sid")%>.<%=rs("Sname")%>    </td>
    <td align="center"><a href="#####" onClick="vbscript:xgxg '<%=rs("Sid")%>','<%=rs("Sname")%>'">修改</a> <a href="?action=dLM&lid=<%=rs("Sid")%>&delname=<%=rs("Sname")%>">删除</a></td>
  </tr>
  <%
rs.movenext
loop
end if %>
</table>
<script language=vbscript>
function xgxg(lid,lname)
document.xform.apc_l11.value=lname
document.xform.apc_l44.value=lid
end function
</script>
<br>
<table width="600" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#DAEFFF">
  <form method=post name=xform id=xform onSubmit="javascript:return CheckForm('apc_l11');">
    <tr> 
      <td colspan="2"><span class="style4"> <span class="t34 style5">4</span> <b>修改栏目分类 </b></span></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="60" height="30"><NOBR>分类名称： </td>
      <td width="426"> <input name="apc_l11" type="text" id="apc_l11" size="25"><input name="apc_l44" type="hidden" id="apc_l44" size="25"><input name="action" type="hidden" id="action" size="25" value="editLM"> <font color="#FF0000">*</font><font color="#999999">最长为五十个字符.</font></td>
    </tr>
    <tr align="center" bgcolor="#FFFFFF"> 
      <td height="40" colspan="2"> <input name="Submit42" type="submit" class="sub_Add" value="修改"> 
      　
        <input name="Submit232" type="reset" class="sub_Add" value="重置"></td>
    </tr>
  </form>
</table>
<% case 3 %>
<table width="600" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#DAEFFF">
  <form method=post name=xform onSubmit="javascript:return CheckForm('apc_level2');">
    <tr> 
      <td colspan="2"><span class="style4"> <span class="t34 style5">4</span> <b>添加二级栏目 </b> 
      <% if xmsg<>"" then response.write xmsg %></span>      </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="60"><NOBR>二级名称： </td>
      <td width="426"> <input name="apc_level2" type="text" id="apc_level2" size="25">
        <font color="#FF0000">*</font><font color="#999999">最长为五十个字符. 
        <select name="apc_lparent" id="apc_lparent">
<%
Set Rs = Server.CreateObject("ADODB.RecordSet")
rs.open "select * from News_Sort where Stype=0 and sTid=0 order by Sid asc",conn,1,1
if not rs.eof then
  n=1
  do while not rs.eof 
%>
<option value="<%=rs("Sid")%>" <%if n=1 then response.write "selected"%>><%=rs("Sname")%></option>
<%n=n+1
  rs.movenext
  loop
end if
%>

        </select>
      </font></td>
    </tr>
    <tr align="center" bgcolor="#FFFFFF"> 
      <td height="40" colspan="2"> <input name="Submit4" type="submit" class="sub_Add" value="添加"> 
      　
        <input name="Submit23" type="reset" class="sub_Add" value="重置"></td>
    </tr>
  </form>
</table>
<% case 4 %>
<table width="600" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#DAEFFF">
  <tr> 
    <td colspan="2"><span class="style4"> <span class="t34 style5">4</span> <b>管理二级栏目 </b>
    <% if xmsg<>"" then response.write xmsg %></span></td>
  </tr>
  <tr bgcolor="#F4F5F6"> 
    <td width="367" height="19" bgcolor="#F4F5F6"><font color="#FFFFFF"><NOBR></font><span class="t34 style6">4</span><span class="style6"> 
      分类名称 </span><font color="#999999">
      <script language=javascript>
function go4(){
window.location.href="?num=4&tempNum="+document.getElementById("apc_level2_edit").value;
}
      </script>
      <select name="apc_level2_edit" id="apc_level2_edit" onChange="javascript:go4()">
        <option value="">--选择栏目--</option>
        <%
tempNUM=0
Set Rs = Server.CreateObject("ADODB.RecordSet")
rs.open "select * from News_Sort where Stype=0 and Stid=0 order by Sid asc",conn,1,1
if not rs.eof then
  n=1
  do while not rs.eof 
  if request("tempNUM")<>"" then
%>
        <option value="<%=rs("Sid")%>" <%if rs("Sid")=cint(trim(request.QueryString("tempNUM"))) then response.Write " selected"%>><%=rs("Sname")%></option>
<%
else
%>
<option value="<%=rs("Sid")%>"><%=rs("Sname")%></option>
<%
end if
if n=1 then tempNUM=rs("Sid")
  rs.movenext
  n=n+1
  loop
end if
rs.close
%>
      </select>
      </font></td>
    <td width="119" align="center"><span class="style6"> 操作</span></td>
  </tr>
  <%
if request("tempNUM")<>"" then tempNUM=request("tempNUM")
rs.open "select * from News_Sort where Stype=1 and Spid="&tempNUM&" order by Sid asc",conn,1,1
if rs.eof then
%>
  <tr bgcolor="#FFFFFF"> 
    <td height="25" colspan="2">没有数据！</td>
  </tr>
  <% else 
n=1
do while not rs.eof
%>
  <tr bgcolor="#FFFFFF"> 
    <td height="25"><%=rs("Sid")%>.<%=rs("Sname")%></td>
    <td align="center"><a href="#####" onClick="vbscript:xgxg '<%=rs("Sid")%>','<%=rs("Sname")%>'">修改</a> 
      <a href="?action=dLM2&lid=<%=rs("Sid")%>&delname=<%=rs("Sname")%>">删除</a></td>
  </tr>
  <%
rs.movenext
loop
end if %>
</table>
<script language=vbscript>
function xgxg(lid,lname)
document.xform.apc_l111.value=lname
document.xform.apc_l222.value=lid
end function
</script>
<br>
<table width="600" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#DAEFFF">
  <form method=post name=xform id=xform onSubmit="javascript:return CheckForm('apc_l111');">
    <tr> 
      <td colspan="2"><span class="style4"> <span class="t34 style5">4</span> <b>修改栏目分类 </b></span></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="60"><NOBR>分类名称： </td>
      <td width="426"> <input name="apc_l111" type="text" id="apc_l111" size="25"> 
        <input name="apc_l222" type="hidden" id="apc_l222" size="25"> <input name="action" type="hidden" id="action" size="25" value="editLM2"> 
      <font color="#FF0000">*</font><font color="#999999">最长为五十个字符.</font></td>
    </tr>
    <tr align="center" bgcolor="#FFFFFF"> 
      <td height="40" colspan="2"> <input name="Submit422" type="submit" class="sub_Add" value="修改"> 
      　
        <input name="Submit2322" type="reset" class="sub_Add" value="重置"></td>
    </tr>
  </form>
</table>
<%
case else %>
<table width="600" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#DAEFFF">
  <form method=post name=xform onSubmit="javascript:return CheckForm('apc_l1');">
  <tr> 
      <td colspan="2"><span class="style4"> <span class="t34 style5">4</span> <b>添加栏目分类 </b></span>
	  <% if xmsg<>"" then response.write xmsg %></td>
  </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="60"><NOBR>分类名称： </td>
      <td width="426"> 
        <input name="apc_l1" type="text" id="apc_l1" size="25">
      <font color="#FF0000">*</font><font color="#999999">最长为五十个字符.</font></td>
  </tr>
    <tr align="center" bgcolor="#FFFFFF"> 
      <td height="40" colspan="2"> 
        <input name="Submit" type="submit" class="sub_Add" value="添加">
      　
      <input name="Submit2" type="reset" class="sub_Add" value="重置"></td>
  </tr></form>
</table>
<%
end select
%>
<script language=vbscript>
//document.all.text(0).focus()
</script>
</body>
</html>
