%@LANGUAGE="VBSCRIPT"%> <% If Session("cAdminUserName") = "" Then Response.Redirect "AdminLogin.asp" End If %> <% Dim strView, rsRecordset, strTable, strSort, strOrderBy, VarSortOrder, strSelect strView = Request("View") strSort = Trim(Request("Sort")) If strSort <> "" Then If strSort = "" Then If strView = "Users" Then strOrderBy = "ASC" strSort = "UserID" & " " & strOrderBy Else strOrderBy = "ASC" strSort = "nAdID" & " " & strOrderBy End If Else strOrderBy = Request("SortOrder") strSort = strSort & " " & strOrderBy End If If strView = "Users" Then strTable = "UserID, EmailAddress, LastLogin, Country FROM tblUsers" strField1 = "UserID" strField2 = "EmailAddress" strField3 = "LastLogin" strField4 = "Country" ElseIf strView = "Ads" Then strTable = "nAdID, nUserID, cTitle, cNetAddress FROM tblAds" strField1 = "nAdID" strField2 = "nUserID" strField3 = "cTitle" strField4 = "dNetAddress" End If set rsRecordset = Server.CreateObject("ADODB.Recordset") rsRecordset.ActiveConnection = strConn rsRecordset.Source = "SELECT " & strTable & " ORDER BY " & strSort rsRecordset.CursorType = 0 rsRecordset.CursorLocation = 2 rsRecordset.LockType = 3 rsRecordset.Open rsRecordset_numRows = 0 If strView = "Users" Then strField1 = "UserID" strField2 = "EmailAddress" strField3 = "LastLogin" strField4 = "Country" strHeading1 = "User ID" strHeading2 = "Email address" strHeading3 = "Last Login" strHeading4 = "Country" ElseIf strView = "Ads" Then strField1 = "nAdID" strField2 = "nUserID" strField3 = "cTitle" strField4 = "cNetAddress" strHeading1 = "Ad ID" strHeading2 = "User ID" strHeading3 = "Title" strHeading4 = "Photo File Name" End If If strOrderBy = "ASC" Then varSortOrder = "DESC" Else varSortOrder = "ASC" End If %><% Dim Repeat1__numRows, intTotalRows intTotalRows = request("totalRows") If intTotalRows <> "" then Repeat1__numRows = intTotalRows Else Repeat1__numRows = 10 End if Dim Repeat1__index Repeat1__index = 0 rsRecordset_numRows = rsRecordset_numRows + Repeat1__numRows %> <% ' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables ' set the record count rsRecordset_total = rsRecordset.RecordCount ' set the number of rows displayed on this page If (rsRecordset_numRows < 0) Then rsRecordset_numRows = rsRecordset_total Elseif (rsRecordset_numRows = 0) Then rsRecordset_numRows = 1 End If ' set the first and last displayed record rsRecordset_first = 1 rsRecordset_last = rsRecordset_first + rsRecordset_numRows - 1 ' if we have the correct record count, check the other stats If (rsRecordset_total <> -1) Then If (rsRecordset_first > rsRecordset_total) Then rsRecordset_first = rsRecordset_total If (rsRecordset_last > rsRecordset_total) Then rsRecordset_last = rsRecordset_total If (rsRecordset_numRows > rsRecordset_total) Then rsRecordset_numRows = rsRecordset_total End If %> <% ' *** Recordset Stats: if we don't know the record count, manually count them If (rsRecordset_total = -1) Then ' count the total records by iterating through the recordset rsRecordset_total=0 While (Not rsRecordset.EOF) rsRecordset_total = rsRecordset_total + 1 rsRecordset.MoveNext Wend ' reset the cursor to the beginning If (rsRecordset.CursorType > 0) Then rsRecordset.MoveFirst Else rsRecordset.Requery End If ' set the number of rows displayed on this page If (rsRecordset_numRows < 0 Or rsRecordset_numRows > rsRecordset_total) Then rsRecordset_numRows = rsRecordset_total End If ' set the first and last displayed record rsRecordset_first = 1 rsRecordset_last = rsRecordset_first + rsRecordset_numRows - 1 If (rsRecordset_first > rsRecordset_total) Then rsRecordset_first = rsRecordset_total If (rsRecordset_last > rsRecordset_total) Then rsRecordset_last = rsRecordset_total End If %> <% ' *** Move To Record and Go To Record: declare variables Set EArs = rsRecordset EArsCount = rsRecordset_total EAsize = rsRecordset_numRows EAuniqueCol = "" EAparamName = "" EAoffset = 0 EAatTotal = false EAparamIsDefined = false If (EAparamName <> "") Then EAparamIsDefined = (Request.QueryString(EAparamName) <> "") End If %> <% ' *** Move To Record: handle 'index' or 'offset' parameter if (Not EAparamIsDefined And EArsCount <> 0) then ' use index parameter if defined, otherwise use offset parameter r = Request.QueryString("index") If r = "" Then r = Request.QueryString("offset") If r <> "" Then EAoffset = Int(r) ' if we have a record count, check if we are past the end of the recordset If (EArsCount <> -1) Then If (EAoffset >= EArsCount Or EAoffset = -1) Then ' past end or move last If ((EArsCount Mod EAsize) > 0) Then ' last page not a full repeat region EAoffset = EArsCount - (EArsCount Mod EAsize) Else EAoffset = EArsCount - EAsize End If End If End If ' move the cursor to the selected record i = 0 While ((Not EArs.EOF) And (i < EAoffset Or EAoffset = -1)) EArs.MoveNext i = i + 1 Wend If (EArs.EOF) Then EAoffset = i ' set EAoffset to the last possible record End If %> <% ' *** Move To Record: if we dont know the record count, check the display range If (EArsCount = -1) Then ' walk to the end of the display range for this page i = EAoffset While (Not EArs.EOF And (EAsize < 0 Or i < EAoffset + EAsize)) EArs.MoveNext i = i + 1 Wend ' if we walked off the end of the recordset, set EArsCount and EAsize If (EArs.EOF) Then EArsCount = i If (EAsize < 0 Or EAsize > EArsCount) Then EAsize = EArsCount End If ' if we walked off the end, set the offset based on page size If (EArs.EOF And Not EAparamIsDefined) Then If (EAoffset > EArsCount - EAsize Or EAoffset = -1) Then If ((EArsCount Mod EAsize) > 0) Then EAoffset = EArsCount - (EArsCount Mod EAsize) Else EAoffset = EArsCount - EAsize End If End If End If ' reset the cursor to the beginning If (EArs.CursorType > 0) Then EArs.MoveFirst Else EArs.Requery End If ' move the cursor to the selected record i = 0 While (Not EArs.EOF And i < EAoffset) EArs.MoveNext i = i + 1 Wend End If %> <% ' *** Move To Record: update recordset stats ' set the first and last displayed record rsRecordset_first = EAoffset + 1 rsRecordset_last = EAoffset + EAsize If (EArsCount <> -1) Then If (rsRecordset_first > EArsCount) Then rsRecordset_first = EArsCount If (rsRecordset_last > EArsCount) Then rsRecordset_last = EArsCount End If ' set the boolean used by hide region to check if we are on the last record EAatTotal = (EArsCount <> -1 And EAoffset + EAsize >= EArsCount) %> <% ' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters ' create the list of parameters which should not be maintained EAremoveList = "&index=" If (EAparamName <> "") Then EAremoveList = EAremoveList & "&" & EAparamName & "=" EAkeepURL="":EAkeepForm="":EAkeepBoth="":EAkeepNone="" ' add the URL parameters to the EAkeepURL string For Each Item In Request.QueryString NextItem = "&" & Item & "=" If (InStr(1,EAremoveList,NextItem,1) = 0) Then EAkeepURL = EAkeepURL & NextItem & Server.URLencode(Request.QueryString(Item)) End If Next ' add the Form variables to the EAkeepForm string For Each Item In Request.Form NextItem = "&" & Item & "=" If (InStr(1,EAremoveList,NextItem,1) = 0) Then EAkeepForm = EAkeepForm & NextItem & Server.URLencode(Request.Form(Item)) End If Next ' create the Form + URL string and remove the intial '&' from each of the strings EAkeepBoth = EAkeepURL & EAkeepForm if (EAkeepBoth <> "") Then EAkeepBoth = Right(EAkeepBoth, Len(EAkeepBoth) - 1) if (EAkeepURL <> "") Then EAkeepURL = Right(EAkeepURL, Len(EAkeepURL) - 1) if (EAkeepForm <> "") Then EAkeepForm = Right(EAkeepForm, Len(EAkeepForm) - 1) ' a utility function used for adding additional parameters to these strings Function EAjoinChar(firstItem) If (firstItem <> "") Then EAjoinChar = "&" Else EAjoinChar = "" End If End Function %> <% ' *** Move To Record: set the strings for the first, last, next, and previous links EAkeepMove = EAkeepBoth EAmoveParam = "index" ' if the page has a repeated region, remove 'offset' from the maintained parameters If (EAsize > 0) Then EAmoveParam = "offset" If (EAkeepMove <> "") Then params = Split(EAkeepMove, "&") EAkeepMove = "" For i = 0 To UBound(params) nextItem = Left(params(i), InStr(params(i),"=") - 1) If (StrComp(nextItem,EAmoveParam,1) <> 0) Then EAkeepMove = EAkeepMove & "&" & params(i) End If Next If (EAkeepMove <> "") Then EAkeepMove = Right(EAkeepMove, Len(EAkeepMove) - 1) End If End If End If ' set the strings for the move to links If (EAkeepMove <> "") Then EAkeepMove = EAkeepMove & "&" urlStr = Request.ServerVariables("URL") & "?" & EAkeepMove & EAmoveParam & "=" EAmoveFirst = urlStr & "0" EAmoveLast = urlStr & "-1" EAmoveNext = urlStr & Cstr(EAoffset + EAsize) prev = EAoffset - EAsize If (prev < 0) Then prev = 0 EAmovePrev = urlStr & Cstr(prev) %>
Click on Ad ID to modify that ad. To delete, select the check-boxes of the ads to delete and click "DELETE".
<%End If%>|
|
<% rsRecordset.Close Set rsRecordset = Nothing %> <% End If %>
<% If strView = "Categories" Then %>
<% strAction = Request("Action") Select Case strAction Case "ADD" strCommandText = "INSERT INTO tblCategory(cCategory) VALUES ('" & Request("txtCategory") & "')" set rsRecordset = Server.CreateObject("ADODB.Command") rsRecordset.ActiveConnection = strConn rsRecordset.CommandText = strCommandText rsRecordset.CommandType = adCmdText rsRecordset.Execute set rsRecordset = Nothing Case "MODIFY" strCommandText = "UPDATE tblCategory SET cCategory = ('" & Request("txtCategory") & "') WHERE cCategory = ('" & Request("nCategoryID") & "')" set rsRecordset = Server.CreateObject("ADODB.Command") rsRecordset.ActiveConnection = strConn rsRecordset.CommandText = strCommandText rsRecordset.CommandType = adCmdText rsRecordset.Execute set rsRecordset = Nothing Case "DELETE" strCommandText = "DELETE cCategory FROM tblCategory WHERE cCategory = ('" & Request("nCategoryID") & "')" set rsRecordset = Server.CreateObject("ADODB.Command") rsRecordset.ActiveConnection = strConn rsRecordset.CommandText = strCommandText rsRecordset.CommandType = adCmdText rsRecordset.Execute set rsRecordset = Nothing End Select set rsRecordset = Server.CreateObject("ADODB.Recordset") rsRecordset.ActiveConnection = strConn rsRecordset.Source = "SELECT cCategory, nCategoryID From tblCategory " rsRecordset.CursorType = 0 rsRecordset.CursorLocation = 2 rsRecordset.LockType = 3 rsRecordset.Open rsRecordset_numRows = 0 %>|
<%=strView%>
|
||
|
<%=strView%>
|
||