%
'检查用户权限
call checkuser(",")
%>
<%
'通用分类管理模板
'参数说明:TableName--分类表,WindowName--分类管理的窗口名称,ClassLevel--分类允许的最大的层次,LinkSymbol--间隔字符
Dim TableName,WindowName,ClassLevel,LinkSymbol
TableName="class" '所要操作的分类表
WindowName="九天后台" '分类管理的名称
ClassLevel=1 '分类的最大级数,1表示只有一层
LinkSymbol=" >" '显示分类层次时所用的连接字符
if GetQueryString("TableName")<>"" then
TableName=GetQueryString("TableName")
end if
if GetQueryString("WindowName")<>"" then
WindowName=GetQueryString("WindowName")
end if
if GetQueryString("ClassLevel")<>"" then
ClassLevel=Cint(GetQueryString("ClassLevel"))
end if
if GetQueryString("LinkSymbol")<>"" then
LinkSymbol=GetQueryString("LinkSymbol")
end if
strQueryString="&mnid=" & GetQueryString("mnid") & "&TableName=" & TableName & "&ClassLevel=" & ClassLevel & "&WindowName=" & WindowName
%>
<%
if GetVariable("action")="dele" then
strIDs=GetVariable("id")
Sql="select count(id) from " & TableName & " where c_code like (select c_code from " & TableName & " where id="&strIDs&")+'_%' and id<>"&strIDs
Under=conn.execute(sql)(0)
If Under>0 Then
response.Redirect("../Error.asp?msg=对不起,栏目尚有下属版块!")
else
strSQL="Delete From " & TableName & " Where id in(" & strIDs & ",0)"
conn.execute strSQL
end if
end if
%>
<%
if GetVariable("action")="up" or GetVariable("action")="down" then
On Error Resume Next
if GetVariable("action")="up" then
IsUp=1
else
IsUp=0
end if
ColumnCode=GetVariable("colcode")
CodeLen=Len(ColumnCode)
NBStr=String(CodeLen,"-")
If ColumnCode<>"" And (Len(ColumnCode) Mod 4)=0 Then
If CodeLen>4 Then WStr="and left(c_code,"&CodeLen-4&")='"&Left(ColumnCode,CodeLen-4)&"'"
If IsUp Then
SQL="select top 1 c_code from " & TableName & " where len(c_code)="&CodeLen&" and c_code<'"&ColumnCode&"' "&WStr& " And mn_id=" & GetQueryString("mnid")&" order by c_code desc"
'Response.Write sql&" "
TempStr=conn.execute(sql)(0)
Else
SQL="select top 1 c_code from " & TableName & " where len(c_code)="&CodeLen&" and c_code>'"&ColumnCode&"' "&WStr& " And mn_id=" & GetQueryString("mnid")&" order by c_code"
'Response.Write sql&" "
TempStr=conn.execute(sql)(0)
End If
If TempStr<>"" And (Len(TempStr) Mod 4)=0 Then
'移动上层栏目
SQL="update " & TableName & " set c_code='"&NBStr&"'+MID(c_code,"&CodeLen+1&",len(c_code)) where left(c_code,"&CodeLen&")='"&TempStr&"'"
'Response.Write sql&" "
conn.execute(sql)
'更新目标栏目
SQL="update " & TableName & " set c_code='"&TempStr&"'+MID(c_code,"&CodeLen+1&",len(c_code)) where left(c_code,"&CodeLen&")='"&ColumnCode&"'"
'Response.Write sql&" "
conn.execute(sql)
'更新上层栏目
SQL="update " & TableName & " set c_code='"&ColumnCode&"'+MID(c_code,"&CodeLen+1&",len(c_code)) where left(c_code,"&CodeLen&")='"&NBStr&"'"
'Response.Write sql&" "
conn.execute(sql)
End If
End If
end if
%>
<%
strParent=GetQueryString("parent") '当然层父类ID号
if strParent="" then strParent="0"
strLocation=""
p_Parent=strParent '父类ID,用这个变量用到控制循环
intLevel=1
strUPID="0"
Do while p_Parent<>"0"
strSQL="Select * From " & TableName & " Where id=" & p_Parent & " And mn_id=" & GetQueryString("mnid") '这里要判断是哪个栏目的分类,对应menu表中的ID字段
set rsSub=Server.CreateObject("ADODB.RecordSet")
rsSub.open strSQL,conn,1,1
strClassName=trim(rsSub("c_name"))
if intLevel>1 then
strLocation=LinkSymbol & "" & strClassName & "" & strLocation
else
strLocation=LinkSymbol & strClassName & strLocation
strUPID=p_Parent
end if
p_Parent=trim(rsSub("c_parent"))
if intLevel=1 then strUPID=p_Parent '记录返回上层的Parent
intLevel=intLevel+1
loop
strLocation="所有分类" & strLocation
if strParent="0" then
'如果是最高层,则没有上层了
strGoUp="style='display:none'"
end if
%>
<%=WindowName%>--分类管理
<%
'从这开始读数据
strSQL="Select * From " & TableName & " Where c_parent=" & strParent & " And mn_id=" & GetQueryString("mnid") & " Order By c_code"
rs.open strSQL,conn,1,1
'response.Write(strsql&" ")
'分页显示初始化
page=GetVariable("page")
if page="" then
page=1
else
page=Cint(page)
end if
Section=GetVariable("section")
if Section="" then
Section=1
else
Section=Cint(Section)
end if
'变量赋值
intPageSize=10 '每页显示记录数
intSectionSize=5 '多少页为一段,像GOOGLE一样
PrevSectionText="7" '上一段的链接文字
NextSectionText="8" '下一段的链接文字
PrevPageText="3" '上页的链接文字
NextPageText="4" '下页的链接文字
strPageUrl="?t=" & strQueryString
rs.pagesize=intPageSize
intCount=rs.RecordCount
intPageCount=rs.pagecount
intSectionCount=(intPageCount - 1) \ intSectionSize + 1
if intCount>0 then
rs.AbsolutePage=page
end if
%>
共有<%=intCount%>记录,分<%=intPageCount%>页,当前页<%=Page%>,每页显示<%=intPageSize%>条记录
<%
'计算每一段的开始页
intStarPage=(Section-2) * intSectionSize + 1
'前一段
if Section<=1 then
response.Write(PrevSectionText & " ")
else
response.Write("" & PrevSectionText & " ")
end if
'显示页码列表
response.Write("第")
intStarPage=(Section-1) * intSectionSize + 1
for p=intStarPage to intStarPage + intSectionSize - 1
if p > intPageCount then exit for
if p=page then
response.Write("[" & p & "] ")
else
response.Write("[" & p & "] ")
end if
next
response.Write("页")
'后一段
intStarPage=(Section) * intSectionSize + 1
if Section>=intSectionCount then
response.Write(" " & NextSectionText)
else
response.Write(" " & NextSectionText & " ")
end if
%>