<% If Session("project1_status") <> "login" Then Response.Redirect "login.asp" %> <% Response.expires = 0 Response.expiresabsolute = Now() - 1 Response.addHeader "pragma", "no-cache" Response.addHeader "cache-control", "private" Response.CacheControl = "no-cache" %> <% displayRecs = 20 recRange = 10 %> <% dbwhere = "" masterdetailwhere = "" searchwhere = "" a_search = "" b_search = "" whereClause = "" %> <% ' Get search criteria for basic search pSearch = Request.QueryString("psearch") pSearchType = Request.QueryString("psearchType") If pSearch <> "" Then pSearch = Replace(pSearch,"'","''") pSearch = Replace(pSearch,"[","[[]") If pSearchType <> "" Then While InStr(pSearch, " ") > 0 pSearch = Replace(pSearch, " ", " ") Wend arpSearch = Split(Trim(pSearch), " ") For Each kw In arpSearch b_search = b_search & "(" b_search = b_search & "[inquirytype] LIKE '%" & Trim(kw) & "%' OR " b_search = b_search & "[other] LIKE '%" & Trim(kw) & "%' OR " b_search = b_search & "[timeframe] LIKE '%" & Trim(kw) & "%' OR " b_search = b_search & "[name] LIKE '%" & Trim(kw) & "%' OR " b_search = b_search & "[street] LIKE '%" & Trim(kw) & "%' OR " b_search = b_search & "[city] LIKE '%" & Trim(kw) & "%' OR " b_search = b_search & "[state] LIKE '%" & Trim(kw) & "%' OR " b_search = b_search & "[zip] LIKE '%" & Trim(kw) & "%' OR " b_search = b_search & "[daytimephone] LIKE '%" & Trim(kw) & "%' OR " b_search = b_search & "[eveningphone] LIKE '%" & Trim(kw) & "%' OR " b_search = b_search & "[email] LIKE '%" & Trim(kw) & "%' OR " b_search = b_search & "[besttimetocontact] LIKE '%" & Trim(kw) & "%' OR " b_search = b_search & "[comments] LIKE '%" & Trim(kw) & "%' OR " b_search = b_search & "[notes] LIKE '%" & Trim(kw) & "%' OR " If Right(b_search, 4)=" OR " Then b_search = Left(b_search, Len(b_search)-4) b_search = b_search & ") " & pSearchType & " " Next Else b_search = b_search & "[inquirytype] LIKE '%" & pSearch & "%' OR " b_search = b_search & "[other] LIKE '%" & pSearch & "%' OR " b_search = b_search & "[timeframe] LIKE '%" & pSearch & "%' OR " b_search = b_search & "[name] LIKE '%" & pSearch & "%' OR " b_search = b_search & "[street] LIKE '%" & pSearch & "%' OR " b_search = b_search & "[city] LIKE '%" & pSearch & "%' OR " b_search = b_search & "[state] LIKE '%" & pSearch & "%' OR " b_search = b_search & "[zip] LIKE '%" & pSearch & "%' OR " b_search = b_search & "[daytimephone] LIKE '%" & pSearch & "%' OR " b_search = b_search & "[eveningphone] LIKE '%" & pSearch & "%' OR " b_search = b_search & "[email] LIKE '%" & pSearch & "%' OR " b_search = b_search & "[besttimetocontact] LIKE '%" & pSearch & "%' OR " b_search = b_search & "[comments] LIKE '%" & pSearch & "%' OR " b_search = b_search & "[notes] LIKE '%" & pSearch & "%' OR " End If End If If Right(b_search, 4) = " OR " Then b_search = Left(b_search, Len(b_search)-4) If Right(b_search, 5) = " AND " Then b_search = Left(b_search, Len(b_search)-5) %> <% ' Build search criteria If a_search <> "" Then searchwhere = a_search ' Advanced search ElseIf b_search <> "" Then searchwhere = b_search ' Basic search End If ' Save search criteria If searchwhere <> "" Then Session("contacts_searchwhere") = searchwhere ' Reset start record counter (new search) startRec = 1 Session("contacts_REC") = startRec Else searchwhere = Session("contacts_searchwhere") End If %> <% ' Get clear search cmd If Request.QueryString("cmd").Count > 0 Then cmd = Request.QueryString("cmd") If UCase(cmd) = "RESET" Then ' Reset search criteria searchwhere = "" Session("contacts_searchwhere") = searchwhere ElseIf UCase(cmd) = "RESETALL" Then ' Reset search criteria searchwhere = "" Session("contacts_searchwhere") = searchwhere End If ' Reset start record counter (reset command) startRec = 1 Session("contacts_REC") = startRec End If ' Build dbwhere If masterdetailwhere <> "" Then dbwhere = dbwhere & "(" & masterdetailwhere & ") AND " End If If searchwhere <> "" Then dbwhere = dbwhere & "(" & searchwhere & ") AND " End If If Len(dbwhere) > 5 Then dbwhere = Mid(dbwhere, 1, Len(dbwhere)-5) ' Trim rightmost AND End If %> <% ' Load Default Order DefaultOrder = "" DefaultOrderType = "" ' No Default Filter DefaultFilter = "" ' Check for an Order parameter OrderBy = "" If Request.QueryString("order").Count > 0 Then OrderBy = Request.QueryString("order") ' Check if an ASC/DESC toggle is required If Session("contacts_OB") = OrderBy Then If Session("contacts_OT") = "ASC" Then Session("contacts_OT") = "DESC" Else Session("contacts_OT") = "ASC" End if Else Session("contacts_OT") = "ASC" End If Session("contacts_OB") = OrderBy Session("contacts_REC") = 1 Else OrderBy = Session("contacts_OB") If OrderBy = "" Then OrderBy = DefaultOrder Session("contacts_OB") = OrderBy Session("contacts_OT") = DefaultOrderType End If End If ' Open connection to the database Set conn = Server.CreateObject("ADODB.Connection") conn.Open xDb_Conn_Str ' Build SQL strsql = "SELECT * FROM [contacts]" If DefaultFilter <> "" Then whereClause = whereClause & "(" & DefaultFilter & ") AND " End If If dbwhere <> "" Then whereClause = whereClause & "(" & dbwhere & ") AND " End If If Right(whereClause, 5)=" AND " Then whereClause = Left(whereClause, Len(whereClause)-5) If whereClause <> "" Then strsql = strsql & " WHERE " & whereClause End If If OrderBy <> "" Then strsql = strsql & " ORDER BY [" & OrderBy & "] " & Session("contacts_OT") End If 'Response.Write strsql Set rs = Server.CreateObject("ADODB.Recordset") rs.cursorlocation = 3 rs.Open strsql, conn, 1, 2 totalRecs = rs.RecordCount ' Check for a START parameter If Request.QueryString("start").Count > 0 Then startRec = Request.QueryString("start") Session("contacts_REC") = startRec ElseIf Request.QueryString("pageno").Count > 0 Then pageno = Request.QueryString("pageno") If IsNumeric(pageno) Then startRec = (pageno-1)*displayRecs+1 If startRec <= 0 Then startRec = 1 ElseIf startRec >= ((totalRecs-1)\displayRecs)*displayRecs+1 Then startRec = ((totalRecs-1)\displayRecs)*displayRecs+1 End If Session("contacts_REC") = startRec Else startRec = Session("contacts_REC") If Not IsNumeric(startRec) Or startRec = "" Then startRec = 1 ' Reset start record counter Session("contacts_REC") = startRec End If End If Else startRec = Session("contacts_REC") If Not IsNumeric(startRec) Or startRec = "" Then startRec = 1 'Reset start record counter Session("contacts_REC") = startRec End If End If %>

TABLE: contacts

Quick Search (*)   Show all
 Exact phrase  All words  Any word
<% ' Avoid starting record > total records If CLng(startRec) > CLng(totalRecs) Then startRec = totalRecs End If ' Set the last record to display stopRec = startRec + displayRecs - 1 ' Move to first record directly for performance reason recCount = startRec - 1 If Not rs.Eof Then rs.MoveFirst rs.Move startRec - 1 End If recActual = 0 Do While (Not rs.Eof) And (recCount < stopRec) recCount = recCount + 1 If CLng(recCount) >= CLng(startRec) Then recActual = recActual + 1 %> <% ' Set row color bgcolor = "#FFFFFF" %> <% ' Display alternate color for rows If recCount Mod 2 <> 0 Then bgcolor = "#F5F5F5" End If %> <% ' Load Key for record key = rs("contactID") x_contactID = rs("contactID") x_datestamp = rs("datestamp") x_inquirytype = rs("inquirytype") x_other = rs("other") x_timeframe = rs("timeframe") x_name = rs("name") x_street = rs("street") x_city = rs("city") x_state = rs("state") x_zip = rs("zip") x_daytimephone = rs("daytimephone") x_eveningphone = rs("eveningphone") x_email = rs("email") x_besttimetocontact = rs("besttimetocontact") x_comments = rs("comments") x_notes = rs("notes") %> <% End If rs.MoveNext Loop %>
" style="color: #FFFFFF;">contact ID <% If OrderBy = "contactID" Then %><% If Session("contacts_OT") = "ASC" Then %>5<% ElseIf Session("contacts_OT") = "DESC" Then %>6<% End If %><% End If %> " style="color: #FFFFFF;">datestamp <% If OrderBy = "datestamp" Then %><% If Session("contacts_OT") = "ASC" Then %>5<% ElseIf Session("contacts_OT") = "DESC" Then %>6<% End If %><% End If %> " style="color: #FFFFFF;">Type of Inquiry (*)<% If OrderBy = "inquirytype" Then %><% If Session("contacts_OT") = "ASC" Then %>5<% ElseIf Session("contacts_OT") = "DESC" Then %>6<% End If %><% End If %> " style="color: #FFFFFF;">Proposed Time Frame (*)<% If OrderBy = "timeframe" Then %><% If Session("contacts_OT") = "ASC" Then %>5<% ElseIf Session("contacts_OT") = "DESC" Then %>6<% End If %><% End If %> " style="color: #FFFFFF;">Name (*)<% If OrderBy = "name" Then %><% If Session("contacts_OT") = "ASC" Then %>5<% ElseIf Session("contacts_OT") = "DESC" Then %>6<% End If %><% End If %> " style="color: #FFFFFF;">Street (*)<% If OrderBy = "street" Then %><% If Session("contacts_OT") = "ASC" Then %>5<% ElseIf Session("contacts_OT") = "DESC" Then %>6<% End If %><% End If %> " style="color: #FFFFFF;">City (*)<% If OrderBy = "city" Then %><% If Session("contacts_OT") = "ASC" Then %>5<% ElseIf Session("contacts_OT") = "DESC" Then %>6<% End If %><% End If %> " style="color: #FFFFFF;">State (*)<% If OrderBy = "state" Then %><% If Session("contacts_OT") = "ASC" Then %>5<% ElseIf Session("contacts_OT") = "DESC" Then %>6<% End If %><% End If %> " style="color: #FFFFFF;">Zip (*)<% If OrderBy = "zip" Then %><% If Session("contacts_OT") = "ASC" Then %>5<% ElseIf Session("contacts_OT") = "DESC" Then %>6<% End If %><% End If %> " style="color: #FFFFFF;">Daytime Telephone (*)<% If OrderBy = "daytimephone" Then %><% If Session("contacts_OT") = "ASC" Then %>5<% ElseIf Session("contacts_OT") = "DESC" Then %>6<% End If %><% End If %> " style="color: #FFFFFF;">Evening Telephone (*)<% If OrderBy = "eveningphone" Then %><% If Session("contacts_OT") = "ASC" Then %>5<% ElseIf Session("contacts_OT") = "DESC" Then %>6<% End If %><% End If %> " style="color: #FFFFFF;">E-Mail (*)<% If OrderBy = "email" Then %><% If Session("contacts_OT") = "ASC" Then %>5<% ElseIf Session("contacts_OT") = "DESC" Then %>6<% End If %><% End If %> " style="color: #FFFFFF;">Best Time to Contact (*)<% If OrderBy = "besttimetocontact" Then %><% If Session("contacts_OT") = "ASC" Then %>5<% ElseIf Session("contacts_OT") = "DESC" Then %>6<% End If %><% End If %>        
<% Response.Write x_contactID %>  <% Response.Write x_datestamp %>  <% Response.Write x_inquirytype %>  <% Response.Write x_timeframe %>  <% Response.Write x_name %>  <% Response.Write x_street %>  <% Response.Write x_city %>  <% Response.Write x_state %>  <% Response.Write x_zip %>  <% Response.Write x_daytimephone %>  <% Response.Write x_eveningphone %>  <% Response.Write x_email %>  <% Response.Write x_besttimetocontact %>  ">View ">Edit ">Copy ">Delete
<% ' Close recordset and connection rs.Close Set rs = Nothing conn.Close Set conn = Nothing %>
<% If totalRecs > 0 Then rsEof = (totalRecs < (startRec + displayRecs)) PrevStart = startRec - displayRecs If PrevStart < 1 Then PrevStart = 1 NextStart = startRec + displayRecs If NextStart > totalRecs Then NextStart = startRec LastStart = ((totalRecs-1)\displayRecs)*displayRecs+1 %>
<% If CLng(startRec)=1 Then %> <% Else %> <% End If %> <% If CLng(PrevStart) = CLng(startRec) Then %> <% Else %> <% End If %> <% If CLng(NextStart) = CLng(startRec) Then %> <% Else %> <% End If %> <% If CLng(LastStart) = CLng(startRec) Then %> <% Else %> <% End If %>
Page  FirstFirstPreviousPrevious NextNextLastLastAdd new  of <%=(totalRecs-1)\displayRecs+1%>
<% If CLng(startRec) > CLng(totalRecs) Then startRec = totalRecs stopRec = startRec + displayRecs - 1 recCount = totalRecs - 1 If rsEOF Then recCount = totalRecs If stopRec > recCount Then stopRec = recCount %> Records <%= startRec %> to <%= stopRec %> of <%= totalRecs %> <% Else %> No records found

Add new

<% End If %>