home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey_unconfigured / PageConditionAction.asp < prev    next >
Text File  |  2006-10-25  |  4KB  |  102 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 works with PageCondition.asp, and processes
  7. '                     the form for creating and editing page conditions.  All values
  8. '                      are stored in the SUR_PAGE_CONDITION table.
  9. '
  10. '   COPYRIGHT NOTICE                                
  11. '
  12. '   See attached Software License Agreement
  13. '
  14. '   (c) Copyright 2002 - 2006 by ClassApps.com.  All rights reserved.
  15. '***********************************************************************
  16. %>
  17. <!--#Include File="Include/Config_inc.asp"-->
  18. <!--#Include File="Include/Utility_inc.asp"-->
  19. <!--#Include File="Include/adovbs_inc.asp"-->
  20. <!--#Include File="Include/Constants_inc.asp"-->
  21. <!--#Include File="Include/ID_inc.asp"-->
  22. <!--#Include File="Include/CurrentUser_inc.asp"-->
  23. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  24. <%
  25.     Dim strSQL
  26.     Dim conPageCondition
  27.     Dim lngPageConditionID
  28.     Dim lngAnswerID
  29.     Dim strAnswer
  30.     Dim strState
  31.         
  32.     'Initialization
  33.     Set conPageCondition = Server.CreateObject("ADODB.Connection")
  34.     conPageCondition.Open SURVEY_APP_CONNECTION
  35.     
  36.     If Request.Form("State") = SUR_STATE_EDIT Then
  37.         strState = SUR_STATE_EDIT
  38.     Else
  39.         strState = SUR_STATE_INSERT
  40.     End If
  41.  
  42.     'Make sure that an answer has been selected from the answer combo
  43.     If Len(Request.Form("cboAnswer")) > 0 And Request.Form("cboAnswer") <> SUR_COMBO_NONE Then
  44.         'If the question is a Yes/No, True/False, or database dropdown, the answer ID must be Null.
  45.         If CLng(Request.Form("ItemTypeID")) = SUR_ITEM_YES_NO Or CLng(Request.Form("ItemTypeID")) = SUR_ITEM_TRUE_FALSE Or CLng(Request.Form("ItemTypeID")) = SUR_ITEM_DATABASE_DROPDOWN Then
  46.             lngAnswerID = SUR_ANSWER_ID_NULL
  47.         Else
  48.             lngAnswerID = Request.Form("cboAnswer")
  49.         End If
  50.     Else
  51.         lngAnswerID = SUR_ANSWER_ID_NULL
  52.     End If
  53.     
  54.     If Len(Request.Form("txtAnswer")) > 0 Then
  55.         strAnswer = Request.Form("txtAnswer")
  56.     Else
  57.         'If the question is a Yes/No, True/False, or database dropdown, use the value from the combo for the answer text.
  58.         If CLng(Request.Form("ItemTypeID")) = SUR_ITEM_YES_NO Or CLng(Request.Form("ItemTypeID")) = SUR_ITEM_TRUE_FALSE Or CLng(Request.Form("ItemTypeID")) = SUR_ITEM_DATABASE_DROPDOWN Then
  59.             'If the user select --None-- from the combo, insert Null text
  60.             If Request.Form("cboAnswer") = SUR_COMBO_NONE Then
  61.                 strAnswer = SUR_ANSWER_TEXT_NULL
  62.             Else
  63.                 strAnswer = Request.Form("cboAnswer")
  64.             End If
  65.         Else        
  66.             strAnswer = SUR_ANSWER_TEXT_NULL
  67.         End If
  68.     End If
  69.  
  70.     If strState = SUR_STATE_INSERT Then    
  71.         'Insert the new page condition into the page condition table
  72.         lngPageConditionID = ID_GetNextAvailableID("SurveyGenerationPageConditionID")
  73.         strSQL = "INSERT INTO sur_page_condition(page_condition_id, survey_id, page_number, dependent_item_id, " & _
  74.                     "group_number, operator_id, answer_id, answer_text) VALUES(" & _
  75.                  lngPageConditionID & ", " & _
  76.                  Request.Form("SurveyID") & ", " & _
  77.                  Request.Form("PageNumber") & ", " & _
  78.                  Request.Form("cboQuestion") & ", " & _
  79.                  Request.Form("cboGroupNumber") & ", " & _
  80.                  Request.Form("cboOperator") & ", " & _
  81.                  lngAnswerID & ", " & _
  82.                  SQLEncode(strAnswer) & ")"
  83.     Else
  84.         strSQL = "UPDATE sur_page_condition " & _
  85.                     "SET dependent_item_id = " & Request.Form("cboQuestion") & ", " & _
  86.                     "operator_id = " & Request.Form("cboOperator") & ", " & _
  87.                     "group_number = " & Request.Form("cboGroupNumber") & ", " & _
  88.                     "answer_id = " & lngAnswerID & ", " & _
  89.                     "answer_text = " & SQLEncode(strAnswer) & _
  90.                     " WHERE page_condition_id = " & Request.Form("PageConditionID")
  91.     End If
  92.  
  93.     'Execute the SQL command
  94.     conPageCondition.Execute ConvertSQL(strSQL), , adCmdText
  95.  
  96.     'Clean up
  97.     conPageCondition.Close
  98.     Set conPageCondition = Nothing
  99.  
  100.     'Redirect back to the page condition page.
  101.     Response.Redirect "PageCondition.asp?SurveyID=" & Request.Form("SurveyID") & "&SurveyName=" & Request.Form("SurveyName") & "&PageNumber=" & Request.Form("PageNumber")
  102. %>