<%@ 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("DATE") & StrWhere("DATE", strSearchFor, strSearchOption) strSQL = strSQL & " or " & AddWrappers("TIME") & StrWhere("TIME", strSearchFor, strSearchOption) strSQL = strSQL & " or " & AddWrappers("PLACE") & StrWhere("PLACE", strSearchFor, strSearchOption) strSQL = strSQL & " or " & AddWrappers("Province") & StrWhere("Province", strSearchFor, strSearchOption) strSQL = strSQL & " or " & AddWrappers("TYPE") & StrWhere("TYPE", strSearchFor, strSearchOption) strSQL = strSQL & " or " & AddWrappers("EVALUATION") & StrWhere("EVALUATION", 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("") Response.Write("" & strTableName & "") Response.Write("") Response.Write(""" then Response.Write(" onLoad=""if (document.frmAdmin.SearchFor != null) document.frmAdmin.SearchFor.focus();""") Response.Write(">") %>
>
>
<% ' 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 %>
"> <% If Session("UserID")<>"" Then %> <% End If %>
 Logged as <%=Session("UserID")%>   Log out   Advanced search   Printer-friendly version  
<%' Pagination: Write Search result Header%> <% set rsDetails = setupRs(strConnection,strSQL,PageSize) Call ReportError %>
Search for:     Details found: <%=maxRecords%>
Page <%=mypage%> of <%=maxpages%>
Records Per Page:
<% ' quotes for search and edit fields for i=0 to rsDetails.Fields.Count-1 strNeedQuotes=IfNeedQuotes(rsDetails.Fields(i).Type) Response.Write "" & vbCRLF Response.Write "" & vbCRLF if rsDetails.Fields(i).Name=strKeyField or rsDetails.Fields(i).Name=strKeyField2 or rsDetails.Fields(i).Name=strKeyField3 then %> <% end if next %>
<% for i=0 to rsDetails.Fields.Count-1 strNeedQuotes=IfNeedQuotes(rsDetails.Fields(i).Type) Response.Write "" & vbCrLF Response.Write "" & vbCRLF next %>
> >
<% call WriteTableHeader call loopRs(rsDetails, CLng(PageSize)) %> <% rsDetails.Close Set rsDetails = Nothing %>
<%' 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 %> " else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("ID")%> <% if Request.Form("orderby")="ID" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("ID").Attributes and 128) and ( rsDetails.Fields("ID").Type = 204 or rsDetails.Fields("ID").Type=205 ) then Response.Write Label("ID") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("DATE")%> <% if Request.Form("orderby")="DATE" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("DATE").Attributes and 128) and ( rsDetails.Fields("DATE").Type = 204 or rsDetails.Fields("DATE").Type=205 ) then Response.Write Label("DATE") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("TIME")%> <% if Request.Form("orderby")="TIME" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("TIME").Attributes and 128) and ( rsDetails.Fields("TIME").Type = 204 or rsDetails.Fields("TIME").Type=205 ) then Response.Write Label("TIME") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("PLACE")%> <% if Request.Form("orderby")="PLACE" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("PLACE").Attributes and 128) and ( rsDetails.Fields("PLACE").Type = 204 or rsDetails.Fields("PLACE").Type=205 ) then Response.Write Label("PLACE") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("Province")%> <% if Request.Form("orderby")="Province" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("Province").Attributes and 128) and ( rsDetails.Fields("Province").Type = 204 or rsDetails.Fields("Province").Type=205 ) then Response.Write Label("Province") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("TYPE")%> <% if Request.Form("orderby")="TYPE" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("TYPE").Attributes and 128) and ( rsDetails.Fields("TYPE").Type = 204 or rsDetails.Fields("TYPE").Type=205 ) then Response.Write Label("TYPE") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("EVALUATION")%> <% if Request.Form("orderby")="EVALUATION" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("EVALUATION").Attributes and 128) and ( rsDetails.Fields("EVALUATION").Type = 204 or rsDetails.Fields("EVALUATION").Type=205 ) then Response.Write Label("EVALUATION") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("SOURCE1")%> <% if Request.Form("orderby")="SOURCE1" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("SOURCE1").Attributes and 128) and ( rsDetails.Fields("SOURCE1").Type = 204 or rsDetails.Fields("SOURCE1").Type=205 ) then Response.Write Label("SOURCE1") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("PICTURE")%> <% if Request.Form("orderby")="PICTURE" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("PICTURE").Attributes and 128) and ( rsDetails.Fields("PICTURE").Type = 204 or rsDetails.Fields("PICTURE").Type=205 ) then Response.Write Label("PICTURE") & "
<% 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 %> onmouseover="rowRollover(<%=iNumberOfRows%>, 1);" onmouseout="rowRollover(<%=iNumberOfRows%>, 0);" id="tr_<%=iNumberOfRows%>"> <% if IsBinaryField(rsData.Fields("ID")) then Response.Write CreateImageControl(rsData, "ID") else Response.Write ProcessLargeText(GetData(rsData.Fields("ID"), "")) end if %> <% if IsBinaryField(rsData.Fields("DATE")) then Response.Write CreateImageControl(rsData, "DATE") else Response.Write ProcessLargeText(GetData(rsData.Fields("DATE"), "")) end if %> <% if IsBinaryField(rsData.Fields("TIME")) then Response.Write CreateImageControl(rsData, "TIME") else Response.Write ProcessLargeText(GetData(rsData.Fields("TIME"), "")) end if %> <% if IsBinaryField(rsData.Fields("PLACE")) then Response.Write CreateImageControl(rsData, "PLACE") else Response.Write ProcessLargeText(GetData(rsData.Fields("PLACE"), "")) end if %> <% if IsBinaryField(rsData.Fields("Province")) then Response.Write CreateImageControl(rsData, "Province") else Response.Write ProcessLargeText(GetData(rsData.Fields("Province"), "")) end if %> <% if IsBinaryField(rsData.Fields("TYPE")) then Response.Write CreateImageControl(rsData, "TYPE") else Response.Write ProcessLargeText(GetData(rsData.Fields("TYPE"), "")) end if %> <% if IsBinaryField(rsData.Fields("EVALUATION")) then Response.Write CreateImageControl(rsData, "EVALUATION") else Response.Write ProcessLargeText(GetData(rsData.Fields("EVALUATION"), "")) end if %> <% if IsBinaryField(rsData.Fields("SOURCE1")) then Response.Write CreateImageControl(rsData, "SOURCE1") else Response.Write ProcessLargeText(GetData(rsData.Fields("SOURCE1"), "")) 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 %>