%@ Language=VBScript %>
<%
Session.LCID = 1033
On Error Resume Next
strOrderBy=""
strOrderImage=""
Call CalculateOrderBy
TargetPageNumber=Request.Form("TargetPageNumber")
if TargetPageNumber="" or Request.Form("action")="search" then _
TargetPageNumber=1
if Request.Form("PageSize")<>"" then
Session("PageSize") = Request.Form("PageSize")
end if
if Session("PageSize")<>"" then PageSize = Session("PageSize")
' delete record
if (Request.Form("deleteid")<>"") then
if (Request.Form("NeedQuotes"&BuildFieldName(strKeyField)))="True" then
strQuote="'"
else
strQuote=""
end if
if (Request.Form("NeedQuotes"&BuildFieldName(strKeyField2)))="True" then
strQuote2="'"
else
strQuote2=""
end if
if (Request.Form("NeedQuotes"&BuildFieldName(strKeyField3)))="True" then
strQuote3="'"
else
strQuote3=""
end if
strSQL="delete from " & strTableName & _
" where " & AddWrappers(strKeyField) & "=" & strQuote & Replace(Request.Form("deleteid"),"'","''") & strQuote
if strKeyField2<>"" then _
strSQL=strSQL & " and " & AddWrappers(strKeyField2) & "=" & strQuote2 & Replace(Request.Form("deleteid2"),"'","''") & strQuote2
if strKeyField3<>"" then _
strSQL=strSQL & " and " & AddWrappers(strKeyField3) & "=" & strQuote3 & Replace(Request.Form("deleteid3"),"'","''") & strQuote3
set dbConnection = server.CreateObject ("ADODB.Connection")
dbConnection.ConnectionString = strConnection
dbConnection.Open
Call ReportError
LogInfo(strSQL)
dbConnection.Execute strSQL
Call ReportError
dbConnection.close
set dbConnection = nothing
end if
if Request.Form("action")<>"Search" and Request.Form("SQL")<>"" then
strSQL=Request.Form("SQL")
if strOrderBy<>"" then
if InStr(1, strSQL, "order by")>0 then
strSQL = Left(strSQL,InStr(1, strSQL, "order by")-1) & strOrderBy
else
strSQL = strSQL & strOrderBy
end if
end if
else
if gstrSQL="" then
strSQL="select * from " & strTableName
else
strSQL = gstrSQL
if LCase(Left(strSQL,7)) = "select " then
if InStr(1, LCase(gstrSQL), LCase(strKeyField) & ",")<1 then strSQL = "select " & AddWrappers(strKeyField) & ", " & Mid(strSQL, 8)
if InStr(1, LCase(gstrSQL), LCase(strKeyField2) & ",")<1 then strSQL = "select " & AddWrappers(strKeyField2) & ", " & Mid(strSQL, 8)
if InStr(1, LCase(gstrSQL), LCase(strKeyField3) & ",")<1 then strSQL = "select " & AddWrappers(strKeyField3) & ", " & Mid(strSQL, 8)
if InStr(1, LCase(gstrSQL), LCase(","))<1 then strSQL = "select " & AddWrappers("") & ", " & Mid(strSQL, 8)
end if
end if
' see if we have some search parameters
' regular search
if Request.Form("action")="Search" and Request.Form("SearchFor")<>"" then
strSearchFor=Trim(Request.Form("SearchFor"))
strSearchOption=Trim(Request.Form("SearchOption"))
if Request.Form("SearchField")<>"AnyField" then
strSQL = strSQL & " where " & AddWrappers(Request.Form("SearchField")) & StrWhere(Request.Form("SearchField"), strSearchFor, strSearchOption)
else
strSQL = strSQL & " where 1=0"
strSQL = strSQL & " or " & AddWrappers("Field2") & StrWhere("Field2", strSearchFor, strSearchOption)
strSQL = strSQL & " or " & AddWrappers("Field3") & StrWhere("Field3", strSearchFor, strSearchOption)
strSQL = strSQL & " or " & AddWrappers("Field4") & StrWhere("Field4", strSearchFor, strSearchOption)
strSQL = strSQL & " or " & AddWrappers("Field7") & StrWhere("Field7", strSearchFor, strSearchOption)
end if
end if
' advanced search
if Request.Form("action")="AdvancedSearch" then
sWhere=""
For i = 1 To Request.Form("SearchFor").Count
strSearchFor=Trim(Request.Form("SearchFor")(i))
if strSearchFor<>"" then
if sWhere="" then sWhere=" where 1=1"
strSearchOption=Trim(Request.Form("SearchOption")(i))
sWhere = sWhere & " and " & AddWrappers(Request.Form("FieldName")(i)) & StrWhere(Request.Form("FieldName")(i), strSearchFor, strSearchOption)
end if
next
strSQL = strSQL & sWhere
end if
strSQL = strSQL & " " & Trim(strOrderBy)
end if
Response.Write("")
Response.Write("
Return to Home
<%
' Pagination: Control Variables
dim iNumberOfRows
dim maxRecords
dim maxpages
dim mypage
iNumberOfRows =0
maxRecords = 0
maxpages = 0
mypage = TargetPageNumber
if mypage = "" then mypage =1
if CDBL(mypage)<=0 then mypage =1
%>
<%' Control Functions %>
<%' Pagination: Write Control%>
<%
Response.Write("")
Response.Write("")
function setupRs(strConnection,strSQL,nPageSize)
Err.Clear
Set setupRs = server.CreateObject ("ADODB.Recordset")
set dbConnection = server.CreateObject ("ADODB.Connection")
dbConnection.ConnectionString = strConnection
dbConnection.Open
Call ReportError
LogInfo(strSQL)
setupRs.open strSQL,dbConnection
Call ReportError
' Pagination:
if NOT setupRs.EOF then
setupRs.PageSize =nPageSize
maxRecords = cdbl(setupRs.RecordCount)
maxpages=cdbl(setupRs.PageCount)
if cdbl(mypage) > cdbl(maxpages) then
mypage = maxpages
End IF
setupRs.AbsolutePage = mypage
maxrecs=cdbl(setupRs.pagesize)
End IF
end function
sub WriteTableHeader
%>
<% if (rsDetails.Fields("Field2").Attributes and 128) and ( rsDetails.Fields("Field2").Type = 204 or rsDetails.Fields("Field2").Type=205 ) then
Response.Write Label("Field2") & "
<% if (rsDetails.Fields("Field3").Attributes and 128) and ( rsDetails.Fields("Field3").Type = 204 or rsDetails.Fields("Field3").Type=205 ) then
Response.Write Label("Field3") & "
<% if (rsDetails.Fields("Field4").Attributes and 128) and ( rsDetails.Fields("Field4").Type = 204 or rsDetails.Fields("Field4").Type=205 ) then
Response.Write Label("Field4") & "
<% if (rsDetails.Fields("Field5").Attributes and 128) and ( rsDetails.Fields("Field5").Type = 204 or rsDetails.Fields("Field5").Type=205 ) then
Response.Write Label("Field5") & "
<% if (rsDetails.Fields("Field6").Attributes and 128) and ( rsDetails.Fields("Field6").Type = 204 or rsDetails.Fields("Field6").Type=205 ) then
Response.Write Label("Field6") & "
<% if (rsDetails.Fields("Field7").Attributes and 128) and ( rsDetails.Fields("Field7").Type = 204 or rsDetails.Fields("Field7").Type=205 ) then
Response.Write Label("Field7") & "
<%
end sub
' display table with results
sub loopRs(rsData,nPageSize)
' Pagination:
dim iShadeTheDetail
dim iNumberOfRows
iNumberOfRows = 0
if isObject(rsData) then
' Pagination: UNTIL iNumberOfRows>=maxrecs
DO UNTIL rsData.eof OR iNumberOfRows>=nPageSize
' To insure that every other one is shaded
If iShadeTheDetail = 0 then
sShadeClass = "class=shade"
iShadeTheDetail = 1
Else
sShadeClass = ""
iShadeTheDetail = 0
End If
%>
<%
if IsBinaryField(rsData.Fields("Field2")) then
Response.Write CreateImageControl(rsData, "Field2")
else
Response.Write ProcessLargeText(GetData(rsData.Fields("Field2"), ""))
end if
%>
<%
if IsBinaryField(rsData.Fields("Field3")) then
Response.Write CreateImageControl(rsData, "Field3")
else
Response.Write ProcessLargeText(GetData(rsData.Fields("Field3"), ""))
end if
%>
<%
if IsBinaryField(rsData.Fields("Field4")) then
Response.Write CreateImageControl(rsData, "Field4")
else
Response.Write ProcessLargeText(GetData(rsData.Fields("Field4"), ""))
end if
%>
<%
if IsBinaryField(rsData.Fields("Field5")) then
Response.Write CreateImageControl(rsData, "Field5")
else
Response.Write ProcessLargeText(GetData(rsData.Fields("Field5"), ""))
end if
%>
<%
if IsBinaryField(rsData.Fields("Field6")) then
Response.Write CreateImageControl(rsData, "Field6")
else
Response.Write ProcessLargeText(GetData(rsData.Fields("Field6"), ""))
end if
%>
<%
if IsBinaryField(rsData.Fields("Field7")) then
Response.Write CreateImageControl(rsData, "Field7")
else
Response.Write ProcessLargeText(GetData(rsData.Fields("Field7"), ""))
end if
%>
<%
iNumberOfRows = iNumberOfRows + 1
rsData.movenext
Loop
end if
end sub
Sub CalculateOrderBy
if Request.Form("action")="OrderBy" then
strOrderBy = " order by " & AddWrappers(Request.Form("orderby"))
if Request.Form("SQL")<>"" then
nInd = InStr(1, Request.Form("SQL"),"order by ")
if nInd>0 then
if Left(Mid(Request.Form("SQL"),nInd+Len("order by ")),Len(AddWrappers(Request.Form("orderby")))) = AddWrappers(Request.Form("orderby")) _
and Right(Request.Form("SQL"),3) = "asc" then
strOrderBy = strOrderBy & " desc"
else
strOrderBy = strOrderBy & " asc"
end if
else
strOrderBy = strOrderBy & " asc"
end if
else
strOrderBy = strOrderBy & " asc"
end if
if right(strOrderBy,3)="asc" then
strOrderImage="up.gif"
else
strOrderImage="down.gif"
end if
else
strOrderBy = Request.Form("orderby")
if strOrderBy="" and Request.Form("SQL")="" then strOrderBy=gstrOrderBy
end if
End Sub
Function CheckSecurity(strValue, strAction)
if (cAdvSecurityMethod = ADVSECURITY_ALL and Session("AccessLevel")<>ACCESS_LEVEL_GUEST ) _
or Session("AccessLevel")=ACCESS_LEVEL_ADMIN or (strAction="Add" and Session("AccessLevel")<>ACCESS_LEVEL_GUEST) then
CheckSecurity = True
Exit Function
end if
if Session("AccessLevel")=ACCESS_LEVEL_GUEST then
CheckSecurity = False
Exit Function
end if
if cAdvSecurityMethod = ADVSECURITY_EDIT_OWN then
if RemoveWrappers(Session("OwnerID"))=CStr(strValue) then
CheckSecurity = True
else
CheckSecurity = False
end if
else
CheckSecurity = True
end if
End Function
Function CreateImageControl(rsData, sFieldName)
strImageWhere = " " & strKeyField & "=" & GetData(rsData.Fields(strKeyField), "")
if strKeyField2<>"" then _
strImageWhere = strImageWhere & " and " & strKeyField2 & "=" & GetData(rsData.Fields(strKeyField2), "")
if strKeyField3<>"" then _
strImageWhere = strImageWhere & " and " & strKeyField3 & "=" & GetData(rsData.Fields(strKeyField3), "")
CreateImageControl = ""
End Function
%>