<% ' ' Filename: Add_PackagesGrid.asp ' Generated with CodeCharge 2.0.5 ' ASP 2.0 & Templates.ccp build 11/30/2001 ' '------------------------------- ' Add_PackagesGrid CustomIncludes begin %> <% ' Add_PackagesGrid CustomIncludes end '------------------------------- '=============================== ' Save Page and File Name available into variables '------------------------------- sFileName = "Add_PackagesGrid.asp" sTemplateFileName = "Add_PackagesGrid.html" '=============================== '=============================== ' Add_PackagesGrid PageSecurity begin ' Add_PackagesGrid PageSecurity end '=============================== '=============================== ' Add_PackagesGrid Open Event begin ' Add_PackagesGrid Open Event end '=============================== '=============================== ' Add_PackagesGrid OpenAnyPage Event begin ' Add_PackagesGrid OpenAnyPage Event end '=============================== '=============================== 'Save the name of the form and type of action into the variables '------------------------------- sAction = GetParam("FormAction") sForm = GetParam("FormName") '=============================== ' Add_PackagesGrid Show begin '=============================== ' 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 '------------------------------- Search_Show Add_Packages_Show '------------------------------- ' Process page templates '------------------------------- Parse "main", False '------------------------------- ' Output the page to the browser '------------------------------- Response.write PrintVar("main") ' Add_PackagesGrid Show end '------------------------------- ' Destroy all object variables '------------------------------- ' Add_PackagesGrid Close Event begin ' Add_PackagesGrid Close Event end cn.Close Set cn = Nothing UnloadTemplate '=============================== '=============================== ' Display Search Form '------------------------------- Sub Search_Show() Dim sFormTitle: sFormTitle = "Search our most popular Tour Packages" Dim sActionFileName: sActionFileName = "Add_PackagesGrid.asp" '------------------------------- ' Search Open Event begin ' Search Open Event end '------------------------------- SetVar "FormTitle", sFormTitle SetVar "ActionPage", sActionFileName '------------------------------- ' Set variables with search parameters '------------------------------- flds_Destination = GetParam("s_Destination") flds_Describtion = GetParam("s_Describtion") '------------------------------- ' Search Show begin '------------------------------- '------------------------------- ' Search Show Event begin ' Search Show Event end '------------------------------- SetVar "SearchLBs_Destination", "" openrs rss_Destination, "select Destination_Short, Destination_Long from XXX_English_Destinations order by 2" while not rss_Destination.EOF SetVar "ID", GetValue(rss_Destination, 0) : SetVar "Value", GetValue(rss_Destination, 1) if cstr(GetValue(rss_Destination, 0)) = cstr(flds_Destination) then SetVar "Selected", "SELECTED" else SetVar "Selected", "" Parse "SearchLBs_Destination", True rss_Destination.MoveNext wend set rss_Destination = nothing SetVar "s_Describtion", ToHTML(flds_Describtion) '------------------------------- ' Search Show end '------------------------------- '------------------------------- ' Search Close Event begin ' Search Close Event end '------------------------------- Parse "FormSearch", False End Sub '=============================== '=============================== ' Display Grid Form '------------------------------- Sub Add_Packages_Show() '------------------------------- ' Initialize variables '------------------------------- Dim rs Dim sWhere : sWhere = "" Dim sOrder : sOrder = "" Dim sSQL : sSQL = "" Dim sFormTitle: sFormTitle = "Enjoy our most popular Tour Packages" Dim HasParam : HasParam = false Dim iSort : iSort = "" Dim iSorted : iSorted = "" Dim sDirection : sDirection = "" Dim sSortParams : sSortParams = "" Dim iRecordsPerPage : iRecordsPerPage = 7 Dim iCounter : iCounter = 0 Dim iPage : iPage = 0 Dim bEof : bEof = False SetVar "TransitParams", "s_Describtion=" & ToURL(GetParam("s_Describtion")) & "&s_Destination=" & ToURL(GetParam("s_Destination")) & "&" SetVar "FormParams", "s_Describtion=" & ToURL(GetParam("s_Describtion")) & "&s_Destination=" & ToURL(GetParam("s_Destination")) & "&" '------------------------------- ' Build WHERE statement '------------------------------- ps_Describtion = GetParam("s_Describtion") if not isEmpty(ps_Describtion) then HasParam = true sWhere = sWhere & "A.[Describtion] like '%" & replace(ps_Describtion, "'", "''") & "%'" end if ps_Destination = GetParam("s_Destination") if not isEmpty(ps_Destination) then if not (sWhere = "") then sWhere = sWhere & " and " HasParam = true sWhere = sWhere & "A.[Destination] like '%" & replace(ps_Destination, "'", "''") & "%'" end if if HasParam then sWhere = " WHERE (Active = True) AND (" & sWhere & ")" else sWhere = " WHERE Active = True" end if '------------------------------- ' Build ORDER BY statement '------------------------------- sOrder = " order by A.Destination Asc" iSort = GetParam("FormAdd_Packages_Sorting") iSorted = GetParam("FormAdd_Packages_Sorted") sDirection = "" if IsEmpty(iSort) then SetVar "Form_Sorting", "" else if iSort = iSorted then SetVar "Form_Sorting", "" sDirection = " DESC" sSortParams = "FormAdd_Packages_Sorting=" & iSort & "&FormAdd_Packages_Sorted=" & iSort & "&" else SetVar "Form_Sorting", iSort sDirection = " ASC" sSortParams = "FormAdd_Packages_Sorting=" & iSort & "&FormAdd_Packages_Sorted=" & "&" end if if iSort = 1 then sOrder = " order by A.[Destination]" & sDirection end if '------------------------------- ' Build base SQL statement '------------------------------- sSQL = "select [A].[Active] as A_Active, " & _ "[A].[Describtion] as A_Describtion, " & _ "[A].[Destination] as A_Destination, " & _ "[A].[DownloadURL] as A_DownloadURL, " & _ "[A].[PackNr] as A_PackNr " & _ " from [Add_Packages] A " '------------------------------- '------------------------------- ' Add_Packages Open Event begin ' Add_Packages Open Event end '------------------------------- '------------------------------- ' Assemble full SQL statement '------------------------------- sSQL = sSQL & sWhere & sOrder '------------------------------- SetVar "FormTitle", sFormTitle '------------------------------- ' Process the parameters for sorting '------------------------------- SetVar "SortParams", sSortParams '------------------------------- '------------------------------- ' Open the recordset '------------------------------- openStaticRS rs, sSQL '------------------------------- '------------------------------- ' Process empty recordset '------------------------------- if rs.eof then set rs = nothing SetVar "DListAdd_Packages", "" Parse "Add_PackagesNoRecords", False SetVar "Add_PackagesNavigator", "" Parse "FormAdd_Packages", False exit sub end if '------------------------------- '------------------------------- ' Initialize page counter and records per page '------------------------------- iRecordsPerPage = 7 iCounter = 0 '------------------------------- '------------------------------- ' Process page scroller '------------------------------- iPage = GetParam("FormAdd_Packages_Page") if IsEmpty(iPage) then iPage = 1 else iPage = CLng(iPage) while not rs.eof and iCounter < (iPage-1)*iRecordsPerPage rs.movenext iCounter = iCounter + 1 wend iCounter = 0 '------------------------------- '------------------------------- ' Display grid based on recordset '------------------------------- while not rs.EOF and iCounter < iRecordsPerPage '------------------------------- ' Create field variables based on database fields '------------------------------- fldField1_URLLink = GetValue(rs, "A_DownloadURL") fldActive = GetValue(rs, "A_Active") fldDescribtion = GetValue(rs, "A_Describtion") fldDestination = GetValue(rs, "A_Destination") fldDownloadURL = GetValue(rs, "A_DownloadURL") fldPackNr = GetValue(rs, "A_PackNr") fldField1= "Go" '------------------------------- ' Add_Packages Show begin '------------------------------- '------------------------------- ' Add_Packages Show Event begin fldbuttonurl="" ' Add_Packages Show Event end '------------------------------- '------------------------------- ' Replace Template fields with database values '------------------------------- SetVar "PackNr", ToHTML(fldPackNr) SetVar "Destination", ToHTML(fldDestination) SetVar "Describtion", ToHTML(fldDescribtion) SetVar "DownloadURL", ToHTML(fldDownloadURL) SetVar "Active", ToHTML(fldActive) SetVar "Field1", fldField1 SetVar "Field1_URLLink", fldField1_URLLink Parse "DListAdd_Packages", True '------------------------------- ' Add_Packages Show end '------------------------------- '------------------------------- ' Move to the next record and increase record counter '------------------------------- rs.MoveNext iCounter = iCounter + 1 wend '------------------------------- '------------------------------- ' Add_Packages Navigation begin '------------------------------- bEof = rs.eof if rs.eof and iPage = 1 then SetVar "Add_PackagesNavigator", "" else if bEof then SetVar "Add_PackagesNavigatorLastPage", "_" else SetVar "NextPage", (iPage + 1) end if if iPage = 1 then SetVar "Add_PackagesNavigatorFirstPage", "_" else SetVar "PrevPage", (iPage - 1) end if SetVar "Add_PackagesCurrentPage", iPage Parse "Add_PackagesNavigator", False end if '------------------------------- ' Add_Packages Navigation end '------------------------------- '------------------------------- ' Finish form processing '------------------------------- set rs = nothing SetVar "Add_PackagesNoRecords", "" Parse "FormAdd_Packages", False '------------------------------- ' Add_Packages Close Event begin ' Add_Packages Close Event end '------------------------------- End Sub '=============================== %>