home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
bombers.k12.ar.us
/
bombers.k12.ar.us.tar
/
bombers.k12.ar.us
/
survey_unconfigured
/
ReorderItem.asp
< prev
next >
Wrap
Text File
|
2006-10-25
|
4KB
|
101 lines
<!--#Include File="Include/Top_inc.asp"-->
<%
'***********************************************************************
' Application: SelectSurveyASP Advanced v8.1.11
' Author: Aaron Baril for ClassApps.com
' Page Description: This page allows the user to reorder the items
' in a survey.
'
' COPYRIGHT NOTICE
'
' See attached Software License Agreement
'
' (c) Copyright 2002 - 2006 by ClassApps.com. All rights reserved.
'***********************************************************************
%>
<!--#Include File="Include/Config_inc.asp"-->
<!--#Include File="Include/Utility_inc.asp"-->
<!--#Include File="Include/adovbs_inc.asp"-->
<!--#Include File="Include/ID_inc.asp"-->
<!--#Include File="Include/CurrentUser_inc.asp"-->
<!--#Include File="Include/SurveySecurity_inc.asp"-->
<!--#Include File="Include/Constants_inc.asp"-->
<%
Dim strSQL1
Dim strSQL2
Dim conReorder
Dim lngSurveyID
Dim lngLibraryID
Dim lngItemID
Dim strDirection
Dim lngOrderNumber
Dim flgLibrary
'Initialization
Set conReorder = Server.CreateObject("ADODB.Connection")
conReorder.Open SURVEY_APP_CONNECTION
lngOrderNumber = Request.Form("OrderNumber")
lngItemID = Request.Form("ItemID")
strDirection = Request.Form("Direction")
If Len(Request.Form("SurveyID")) > 0 Then
lngSurveyID = Request.Form("SurveyID")
flgLibrary = False
Else
lngLibraryID = Request.Form("LibraryID")
flgLibrary = True
End If
'Set up two SQL statements, one to move each of the two items
If strDirection = "Down" Then
'strSQL1 moves the following item up 1; strSQL2 moves the item clicked on down 1. Note that moving an item
'up means decreasing its order number (counter-intuitive)
If flgLibrary = True Then
strSQL1 = "UPDATE sur_library_to_item_mapping SET order_number = " & lngOrderNumber & _
" WHERE library_id = " & lngLibraryID & _
" AND order_number = " & lngOrderNumber + 1
strSQL2 = "UPDATE sur_library_to_item_mapping SET order_number = " & lngOrderNumber + 1 & _
" WHERE library_id = " & lngLibraryID & _
" AND item_id = " & lngItemID
Else
strSQL1 = "UPDATE sur_survey_to_item_mapping SET order_number = " & lngOrderNumber & _
" WHERE survey_id = " & lngSurveyID & _
" AND order_number = " & lngOrderNumber + 1
strSQL2 = "UPDATE sur_survey_to_item_mapping SET order_number = " & lngOrderNumber + 1 & _
" WHERE survey_id = " & lngSurveyID & _
" AND item_id = " & lngItemID
End If
Else 'Direction equals "Up"
'strSQL1 moves the previous item down 1; strSQL2 moves the item clicked on up 1. Note that moving an item
'down means increasing its order number (counter-intuitive)
If flgLibrary = True Then
strSQL1 = "UPDATE sur_library_to_item_mapping SET order_number = " & lngOrderNumber & _
" WHERE library_id = " & lngLibraryID & _
" AND order_number = " & lngOrderNumber - 1
strSQL2 = "UPDATE sur_library_to_item_mapping SET order_number = " & lngOrderNumber - 1 & _
" WHERE library_id = " & lngLibraryID & _
" AND item_id = " & lngItemID
Else
strSQL1 = "UPDATE sur_survey_to_item_mapping SET order_number = " & lngOrderNumber & _
" WHERE survey_id = " & lngSurveyID & _
" AND order_number = " & lngOrderNumber - 1
strSQL2 = "UPDATE sur_survey_to_item_mapping SET order_number = " & lngOrderNumber - 1 & _
" WHERE survey_id = " & lngSurveyID & _
" AND item_id = " & lngItemID
End If
End If
'Execute SQL to actually move the ordering in the mapping table
conReorder.Execute strSQL1, , adCmdText
conReorder.Execute strSQL2, , adCmdText
'Clean up
conReorder.Close
Set conReorder = Nothing
'Redirect to the modify survey page for the survey or the modify library page for the library
If flgLibrary = True Then
Response.Redirect "ModifyLibrary.asp?LibraryID=" & lngLibraryID
Else
Response.Redirect "ModifySurvey.asp?SurveyID=" & lngSurveyID
End If
%>