<!--#include file="Config.asp" -->
<!--#include file="Conn.asp" -->
<!--#include file="chkuser.asp" -->
<HTML><HEAD><TITLE>小类管理 </TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<link rel="stylesheet" href="admin.css" type="text/css">
<SCRIPT LANGUAGE=javascript>
<!--
function SelectAll() {
	for (var i=0;i<document.selform.newsID.length;i++) {
		var e=document.selform.newsID[i];
		e.checked=!e.checked;
	}
}
//-->
</script>
</HEAD>
<BODY  leftMargin=0>
<%
set Rs0=server.createobject("adodb.recordset")
rs0.open "select * from dv_user where username='"&UserName&"'",conn,1,1
if not(rs0.bof and rs0.eof) then
bigclass_quanxian=rs0("bigclass_quanxian")
smallclass_quanxian=rs0("smallclass_quanxian")
end if
rs0.close
set rs0=nothing

 dim sql,rs,subrs

  select case request("action")
  case "list" 
       call newslist()
	   case "del" 
       call newsdel()
	   case "set" 
       call sets()
  case else
       isEdit=False
       call myform(isEdit) 
  end select 
  sub sets() 
   set rs=server.createobject("adodb.recordset") 
   sql="select * from news where newsID="&request("newsid")&""
   rs.open sql,conn,1,3
   if not rs.eof then
   if rs("today")=1 then
   rs("today")=0
   else
   rs("today")=1
   end if
   rs.update
   end if
   rs.close
   set rs=nothing
   response.Write "<script language=javascript>alert('设置成功！');</script>"
response.write "<meta http-equiv=""refresh"" content=""0;url=news_list.asp?action=list&bigclassid="&request.QueryString("bigclassid")&"&smallclassid="&request.QueryString("smallclassid")&""">"
response.end
   end sub 
  sub newsdel()
        msgtitle="删除文章"
        conn.execute("delete from news where newsID in ("&Request.Form("newsID")&")")
		msginfo="删除操作成功，该相关信息已全部删除，<a href=""news_list.asp"">点此返回文章管理页面</a>！" 
        call Sysmsg(msgtitle,msginfo) 
  end sub
  %>
  <% sub newslist() %>
   <form name="selform" method="post" action="news_list.asp" >
   <table width="95%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableBorder">
 <th colspan="6">详细文章列表</th>
          <tr>             
            <td class="forumRowHighlight" height="25" align="center" width="70%">标 题</td><td class="forumRowHighlight" height="25" align="center" width="15%">添加人</td><td class="forumRowHighlight" height="25" align="center" width="15%">添加日期</td>
          </tr>
          <% 
		  	PageShowSize = 10            '每页显示多少个页
	MyPageSize   = 12          '每页显示多少条文章
		
	If Not IsNumeric(Request("page")) Or IsEmpty(Request("page")) Or Request("page") <=0 Then
	MyPage=1
	Else
	MyPage=Int(Abs(Request("page")))
	End if
	
	
		  bigclassid=request("bigclassid")
		  smallclassid=request("smallclassid")
		  set Rs=server.createobject("adodb.recordset")
		  if bigclassid<>"" then
		  '大类开始
		    Mypos = Instr(bigclass_quanxian,bigclassID)
		    if Mypos > 0 then
			if request.Cookies("KEY")="super" then
		    rs.open "select * from news where bigclassid="&bigclassid&" order by NewsID desc",conn,1,1
			else
			rs.open "select * from news where bigclassid="&bigclassid&" and depid="&request.Cookies("depid")&" order by NewsID desc",conn,1,1
			end if
		    else
			response.Write "<script language=javascript>alert('请不要越权使用！');window.close();</script>"
            response.end
			end if
			 if rs.eof and rs.bof then %>
           <tr><td class="forumRowHighlight" height="18" colspan="5" > 本类暂时无相关内容！</td></tr>
         <% 
		 else
			 rs.PageSize     = MyPageSize
	MaxPages         = rs.PageCount
	rs.absolutepage = MyPage
	total            = rs.RecordCount

for i=1 to rs.PageSize
if not rs.EOF then
			  smallclassID2= Rs("smallclassID")
			  Mypos1 = Instr(smallclass_quanxian,smallclassID2)
		    if IsNull(smallclassID2) or  Mypos1 > 0 then
			  %>
          <tr>             
            <td class="forumRowHighlight" height="18" ><input type="checkbox" name="newsID" value="<%=Rs("newsID")%>">
			<% 
		  set Rsb=server.createobject("adodb.recordset")
		 rsb.open "select * from bigclass where bigclassid ="&rs("bigclassid")&" ",conn,1,1
	          if not(rsb.bof and rsb.eof) then
			   %>
			   [<a href="news_list.asp?bigclassID=<%=Rs("bigclassID")%>&action=list"><%=rsb("bigclassname")%></a>]
			   <%
			   end if
			   rsb.close
			   set rsb=nothing
			   if not IsNull(smallclassID2) then
			   set Rsb=server.createobject("adodb.recordset")
		         rsb.open "select * from smallclass where smallclassid ="&rs("smallclassid")&"",conn,1,1
	          if not(rsb.bof and rsb.eof) then
			   %>
			   [<a href="news_list.asp?smallclassID=<%=Rs("smallclassID")%>&action=list"><%=rsb("smallclassname")%></a>]
			   <%
			   end if
			   rsb.close
			   set rsb=nothing
			   end if
			   %>
			   
			<a href="news_edit.asp?newsid=<%=Rs("newsID")%>"><%=rs("title")%></a></td><td class="forumRowHighlight" height="25" align="center"><%=rs("editor")%></td><td class="forumRowHighlight" height="25"><%=rs("UpdateTime")%>&nbsp;&nbsp;<%if bigclassid=31 then%><a href="news_list.asp?newsid=<%=Rs("newsID")%>&action=set&smallclassid=<%=smallclassid%>&bigclassid=<%=bigclassid%>"><%if rs("today")=1 then%><font color="#CC0000">取消今日菜品</font><%else%>设为今日菜品<%end if%><%end if%></a></td>
          </tr>
          <%end if
		   rs.movenext
		   end if
	        next
		   end if
		   %>
		   <tr><td colspan="5"  class="forumRowHighlight" height="18" align="center" >
		   共 <%=total%> 条，当前第 <%=Mypage%>/<%=Maxpages%> 
            页，每页 <%=MyPageSize%> 条 
            <%
            url="news_list.asp?bigclassid=" & bigclassid & "&action=list&"

							
PageNextSize=int((MyPage-1)/PageShowSize)+1
Pagetpage=int((total-1)/rs.PageSize)+1

if PageNextSize >1 then
PagePrev=PageShowSize*(PageNextSize-1)
Response.write "<a class=black href='" & Url & "page=" & PagePrev & "' title='上" & PageShowSize & "页'>上一翻页</a> "
Response.write "<a class=black href='" & Url & "page=1' title='第1页'>页首</a> "
end if
if MyPage-1 > 0 then
Prev_Page = MyPage - 1
Response.write "<a class=black href='" & Url & "page=" & Prev_Page & "' title='第" & Prev_Page & "页'>上一页</a> "
end if

if Maxpages>=PageNextSize*PageShowSize then
PageSizeShow = PageShowSize
Else
PageSizeShow = Maxpages-PageShowSize*(PageNextSize-1)
End if
If PageSizeShow < 1 Then PageSizeShow = 1
for PageCounterSize=1 to PageSizeShow
PageLink = (PageCounterSize+PageNextSize*PageShowSize)-PageShowSize
if PageLink <> MyPage Then
Response.write "<a class=black href='" & Url & "page=" & PageLink & "'>[" & PageLink & "]</a> "
else
Response.Write "<B>["& PageLink &"]</B> "
end if
If PageLink = MaxPages Then Exit for
Next

if Mypage+1 <=Pagetpage  then
Next_Page = MyPage + 1
Response.write "<a class=black href='" & Url & "page=" & Next_Page & "' title='第" & Next_Page & "页'>下一页</A>"
end if

if MaxPages > PageShowSize*PageNextSize then
PageNext = PageShowSize * PageNextSize + 1
Response.write " <A class=black href='" & Url & "page=" & Pagetpage & "' title='第"& Pagetpage &"页'>页尾</A>"
Response.write " <a class=black href='" & Url & "page=" & PageNext & "' title='下" & PageShowSize & "页'>下一翻页</a>"
End if
%></td></tr>
		   <%
		   '大类结束
		  end if
		 '小类开始
		 if smallclassid<>"" then
		    Mypos1 = Instr(smallclass_quanxian,smallclassID)
		    if Mypos1 > 0 then
		    rs.open "select * from news where smallclassid="&smallclassid&" order by NewsID desc",conn,1,1
			else
			response.Write "<script language=javascript>alert('请不要越权使用！');window.close();</script>"
            response.end
			end if
		 
	           if rs.eof and rs.bof then %>
           <tr><td class="forumRowHighlight" height="18" colspan="5" > 本类暂时无相关内容！</td></tr>
         <% 
		 else
			 rs.PageSize     = MyPageSize
	MaxPages         = rs.PageCount
	rs.absolutepage = MyPage
	total            = rs.RecordCount

for i=1 to rs.PageSize
if not rs.EOF then
%>
          <tr>             
            <td class="forumRowHighlight" height="18" ><input type="checkbox" name="newsID" value="<%=Rs("newsID")%>">
			<% 
		  set Rsb=server.createobject("adodb.recordset")
		 rsb.open "select * from bigclass where bigclassid ="&rs("bigclassid")&"",conn,1,1
	          if not(rsb.bof and rsb.eof) then
			   %>
			   [<a href="news_list.asp?bigclassID=<%=Rs("bigclassID")%>&action=list"><%=rsb("bigclassname")%></a>]
			   <%
			   end if
			   rsb.close
			   set rsb=nothing
			   set Rsb=server.createobject("adodb.recordset")
		         rsb.open "select * from smallclass where smallclassid ="&rs("smallclassid")&"",conn,1,1
	          if not(rsb.bof and rsb.eof) then
			   %>
			   [<a href="news_list.asp?smallclassID=<%=Rs("smallclassID")%>&action=list"><%=rsb("smallclassname")%></a>]
			   <%
			   end if
			   rsb.close
			   set rsb=nothing
			   %>
			<a href="news_edit.asp?newsid=<%=Rs("newsID")%>"><%=rs("title")%></a></td><td class="forumRowHighlight" height="25"><%=rs("editor")%></td><td class="forumRowHighlight" height="25" align="center"><%=rs("UpdateTime")%>&nbsp;&nbsp;<%if rs("bigclassid")=31 then%><a href="news_list.asp?newsid=<%=Rs("newsID")%>&action=set&smallclassid=<%=smallclassid%>&bigclassid=<%=bigclassid%>"><%if rs("today")=1 then%><font color="#CC0000">取消今日菜品</font><%else%>设为今日菜品<%end if%><%end if%></a></td>
          </tr>
          <% rs.movenext
	        end if
			next
			
			end if
			 %>
		   
		   <tr><td colspan="5"  class="forumRowHighlight" height="18"  align="center">
		   共 <%=total%> 条，当前第 <%=Mypage%>/<%=Maxpages%> 
            页，每页 <%=MyPageSize%> 条 
            <%
            url="news_list.asp?smallclassid=" & smallclassid & "&action=list&"

							
PageNextSize=int((MyPage-1)/PageShowSize)+1
Pagetpage=int((total-1)/rs.PageSize)+1

if PageNextSize >1 then
PagePrev=PageShowSize*(PageNextSize-1)
Response.write "<a class=black href='" & Url & "page=" & PagePrev & "' title='上" & PageShowSize & "页'>上一翻页</a> "
Response.write "<a class=black href='" & Url & "page=1' title='第1页'>页首</a> "
end if
if MyPage-1 > 0 then
Prev_Page = MyPage - 1
Response.write "<a class=black href='" & Url & "page=" & Prev_Page & "' title='第" & Prev_Page & "页'>上一页</a> "
end if

if Maxpages>=PageNextSize*PageShowSize then
PageSizeShow = PageShowSize
Else
PageSizeShow = Maxpages-PageShowSize*(PageNextSize-1)
End if
If PageSizeShow < 1 Then PageSizeShow = 1
for PageCounterSize=1 to PageSizeShow
PageLink = (PageCounterSize+PageNextSize*PageShowSize)-PageShowSize
if PageLink <> MyPage Then
Response.write "<a class=black href='" & Url & "page=" & PageLink & "'>[" & PageLink & "]</a> "
else
Response.Write "<B>["& PageLink &"]</B> "
end if
If PageLink = MaxPages Then Exit for
Next

if Mypage+1 <=Pagetpage  then
Next_Page = MyPage + 1
Response.write "<a class=black href='" & Url & "page=" & Next_Page & "' title='第" & Next_Page & "页'>下一页</A>"
end if

if MaxPages > PageShowSize*PageNextSize then
PageNext = PageShowSize * PageNextSize + 1
Response.write " <A class=black href='" & Url & "page=" & Pagetpage & "' title='第"& Pagetpage &"页'>页尾</A>"
Response.write " <a class=black href='" & Url & "page=" & PageNext & "' title='下" & PageShowSize & "页'>下一翻页</a>"
End if
%></td></tr>
		   <%
		   end if'小类结束
		  
		 rs.close
		 set rs=nothing
	%>
	<td class="forumRow" colspan="6">管理操作：选择/反选 
        <input type="checkbox" name="checkbox" value="checkbox" onClick="javascript:SelectAll()"> 
              <input onClick="{if(confirm('确定要执行此项操作吗？')){this.document.selform.submit();return true;}return false;}" type=submit value=删除 name=action2> 
              <input type="Hidden" name="action" value='del'>
        <font color="#FF0000">此操作不可逆，请慎重！</font> 点击标题查看/修改</td>
          </tr>
        </form>
      </table>
   
   
  <%
  end sub
   sub myform(isEdit) %> 
<table width="95%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableBorder">
 <th>点击栏目名查看相关文章列表</th>
          <% 
		  if bigclass_quanxian <> "" then
		  set Rs=server.createobject("adodb.recordset")
		set SubRs=server.createobject("adodb.recordset")
		 rs.open "select * from bigclass where bigclassid in ("&bigclass_quanxian&") order by bigclassorder",conn,1,1
	          if not(rs.bof and rs.eof) then
			  do while not rs.eof %>
          <tr>             
      <td  bgcolor="#D4DEF9" height="25">&nbsp; <font color="#FF0000"><b><%=rs("bigclassorder")%>、</b></font><a href="news_list.asp?bigclassID=<%=Rs("bigclassID")%>&action=list"><b><%=rs("bigclassName")%></b></a> </td>
          </tr>
		  <%
		  if smallclass_quanxian<>"" then
		  %>
          <tr> 
            
      <td class="forumRow"  height="25"> 
        <% SubRs.open "select * from smallclass where smallclassid in ("&smallclass_quanxian&") and bigclassID="&Rs("bigclassID")&" order by smallclassorder asc",conn,1,1
        if err.number <> 0 then
	           response.write "数据库出错"
           else
	           if SubRs.bof and SubRs.eof then
		        response.write "&nbsp; 没有小类"
	           else
			   i=1
			 do while not SubRs.eof 			 
			 %> <%=SubRs("smallclassorder")%>、<a href="news_list.asp?smallclassID=<%=SubRs("smallclassID")%>&action=list" class="ArticleList"><%=SubRS("smallclassName")%></a> <% if (i mod 7)=0 then response.write "<br>"
			i=i+1
			SubRs.movenext
	               loop
	           end if
  end if
  SubRs.close
  %> </td>
          </tr>
          <%
		  end if
		   rs.movenext
	        loop
		   end if
		 rs.close
		 set subrs=nothing
		 set rs=nothing
		 else
	%>
	<tr>             
      <td  bgcolor="#D4DEF9" height="55" align="center">对不起您还没有任何栏目的管理权限！</td>
          </tr>
		  <%end if%>
      </table>
	  <% end sub 
		sub Sysmsg(msgtitle,msginfo)
		%> <br>
<table width="85%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableBorder" >
  <tr> 
    <th><%=msgtitle%></th>
  </tr>
  <tr> 
    <td class="forumRow"><%=msginfo%></td>
  </tr>
  <tr> 
    <td height="22" align="center" class="forumRowHighlight"><a href="javascript:history.go(-1)" >&lt;&lt; 
      返回上一页</a></td>
  </tr>
</table>
<br> <%end sub %>
 </BODY></HTML>
