<% ' ' Filename: index.asp ' Generated with CodeCharge 2.0.7 ' ASP 2.0 & Templates.ccp build 11/30/2001 ' '------------------------------- ' index CustomIncludes begin %> <% ' index CustomIncludes end '------------------------------- '=============================== ' Save Page and File Name available into variables '------------------------------- sFileName = "index.asp" sTemplateFileName = "index.html" '=============================== '=============================== ' index PageSecurity begin ' index PageSecurity end '=============================== '=============================== ' index Open Event begin ' index Open Event end '=============================== '=============================== ' index OpenAnyPage Event begin ' index OpenAnyPage Event end '=============================== '=============================== 'Save the name of the form and type of action into the variables '------------------------------- sAction = GetParam("FormAction") sForm = GetParam("FormName") '=============================== ' index Show begin '=============================== ' Perform the form's action '------------------------------- ' Initialize error variables '------------------------------- sGHBErr = "" '------------------------------- ' Select the FormAction '------------------------------- Select Case sForm Case "GHB" GHBAction(sAction) end select '=============================== '=============================== ' Display page '------------------------------- ' Load HTML template for this page '------------------------------- LoadTemplate sAppPath & sTemplateFileName, "main" '------------------------------- ' Load HTML template of Header and Footer '------------------------------- '------------------------------- SetVar "FileName", sFileName '------------------------------- ' Step through each form '------------------------------- GHB_Show '------------------------------- ' Process page templates '------------------------------- Parse "main", False '------------------------------- ' Output the page to the browser '------------------------------- Response.write PrintVar("main") ' index Show end '------------------------------- ' Destroy all object variables '------------------------------- ' index Close Event begin ' index Close Event end cn.Close Set cn = Nothing UnloadTemplate '=============================== '=============================== ' Action of the Record Form '------------------------------- Sub GHBAction(sAction) '------------------------------- ' Initialize variables '------------------------------- Dim bExecSQL: bExecSQL = true Dim sActionFileName : sActionFileName = "" Dim sWhere : sWhere = "" Dim bErr : bErr = False Dim pPKID : pPKID = "" Dim fldPrefix : fldPrefix = "" Dim fldFirstName : fldFirstName = "" Dim fldLastName : fldLastName = "" Dim fldEmail : fldEmail = "" Dim fldAddress : fldAddress = "" Dim fldCity : fldCity = "" Dim fldState : fldState = "" Dim fldZip : fldZip = "" Dim fldCounty : fldCounty = "" Dim fldHome : fldHome = "" Dim fldWork : fldWork = "" Dim fldComments : fldComments = "" '------------------------------- '------------------------------- ' GHB Action begin '------------------------------- sActionFileName = "ThankYou.asp" '------------------------------- ' CANCEL action '------------------------------- if sAction = "cancel" then '------------------------------- ' GHB BeforeCancel Event begin ' GHB BeforeCancel Event end '------------------------------- cn.Close Set cn = Nothing response.redirect sActionFileName end if '------------------------------- '------------------------------- ' Build WHERE statement '------------------------------- if sAction = "update" or sAction = "delete" then pPKID = GetParam("PK_ID") if IsEmpty(pPKID) then exit sub sWhere = "ID=" & ToSQL(pPKID, "Number") end if '------------------------------- '------------------------------- ' Load all form fields into variables '------------------------------- fldPrefix = GetParam("Prefix") fldFirstName = GetParam("FirstName") fldLastName = GetParam("LastName") fldEmail = GetParam("Email") fldAddress = GetParam("Address") fldCity = GetParam("City") fldState = GetParam("State") fldZip = GetParam("Zip") fldCounty = GetParam("County") fldHome = GetParam("Home") fldWork = GetParam("Work") fldComments = GetParam("Comments") '------------------------------- ' Validate fields '------------------------------- if sAction = "insert" or sAction = "update" then '------------------------------- ' GHB Check Event begin ' GHB Check Event end '------------------------------- If len(sGHBErr) > 0 then exit sub end if end if '------------------------------- '------------------------------- ' Create SQL statement '------------------------------- select case sAction case "insert" '------------------------------- ' GHB Insert Event begin ' GHB Insert Event end '------------------------------- sSQL = "insert into Candidates (" & _ "[Prefix]," & _ "[FirstName]," & _ "[LastName]," & _ "[Email]," & _ "[Address]," & _ "[City]," & _ "[State]," & _ "[Zip]," & _ "[County]," & _ "[Home]," & _ "[Work]," & _ "[Comments])" & _ " values (" & _ ToSQL(fldPrefix, "Text") & "," & _ ToSQL(fldFirstName, "Text") & "," & _ ToSQL(fldLastName, "Text") & "," & _ ToSQL(fldEmail, "Text") & "," & _ ToSQL(fldAddress, "Text") & "," & _ ToSQL(fldCity, "Text") & "," & _ ToSQL(fldState, "Text") & "," & _ ToSQL(fldZip, "Text") & "," & _ ToSQL(fldCounty, "Text") & "," & _ ToSQL(fldHome, "Text") & "," & _ ToSQL(fldWork, "Text") & "," & _ ToSQL(fldComments, "Memo") & _ ")" case "update" '------------------------------- ' GHB Update Event begin ' GHB Update Event end '------------------------------- sSQL = "update Candidates set " & _ "[Prefix]=" & ToSQL(fldPrefix, "Text") & _ ",[FirstName]=" & ToSQL(fldFirstName, "Text") & _ ",[LastName]=" & ToSQL(fldLastName, "Text") & _ ",[Email]=" & ToSQL(fldEmail, "Text") & _ ",[Address]=" & ToSQL(fldAddress, "Text") & _ ",[City]=" & ToSQL(fldCity, "Text") & _ ",[State]=" & ToSQL(fldState, "Text") & _ ",[Zip]=" & ToSQL(fldZip, "Text") & _ ",[County]=" & ToSQL(fldCounty, "Text") & _ ",[Home]=" & ToSQL(fldHome, "Text") & _ ",[Work]=" & ToSQL(fldWork, "Text") & _ ",[Comments]=" & ToSQL(fldComments, "Memo") sSQL = sSQL & " where " & sWhere case "delete" '------------------------------- ' GHB Delete Event begin ' GHB Delete Event end '------------------------------- sSQL = "delete from Candidates where " & sWhere end select '------------------------------- '------------------------------- ' GHB BeforeExecute Event begin ' GHB BeforeExecute Event end '------------------------------- '------------------------------- ' Execute SQL statement '------------------------------- if len(sGHBErr) > 0 then Exit Sub on error resume next if bExecSQL then cn.execute sSQL end if sGHBErr = ProcessError on error goto 0 if len(sGHBErr) > 0 then Exit Sub select case sAction case "insert" '------------------------------- ' GHB AfterInsert Event begin Set Mailer = Server.CreateObject("SMTPsvg.Mailer") Mailer.FromName = "Jim Herring" Mailer.FromAddress= "info@jimherring.ms" Mailer.RemoteHost = "localhost" Mailer.AddRecipient "Email", Request.Form("Email") Mailer.AddBCC "Josh Gregory", "josh@frontier.ms" Mailer.AddBCC "Jim Herring", "jim@jimherring.ms" Mailer.Subject = "Jim Herring" Mailer.BodyText = "Thank you for signing-up to receive e-mail updates from Jim Herring. Please visit the website often for new and updated information." & VbCrLf & VbCrLf & Request.Form("FirstName")&" "& Request.Form("LastName")& VbCrLf & Request.Form("Address")& VbCrLf & Request.Form("City")&", "& Request.Form("State")&" "& Request.Form("Zip")& VbCrLf & Request.Form("Home")& VbCrLf & Request.Form("Work") & VbCrLf & Request.Form("Email")& VbCrLf & Request.Form("Comments") if Mailer.SendMail then Response.Write "Mail sent..." else Response.Write "Mail send failure. Error was " & Mailer.Response end if ' GHB AfterInsert Event end '------------------------------- end select cn.Close Set cn = Nothing response.redirect sActionFileName '------------------------------- ' GHB Action end '------------------------------- end sub '=============================== '=============================== ' Display Record Form '------------------------------- Sub GHB_Show() '------------------------------- ' GHB Show begin '------------------------------- Dim sWhere : sWhere = "" Dim sFormTitle: sFormTitle = "GHB" Dim bPK : bPK = True Dim sPrefixDisplayValue: sPrefixDisplayValue = "" if request.querystring("Email") <> "" then fldEmail = request.querystring("Email") end if '------------------------------- ' Load primary key and form parameters '------------------------------- if sGHBErr = "" then pID = GetParam("ID") SetVar "GHBError", "" else fldID = GetParam("ID") fldPrefix = GetParam("Prefix") fldFirstName = GetParam("FirstName") fldLastName = GetParam("LastName") fldEmail = GetParam("Email") fldAddress = GetParam("Address") fldCity = GetParam("City") fldState = GetParam("State") fldZip = GetParam("Zip") fldCounty = GetParam("County") fldHome = GetParam("Home") fldWork = GetParam("Work") fldComments = GetParam("Comments") pID = GetParam("PK_ID") SetVar "sGHBErr", sGHBErr SetVar "FormTitle", sFormTitle Parse "GHBError", False end if '------------------------------- '------------------------------- ' Load all form fields '------------------------------- '------------------------------- ' Build WHERE statement if IsEmpty(pID) then bPK = False sWhere = sWhere & "ID=" & ToSQL(pID, "Number") SetVar "PK_ID", pID '------------------------------- '------------------------------- ' GHB Open Event begin ' GHB Open Event end '------------------------------- SetVar "FormTitle", sFormTitle '------------------------------- ' Build SQL statement and open recordset '------------------------------- sSQL = "select * from Candidates where " & sWhere openStaticRS rs, sSQL bIsUpdateMode = (bPK and not(sAction = "insert" and sForm = "GHB") and not rs.eof) '------------------------------- '------------------------------- ' Load all fields into variables from recordset or input parameters '------------------------------- if bIsUpdateMode then fldID = GetValue(rs, "ID") '------------------------------- ' Load data from recordset when form displayed first time '------------------------------- if sGHBErr = "" then fldPrefix = GetValue(rs, "Prefix") fldFirstName = GetValue(rs, "FirstName") fldLastName = GetValue(rs, "LastName") fldEmail = GetValue(rs, "Email") fldAddress = GetValue(rs, "Address") fldCity = GetValue(rs, "City") fldState = GetValue(rs, "State") fldZip = GetValue(rs, "Zip") fldCounty = GetValue(rs, "County") fldHome = GetValue(rs, "Home") fldWork = GetValue(rs, "Work") fldComments = GetValue(rs, "Comments") end if SetVar "GHBInsert", "" Parse "GHBEdit", False '------------------------------- ' GHB ShowEdit Event begin ' GHB ShowEdit Event end '------------------------------- else SetVar "GHBEdit", "" Parse "GHBInsert", False '------------------------------- ' GHB ShowInsert Event begin ' GHB ShowInsert Event end '------------------------------- end if Parse "GHBCancel", false '------------------------------- ' GHB Show Event begin ' GHB Show Event end '------------------------------- '------------------------------- ' Show form field '------------------------------- SetVar "ID", ToHTML(fldID) SetVar "GHBLBPrefix", "" SetVar "Selected", "" SetVar "ID", "" SetVar "Value", sPrefixDisplayValue Parse "GHBLBPrefix", True openrs rsPrefix, "select Prefix, Prefix from Prefix order by 2" while not rsPrefix.EOF SetVar "ID", GetValue(rsPrefix, 0) : SetVar "Value", GetValue(rsPrefix, 1) if cstr(GetValue(rsPrefix, 0)) = cstr(fldPrefix) then SetVar "Selected", "SELECTED" else SetVar "Selected", "" Parse "GHBLBPrefix", True rsPrefix.MoveNext wend set rsPrefix = nothing SetVar "FirstName", ToHTML(fldFirstName) SetVar "LastName", ToHTML(fldLastName) SetVar "Email", ToHTML(fldEmail) SetVar "Address", ToHTML(fldAddress) SetVar "City", ToHTML(fldCity) SetVar "State", ToHTML(fldState) SetVar "Zip", ToHTML(fldZip) SetVar "County", ToHTML(fldCounty) SetVar "Home", ToHTML(fldHome) SetVar "Work", ToHTML(fldWork) SetVar "Comments", ToHTML(fldComments) Parse "FormGHB", False '------------------------------- ' GHB Close Event begin ' GHB Close Event end '------------------------------- Set rs = Nothing '------------------------------- ' GHB Show end '------------------------------- End Sub '=============================== %>