<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../Conn/conn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link rel="stylesheet" href="../css/indexTwo.css" type="text/css">
<title>网站后台</title>
</head>
<body>
<table width="100%" border="0" cellspacing="1" class="Navi2">
  <tr>
    <th>设置信息类别列表的默认状态</th>
  </tr>
</table>
<%
if request.Form("submit1")="提交设置项" then
	SetSortID=request.Form("SetSortID")
	conn.execute("update TbNewsSort set setmode=0")
	if SetSortID<>"" then
		conn.execute("update TbNewsSort set setmode=1 where id in ("&SetSortID&")")
		response.write "<script> alert('修改成功');window.document.location.href='?';   </script>"
		response.End()	
	end if
end if
if request.Form("submit2")="提交添加项" then
	AddSortID=request.Form("AddSortID")
	conn.execute("update TbNewsSort set addmode=0")
	if AddSortID<>"" then
		conn.execute("update TbNewsSort set addmode=1 where id in ("&AddSortID&")")
		response.write "<script> alert('修改成功');window.document.location.href='?';   </script>"
		response.End()	
	end if
end if
if request.Form("submit3")="提交修改项" then
	EditSortID=request.Form("EditSortID")
	conn.execute("update TbNewsSort set editmode=0")
	if EditSortID<>"" then
		conn.execute("update TbNewsSort set editmode=1 where id in ("&EditSortID&")")
		response.write "<script> alert('修改成功');window.document.location.href='?';   </script>"
		response.End()	
	end if
end if
if request.Form("submit4")="提交删除项" then
	DelSortID=request.Form("DelSortID")
	conn.execute("update TbNewsSort set delmode=0")
	if DelSortID<>"" then
		conn.execute("update TbNewsSort set delmode=1 where id in ("&DelSortID&")")
		response.write "<script> alert('修改成功');window.document.location.href='?';   </script>"
		response.End()	
	end if
end if

if request.Form("yessubmit1")="全选设置项" then
	conn.execute("update TbNewsSort set setmode=1")
	response.write "<script> alert('修改成功');window.document.location.href='?';   </script>"
	response.End()	
end if
if request.Form("yessubmit2")="全选添加项" then
	conn.execute("update TbNewsSort set addmode=1")
	response.write "<script> alert('修改成功');window.document.location.href='?';   </script>"
	response.End()	
end if
if request.Form("yessubmit3")="全选修改项" then
	conn.execute("update TbNewsSort set editmode=1")
	response.write "<script> alert('修改成功');window.document.location.href='?';   </script>"
	response.End()	
end if
if request.Form("yessubmit4")="全选删除项" then
	conn.execute("update TbNewsSort set delmode=1")
	response.write "<script> alert('修改成功');window.document.location.href='?';   </script>"
	response.End()
end if


if request.Form("nosubmit1")="全不选设置项" then
	conn.execute("update TbNewsSort set setmode=0")
	response.write "<script> alert('修改成功');window.document.location.href='?';   </script>"
	response.End()
end if
if request.Form("nosubmit2")="全不选添加项" then
	conn.execute("update TbNewsSort set addmode=0")
	response.write "<script> alert('修改成功');window.document.location.href='?';   </script>"
	response.End()
end if
if request.Form("nosubmit3")="全不选修改项" then
	conn.execute("update TbNewsSort set editmode=0")
	response.write "<script> alert('修改成功');window.document.location.href='?';   </script>"
	response.End()
end if
if request.Form("nosubmit4")="全不选删除项" then
	conn.execute("update TbNewsSort set delmode=0")
	response.write "<script> alert('修改成功');window.document.location.href='?';   </script>"
	response.End()
end if


if request.Form("rootsubmit")="提交根目录项" then
	if request.Form("rootadd")<>"" then
		conn.execute("update TbNewsSet set mode=1 where id=1")
		response.write "<script> alert('修改成功');window.document.location.href='?';   </script>"
		response.End()
	else
		conn.execute("update TbNewsSet set mode=0 where id=1")
		response.write "<script> alert('修改成功');window.document.location.href='?';   </script>"
		response.End()
	end if
end if

sql="select mode from TbNewsSet where id=1"
rs.open sql,conn,1,1
if not rs.eof then
	rootmode=rs("mode")
end if
rs.close
%>
<form name="form" method="post" action="?">
  <table width="100%" border="0" cellspacing="1" class="Navi2">
    <tr>
      <td>类别名称</td>
      <td style="text-align:center">操作</td>
    </tr>
    <tr onmouseout="style.backgroundColor=''" onMouseover="style.backgroundColor='#bfdfff'">
      <td><img src='../images/file1.gif'><font color="#FF0000">根目录</font></td>
      <td style="text-align:left;padding-left:8px;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr style="background:none;">
            <td style="width:25%;">&nbsp;</td>
            <td style="width:25%;"><input type="checkbox" name="rootadd" value="1" <%if rootmode=1 then:response.Write("checked"): end if%> />
              添加</td>
            <td style="width:25%;"><input type="submit" name="rootsubmit" value="提交根目录项" /></td>
            <td style="width:25%;">&nbsp;</td>
          </tr>
        </table></td>
    </tr>
    <%
sql="select * from TbNewsSort where pid=0 order by [order] asc"
rs.open sql,conn,1,1
if not rs.eof then
	do while not rs.eof 
		call sortShow(1,rs("name"),rs("id"),rs("setmode"),rs("addmode"),rs("editmode"),rs("delmode"))
		call Sort2(rs("id"))
		rs.movenext
	loop
end if
rs.close
%>
    <tr>
      <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" align="center"><input type="submit" name="submit1" value="提交设置项" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="submit" name="submit2" value="提交添加项" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="submit" name="submit3" value="提交修改项" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="submit" name="submit4" value="提交删除项" />
      </td>
    </tr>
    <tr>
      <td colspan="2" align="center"><input type="submit" name="yessubmit1" value="全选设置项" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="submit" name="yessubmit2" value="全选添加项" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="submit" name="yessubmit3" value="全选修改项" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="submit" name="yessubmit4" value="全选删除项" />
      </td>
    </tr>
    <tr>
      <td colspan="2" align="center"><input type="submit" name="nosubmit1" value="全不选设置项" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="submit" name="nosubmit2" value="全不选添加项" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="submit" name="nosubmit3" value="全不选修改项" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="submit" name="nosubmit4" value="全不选删除项" />
      </td>
    </tr>
    <tr>
      <td colspan="2">&nbsp;</td>
    </tr>
  </table>
</form>
<%
if request.Form("action")="SetModeRank" then
	modeRank=request.Form("modeRank")
	conn.execute("update TbNewsSet set mode="&modeRank&" where id=2")
	response.write "<script> alert('修改成功');window.document.location.href='?';   </script>"
	response.End()
end if
%>
<form name="form2" method="post" action="?">
  <input type="hidden" name="action" value="SetModeRank" />
  <table width="100%" border="0" cellspacing="1" class="Navi2">
    <tr>
      <th align="center" colspan="2">设置默认栏目级数</th>
    </tr>
    <tr>
      <td align="center" style="width:200px;"><%
	sql="select id,mode from TbNewsSet where id=2"
	rs.open sql,conn,1,1
	if not rs.eof then
		response.Write("<select name='modeRank'>")
		response.Write("	<option value='1'")
		if rs("mode")=1 then : response.Write(" selected ") : end if
		response.Write(" >===一级栏目===</option>")
		response.Write("	<option value='2' ")
		if rs("mode")=2 then : response.Write(" selected ") : end if
		response.Write(">===二级栏目===</option>")
		response.Write("	<option value='3' ")
		if rs("mode")=3 then : response.Write(" selected ") : end if
		response.Write(">===三级栏目===</option>")
		response.Write("	<option value='4'")
		if rs("mode")=4 then : response.Write(" selected ") : end if
		response.Write(" >===四级栏目===</option>")
		response.Write("	<option value='5'")
		if rs("mode")=5 then : response.Write(" selected ") : end if
		response.Write(" >===五级栏目===</option>")
		response.Write("</select>")
	end if
	rs.close
	%>
      </td>
      <td align="left" style="padding-left:8px;"><input type="submit" name="submitSetModeRank" value="提交" /></td>
    </tr>
    <tr>
      <td colspan="2">&nbsp;</td>
    </tr>
  </table>
</form>
</body>
</html>
<!--#include file="../Conn/conn_close.asp"-->
<%
sub sortShow(rank,SortName,SortID,SetMode,AddMode,EditMode1,DelMode)
	response.Write("<tr onmouseout=""style.backgroundColor=''"" onMouseover=""style.backgroundColor='#bfdfff'"">")
	response.Write("<td>")
	for i=1 to rank 
		response.Write("&nbsp;&nbsp;&nbsp;&nbsp;")
	next
	response.Write("<img src='../images/file1.gif'>")
	response.Write(SortName)
	response.Write("</td>")
	response.Write("<td style='text-align:left;padding-left:8px;'>")
	
	
	response.Write("<table width='100%' border='0' cellspacing='0' cellpadding='0'>")
	response.Write("  <tr style='background:none;'>")
	'设置
	response.Write("<td style='width:25%'>")
	call IsSetSort(SortID,SetMode)
	response.Write("</td>")
	'添加
	response.Write("<td style='width:25%'>")
	if rank<5 then
		response.Write("<input type='checkbox' name='AddSortID' value='"&SortID&"'")
		if clng(AddMode)=1 then
			response.Write(" checked ")
		end if
		response.Write(" />")
		
		response.Write("添加")
		response.Write("&nbsp;&nbsp;&nbsp;&nbsp;")
	end if
	response.Write("</td>")
	'修改
	response.Write("<td style='width:25%'>")
	response.Write("<input type='checkbox' name='EditSortID' value='"&SortID&"'")
		if clng(EditMode1)=1 then
			response.Write(" checked ")
		end if
		response.Write(" />")
	response.Write("修改")
	response.Write("</td>")
	'删除
	response.Write("<td style='width:25%'>")
	call IsDelSort(SortID,DelMode)
	response.Write("</td>")	
	response.Write("  </tr>")
	response.Write("</table>")

	response.Write("</td>")
	response.Write("</tr>")
end sub
sub Sort2(SortPid)
	sql2="select * from TbNewsSort where pid="&SortPid&" order by [order] asc"
	rs2.open sql2,conn,1,1
	if not rs2.eof then
		do while not rs2.eof
			call sortShow(2,rs2("name"),rs2("id"),rs2("setmode"),rs2("addmode"),rs2("editmode"),rs2("delmode"))
			call Sort3(rs2("id"))
			rs2.movenext
		loop
	end if
	rs2.close
end sub
sub Sort3(SortPid)
	set rs3=server.CreateObject("adodb.recordset")
	sql3="select * from TbNewsSort where pid="&SortPid&" order by [order] asc"
	rs3.open sql3,conn,1,1
	if not rs3.eof then
		do while not rs3.eof
			call sortShow(3,rs3("name"),rs3("id"),rs3("setmode"),rs3("addmode"),rs3("editmode"),rs3("delmode"))
			call Sort4(rs3("id"))
			rs3.movenext
		loop
	end if
	rs3.close
end sub
sub Sort4(SortPid)
	set rs4=server.CreateObject("adodb.recordset")
	sql4="select * from TbNewsSort where pid="&SortPid&" order by [order] asc"
	rs4.open sql4,conn,1,1
	if not rs4.eof then
		do while not rs4.eof
			call sortShow(4,rs4("name"),rs4("id"),rs4("setmode"),rs4("addmode"),rs4("editmode"),rs4("delmode"))
			call Sort5(rs4("id"))
			rs4.movenext
		loop
	end if
	rs4.close
end sub
sub Sort5(SortPid)
	set rs5=server.CreateObject("adodb.recordset")
	sql5="select * from TbNewsSort where pid="&SortPid&" order by [order] asc"
	rs5.open sql5,conn,1,1

	if not rs5.eof then
		do while not rs5.eof
			call sortShow(5,rs5("name"),rs5("id"),rs5("setmode"),rs5("addmode"),rs5("editmode"),rs5("delmode"))
			rs5.movenext
		loop
	end if
	rs5.close
end sub
sub IsSetSort(SortID,SetMode)
	set rsn=server.CreateObject("adodb.recordset")
	sqln="select top 1 * from TbNewsSort where pid="&SortID
	rsn.open sqln,conn,1,1
	if rsn.eof then
		response.Write("<input type='checkbox' name='SetSortID' value='"&SortID&"'")
		if clng(SetMode)=1 then
			response.Write(" checked ")
		end if
		response.Write(" />")
		response.Write("设置")
		response.Write("&nbsp;&nbsp;")
	end if
	rsn.close
end sub
sub IsDelSort(SortID,DelMode)
	set rsn=server.CreateObject("adodb.recordset")
	sqln="select top 1 * from TbNewsSort where pid="&SortID
	rsn.open sqln,conn,1,1
	if rsn.eof then
		response.Write("<input type='checkbox' name='DelSortID' value='"&SortID&"'")
		if clng(DelMode)=1 then
			response.Write(" checked ")
		end if
		response.Write(" />")
		response.Write("删除")
		response.Write("&nbsp;&nbsp;")
	end if
	rsn.close
end sub
%>
