<% ' UltraApps Portal - FREE edition, Version 1.5 ' (C) Copyright 2001 by UltraApps ' This program may be used and modified for your own use ' so long as this copyright notice and this comment remain intact. ' You are not permitted to sell or distribute modified version of this software ' View files/license.html for full Legal Information ' ' Filename:AdView.asp ' Generated with CodeCharge 2.0.1 '------------------------------- ' AdView CustomIncludes begin %> <% ' AdView CustomIncludes end '------------------------------- '=============================== ' Save Page and File Name available into variables '------------------------------- sFileName = "AdView.asp" sTemplateFileName = "AdView.html" '=============================== '=============================== ' AdView PageSecurity begin ' AdView PageSecurity end '=============================== '=============================== ' AdView Open Event begin ' AdView Open Event end '=============================== '=============================== ' AdView OpenAnyPage Event begin ' AdView OpenAnyPage Event end '=============================== '=============================== 'Save the name of the form and type of action into the variables '------------------------------- sAction = GetParam("FormAction") sForm = GetParam("FormName") '=============================== ' AdView Show begin '=============================== ' Perform the form's action '------------------------------- ' Initialize error variables '------------------------------- sViewAdErr = "" '------------------------------- ' Select the FormAction '------------------------------- Select Case sForm Case "ViewAd" ViewAdAction(sAction) end select '=============================== '=============================== ' Display page '------------------------------- ' Load HTML template for this page '------------------------------- LoadTemplate sAppPath & sTemplateFileName, "main" '------------------------------- ' Load HTML template of Header and Footer '------------------------------- LoadTemplate sHeaderFileName, "Header" LoadTemplate sFooterFileName, "Footer" '------------------------------- SetVar "FileName", sFileName '------------------------------- ' Step through each form '------------------------------- Header_Show Footer_Show ViewAd_Show '------------------------------- ' Process page templates '------------------------------- Parse "Header", False Parse "Footer", False Parse "main", False '------------------------------- ' Output the page to the browser '------------------------------- Response.write PrintVar("main") ' AdView Show end '------------------------------- ' Destroy all object variables '------------------------------- ' AdView Close Event begin ' AdView Close Event end cn.Close Set cn = Nothing UnloadTemplate '=============================== '=============================== ' Action of the Record Form '------------------------------- Sub ViewAdAction(sAction) '------------------------------- ' Initialize variables '------------------------------- Dim bExecSQL: bExecSQL = true Dim sActionFileName : sActionFileName = "" Dim sWhere : sWhere = "" Dim bErr : bErr = False Dim pPKad_id : pPKad_id = "" Dim fldad_title : fldad_title = "" Dim fldad_added_by2 : fldad_added_by2 = "" '------------------------------- '------------------------------- ' ViewAd Action begin '------------------------------- sActionFileName = ".asp" '------------------------------- ' Load all form fields into variables '------------------------------- fldad_title = GetParam("ad_title") fldad_added_by2 = GetParam("ad_added_by2") '------------------------------- ' ViewAd BeforeExecute Event begin ' ViewAd BeforeExecute Event end '------------------------------- '------------------------------- ' Execute SQL statement '------------------------------- if len(sViewAdErr) > 0 then Exit Sub on error resume next if bExecSQL then cn.execute sSQL end if sViewAdErr = ProcessError on error goto 0 if len(sViewAdErr) > 0 then Exit Sub cn.Close Set cn = Nothing response.redirect sActionFileName '------------------------------- ' ViewAd Action end '------------------------------- end sub '=============================== '=============================== ' Display Record Form '------------------------------- Sub ViewAd_Show() '------------------------------- ' ViewAd Show begin '------------------------------- Dim sWhere : sWhere = "" Dim sFormTitle: sFormTitle = "{ad_title}" Dim bPK : bPK = True '------------------------------- ' Load primary key and form parameters '------------------------------- if sViewAdErr = "" then fldad_id = GetParam("ad_id") pad_id = GetParam("ad_id") SetVar "ViewAdError", "" else fldad_id = GetParam("ad_id") fldad_title = GetParam("ad_title") fldad_added_by2 = GetParam("ad_added_by2") pad_id = GetParam("PK_ad_id") SetVar "sViewAdErr", sViewAdErr SetVar "FormTitle", sFormTitle Parse "ViewAdError", False end if '------------------------------- '------------------------------- ' Load all form fields '------------------------------- '------------------------------- ' Build WHERE statement if IsEmpty(pad_id) then bPK = False sWhere = sWhere & "ad_id=" & ToSQL(pad_id, "Number") SetVar "PK_ad_id", pad_id '------------------------------- '------------------------------- ' ViewAd Open Event begin ' ViewAd Open Event end '------------------------------- SetVar "FormTitle", sFormTitle '------------------------------- ' Build SQL statement and open recordset '------------------------------- sSQL = "select * from ads where " & sWhere openrs rs, sSQL bIsUpdateMode = (bPK and not(sAction = "insert" and sForm = "ViewAd") and not rs.eof) '------------------------------- '------------------------------- ' Load all fields into variables from recordset or input parameters '------------------------------- if bIsUpdateMode then fldad_added_by = GetValue(rs, "ad_added_by") fldad_added_by2 = GetValue(rs, "ad_added_by") fldad_category_id = GetValue(rs, "ad_category_id") fldad_contact = GetValue(rs, "ad_contact") fldad_date_expires = GetValue(rs, "ad_date_expires") fldad_date_posted = GetValue(rs, "ad_date_posted") fldad_id = GetValue(rs, "ad_id") fldad_location = GetValue(rs, "ad_location") fldad_price = GetValue(rs, "ad_price") fldad_text = GetValue(rs, "ad_text") fldad_title = GetValue(rs, "ad_title") SetVar "ViewAdDelete", "" SetVar "ViewAdUpdate", "" SetVar "ViewAdInsert", "" '------------------------------- ' ViewAd ShowEdit Event begin ' ViewAd ShowEdit Event end '------------------------------- else if sViewAdErr = "" then fldad_id = ToHTML(GetParam("ad_id")) end if SetVar "ViewAdEdit", "" SetVar "ViewAdInsert", "" '------------------------------- ' ViewAd ShowInsert Event begin ' ViewAd ShowInsert Event end '------------------------------- end if SetVar "ViewAdCancel", "" '------------------------------- ' Set lookup fields '------------------------------- fldad_category_id = DLookUp("ad_categories", "ad_category", "ad_category_id=" & ToSQL(fldad_category_id, "Number")) fldad_added_by = DLookUp("members", "member_login", "member_id=" & ToSQL(fldad_added_by, "Number")) if sViewAdErr = "" then '------------------------------- ' ViewAd Show Event begin if fldad_price = 0 then fldad_price = "Non précisé" else fldad_price = "" & fldad_price fldad_contact = replace(fldad_contact,vbCRLF,"
") fldad_text = replace(fldad_text,vbCRLF,"
") ' ViewAd Show Event end '------------------------------- end if '------------------------------- ' Show form field '------------------------------- SetVar "ad_id", ToHTML(fldad_id) SetVar "ad_category_id", ToHTML(fldad_category_id) SetVar "ad_date_posted", ToHTML(fldad_date_posted) SetVar "ad_text", fldad_text SetVar "ad_location", fldad_location SetVar "ad_contact", fldad_contact SetVar "ad_price", ToHTML(fldad_price) SetVar "ad_added_by", fldad_added_by SetVar "ad_date_expires", ToHTML(fldad_date_expires) SetVar "ad_title", ToHTML(fldad_title) SetVar "ad_added_by2", ToHTML(fldad_added_by2) Parse "FormViewAd", False '------------------------------- ' ViewAd Close Event begin ' ViewAd Close Event end '------------------------------- Set rs = Nothing '------------------------------- ' ViewAd Show end '------------------------------- End Sub '=============================== %>