<%Dim strReferringPage%> <%strThisPage = Request.ServerVariables("SCRIPT_NAME")%> <%if strReferringPage ="" then%> <%strReferringPage = Request.ServerVariables("HTTP_REFERER")%> <%end if%> <%if Session("ReferringPage") ="" then%> <%Session("ReferringPage") = Request.ServerVariables("HTTP_REFERER")%> <%End if%> <%if Request.ServerVariables("HTTP_REFERER") = "" then%> <%Response.Redirect "http://www.futonsofabedsdirect.co.uk"%> <%end if%> <%if left(Request.ServerVariables("HTTP_REFERER"),37)<>"http://www.futonsofabedsdirect.co.uk/" then%> <%Response.Redirect (strReferringPage)%> <% end if%> <%sFileName = "FSB_SwatchQuery.asp"%> <%sTemplateFileName = "Swatch-Request-Template.html"%> <%sAction = GetParam("FormAction")%> <%sForm = GetParam("FormName")%> <%sCustomersErr = ""%> <%Select Case sForm%> <% Case "Customers"%> <% CustomersAction(sAction)%> <%end select%> <%LoadTemplate sAppPath & sTemplateFileName, "main"%> <%SetVar "FileName", sFileName%> <%Customers_Show%> <%Parse "main", False%> <%Response.write PrintVar("main")%> <%cn.Close%> <%Set cn = Nothing%> <%UnloadTemplate%> <%Sub CustomersAction(sAction)%> <% Dim bExecSQL: bExecSQL = true%> <% Dim sActionFileName : sActionFileName = ""%> <% Dim sWhere : sWhere = "" %> <%Dim bErr : bErr = False%> <% Dim pPKCustomerID : pPKCustomerID = ""%> <% Dim fldTitleOfCourtesy : fldTitleOfCourtesy = ""%> <% Dim fldFirstName : fldFirstName = ""%> <% Dim fldOrganisation : fldOrganisation = ""%> <% Dim fldProperty : fldProperty = ""%> <% Dim fldStreet : fldStreet = ""%> <% Dim fldLocality : fldLocality = ""%> <% Dim fldTown : fldTown = ""%> <% Dim fldCounty : fldCounty = ""%> <% Dim fldPostCode : fldPostCode = ""%> <% Dim fldWeb : fldWeb = ""%> <% Dim fldNotes : fldNotes = ""%> <% Dim fldRecieveEmails : fldRecieveEmails = ""%> <% Dim fldReferrer : fldReferrer = Session("ReferringPage")%> <% Dim Page%> <% Page = "Swatch-thankyou.html"%> <% sActionFileName = Page%> <% if sAction = "cancel" then%> <% cn.Close%> <% Set cn = Nothing%> <% response.redirect sActionFileName%> <% end if%> <% fldTitleOfCourtesy = GetParam("TitleOfCourtesy")%> <% fldFirstName = GetParam("FirstName")%> <% fldOrganisation = GetParam("Organisation")%> <% fldProperty = GetParam("Property")%> <% fldStreet = GetParam("Street")%> <% fldLocality = GetParam("Locality")%> <% fldTown = GetParam("Town")%> <% fldCounty = GetParam("County")%> <% fldPostCode = GetParam("PostCode")%> <% fldWeb = GetParam("Web")%> <%fldNotes = GetParam("Notes")%> <% fldRecieveEmails = GetParam("RecieveEmails")%> <% if sAction = "insert" or sAction = "update" then%> <% sCustomersErr="Please enter your - "%> <% if IsEmpty(fldTitleOfCourtesy) then%> <% sCustomersErr = sCustomersErr & "Title," %> <% end if%> <% if IsEmpty(fldOrganisation) then%> <% sCustomersErr = sCustomersErr & "Surname, "%> <% end if%> <% if IsEmpty(fldProperty) then%> <% sCustomersErr = sCustomersErr & "House Name or Number, "%> <% end if%> <% if IsEmpty(fldPostCode) then%> <% sCustomersErr = sCustomersErr & "Postcode, "%> <% end if%> <% if IsEmpty(fldNotes) then%> <% sCustomersErr = sCustomersErr & "Swatches requirements, "%> <% end if%> <% If Len(fldWeb) < 5 Then%> <% sCustomersErr = sCustomersErr & "Full Email Address, "%> <% Else%> <% If Instr(1, fldWeb, " ") <> 0 Then%> <% sCustomersErr = sCustomersErr & "Full Email Address, "%> <% Else%> <% If InStr(1, fldWeb, "@", 1) < 2 Then%> <% sCustomersErr = sCustomersErr & "Full Email Address, "%> <% Else%> <% If InStrRev(fldWeb, ".") < InStr(1, fldWeb, "@", 1) + 2 Then%> <% sCustomersErr = sCustomersErr & "Full Email Address, "%> <% End If%> <% End If%> <% End If%> <% End If%> <% if sCustomersErr="Please enter your - " then%> <% sCustomersErr=""%> <% end if%> <% If len(sCustomersErr) > 0 then%> <% exit sub%> <% end if%> <% end if%> <% select case sAction%> <% case "insert"%> <% sSQL = "insert into Customers (" & _%> <% "[TitleOfCourtesy]," & _%> <% "[FirstName]," & _%> <% "[Organisation]," & _%> <% "[Property]," & _%> <% "[Street]," & _%> <% "[Locality]," & _%> <% "[Town]," & _%> <% "[County]," & _%> <% "[PostCode]," & _%> <% "[Web]," & _%> <% "[Notes]," & _%> <% "[Referrer]," & _%> <% "[RecieveEmails])" & _%> <% " values (" & _%> <% ToSQL(fldTitleOfCourtesy, "Text") & "," & _%> <% ToSQL(fldFirstName, "Text") & "," & _%> <% ToSQL(fldOrganisation, "Text") & "," & _%> <% ToSQL(fldProperty, "Text") & "," & _%> <% ToSQL(fldStreet, "Text") & "," & _%> <% ToSQL(fldLocality, "Text") & "," & _%> <% ToSQL(fldTown, "Text") & "," & _%> <% ToSQL(fldCounty, "Text") & "," & _%> <% ToSQL(fldPostCode, "Text") & "," & _%> <% ToSQL(fldWeb, "Text") & "," & _%> <% ToSQL(fldNotes, "Text") & "," & _%> <% ToSQL(fldReferrer, "Text") & "," & _%> <% ToSQL(fldRecieveEmails, "Text") & _%> <% ")"%> <% end select%> <%if len(sCustomersErr) > 0 then Exit Sub%> <% on error resume next%> <% if bExecSQL then %> <% cn.execute sSQL%> <% end if%> <% sCustomersErr = ProcessError%> <% on error goto 0%> <% if len(sCustomersErr) > 0 then Exit Sub%> <% cn.Close%> <% Set cn = Nothing%> <% response.redirect sActionFileName%> <%end sub%> <%Sub Customers_Show()%> <% Dim sWhere : sWhere = ""%> <% Dim sFormTitle: sFormTitle = "Customers"%> <% Dim bPK : bPK = True%> <%if sCustomersErr = "" then%> <% pCustomerID = GetParam("CustomerID")%> <% SetVar "CustomersError", ""%> <% else%> <% fldCustomerID = GetParam("CustomerID")%> <% fldTitleOfCourtesy = GetParam("TitleOfCourtesy")%> <% fldFirstName = GetParam("FirstName")%> <% fldOrganisation = GetParam("Organisation")%> <% fldProperty = GetParam("Property")%> <% fldStreet = GetParam("Street")%> <% fldLocality = GetParam("Locality")%> <% fldTown = GetParam("Town")%> <% fldCounty = GetParam("County")%> <% fldPostCode = GetParam("PostCode")%> <% fldWeb = GetParam("Web")%> <% fldNotes = GetParam("Notes")%> <%fldRecieveEmails = GetParam("RecieveEmails")%> <% fldReferrer = GetParam("Referrer")%> <% pCustomerID = GetParam("PK_CustomerID")%> <% SetVar "sCustomersErr", sCustomersErr%> <% SetVar "FormTitle", sFormTitle%> <% Parse "CustomersError", False%> <% end if%> <% if IsEmpty(pCustomerID) then bPK = False%> <% sWhere = sWhere & "CustomerID=" & ToSQL(pCustomerID, "Number")%> <% SetVar "PK_CustomerID", pCustomerID%> <% SetVar "FormTitle", sFormTitle%> <% sSQL = "select * from Customers where " & sWhere%> <% openrs rs, sSQL%> <% bIsUpdateMode = (bPK and not(sAction = "insert" and sForm = "Customers") and not rs.eof)%> <% if bIsUpdateMode then%> <% fldCustomerID = GetValue(rs, "CustomerID")%> <% if sCustomersErr = "" then%> <% fldTitleOfCourtesy = GetValue(rs, "TitleOfCourtesy")%> <% fldFirstName = GetValue(rs, "FirstName")%> <% fldOrganisation = GetValue(rs, "Organisation")%> <% fldProperty = GetValue(rs, "Property")%> <% fldStreet = GetValue(rs, "Street")%> <% fldLocality = GetValue(rs, "Locality")%> <% fldTown = GetValue(rs, "Town")%> <% fldCounty = GetValue(rs, "County")%> <% fldPostCode = GetValue(rs, "PostCode")%> <% fldWeb = GetValue(rs, "Web")%> <% fldNotes = GetValue(rs, "Notes")%> <% fldRecieveEmails = GetValue(rs, "RecieveEmails")%> <% fldReferrer = GetValue(rs, "Referrer")%> <% end if%> <% SetVar "CustomersDelete", ""%> <% SetVar "CustomersUpdate", ""%> <% SetVar "CustomersInsert", ""%> <% else%> <% SetVar "CustomersEdit", ""%> <% Parse "CustomersInsert", False%> <% end if%> <% Parse "CustomersCancel", false%>%> <% SetVar "CustomerID", ToHTML(fldCustomerID)%> <% SetVar "TitleOfCourtesy", ToHTML(fldTitleOfCourtesy)%> <% SetVar "FirstName", ToHTML(fldFirstName)%> <% SetVar "Organisation", ToHTML(fldOrganisation)%> <% SetVar "Property", ToHTML(fldProperty)%> <% SetVar "Street", ToHTML(fldStreet)%> <% SetVar "Locality", ToHTML(fldLocality)%> <% SetVar "Town", ToHTML(fldTown)%> <% SetVar "County", ToHTML(fldCounty)%> <% SetVar "PostCode", ToHTML(fldPostCode)%> <% SetVar "Web", ToHTML(fldWeb)%> <% SetVar "Notes", ToHTML(fldNotes)%> <% SetVar "RecieveEmails", ToHTML(fldRecieveEmails)%> <% SetVar "Referrer", ToHTML(fldReferrer)%> <% Parse "FormCustomers", False%> <%Set rs = Nothing%> <%End Sub%>