% Option Explicit %>
<% if session("authenticated") <> 1 then response.redirect "affmain.asp" %>
<%
Dim Conn
Dim RS
Dim sql
Dim sql1
Dim sql_where
Dim sqll_where
Dim gState
Dim gCountry
Sub ProcessPage
if request.form("SubmitState") <> "" or request.form("SubmitCountry") <> "" then
ShowResultsPage
else
ShowSearchPage
end if
End Sub
Sub Build_Search_Criteria
if request.form("SubmitState") <> "" then
Build_Search_By_State
elseif request.form("SubmitCountry") <> "" then
Build_Search_By_Country
end if
End Sub
Sub Build_Search_By_State
sql_where = " where "
Build_State
if sql1 <> "" then
if sql_where <> " where " then
sql_where = sql_where & " and " & sql1
else
sql_where = sql_where & sql1
end if
end if
'response.write "DEBUG: sql_where=" & sql_where & "
"
if sql_where = " where " then sql_where = " "
sql = "select * from v_SB32StateDistr " & sql_where & " order by country, DistrByState "
'response.write "
DEBUG: " & sql
End Sub
Sub Build_Search_By_Country
sql_where = " where "
Build_Country
if sql1 <> "" then
if sql_where <> " where " then
sql_where = sql_where & " and " & sql1
else
sql_where = sql_where & sql1
end if
end if
'response.write "DEBUG: sql_where=" & sql_where & "
"
if sql_where = " where " then sql_where = " "
sql = "select * from v_SB32StateDistr " & sql_where & " order by country, DistrByState, city "
'response.write "DEBUG: sql=" & sql & "
"
End Sub
Sub Build_State
Dim Key
Dim Keys
Keys = ""
sql1 = ""
if request.form("cboState") = "" then
sql1 = "(country = '' or country is NULL)"
gState = "All States"
exit sub
end if
for each Key in request.form("cboState")
if Key = "all" then
sql1 = "(country = '' or country is NULL)"
gState = "All States"
exit sub
else
Keys = Keys & Key & "/,/"
end if
next
Keys = Replace(Keys, "/,/", "','")
Keys = Keys & "//"
Keys = Replace(Keys, "','//", "")
if Keys = "//" then
Keys = ""
sql1 = ""
gState = "All States"
exit sub
end if
sql1 = " DistrByState in ('" & Keys & "')"
End Sub
Sub Build_Country
Dim Key
Dim Keys
Keys = ""
sql1 = ""
if request.form("cboCountry") = "" then
sql1 = "country <> ''"
gState = "All Countries Outside the U.S."
exit sub
end if
for each Key in request.form("cboCountry")
if Key = "all" then
sql1 = "country <> ''"
gState = "All Countries Outside the U.S."
exit sub
else
Keys = Keys & Key & "/,/"
end if
next
Keys = Replace(Keys, "/,/", "','")
Keys = Keys & "//"
Keys = Replace(Keys, "','//", "")
if Keys = "//" then
Keys = ""
sql1 = ""
gState = "All Countries Outside the U.S."
exit sub
end if
sql1 = " country in ('" & Keys & "')"
End Sub
Sub ShowResultsPage
Dim current_city
Dim current_state
Dim current_country
Dim connString
Build_Search_Criteria
Set Conn = Server.CreateObject("ADODB.Connection")
connString = "greenearth"
Conn.open connString,"",""
Set RS = Conn.Execute(sql)
if RS.EOF then
response.write "
No cleaners were found matching your criteria.
" exit sub end if current_state = "" current_country = "" while (not RS.EOF) 'if gCountry <> "" then ' Response.Write "" current_country = rs("Country") end if if current_state <> rs("DistrByState") then response.write "" & rs("Country") & "
" current_state = rs("DistrByState") end if %>"& rs("DistrByState") & "
| Name of Cleaner: | <%response.write rs("Location DBA")%> | |
| Address : | <%response.write rs("Address1") %><% if rs("Address2") <> "" then response.write " " & rs("Address2") %> |
|
| City/State/Zip : | <%response.write rs("City") & ", " & rs("State") & " " & rs("Postal Code") %> | |
| Phone Number: | <%response.write rs("Phone")%> |
<% RS.MoveNext wend RS.Close Set RS = nothing Conn.Close Set Conn = nothing End Sub Sub ShowSearchPage %> <% End Sub %>
| |||||||
|
|||||||