/members_only/training_library/index.asp

https://github.com/evizitei/bcfpd_asp · ASP · 178 lines · 139 code · 23 blank · 16 comment · 3 complexity · e690af7ca8f96f25a4f32717467e2e10 MD5 · raw file

  1. <!-- #include virtual="/include/constants/database.asa"-->
  2. <!-- #include virtual="/members_only/include/functions.asa"-->
  3. <%
  4. Server.ScriptTimeout = 10000
  5. If Not Session("Authorized")(20) Then
  6. Response.Redirect "/members_only/index.asp"
  7. End If
  8. ' Create a recordset object called rsCategory.
  9. set rsCategory = Server.CreateObject("ADODB.Recordset")
  10. strNode = "SELECT * FROM Training_library_category"
  11. ' If there is a request to delete, delete the record.
  12. 'If Request.Form("Submit") = "Delete Category" Then
  13. 'rsCategory.Open "Training_library_category", cnnMain, 3, 3
  14. ' Do While Not rsCategory.EOF
  15. ' If Request.Form("Delete" & rsCategory("Category_ID")) Then
  16. ' rsCategory.Delete
  17. ' End If
  18. ' rsCategory.MoveNext
  19. ' Loop
  20. 'rsCategory.Close
  21. 'End If
  22. If Request.Form("Submit") = "Delete Category" Then
  23. dim arrDelete
  24. arrDelete = split(Request.Form("DeleteMe"), ",")
  25. for each item in arrDelete
  26. strSQL = "DELETE FROM Training_library_category WHERE Category_ID = " & trim(item)
  27. cnnMain.execute(strSQL)
  28. next
  29. end if
  30. ' If there is a request to update the new record, update the new record.
  31. If Request.Form("Submit") = "Update Category" Then
  32. rsCategory.Open "Training_library_category", cnnMain,3,3
  33. rsCategory.AddNew
  34. For Each Item in Request.Form
  35. If Item <> "Submit" Then
  36. rsCategory(Item) = Request.Form(Item)
  37. End If
  38. Next
  39. rsCategory.Update
  40. rsCategory.Close
  41. End If
  42. ' If there is a request to update an existing record, update the existing record.
  43. If Request.Form("Submit") = "Update Existing Category" Then
  44. rsCategory.Open "SELECT * FROM Training_library_category WHERE Category_ID =" & Request.Form("Category_ID"), cnnMain,3,3
  45. For Each Item in Request.Form
  46. If Item <> "Submit" AND Item <> "Category_ID" Then
  47. rsCategory(Item) = Request.Form(Item)
  48. End If
  49. Next
  50. rsCategory.Update
  51. rsCategory.Close
  52. End If
  53. %>
  54. <!--#include virtual="/members_only/include/templates/top.asa"-->
  55. <!--#include virtual="/members_only/include/templates/members.asa"-->
  56. <table border="0" width="98%" cellspacing="0" cellpadding="5">
  57. <tr>
  58. <td class="PageTitle">Library Categories</td>
  59. </tr>
  60. <tr>
  61. <td width="100%" valign="bottom">
  62. <% If Request.Form("Submit") = "Add New Category" OR Request.QueryString("Category_ID") <> "" Then
  63. ' If there is a request to add new record, add new record.
  64. If Request.Form("Submit") = "Add New Category" Then
  65. rsCategory.Open strNode, cnnMain, 3, 3
  66. rsCategory.AddNew
  67. End If
  68. ' If there is a request by clicking a hyper link, open the recordset and grab the selected record.
  69. If Request.QueryString("Category_ID") <> "" Then
  70. rsCategory.Open "SELECT * FROM Training_library_category WHERE Category_ID = " & Request.QueryString("Category_ID"), cnnMain, 3, 3
  71. End If
  72. %>
  73. <!--' 9. A form is created that contains a table with update fields.-->
  74. <form method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>" id="form1" name="form1">
  75. <!-- 9a. A table is created that contains the requested information.-->
  76. <table border="0" cellpadding="3" cellspacing="3">
  77. <tr>
  78. <td></td>
  79. <td>
  80. <table border="0" cellpadding="0" cellspacing="0" bordercolor="#f2f2f2">
  81. <tr>
  82. <td class="ContactInfo" bordercolor="#f2f2f2">Name:</td>
  83. <td bordercolor="#f2f2f2"><input type="text" name="Name" size="50" maxlength="200" value="<%=rsCategory("Name")%>"></td>
  84. </tr>
  85. <tr>
  86. <td align="right" colspan="2">
  87. <!-- 9b. If Then Else statement to check if updating new record or existing.-->
  88. <% If Request.QueryString("Category_ID") <> "" Then %>
  89. <a href="javascript:submit(document.form1, 'Update Existing Category');"><img SRC="/images/members/buttons/Save.gif" border="0"></a>
  90. <img src="/images/spacer.gif" border="0" height="1" width="35">
  91. <a style="cursor: hand" OnClick="window.history.back();"><img src="/images/members/buttons/cancel.gif" border="0" width="45" height="34"></a>
  92. <input type="hidden" name="Submit">
  93. <input type="hidden" name="Category_ID" value="<%=rsCategory("Category_ID")%>">
  94. <% Else %>
  95. <a href="javascript:submit(document.form1, 'Update Category');"><img SRC="/images/members/buttons/Save.gif" border="0"></a>
  96. <img src="/images/spacer.gif" border="0" height="1" width="35">
  97. <a style="cursor: hand" OnClick="window.history.back();"><img src="/images/members/buttons/cancel.gif" border="0" width="45" height="34"></a>
  98. <input type="Hidden" name="Submit">
  99. <% End If %>
  100. </td>
  101. </tr>
  102. </table>
  103. </td>
  104. </tr>
  105. </table>
  106. </form>
  107. <% Else %>
  108. <%
  109. rsCategory.Open "SELECT * FROM Training_library_category ORDER BY Name ASC" , cnnMain, 3, 3
  110. %>
  111. <form method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>" id="form2" name="form2">
  112. <!-- 11. A table is created that will contain a delete check box, Make Feature/Headline links, and date info.-->
  113. <table border="0" cellpadding="3" cellspacing="3">
  114. <tr>
  115. <td></td>
  116. <td>
  117. <table border="0" cellpadding="3" cellspacing="3" bordercolor="#f2f2f2">
  118. <tr>
  119. <td class="subheadercenter">Delete</td>
  120. <td class="subheadercenter">Name</td>
  121. <td class="subheadercenter">Edit Category</td>
  122. <td class="subheadercenter">Add Files</td>
  123. </tr>
  124. <!-- 12. Do While Loop to populate the table with database information.-->
  125. <% Do while not rsCategory.EOF %>
  126. <tr>
  127. <td align="center" bordercolor="#f2f2f2"><input type="checkbox" name="DeleteMe" value="<%=rsCategory("Category_ID")%>"></td>
  128. <td class="ContactInfo" bordercolor="#f2f2f2"><%=rsCategory("Name")%></td>
  129. <td align="center"><a class="update" href="index.asp?Category_ID=<%=rsCategory("Category_ID")%>">Edit</a></td>
  130. <td align="center"><a class="update" href="files.asp?Category_ID=<%=rsCategory("Category_ID")%>">Add files</a></td>
  131. </tr>
  132. <% rsCategory.MoveNext
  133. Loop
  134. %>
  135. <tr>
  136. <td align="right" colspan="4">
  137. <a href="javascript:submit(document.form2, 'Add New Category');"><img SRC="/images/members/buttons/add.gif" border="0"></a>
  138. <img src="/images/spacer.gif" border="0" height="1" width="35">
  139. <a href="javascript:DeletePlus(document.form2, 'Delete Category');"><img SRC="/images/members/buttons/Delete.gif" border="0"></a>
  140. <img src="/images/spacer.gif" border="0" height="1" width="35">
  141. <a href="/members_only/index2.asp"><img src="/images/members/buttons/cancel.gif" border="0" width="45" height="34"></a>
  142. <input type="hidden" name="Submit">
  143. </td>
  144. </tr>
  145. </table>
  146. </td>
  147. </tr>
  148. </table>
  149. </form>
  150. <%rsCategory.Close%>
  151. <% End If %>
  152. </td>
  153. </tr>
  154. </table>
  155. <!--#include virtual="/members_only/include/templates/bottom.asa"-->