PageRenderTime 27ms CodeModel.GetById 33ms RepoModel.GetById 1ms app.codeStats 0ms

/members_only/quick_links/index.asp

https://github.com/evizitei/bcfpd_asp
ASP | 172 lines | 147 code | 16 blank | 9 comment | 3 complexity | b534f30cb327d67101a9c01b6e3a8c1b MD5 | raw file
  1. <!-- #include virtual="/members_only/include/functions.asa"-->
  2. <%
  3. If Not Session("Authorized")(6) Then
  4. Response.Redirect "/members_only/index.asp"
  5. End If
  6. ' 2. Create a recordset object called rsLinks.
  7. Category_ID = GetVal("Category_ID", "")
  8. Set rsLinks = Server.CreateObject("ADODB.Recordset")
  9. Set rsLinksCat = Server.CreateObject("ADODB.Recordset")
  10. strEmp = "SELECT * FROM Quick_Links"
  11. ' 3. If there is a request to delete, delete the record.
  12. 'If Request.Form("Submit") = "Delete Record" Then
  13. rsLinks.Open "Quick_Links", cnnBCFPD, 3, 3
  14. Do While Not rsLinks.EOF
  15. If Request.Form("Delete" & rsLinks("Link_id")) Then
  16. rsLinks.Delete
  17. End If
  18. rsLinks.MoveNext
  19. Loop
  20. rsLinks.Close
  21. 'End If
  22. ' 4. If there is a request to update the new record, update the new record.
  23. If Request.Form("Submit") = "Update Link" Then
  24. rsLinks.Open "Quick_Links", cnnBCFPD,3,3
  25. rsLinks.AddNew
  26. For Each Item in Request.Form
  27. If Item <> "Submit" Then
  28. rsLinks(Item) = Request.Form(Item)
  29. End If
  30. Next
  31. rsLinks.Update
  32. rsLinks.Close
  33. End If
  34. ' 5. If there is a request to update an existing record, update the existing record.
  35. If Request.Form("Submit") = "Update Existing Link" Then
  36. rsLinks.Open "SELECT * FROM Quick_Links WHERE Link_id =" & Request.Form("Record_ID"), cnnBCFPD,3,3
  37. For Each Item in Request.Form
  38. If Item <> "Submit" AND Item <> "Record_ID" Then
  39. rsLinks(Item) = Request.Form(Item)
  40. End If
  41. Next
  42. rsLinks.Update
  43. rsLinks.Close
  44. End If
  45. %>
  46. <!--#include virtual="/members_only/include/templates/top.asa"-->
  47. <!--#include virtual="/members_only/include/templates/members.asa"-->
  48. <table width="98%" border="0" cellspacing="0" cellpadding="5" bordercolor="orange">
  49. <tr>
  50. <td class="PageTitle">Quick Links Information</td>
  51. </tr>
  52. <tr>
  53. <td valign="bottom">
  54. <% If Request.Form("Submit") = "Add New Link" OR Request.QueryString("Link_id") <> "" Then
  55. ' 7. If there is a request to add new record, add new record.
  56. If Request.Form("Submit") = "Add New Link" Then
  57. rsLinks.Open strEmp, cnnBCFPD, 3, 3
  58. rsLinks.AddNew
  59. End If
  60. ' 8. If there is a request by clicking a hyper link, open the recordset and grab the selected record.
  61. If Request.QueryString("Link_id") <> "" Then
  62. rsLinks.Open "SELECT * FROM Quick_Links WHERE Link_id = " & Request.QueryString("Link_id"), cnnBCFPD, 3, 3
  63. End If
  64. %>
  65. <!--' 9. A form is created that contains a table with update fields.-->
  66. <form method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>?Category_ID=<%=Category_ID%>" id="form1" name="form1">
  67. <!-- 9a. A table is created that contains the requested information.-->
  68. <table border="0" cellpadding="3" cellspacing="3">
  69. <tr>
  70. <td class="ContactInfo">Name:</td>
  71. <td><input type="text" name="Name" value="<%=rsLinks("Name")%>"></td>
  72. </tr>
  73. <tr>
  74. <td class="ContactInfo">Web Address:</td>
  75. <td><input type="text" name="URL" value="<%=rsLinks("URL")%>"></td>
  76. </tr>
  77. <tr>
  78. <td class="ContactInfo">Description:</td>
  79. <td><textarea name="Description" maxlength="8000" cols="50" rows="10"><%=rsLinks("Description")%></textarea></td>
  80. </tr>
  81. <tr>
  82. <td class="ContactInfo">Category:</td>
  83. <td><select id="select1" name="Link_Category_ID">
  84. <% rsLinksCat.Open "SELECT * FROM Quick_Links_Category", cnnBCFPD, 3
  85. do while not rsLinksCat.EOF %>
  86. <option value="<%=rsLinksCat("Category_ID")%>" <%if rsLinksCat("Category_ID") = cint(Category_ID) then %> selected <%end if%>><%=rsLinksCat("Name")%></option>
  87. <% rsLinksCat.MoveNext
  88. loop
  89. rsLinksCat.Close %>
  90. </select>
  91. </td>
  92. </tr>
  93. <tr>
  94. <td align="right" colspan="2">
  95. <!-- 9b. If Then Else statement to check if updating new record or existing.-->
  96. <% If Request.QueryString("Link_id") <> "" Then %>
  97. <input type="hidden" name="Record_ID" value="<%=rsLinks("Link_id")%>">
  98. <a href="javascript:submit(document.form1, 'Update Existing Link');"><img SRC="/images/members/buttons/Save.gif" border="0"></a>
  99. <img src="/images/spacer.gif" border="0" height="1" width="35">
  100. <a style="cursor: hand" OnClick="window.history.back();"><img src="/images/members/buttons/cancel.gif" border="0" width="45" height="34"></a>
  101. <input type="hidden" name="Submit">
  102. <% Else %>
  103. <a href="javascript:submit(document.form1, 'Update Link');"><img SRC="/images/members/buttons/Save.gif" border="0"></a>
  104. <img src="/images/spacer.gif" border="0" height="1" width="35">
  105. <a style="cursor: hand" OnClick="window.history.back();"><img src="/images/members/buttons/cancel.gif" border="0" width="45" height="34"></a>
  106. <input type="Hidden" name="Submit">
  107. <% End If %>
  108. </td>
  109. </tr>
  110. </table>
  111. </form>
  112. <% Else %>
  113. <% 'rsLinks.Open "SELECT * FROM employment WHERE publication_date <= #" & now() & "# AND expiration_date >= #" & now() & "# ORDER BY expiration_date" , cnnBCFPD, 3, 3
  114. rsLinks.Open "SELECT * FROM Quick_Links WHERE Link_Category_ID = " & Category_ID & " ORDER BY Name ASC" , cnnBCFPD, 3, 3
  115. 'rsLinks.Open strEmp, cnnBCFPD, 3, 3%>
  116. <!-- 10. A form is created that contains a table with delete/make feature capability, Headline hyper links, and date info.-->
  117. <form method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>?Category_ID=<%=Category_ID%>" id="form2" name="form2">
  118. <!-- 11. A table is created that will contain a delete check box, Make Feature/Headline links, and date info.-->
  119. <table border="0" cellpadding="3" cellspacing="3">
  120. <tr>
  121. <td class="subheadercenter">Delete</td>
  122. <td class="subheadercenter">Link Name</td>
  123. <td class="subheadercenter">Web Address</td>
  124. <td class="subheadercenter">Link Category</td>
  125. </tr>
  126. <!-- 12. Do While Loop to populate the table with database information.-->
  127. <% Do while not rsLinks.EOF %>
  128. <tr>
  129. <td align="center"><input type="checkbox" name="Delete<%=rsLinks("Link_ID")%>" value="true"></td>
  130. <td><a href="<%Request.ServerVariables("SCRIPT_NAME")%>?Link_ID=<%=rsLinks("Link_ID")%>&amp;Category_ID=<%=Category_ID%>"><%=rsLinks("Name")%></a></td>
  131. <td><a href="http://<%=rsLinks("URL")%>" target="_new"><%=rsLinks("URL")%></td>
  132. <% rsLinksCat.Open "SELECT * FROM Quick_Links_Category WHERE Category_ID=" & rsLinks("Link_Category_ID"), cnnBCFPD, 3 %>
  133. <td class="ContactInfo"><%=rsLinksCat("Name")%></td>
  134. <% rsLinksCat.Close %>
  135. </tr>
  136. <% rsLinks.MoveNext
  137. Loop
  138. %>
  139. <tr>
  140. <td align="right" colspan="4">
  141. <a href="javascript:submit(document.form2, 'Add New Link');"><img SRC="/images/members/buttons/add.gif" border="0"></a>
  142. <img src="/images/spacer.gif" border="0" height="1" width="35">
  143. <a href="javascript:Delete();"><img SRC="/images/members/buttons/Delete.gif" border="0"></a>
  144. <img src="/images/spacer.gif" border="0" height="1" width="35">
  145. <a style="cursor: hand" OnClick="window.history.back();"><img src="/images/members/buttons/cancel.gif" border="0" width="45" height="34"></a>
  146. <input type="hidden" name="Submit">
  147. </td>
  148. </tr>
  149. </table>
  150. </form>
  151. <%rsLinks.Close%>
  152. <% End If %>
  153. </td>
  154. </tr>
  155. </table>
  156. <!--#include virtual="/members_only/include/templates/bottom.asa"-->