% Response.Buffer = EW_RESPONSE_BUFFER %> <% Session.Timeout = 20 %> <% Response.Expires = 0 Response.ExpiresAbsolute = Now() - 1 Response.AddHeader "pragma", "no-cache" Response.AddHeader "cache-control", "private, no-cache, no-store, must-revalidate" %> <% Server.ScriptTimeOut = 240 %> <% ' Define page object Dim Domestic_Cars_view Set Domestic_Cars_view = New cDomestic_Cars_view Set Page = Domestic_Cars_view ' Page init processing Call Domestic_Cars_view.Page_Init() ' Page main processing Call Domestic_Cars_view.Page_Main() %> <% If Domestic_Cars.Export = "" Then %> <% End If %>
View View: Domestic Cars
<% If Domestic_Cars.Export = "" Then %>
Back to List
<% End If %>
|
<% If Domestic_Cars.Export = "" Then %>
<% End If %>
<%
' Drop page object
Set Domestic_Cars_view = Nothing
%>
<%
' -----------------------------------------------------------------
' Page Class
'
Class cDomestic_Cars_view
' Page ID
Public Property Get PageID()
PageID = "view"
End Property
' Table Name
Public Property Get TableName()
TableName = "Domestic Cars"
End Property
' Page Object Name
Public Property Get PageObjName()
PageObjName = "Domestic_Cars_view"
End Property
' Page Name
Public Property Get PageName()
PageName = ew_CurrentPage()
End Property
' Page Url
Public Property Get PageUrl()
PageUrl = ew_CurrentPage() & "?"
If Domestic_Cars.UseTokenInUrl Then PageUrl = PageUrl & "t=" & Domestic_Cars.TableVar & "&" ' add page token
End Property
' Message
Public Property Get Message()
Message = Session(EW_SESSION_MESSAGE)
End Property
Public Property Let Message(v)
If Session(EW_SESSION_MESSAGE) <> "" Then ' Append
Session(EW_SESSION_MESSAGE) = Session(EW_SESSION_MESSAGE) & "
" & v
Else
Session(EW_SESSION_MESSAGE) = v
End If
End Property
' Show Message
Public Sub ShowMessage()
If Message <> "" Then ' Message in Session, display
Response.Write "
" & Message & "
" Session(EW_SESSION_MESSAGE) = "" ' Clear message in Session End If End Sub ' ----------------------- ' Validate Page request ' Public Function IsPageRequest() If Domestic_Cars.UseTokenInUrl Then IsPageRequest = False If Not (ObjForm Is Nothing) Then IsPageRequest = (Domestic_Cars.TableVar = ObjForm.GetValue("t")) End If If Request.QueryString("t").Count > 0 Then IsPageRequest = (Domestic_Cars.TableVar = Request.QueryString("t")) End If Else IsPageRequest = True End If End Function ' ----------------------------------------------------------------- ' Class initialize ' - init objects ' - open ADO connection ' Private Sub Class_Initialize() ' Initialize table object Set Domestic_Cars = New cDomestic_Cars ' Initialize other table object Set All_Rebuilders = New cAll_Rebuilders ' Initialize form object Set ObjForm = Nothing ' Intialize page id (for backward compatibility) EW_PAGE_ID = "view" ' Initialize table name (for backward compatibility) EW_TABLE_NAME = "Domestic Cars" ' Open connection to the database Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open EW_DB_CONNECTION_STRING End Sub ' ----------------------------------------------------------------- ' Subroutine Page_Init ' - called before page main ' - check Security ' - set up response header ' - call page load events ' Sub Page_Init() Set Security = New cAdvancedSecurity If Not Security.IsLoggedIn() Then Call Security.AutoLogin() ' Global page loading event (in userfn7.asp) Call Page_Loading() ' Page load event, used in current page Call Page_Load() End Sub ' ----------------------------------------------------------------- ' Class terminate ' - clean up page object ' Private Sub Class_Terminate() Call Page_Terminate("") End Sub ' ----------------------------------------------------------------- ' Subroutine Page_Terminate ' - called when exit page ' - clean up ADO connection and objects ' - if url specified, redirect to url ' Sub Page_Terminate(url) ' Page unload event, used in current page Call Page_Unload() ' Global page unloaded event (in userfn60.asp) Call Page_Unloaded() If Not (Conn Is Nothing) Then Conn.Close ' Close Connection Set Conn = Nothing Set Security = Nothing Set Domestic_Cars = Nothing ' Go to url if specified If url <> "" Then Response.Clear Response.Redirect url End If End Sub ' ' Subroutine Page_Terminate (End) ' ---------------------------------------- Dim lDisplayRecs ' Number of display records Dim lStartRec, lStopRec, lTotalRecs, lRecRange Dim lRecCnt ' ----------------------------------------------------------------- ' Page main processing ' Sub Page_Main() Dim sReturnUrl sReturnUrl = "" Dim bMatchRecord bMatchRecord = False If IsPageRequest Then ' Validate request If Request.QueryString("Stock_23").Count > 0 Then Domestic_Cars.Stock_23.QueryStringValue = Request.QueryString("Stock_23") Else sReturnUrl = "Domestic_Carslist.asp" ' Return to list End If ' Get action Domestic_Cars.CurrentAction = "I" ' Display form Select Case Domestic_Cars.CurrentAction Case "I" ' Get a record to display If Not LoadRow() Then ' Load record based on key Message = "No records found" ' Set no record message sReturnUrl = "Domestic_Carslist.asp" ' No matching record, return to list End If End Select Else sReturnUrl = "Domestic_Carslist.asp" ' Not page request, return to list End If If sReturnUrl <> "" Then Call Page_Terminate(sReturnUrl) ' Render row Domestic_Cars.RowType = EW_ROWTYPE_VIEW Call RenderRow() End Sub Dim Pager ' ----------------------------------------------------------------- ' Set up Starting Record parameters based on Pager Navigation ' Sub SetUpStartRec() Dim nPageNo ' Exit if lDisplayRecs = 0 If lDisplayRecs = 0 Then Exit Sub If IsPageRequest Then ' Validate request ' Check for a START parameter If Request.QueryString(EW_TABLE_START_REC).Count > 0 Then lStartRec = Request.QueryString(EW_TABLE_START_REC) Domestic_Cars.StartRecordNumber = lStartRec ElseIf Request.QueryString(EW_TABLE_PAGE_NO).Count > 0 Then nPageNo = Request.QueryString(EW_TABLE_PAGE_NO) If IsNumeric(nPageNo) Then lStartRec = (nPageNo-1)*lDisplayRecs+1 If lStartRec <= 0 Then lStartRec = 1 ElseIf lStartRec >= ((lTotalRecs-1)\lDisplayRecs)*lDisplayRecs+1 Then lStartRec = ((lTotalRecs-1)\lDisplayRecs)*lDisplayRecs+1 End If Domestic_Cars.StartRecordNumber = lStartRec End If End If End If lStartRec = Domestic_Cars.StartRecordNumber ' Check if correct start record counter If Not IsNumeric(lStartRec) Or lStartRec = "" Then ' Avoid invalid start record counter lStartRec = 1 ' Reset start record counter Domestic_Cars.StartRecordNumber = lStartRec ElseIf CLng(lStartRec) > CLng(lTotalRecs) Then ' Avoid starting record > total records lStartRec = ((lTotalRecs-1)\lDisplayRecs)*lDisplayRecs+1 ' Point to last page first record Domestic_Cars.StartRecordNumber = lStartRec ElseIf (lStartRec-1) Mod lDisplayRecs <> 0 Then lStartRec = ((lStartRec-1)\lDisplayRecs)*lDisplayRecs+1 ' Point to page boundary Domestic_Cars.StartRecordNumber = lStartRec End If End Sub ' ----------------------------------------------------------------- ' Load row based on key values ' Function LoadRow() Dim RsRow, sSql, sFilter sFilter = Domestic_Cars.KeyFilter ' Call Row Selecting event Call Domestic_Cars.Row_Selecting(sFilter) ' Load sql based on filter Domestic_Cars.CurrentFilter = sFilter sSql = Domestic_Cars.SQL If EW_DEBUG_ENABLED Then Response.Write sSql ' Show SQL for debugging Set RsRow = Server.CreateObject("ADODB.Recordset") RsRow.Open sSql, Conn If RsRow.Eof Then LoadRow = False Else LoadRow = True RsRow.MoveFirst Call LoadRowValues(RsRow) ' Load row values ' Call Row Selected event Call Domestic_Cars.Row_Selected(RsRow) End If RsRow.Close Set RsRow = Nothing End Function ' ----------------------------------------------------------------- ' Load row values from recordset ' Sub LoadRowValues(RsRow) Domestic_Cars.Preview.Upload.DbValue = RsRow("Preview") Domestic_Cars.Store.DbValue = RsRow("Store") Domestic_Cars.Stock_23.DbValue = RsRow("Stock #") Domestic_Cars.zYear.DbValue = RsRow("Year") Domestic_Cars.Make.DbValue = RsRow("Make") Domestic_Cars.Model.DbValue = RsRow("Model") Domestic_Cars.Price.DbValue = RsRow("Price") Domestic_Cars.Description.DbValue = RsRow("Description") Domestic_Cars.Image_1.Upload.DbValue = RsRow("Image 1") Domestic_Cars.Image_2.Upload.DbValue = RsRow("Image 2") Domestic_Cars.Image_3.Upload.DbValue = RsRow("Image 3") Domestic_Cars.Image_4.Upload.DbValue = RsRow("Image 4") Domestic_Cars.Image_5.Upload.DbValue = RsRow("Image 5") End Sub ' ----------------------------------------------------------------- ' Render row values based on field settings ' Sub RenderRow() ' Call Row Rendering event Call Domestic_Cars.Row_Rendering() ' --------------------------------------- ' Common render codes for all row types ' --------------------------------------- ' Store Domestic_Cars.Store.CellCssStyle = "" Domestic_Cars.Store.CellCssClass = "" ' Stock # Domestic_Cars.Stock_23.CellCssStyle = "" Domestic_Cars.Stock_23.CellCssClass = "" ' Year Domestic_Cars.zYear.CellCssStyle = "" Domestic_Cars.zYear.CellCssClass = "" ' Make Domestic_Cars.Make.CellCssStyle = "" Domestic_Cars.Make.CellCssClass = "" ' Model Domestic_Cars.Model.CellCssStyle = "" Domestic_Cars.Model.CellCssClass = "" ' Price Domestic_Cars.Price.CellCssStyle = "" Domestic_Cars.Price.CellCssClass = "" ' Description Domestic_Cars.Description.CellCssStyle = "" Domestic_Cars.Description.CellCssClass = "" ' Image 1 Domestic_Cars.Image_1.CellCssStyle = "" Domestic_Cars.Image_1.CellCssClass = "" ' Image 2 Domestic_Cars.Image_2.CellCssStyle = "" Domestic_Cars.Image_2.CellCssClass = "" ' Image 3 Domestic_Cars.Image_3.CellCssStyle = "" Domestic_Cars.Image_3.CellCssClass = "" ' Image 4 Domestic_Cars.Image_4.CellCssStyle = "" Domestic_Cars.Image_4.CellCssClass = "" ' Image 5 Domestic_Cars.Image_5.CellCssStyle = "" Domestic_Cars.Image_5.CellCssClass = "" ' ----------- ' View Row ' ----------- If Domestic_Cars.RowType = EW_ROWTYPE_VIEW Then ' View row ' Store Domestic_Cars.Store.ViewValue = Domestic_Cars.Store.CurrentValue Domestic_Cars.Store.CssStyle = "" Domestic_Cars.Store.CssClass = "" Domestic_Cars.Store.ViewCustomAttributes = "" ' Stock # Domestic_Cars.Stock_23.ViewValue = Domestic_Cars.Stock_23.CurrentValue Domestic_Cars.Stock_23.CssStyle = "" Domestic_Cars.Stock_23.CssClass = "" Domestic_Cars.Stock_23.ViewCustomAttributes = "" ' Year Domestic_Cars.zYear.ViewValue = Domestic_Cars.zYear.CurrentValue Domestic_Cars.zYear.CssStyle = "" Domestic_Cars.zYear.CssClass = "" Domestic_Cars.zYear.ViewCustomAttributes = "" ' Make Domestic_Cars.Make.ViewValue = Domestic_Cars.Make.CurrentValue Domestic_Cars.Make.CssStyle = "" Domestic_Cars.Make.CssClass = "" Domestic_Cars.Make.ViewCustomAttributes = "" ' Model Domestic_Cars.Model.ViewValue = Domestic_Cars.Model.CurrentValue Domestic_Cars.Model.CssStyle = "" Domestic_Cars.Model.CssClass = "" Domestic_Cars.Model.ViewCustomAttributes = "" ' Price Domestic_Cars.Price.ViewValue = Domestic_Cars.Price.CurrentValue Domestic_Cars.Price.CssStyle = "" Domestic_Cars.Price.CssClass = "" Domestic_Cars.Price.ViewCustomAttributes = "" ' Description Domestic_Cars.Description.ViewValue = Domestic_Cars.Description.CurrentValue Domestic_Cars.Description.CssStyle = "" Domestic_Cars.Description.CssClass = "" Domestic_Cars.Description.ViewCustomAttributes = "" ' Image 1 If Not IsNull(Domestic_Cars.Image_1.Upload.DbValue) Then Domestic_Cars.Image_1.ViewValue = Domestic_Cars.Image_1.Upload.DbValue Domestic_Cars.Image_1.ImageWidth = 640 Domestic_Cars.Image_1.ImageHeight = 480 Domestic_Cars.Image_1.ImageAlt = "" Else Domestic_Cars.Image_1.ViewValue = "" End If Domestic_Cars.Image_1.CssStyle = "" Domestic_Cars.Image_1.CssClass = "" Domestic_Cars.Image_1.ViewCustomAttributes = "" ' Image 2 If Not IsNull(Domestic_Cars.Image_2.Upload.DbValue) Then Domestic_Cars.Image_2.ViewValue = Domestic_Cars.Image_2.Upload.DbValue Domestic_Cars.Image_2.ImageWidth = 640 Domestic_Cars.Image_2.ImageHeight = 480 Domestic_Cars.Image_2.ImageAlt = "" Else Domestic_Cars.Image_2.ViewValue = "" End If Domestic_Cars.Image_2.CssStyle = "" Domestic_Cars.Image_2.CssClass = "" Domestic_Cars.Image_2.ViewCustomAttributes = "" ' Image 3 If Not IsNull(Domestic_Cars.Image_3.Upload.DbValue) Then Domestic_Cars.Image_3.ViewValue = Domestic_Cars.Image_3.Upload.DbValue Domestic_Cars.Image_3.ImageWidth = 640 Domestic_Cars.Image_3.ImageHeight = 480 Domestic_Cars.Image_3.ImageAlt = "" Else Domestic_Cars.Image_3.ViewValue = "" End If Domestic_Cars.Image_3.CssStyle = "" Domestic_Cars.Image_3.CssClass = "" Domestic_Cars.Image_3.ViewCustomAttributes = "" ' Image 4 If Not IsNull(Domestic_Cars.Image_4.Upload.DbValue) Then Domestic_Cars.Image_4.ViewValue = Domestic_Cars.Image_4.Upload.DbValue Domestic_Cars.Image_4.ImageWidth = 640 Domestic_Cars.Image_4.ImageHeight = 480 Domestic_Cars.Image_4.ImageAlt = "" Else Domestic_Cars.Image_4.ViewValue = "" End If Domestic_Cars.Image_4.CssStyle = "" Domestic_Cars.Image_4.CssClass = "" Domestic_Cars.Image_4.ViewCustomAttributes = "" ' Image 5 If Not IsNull(Domestic_Cars.Image_5.Upload.DbValue) Then Domestic_Cars.Image_5.ViewValue = Domestic_Cars.Image_5.Upload.DbValue Domestic_Cars.Image_5.ImageWidth = 640 Domestic_Cars.Image_5.ImageHeight = 480 Domestic_Cars.Image_5.ImageAlt = "" Else Domestic_Cars.Image_5.ViewValue = "" End If Domestic_Cars.Image_5.CssStyle = "" Domestic_Cars.Image_5.CssClass = "" Domestic_Cars.Image_5.ViewCustomAttributes = "" ' View refer script ' Store Domestic_Cars.Store.HrefValue = "" ' Stock # Domestic_Cars.Stock_23.HrefValue = "" ' Year Domestic_Cars.zYear.HrefValue = "" ' Make Domestic_Cars.Make.HrefValue = "" ' Model Domestic_Cars.Model.HrefValue = "" ' Price Domestic_Cars.Price.HrefValue = "" ' Description Domestic_Cars.Description.HrefValue = "" ' Image 1 Domestic_Cars.Image_1.HrefValue = "" ' Image 2 Domestic_Cars.Image_2.HrefValue = "" ' Image 3 Domestic_Cars.Image_3.HrefValue = "" ' Image 4 Domestic_Cars.Image_4.HrefValue = "" ' Image 5 Domestic_Cars.Image_5.HrefValue = "" End If ' Call Row Rendered event Call Domestic_Cars.Row_Rendered() End Sub ' Page Load event Sub Page_Load() 'Response.Write "Page Load" End Sub ' Page Unload event Sub Page_Unload() 'Response.Write "Page Unload" End Sub End Class %>