%
'
' Filename: Newsletter_Users.asp
' Generated with CodeCharge 2.0.5
' ASP 2.0 & Templates.ccp build 11/30/2001
'
'-------------------------------
' Newsletter_Users CustomIncludes begin
%>
<%
' Newsletter_Users CustomIncludes end
'-------------------------------
'===============================
' Save Page and File Name available into variables
'-------------------------------
sFileName = "Newsletter_Users.asp"
sTemplateFileName = "Newsletter_Users.html"
'===============================
'===============================
' Newsletter_Users PageSecurity begin
' Newsletter_Users PageSecurity end
'===============================
'===============================
' Newsletter_Users Open Event begin
' Newsletter_Users Open Event end
'===============================
'===============================
' Newsletter_Users OpenAnyPage Event begin
' Newsletter_Users OpenAnyPage Event end
'===============================
'===============================
'Save the name of the form and type of action into the variables
'-------------------------------
sAction = GetParam("FormAction")
sForm = GetParam("FormName")
'===============================
' Newsletter_Users Show begin
'===============================
' Perform the form's action
'-------------------------------
' Initialize error variables
'-------------------------------
sUsersErr = ""
'-------------------------------
' Select the FormAction
'-------------------------------
Select Case sForm
Case "Users"
UsersAction(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
'-------------------------------
Users_Show
'-------------------------------
' Process page templates
'-------------------------------
Parse "main", False
'-------------------------------
' Output the page to the browser
'-------------------------------
Response.write PrintVar("main")
' Newsletter_Users Show end
'-------------------------------
' Destroy all object variables
'-------------------------------
' Newsletter_Users Close Event begin
' Newsletter_Users Close Event end
cn.Close
Set cn = Nothing
UnloadTemplate
'===============================
'===============================
' Action of the Record Form
'-------------------------------
Sub UsersAction(sAction)
'-------------------------------
' Initialize variables
'-------------------------------
Dim bExecSQL: bExecSQL = true
Dim sActionFileName : sActionFileName = ""
Dim sWhere : sWhere = ""
Dim bErr : bErr = False
Dim pPKuser_id : pPKuser_id = ""
Dim flduser_type_id : flduser_type_id = ""
Dim flduser_name : flduser_name = ""
Dim fldCompany : fldCompany = ""
Dim fldIndustry : fldIndustry = ""
Dim fldf_name : fldf_name = ""
Dim fldl_name : fldl_name = ""
Dim fldFunction : fldFunction = ""
Dim fldemail : fldemail = ""
Dim fldhomepage_url : fldhomepage_url = ""
Dim fldpassword : fldpassword = ""
Dim fldaddr1 : fldaddr1 = ""
Dim fldaddr2 : fldaddr2 = ""
Dim fldcity : fldcity = ""
Dim fldstate : fldstate = ""
Dim fldpostalcode : fldpostalcode = ""
Dim fldcountry : fldcountry = ""
Dim fldphone : fldphone = ""
Dim fldfax : fldfax = ""
Dim fldnotes : fldnotes = ""
Dim fldselfemp : fldselfemp = ""
Dim flddtInserted : flddtInserted = ""
Dim flddtModified : flddtModified = ""
Dim fldaccesslevel : fldaccesslevel = ""
Dim fldmailing_list : fldmailing_list = ""
Dim fldutil_val : fldutil_val = ""
Dim fldutil_flag : fldutil_flag = ""
Dim fldsignature : fldsignature = ""
'-------------------------------
'-------------------------------
' Users Action begin
'-------------------------------
sActionFileName = "Newsletter_Users.asp"
'-------------------------------
' CANCEL action
'-------------------------------
if sAction = "cancel" then
'-------------------------------
' Users BeforeCancel Event begin
' Users BeforeCancel Event end
'-------------------------------
cn.Close
Set cn = Nothing
response.redirect sActionFileName
end if
'-------------------------------
'-------------------------------
' Build WHERE statement
'-------------------------------
if sAction = "update" or sAction = "delete" then
pPKuser_id = GetParam("PK_user_id")
if IsEmpty(pPKuser_id) then exit sub
sWhere = "user_id=" & ToSQL(pPKuser_id, "Number")
end if
'-------------------------------
'-------------------------------
' Load all form fields into variables
'-------------------------------
flduser_type_id = GetParam("user_type_id")
flduser_name = GetParam("user_name")
fldCompany = GetParam("Company")
fldIndustry = GetParam("Industry")
fldf_name = GetParam("f_name")
fldl_name = GetParam("l_name")
fldFunction = GetParam("Function")
fldemail = GetParam("email")
fldhomepage_url = GetParam("homepage_url")
fldpassword = GetParam("password")
fldaddr1 = GetParam("addr1")
fldaddr2 = GetParam("addr2")
fldcity = GetParam("city")
fldstate = GetParam("state")
fldpostalcode = GetParam("postalcode")
fldcountry = GetParam("country")
fldphone = GetParam("phone")
fldfax = GetParam("fax")
fldnotes = GetParam("notes")
fldselfemp = GetParam("selfemp")
flddtInserted = GetParam("dtInserted")
flddtModified = GetParam("dtModified")
fldaccesslevel = GetParam("accesslevel")
fldmailing_list = getCheckBoxValue(GetParam("mailing_list"), "1", "0", "Number")
fldutil_val = GetParam("util_val")
fldutil_flag = GetParam("util_flag")
fldsignature = GetParam("signature")
'-------------------------------
' Validate fields
'-------------------------------
if sAction = "insert" or sAction = "update" then
if not isNumeric(flduser_type_id) then
sUsersErr = sUsersErr & "The value in field user_type_id is incorrect.
"
end if
if not isNumeric(fldselfemp) then
sUsersErr = sUsersErr & "The value in field selfemp is incorrect.
"
end if
if not isNumeric(fldaccesslevel) then
sUsersErr = sUsersErr & "The value in field accesslevel is incorrect.
"
end if
if not isNumeric(fldutil_val) then
sUsersErr = sUsersErr & "The value in field util_val is incorrect.
"
end if
if not isNumeric(fldutil_flag) then
sUsersErr = sUsersErr & "The value in field util_flag is incorrect.
"
end if
'-------------------------------
' Users Check Event begin
' Users Check Event end
'-------------------------------
If len(sUsersErr) > 0 then
exit sub
end if
end if
'-------------------------------
'-------------------------------
' Create SQL statement
'-------------------------------
select case sAction
case "insert"
'-------------------------------
' Users Insert Event begin
' Users Insert Event end
'-------------------------------
sSQL = "insert into Users (" & _
"[user_type_id]," & _
"[user_name]," & _
"[Company]," & _
"[Industry]," & _
"[f_name]," & _
"[l_name]," & _
"[Function]," & _
"[email]," & _
"[homepage_url]," & _
"[password]," & _
"[addr1]," & _
"[addr2]," & _
"[city]," & _
"[state]," & _
"[postalcode]," & _
"[country]," & _
"[phone]," & _
"[fax]," & _
"[notes]," & _
"[selfemp]," & _
"[dtInserted]," & _
"[dtModified]," & _
"[accesslevel]," & _
"[mailing_list]," & _
"[util_val]," & _
"[util_flag]," & _
"[signature])" & _
" values (" & _
ToSQL(flduser_type_id, "Number") & "," & _
ToSQL(flduser_name, "Text") & "," & _
ToSQL(fldCompany, "Text") & "," & _
ToSQL(fldIndustry, "Text") & "," & _
ToSQL(fldf_name, "Text") & "," & _
ToSQL(fldl_name, "Text") & "," & _
ToSQL(fldFunction, "Text") & "," & _
ToSQL(fldemail, "Text") & "," & _
ToSQL(fldhomepage_url, "Text") & "," & _
ToSQL(fldpassword, "Text") & "," & _
ToSQL(fldaddr1, "Text") & "," & _
ToSQL(fldaddr2, "Text") & "," & _
ToSQL(fldcity, "Text") & "," & _
ToSQL(fldstate, "Text") & "," & _
ToSQL(fldpostalcode, "Text") & "," & _
ToSQL(fldcountry, "Text") & "," & _
ToSQL(fldphone, "Text") & "," & _
ToSQL(fldfax, "Text") & "," & _
ToSQL(fldnotes, "Memo") & "," & _
ToSQL(fldselfemp, "Number") & "," & _
ToSQL(flddtInserted, "Date") & "," & _
ToSQL(flddtModified, "Date") & "," & _
ToSQL(fldaccesslevel, "Number") & "," & _
fldmailing_list & "," & _
ToSQL(fldutil_val, "Number") & "," & _
ToSQL(fldutil_flag, "Number") & "," & _
ToSQL(fldsignature, "Text") & _
")"
case "update"
'-------------------------------
' Users Update Event begin
' Users Update Event end
'-------------------------------
sSQL = "update Users set " & _
"[user_type_id]=" & ToSQL(flduser_type_id, "Number") & _
",[user_name]=" & ToSQL(flduser_name, "Text") & _
",[Company]=" & ToSQL(fldCompany, "Text") & _
",[Industry]=" & ToSQL(fldIndustry, "Text") & _
",[f_name]=" & ToSQL(fldf_name, "Text") & _
",[l_name]=" & ToSQL(fldl_name, "Text") & _
",[Function]=" & ToSQL(fldFunction, "Text") & _
",[email]=" & ToSQL(fldemail, "Text") & _
",[homepage_url]=" & ToSQL(fldhomepage_url, "Text") & _
",[password]=" & ToSQL(fldpassword, "Text") & _
",[addr1]=" & ToSQL(fldaddr1, "Text") & _
",[addr2]=" & ToSQL(fldaddr2, "Text") & _
",[city]=" & ToSQL(fldcity, "Text") & _
",[state]=" & ToSQL(fldstate, "Text") & _
",[postalcode]=" & ToSQL(fldpostalcode, "Text") & _
",[country]=" & ToSQL(fldcountry, "Text") & _
",[phone]=" & ToSQL(fldphone, "Text") & _
",[fax]=" & ToSQL(fldfax, "Text") & _
",[notes]=" & ToSQL(fldnotes, "Memo") & _
",[selfemp]=" & ToSQL(fldselfemp, "Number") & _
",[dtInserted]=" & ToSQL(flddtInserted, "Date") & _
",[dtModified]=" & ToSQL(flddtModified, "Date") & _
",[accesslevel]=" & ToSQL(fldaccesslevel, "Number") & _
",[mailing_list]=" & fldmailing_list & _
",[util_val]=" & ToSQL(fldutil_val, "Number") & _
",[util_flag]=" & ToSQL(fldutil_flag, "Number") & _
",[signature]=" & ToSQL(fldsignature, "Text")
sSQL = sSQL & " where " & sWhere
case "delete"
'-------------------------------
' Users Delete Event begin
' Users Delete Event end
'-------------------------------
sSQL = "delete from Users where " & sWhere
end select
'-------------------------------
'-------------------------------
' Users BeforeExecute Event begin
' Users BeforeExecute Event end
'-------------------------------
'-------------------------------
' Execute SQL statement
'-------------------------------
if len(sUsersErr) > 0 then Exit Sub
on error resume next
if bExecSQL then
cn.execute sSQL
end if
sUsersErr = ProcessError
on error goto 0
if len(sUsersErr) > 0 then Exit Sub
cn.Close
Set cn = Nothing
response.redirect sActionFileName
'-------------------------------
' Users Action end
'-------------------------------
end sub
'===============================
'===============================
' Display Record Form
'-------------------------------
Sub Users_Show()
'-------------------------------
' Users Show begin
'-------------------------------
Dim sWhere : sWhere = ""
Dim sFormTitle: sFormTitle = "Subscribe to our Newsletter"
Dim bPK : bPK = True
'-------------------------------
' Load primary key and form parameters
'-------------------------------
if sUsersErr = "" then
puser_id = GetParam("user_id")
SetVar "UsersError", ""
else
flduser_id = GetParam("user_id")
flduser_type_id = GetParam("user_type_id")
flduser_name = GetParam("user_name")
fldCompany = GetParam("Company")
fldIndustry = GetParam("Industry")
fldf_name = GetParam("f_name")
fldl_name = GetParam("l_name")
fldFunction = GetParam("Function")
fldemail = GetParam("email")
fldhomepage_url = GetParam("homepage_url")
fldpassword = GetParam("password")
fldaddr1 = GetParam("addr1")
fldaddr2 = GetParam("addr2")
fldcity = GetParam("city")
fldstate = GetParam("state")
fldpostalcode = GetParam("postalcode")
fldcountry = GetParam("country")
fldphone = GetParam("phone")
fldfax = GetParam("fax")
fldnotes = GetParam("notes")
fldselfemp = GetParam("selfemp")
flddtInserted = GetParam("dtInserted")
flddtModified = GetParam("dtModified")
fldaccesslevel = GetParam("accesslevel")
fldmailing_list = getCheckBoxValue(GetParam("mailing_list"), "1", "0", "Number")
fldutil_val = GetParam("util_val")
fldutil_flag = GetParam("util_flag")
fldsignature = GetParam("signature")
puser_id = GetParam("PK_user_id")
SetVar "sUsersErr", sUsersErr
SetVar "FormTitle", sFormTitle
Parse "UsersError", False
end if
'-------------------------------
'-------------------------------
' Load all form fields
'-------------------------------
'-------------------------------
' Build WHERE statement
if IsEmpty(puser_id) then bPK = False
sWhere = sWhere & "user_id=" & ToSQL(puser_id, "Number")
SetVar "PK_user_id", puser_id
'-------------------------------
'-------------------------------
' Users Open Event begin
' Users Open Event end
'-------------------------------
SetVar "FormTitle", sFormTitle
'-------------------------------
' Build SQL statement and open recordset
'-------------------------------
sSQL = "select * from Users where " & sWhere
openStaticRS rs, sSQL
bIsUpdateMode = (bPK and not(sAction = "insert" and sForm = "Users") and not rs.eof)
'-------------------------------
'-------------------------------
' Load all fields into variables from recordset or input parameters
'-------------------------------
if bIsUpdateMode then
fldaccesslevel = GetValue(rs, "accesslevel")
flddtInserted = GetValue(rs, "dtInserted")
flddtModified = GetValue(rs, "dtModified")
fldpassword = GetValue(rs, "password")
fldselfemp = GetValue(rs, "selfemp")
fldsignature = GetValue(rs, "signature")
flduser_id = GetValue(rs, "user_id")
flduser_name = GetValue(rs, "user_name")
flduser_type_id = GetValue(rs, "user_type_id")
fldutil_flag = GetValue(rs, "util_flag")
fldutil_val = GetValue(rs, "util_val")
'-------------------------------
' Load data from recordset when form displayed first time
'-------------------------------
if sUsersErr = "" then
fldCompany = GetValue(rs, "Company")
fldIndustry = GetValue(rs, "Industry")
fldf_name = GetValue(rs, "f_name")
fldl_name = GetValue(rs, "l_name")
fldFunction = GetValue(rs, "Function")
fldemail = GetValue(rs, "email")
fldhomepage_url = GetValue(rs, "homepage_url")
fldaddr1 = GetValue(rs, "addr1")
fldaddr2 = GetValue(rs, "addr2")
fldcity = GetValue(rs, "city")
fldstate = GetValue(rs, "state")
fldpostalcode = GetValue(rs, "postalcode")
fldcountry = GetValue(rs, "country")
fldphone = GetValue(rs, "phone")
fldfax = GetValue(rs, "fax")
fldnotes = GetValue(rs, "notes")
fldmailing_list = GetValue(rs, "mailing_list")
end if
SetVar "UsersInsert", ""
Parse "UsersEdit", False
'-------------------------------
' Users ShowEdit Event begin
' Users ShowEdit Event end
'-------------------------------
else
if sUsersErr = "" then
fldhomepage_url= "http://"
end if
SetVar "UsersEdit", ""
Parse "UsersInsert", False
'-------------------------------
' Users ShowInsert Event begin
' Users ShowInsert Event end
'-------------------------------
end if
Parse "UsersCancel", false
'-------------------------------
' Users Show Event begin
' Users Show Event end
'-------------------------------
'-------------------------------
' Show form field
'-------------------------------
SetVar "user_id", ToHTML(flduser_id)
SetVar "user_type_id", ToHTML(flduser_type_id)
SetVar "user_name", ToHTML(flduser_name)
SetVar "Company", ToHTML(fldCompany)
SetVar "Industry", ToHTML(fldIndustry)
SetVar "f_name", ToHTML(fldf_name)
SetVar "l_name", ToHTML(fldl_name)
SetVar "Function", ToHTML(fldFunction)
SetVar "email", ToHTML(fldemail)
SetVar "homepage_url", ToHTML(fldhomepage_url)
SetVar "password", ToHTML(fldpassword)
SetVar "addr1", ToHTML(fldaddr1)
SetVar "addr2", ToHTML(fldaddr2)
SetVar "city", ToHTML(fldcity)
SetVar "state", ToHTML(fldstate)
SetVar "postalcode", ToHTML(fldpostalcode)
SetVar "country", ToHTML(fldcountry)
SetVar "phone", ToHTML(fldphone)
SetVar "fax", ToHTML(fldfax)
SetVar "notes", ToHTML(fldnotes)
SetVar "selfemp", ToHTML(fldselfemp)
SetVar "dtInserted", ToHTML(flddtInserted)
SetVar "dtModified", ToHTML(flddtModified)
SetVar "accesslevel", ToHTML(fldaccesslevel)
if (LCase(fldmailing_list) = LCase("1")) then
SetVar "mailing_list_CHECKED", "CHECKED"
else
SetVar "mailing_list_CHECKED", ""
end if
SetVar "util_val", ToHTML(fldutil_val)
SetVar "util_flag", ToHTML(fldutil_flag)
SetVar "signature", ToHTML(fldsignature)
Parse "FormUsers", False
'-------------------------------
' Users Close Event begin
' Users Close Event end
'-------------------------------
Set rs = Nothing
'-------------------------------
' Users Show end
'-------------------------------
End Sub
'===============================
%>