home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey / DeleteResponse.asp < prev    next >
Text File  |  2006-11-29  |  3KB  |  76 lines

  1. <!--#Include File="Include/Top_inc.asp"-->
  2. <%
  3. '***********************************************************************
  4. '   Application: SelectSurveyASP Advanced v8.1.11
  5. '   Author: Aaron Baril for ClassApps.com
  6. '   Page Description: This page deletes a single response.
  7. '
  8. '   COPYRIGHT NOTICE                                
  9. '
  10. '   See attached Software License Agreement
  11. '
  12. '   (c) Copyright 2002 - 2006 by ClassApps.com.  All rights reserved.
  13. '***********************************************************************
  14. %>
  15. <!--#Include File="Include/Config_inc.asp"-->
  16. <!--#Include File="Include/Utility_inc.asp"-->
  17. <!--#Include File="Include/adovbs_inc.asp"-->
  18. <!--#Include File="Include/ID_inc.asp"-->
  19. <!--#Include File="Include/CurrentUser_inc.asp"-->
  20. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  21. <!--#Include File="Include/Constants_inc.asp"-->
  22. <%
  23.     'In order to delete a survey response, the user must be the survey owner or an admin
  24.     If IsUserOwnerOrAdmin(Request.QueryString("SurveyID")) = False Then
  25.         Response.Redirect "AccessDenied.asp?SurveyID=" & Request.QueryString("SurveyID") & "&Reason=" & SUR_ACCESS_DENIED_NOT_OWNER
  26.     End If
  27.  
  28.     Dim strSQL
  29.     Dim conDeleteResponse
  30.     Dim lngQuestionID
  31.     Dim lngOrderNumber
  32.     Dim lngSurveyID
  33.     Dim lngResponseID
  34.     Dim lngResponseNumber
  35.     Dim strRedirectURL
  36.     
  37.     'Initialization
  38.     Set conDeleteResponse = Server.CreateObject("ADODB.Connection")
  39.     conDeleteResponse.Open SURVEY_APP_CONNECTION
  40.     lngSurveyID = Request.QueryString("SurveyID")
  41.     lngResponseID = Request.QueryString("ResponseID")
  42.     lngResponseNumber = Request.QueryString("ResponseNumber")
  43.     
  44.     'Delete all the response answers from the response answer table (SUR_RESPONSE_ANSWER)
  45.     strSQL = "DELETE FROM sur_response_answer WHERE response_id = " & lngResponseID
  46.     conDeleteResponse.Execute ConvertSQL(strSQL), , adCmdText
  47.  
  48.     'Delete the response for this survey from the response table (SUR_RESPONSE)
  49.     strSQL = "DELETE FROM sur_response WHERE response_id = " & lngResponseID
  50.     conDeleteResponse.Execute ConvertSQL(strSQL), , adCmdText
  51.  
  52.     'Delete any hidden fields from the hidden field table (SUR_RESPONSE_HIDDEN_FIELD)
  53.     strSQL = "DELETE FROM sur_response_hidden_field WHERE response_id = " & lngResponseID
  54.     conDeleteResponse.Execute ConvertSQL(strSQL), , adCmdText
  55.  
  56.     'Update the response count in the survey table (SUR_SURVEY)
  57.     strSQL = "UPDATE sur_survey SET response_count = response_count - 1 WHERE survey_id = " & lngSurveyID
  58.     conDeleteResponse.Execute ConvertSQL(strSQL), , adCmdText
  59.     
  60.     'Clean up
  61.     conDeleteResponse.Close
  62.     Set conDeleteResponse = Nothing
  63.  
  64.     'Redirect back to the same page (the individual results page).  The user should be redirected to the response after 
  65.     'the one that was deleted.  If the last response was deleted, the user is redirected to the "new" last response, which 
  66.     'is essentially the previous response.
  67.     If CLng(lngResponseNumber) = CLng(Request.QueryString("ResponseCount")) Then
  68.         lngResponseNumber = lngResponseNumber - 1
  69.     End If
  70.     
  71.     strRedirectURL = "ResultsIndividual.asp?SurveyID=" & lngSurveyID & "&ResponseNumber=" & lngResponseNumber
  72.     If Len(Request.QueryString("DisplayHeader")) > 0 Then
  73.         strRedirectURL = strRedirectURL & "&DisplayHeader=" & Request.QueryString("DisplayHeader")
  74.     End If
  75.     Response.Redirect strRedirectURL
  76. %>