%@ CodePage = 28591 LCID = 1033 %>
<%
ewCurSec = 0 ' Initialise
' User levels
Const ewAllowAdd = 1
Const ewAllowDelete = 2
Const ewAllowEdit = 4
Const ewAllowView = 8
Const ewAllowList = 8
Const ewAllowReport = 8
Const ewAllowSearch = 8
Const ewAllowAdmin = 16
%>
<%
If Session("nationalproduct_status") <> "login" Then
Response.Redirect "login.asp"
End If
%>
<%
' Initialize common variables
x_customerID = Null
x_username = Null
x_password = Null
x_contactname = Null
x_company = Null
x_address = Null
x_city = Null
x_state = Null
x_zip = Null
x_phone = Null
x_ship_contactname = Null
x_ship_company = Null
x_ship_address = Null
x_ship_city = Null
x_ship_state = Null
x_ship_zip = Null
x_ship_phone = Null
%>
<%
xDb_Conn_Str = "dsn=NATIONALPRODUCT;uid=nationalproduct;pwd=pvhstvdb"
Function executeSQL(sSQL)
dim conn
Set conn = Server.CreateObject("ADODB.connection")
if conn.State = close then
conn.open xDb_Conn_Str
end if
retVal = conn.Execute(sSQL)
conn.close
set conn = nothing
End function
%>
<%
'-------------------------------------------------------------------------------
' Functions for default date format
' ANamedFormat = 0-7, where 0-4 same as VBScript
' 5 = "yyyy/mm/dd"
' 6 = "mm/dd/yyyy"
' 7 = "dd/mm/yyyy"
Const EW_DATE_SEPARATOR = "/"
Function EW_FormatDateTime(ADate, ANamedFormat)
If IsDate(ADate) Then
If ANamedFormat >= 0 And ANamedFormat <= 4 Then
EW_FormatDateTime = FormatDateTime(ADate, ANamedFormat)
ElseIf ANamedFormat = 5 Then
EW_FormatDateTime = Year(ADate) & EW_DATE_SEPARATOR & Month(ADate) & EW_DATE_SEPARATOR & Day(ADate)
ElseIf ANamedFormat = 6 Then
EW_FormatDateTime = Month(ADate) & EW_DATE_SEPARATOR & Day(ADate) & EW_DATE_SEPARATOR & Year(ADate)
ElseIf ANamedFormat = 7 Then
EW_FormatDateTime = Day(ADate) & EW_DATE_SEPARATOR & Month(ADate) & EW_DATE_SEPARATOR & Year(ADate)
Else
EW_FormatDateTime = ADate
End If
Else
EW_FormatDateTime = ADate
End If
End Function
Function EW_UnFormatDateTime(ADate, ANamedFormat)
Dim arDateTime, arDate, AYear, AMonth, ADay
ADate = Trim(ADate)
While Instr(ADate, " ") > 0
ADate = Replace(ADate, " ", " ")
Wend
arDateTime = Split(ADate, " ")
If UBound(arDateTime) < 0 Then
EW_UnFormatDateTime = ADate
Exit Function
End If
arDate = Split(arDateTime(0), EW_DATE_SEPARATOR)
If UBound(arDate) = 2 Then
If ANamedFormat = 6 Then
EW_UnFormatDateTime = arDate(2) & "/" & arDate(0) & "/" & arDate(1)
ElseIf ANamedFormat = 7 Then
EW_UnFormatDateTime = arDate(2) & "/" & arDate(1) & "/" & arDate(0)
Else ' ANamedFormat = 5 or other
EW_UnFormatDateTime = arDateTime(0)
End If
If UBound(arDateTime) > 0 Then
If IsDate(arDateTime(1)) Then ' Is time
EW_UnFormatDateTime = EW_UnFormatDateTime & " " & arDateTime(1)
End If
End If
Else
EW_UnFormatDateTime = ADate
End If
End Function
'-------------------------------------------------------------------------------
' Function for debug
Sub Trace(aMsg)
On Error Resume Next
Dim fso, ts
Set fso = Server.Createobject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(Server.MapPath("debug.txt"), 8, True)
ts.writeline(aMsg)
ts.Close
Set ts = Nothing
Set fso = Nothing
End Sub
%>
<%
' Function to Adjust SQL
Function AdjustSql(str)
Dim sWrk
sWrk = Trim(str&"")
sWrk = Replace(sWrk, "'", "''") ' Adjust for Single Quote
AdjustSql = sWrk
End Function
%>
<%
' Function to generate Value Separator based on current row count
' rowcnt - zero based row count
'
Function ValueSeparator(rowcnt)
ValueSeparator = ", "
End Function
' Function to generate View Option Separator based on current row count (Multi-Select / CheckBox)
' rowcnt - zero based row count
'
Function ViewOptionSeparator(rowcnt)
ViewOptionSeparator = ", "
' Sample code to adjust 2 options per row
'If ((rowcnt + 1) Mod 2 = 0) Then ' 2 options per row
'ViewOptionSeparator = ViewOptionSeparator & "
"
'End If
End Function
' Function to generate Edit Option Separator based on current row count (Radio / CheckBox)
' rowcnt - zero based row count
'
Function EditOptionSeparator(rowcnt)
EditOptionSeparator = " "
' Sample code to adjust 2 options per row
'If ((rowcnt + 1) Mod 2 = 0) Then ' 2 options per row
'EditOptionSeparator = EditOptionSeparator & "
"
'End If
End Function
' Function to truncate Memo Field based on specified length, string truncated to nearest space or CrLf
'
Function TruncateMemo(str, ln)
Dim i, j, k
If Len(str) > 0 And Len(str) > ln Then
k = 1
Do While k > 0 And k < Len(str)
i = InStr(k, str, " ", 1)
j = InStr(k, str, vbCrLf, 1)
If i < 0 And j < 0 Then ' Not able to truncate
TruncateMemo = str
Exit Function
Else
' Get nearest space or CrLf
If i > 0 And j > 0 Then
If i < j Then
k = i
Else
k = j
End If
ElseIf i > 0 Then
k = i
ElseIf j > 0 Then
k = j
End If
' Get truncated text
If k >= ln Then
TruncateMemo = Mid(str, 1, k-1) & " ..."
Exit Function
Else
k = k + 1
End If
End If
Loop
Else
TruncateMemo = str
End If
End Function
%>
<%
Response.Buffer = True
sKey = Request.Querystring("key")
If sKey = "" Or IsNull(sKey) Then Response.Redirect"login.asp"
sAction = "I"
' Open connection to the database
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str
Select Case sAction
Case "I": ' Get a record to display
If Not LoadData(sKey) Then ' Load Record based on key
Session("ewmsg") = "No Record Found for Key = " & sKey
conn.Close ' Close Connection
Set conn = Nothing
Response.Clear
Response.Redirect "customerlist.asp"
End If
End Select
%>
Step Mats, Walk Off Mats and Port-A-Lawn Products for your RV / Travel Trailer
<%
'-------------------------------------------------------------------------------
' Function LoadData
' - Load Data based on Key Value sKey
' - Variables setup: field variables
Function LoadData(sKey)
Dim sKeyWrk, sSql, rs, sWhere, sGroupBy, sHaving, sOrderBy
sKeyWrk = "" & AdjustSql(sKey) & ""
sSql = "SELECT * FROM `customer`"
sSql = sSql & " WHERE `customerID` = " & sKeyWrk
sGroupBy = ""
sHaving = ""
sOrderBy = ""
If sGroupBy <> "" Then
sSql = sSql & " GROUP BY " & sGroupBy
End If
If sHaving <> "" Then
sSql = sSql & " HAVING " & sHaving
End If
If sOrderBy <> "" Then
sSql = sSql & " ORDER BY " & sOrderBy
End If
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sSql, conn
If rs.Eof Then
LoadData = False
Else
LoadData = True
rs.MoveFirst
' Get the field contents
x_customerID = rs("customerID")
x_username = rs("username")
Session("x_username")= x_username
x_password = rs("password")
x_contactname = rs("contactname")
x_company = rs("company")
x_address = rs("address")
x_city = rs("city")
x_state = rs("state")
x_zip = rs("zip")
x_phone = rs("phone")
x_ship_contactname = rs("ship_contactname")
x_ship_company = rs("ship_company")
x_ship_address = rs("ship_address")
x_ship_city = rs("ship_city")
x_ship_state = rs("ship_state")
x_ship_zip = rs("ship_zip")
x_ship_phone = rs("ship_phone")
End If
rs.Close
Set rs = Nothing
End Function
%>