<!--#include file="conn.asp"-->
<!--#include file="chkadmin.asp"-->
<!--#include file="inc/char.asp"-->
<%dim id,action
id=CInt(Trim(Request.QueryString("id")))
action=Trim(Request.QueryString("action"))

sub up()
	dim sql,rs,ParentID,Sequence
	sql="select ParentID,Sequence from Class where ID="&id
	set rs=conn.execute(sql)
	ParentID=rs(0)
	Sequence=rs(1)
	if Sequence>1 then
		conn.execute("update Class set Sequence=Sequence+1 where ParentID="&ParentID&" and Sequence="&(Sequence-1))
		conn.execute("update Class set Sequence=Sequence-1 where ID="&id)
	end if
	set rs=nothing
	response.Redirect(request.ServerVariables("HTTP_REFERER"))
end sub

sub down()
	dim sql,rs,ParentID,Sequence
	sql="select ParentID,Sequence from Class where ID="&id
	set rs=conn.execute(sql)
	ParentID=rs(0)
	Sequence=rs(1)
	sql="select Max(Sequence) as MaxSequ from Class where ParentID="&ParentID
	set rs=conn.execute(sql)
	if Sequence<>rs("MaxSequ") then
		conn.execute("update Class set Sequence=Sequence-1 where ParentID="&ParentID&" and Sequence="&(Sequence+1))
		conn.execute("update Class set Sequence=Sequence+1 where ID="&id)
	end if
	set rs=nothing
	response.Redirect(request.ServerVariables("HTTP_REFERER"))
end sub

dim errmsg,founderr
founderr=false

if chkadmin=false or power(5)="0" then
	founderr=true
	errmsg=errmsg+"<li>您没有移动分类的权限</li>"
end if

if founderr=false then
	select case action
		case "up" call up()
		case "down" call down()
	end select
else
	call error()
end if

conn.close
set conn=nothing
%>