<!--#include virtual="/common/lib/dbcon.asp"-->
<!--#include virtual="/common/lib/func.asp"-->
<%
Dim sql, a_num, ct_idx, ct_code, move, ct_ref, ok_url

a_num		= InputValue( request.queryString("a_num"))
ct_idx		= InputValue( request.queryString("ct_idx"))	'//--일련번호
ct_code		= InputValue( request.queryString("ct_code"))	'//--정렬번호
move		= InputValue( request.queryString("move"))		'//--이동
ct_ref		= InputValue( request.queryString("ct_ref"))



if move = "up" then
	sql = "select top 1 ct_idx, ct_code from board_code where a_num=" & a_num & " AND ct_code < " & ct_code & " AND ct_ref='" & ct_ref & "' order by ct_code desc"
elseif move = "down" then
	sql = "select top 1 ct_idx, ct_code from board_code where a_num=" & a_num & " AND ct_code > " & ct_code & " AND ct_ref='" & ct_ref & "' order by ct_code"
End if

Set rs = dbcon.execute( sql )

If Not( rs.bof Or rs.eof ) then

	v_rsct_idx  = rs("ct_idx")		'//-- 대체할 디비번호
	v_rsct_code = rs("ct_code")		'//-- 대체할 값
	sql1 = "update board_code set ct_code = " & ct_code & " where ct_idx = " & v_rsct_idx
	sql2 = "update board_code set ct_code = " & v_rsct_code & " where ct_idx = " &ct_idx

	dbcon.execute sql1
	dbcon.execute sql2

End if


If ct_ref = "0" Then ct_ref = ""

ok_url = "write.asp?a_num=" & a_num & "&amp;ct_idx=" & ct_ref
Call loding ("0", ok_url)

%>