% if session("admin") <> "TRUE" then response.redirect("../index.asp")%> <% ' *** Edit Operations: declare variables MM_editAction = CStr(Request("URL")) If (Request.QueryString <> "") Then MM_editAction = MM_editAction & "?" & Request.QueryString End If ' boolean to abort record edit MM_abortEdit = false ' query string to execute MM_editQuery = "" %> <% ' *** Delete Record: declare variables if (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then MM_editConnection = MM_workspace_STRING MM_editTable = "workspace_categories" MM_editColumn = "category_id" MM_recordId = "" + Request.Form("MM_recordId") + "" MM_editRedirectUrl = "../thanks.asp?action=deleteCategory" ' append the query string to the redirect URL If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString Else MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString End If End If End If %> <% ' *** Delete Record: construct a sql delete statement and execute it If (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then ' create the sql delete statement MM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordId If (Not MM_abortEdit) Then ' execute the delete Set MM_editCmd = Server.CreateObject("ADODB.Command") MM_editCmd.ActiveConnection = MM_editConnection MM_editCmd.CommandText = MM_editQuery MM_editCmd.Execute MM_editCmd.ActiveConnection.Close ' ################################################################################################### ' This time we have to delete the Entity and the documents and the category ' First lets loop through all the entities deleting the documents as we go along. set RSentity = Server.CreateObject("ADODB.Recordset") RSentity.ActiveConnection = MM_workspace_STRING RSentity.Source = "SELECT * FROM workspace_entity WHERE category_id = " & MM_recordId & "" RSentity.CursorType = 0 RSentity.CursorLocation = 2 RSentity.LockType = 3 RSentity.Open() RSentity_numRows = 0 ' Now start the entity Loop Dim Repeat2__numRows Repeat2__numRows = -1 Dim Repeat2__index Repeat2__index = 0 RSentity_numRows = RSentity_numRows + Repeat2__numRows While ((Repeat2__numRows <> 0) AND (NOT RSentity.EOF)) MM_editQuery = "delete from workspace_entity where category_id = " & MM_recordId Set MM_editCmd = Server.CreateObject("ADODB.Command") MM_editCmd.ActiveConnection = MM_editConnection MM_editCmd.CommandText = MM_editQuery MM_editCmd.Execute MM_editCmd.ActiveConnection.Close ' Also Delete all the document records that reside under this entity and their associated documents. ' First we are going to have to set up a documents recordset and then loop through it. set RSdocuments = Server.CreateObject("ADODB.Recordset") RSdocuments.ActiveConnection = MM_workspace_STRING RSdocuments.Source = "SELECT * FROM workspace_documents WHERE entity_id = " & RSentity("entity_id") & "" RSdocuments.CursorType = 0 RSdocuments.CursorLocation = 2 RSdocuments.LockType = 3 RSdocuments.Open() RSdocuments_numRows = 0 ' Now set up the loop Dim Repeat1__numRows Repeat1__numRows = -1 Dim Repeat1__index Repeat1__index = 0 RSdocuments_numRows = RSdocuments_numRows + Repeat1__numRows ' Then for each valid entry delete the Associated File FIRST and then the records While ((Repeat1__numRows <> 0) AND (NOT RSdocuments.EOF)) myFileName = RSdocuments("filename") 'Create the FileSystemObject Dim objFSO Set objFSO = Server.CreateObject("Scripting.FileSystemObject") 'Delete the file objFSO.DeleteFile server.mapPath("../../images/uploaded/" & myFileName), True Repeat1__index=Repeat1__index+1 Repeat1__numRows=Repeat1__numRows-1 RSdocuments.MoveNext() Wend ' Finaly we get to delete the documents records MM_editQuery = "delete from workspace_documents where entity_id = " & RSentity("entity_id") Set MM_editCmd = Server.CreateObject("ADODB.Command") MM_editCmd.ActiveConnection = MM_editConnection MM_editCmd.CommandText = MM_editQuery MM_editCmd.Execute MM_editCmd.ActiveConnection.Close Repeat2__index=Repeat2__index+1 Repeat2__numRows=Repeat2__numRows-1 RSentity.MoveNext() Wend ' ################################################################################################### If (MM_editRedirectUrl <> "") Then Response.Redirect(MM_editRedirectUrl) End If End If End If %> <% Dim RScategory__MMColParam RScategory__MMColParam = "1" if (Request.QueryString("category_id") <> "") then RScategory__MMColParam = Request.QueryString("category_id") %> <% set RScategory = Server.CreateObject("ADODB.Recordset") RScategory.ActiveConnection = MM_workspace_STRING RScategory.Source = "SELECT * FROM workspace_categories WHERE category_id = " + Replace(RScategory__MMColParam, "'", "''") + "" RScategory.CursorType = 0 RScategory.CursorLocation = 2 RScategory.LockType = 3 RScategory.Open() RScategory_numRows = 0 %>
Delete Category |
<% RScategory.Close() %>