<!--#include file="system_manage.asp"-->
<%

   Call DBConnBegin()
   Set rs = server.createobject("adodb.recordset")

 sql="select * from tx_catasort where id="&request("postid")
 set rs=conn.execute(sql)
	 if not rs.eof and not rs.bof then
	 aid=rs("aid")
	 level=rs("level")
	 code=rs("code")
	 lencode=len(code)
	 txstr=String(lencode,"-")
	 end if
	 rs.close
	 if request("action")="up"  then
	 '获取up的分类
	 sql="select top 1 code from tx_catasort where aid="&aid&" and len(code)="&lencode&" and code<'"&code&"' and left(code,"&lencode-4&")='"&Left(code,lencode-4)&"' order by code desc"
	 else
	 '获取down的分类
	  sql="select top 1 code from tx_catasort where aid="&aid&" and len(code)="&lencode&" and code>'"&code&"' and left(code,"&lencode-4&")='"&Left(code,lencode-4)&"' order by code"
      end if
	set rs=conn.execute(sql)
	if rs.bof and rs.eof then
	  Call tx_common.message("·无法移动,不是同一级别分类或者已经到了尽头<br>·如果你的浏览器不支持跳转，<a href='admin_catasort.asp'>点击这里返回</a><meta http-equiv=refresh content='3;URL=admin_catasort.asp'>",1) 
	else
	tempstr=rs(0)
	end if
	 SQL="update tx_catasort set code='"&txStr&"'+mid(code,"&lencode+1&",len(code)) where left(code,"&lencode&")='"&TempStr&"'"
		Conn.Execute(SQL)
			SQL="update tx_catasort set code='"&TempStr&"'+mid(code,"&lencode+1&",len(code)) where left(code,"&lencode&")='"&code&"'"
		Conn.Execute(SQL)
			SQL="update tx_catasort set code='"&code&"'+mid(code,"&lencode+1&",len(code)) where left(code,"&lencode&")='"&txStr&"'"
		Conn.Execute(SQL) 
		Call ClassEnd()
Call DBConnEnd()
		response.Redirect("admin_catasort.asp")

%>