<% ' ' Filename: Add_LinksGrid.asp ' Generated with CodeCharge 2.0.5 ' ASP 2.0 & Templates.ccp build 11/30/2001 ' '------------------------------- ' Add_LinksGrid CustomIncludes begin %> <% ' Add_LinksGrid CustomIncludes end '------------------------------- '=============================== ' Save Page and File Name available into variables '------------------------------- sFileName = "Add_LinksGrid.asp" sTemplateFileName = "Add_LinksGrid.html" '=============================== '=============================== ' Add_LinksGrid PageSecurity begin ' Add_LinksGrid PageSecurity end '=============================== '=============================== ' Add_LinksGrid Open Event begin ' Add_LinksGrid Open Event end '=============================== '=============================== ' Add_LinksGrid OpenAnyPage Event begin ' Add_LinksGrid OpenAnyPage Event end '=============================== '=============================== 'Save the name of the form and type of action into the variables '------------------------------- sAction = GetParam("FormAction") sForm = GetParam("FormName") '=============================== ' Add_LinksGrid 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_Links_Show '------------------------------- ' Process page templates '------------------------------- Parse "main", False '------------------------------- ' Output the page to the browser '------------------------------- Response.write PrintVar("main") ' Add_LinksGrid Show end '------------------------------- ' Destroy all object variables '------------------------------- ' Add_LinksGrid Close Event begin ' Add_LinksGrid Close Event end cn.Close Set cn = Nothing UnloadTemplate '=============================== '=============================== ' Display Search Form '------------------------------- Sub Search_Show() Dim sFormTitle: sFormTitle = "Search our Links" Dim sActionFileName: sActionFileName = "Add_LinksGrid.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_Linkdescribtion = GetParam("s_Linkdescribtion") '------------------------------- ' 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_Linkdescribtion", ToHTML(flds_Linkdescribtion) '------------------------------- ' Search Show end '------------------------------- '------------------------------- ' Search Close Event begin ' Search Close Event end '------------------------------- Parse "FormSearch", False End Sub '=============================== '=============================== ' Display Grid Form '------------------------------- Sub Add_Links_Show() '------------------------------- ' Initialize variables '------------------------------- Dim rs Dim sWhere : sWhere = "" Dim sOrder : sOrder = "" Dim sSQL : sSQL = "" Dim sFormTitle: sFormTitle = "Enjoy our Links" Dim HasParam : HasParam = false Dim iSort : iSort = "" Dim iSorted : iSorted = "" Dim sDirection : sDirection = "" Dim sSortParams : sSortParams = "" Dim iRecordsPerPage : iRecordsPerPage = 10 Dim iCounter : iCounter = 0 Dim iPage : iPage = 0 Dim bEof : bEof = False SetVar "TransitParams", "s_Destination=" & ToURL(GetParam("s_Destination")) & "&s_Linkdescribtion=" & ToURL(GetParam("s_Linkdescribtion")) & "&" SetVar "FormParams", "s_Destination=" & ToURL(GetParam("s_Destination")) & "&s_Linkdescribtion=" & ToURL(GetParam("s_Linkdescribtion")) & "&" '------------------------------- ' Build WHERE statement '------------------------------- ps_Destination = GetParam("s_Destination") if not isEmpty(ps_Destination) then HasParam = true sWhere = sWhere & "A.[Destination] like '%" & replace(ps_Destination, "'", "''") & "%'" end if ps_Linkdescribtion = GetParam("s_Linkdescribtion") if not isEmpty(ps_Linkdescribtion) then if not (sWhere = "") then sWhere = sWhere & " and " HasParam = true sWhere = sWhere & "A.[Linkdescribtion] like '%" & replace(ps_Linkdescribtion, "'", "''") & "%'" 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_Links_Sorting") iSorted = GetParam("FormAdd_Links_Sorted") sDirection = "" if IsEmpty(iSort) then SetVar "Form_Sorting", "" else if iSort = iSorted then SetVar "Form_Sorting", "" sDirection = " DESC" sSortParams = "FormAdd_Links_Sorting=" & iSort & "&FormAdd_Links_Sorted=" & iSort & "&" else SetVar "Form_Sorting", iSort sDirection = " ASC" sSortParams = "FormAdd_Links_Sorting=" & iSort & "&FormAdd_Links_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].[Destination] as A_Destination, " & _ "[A].[LNr] as A_LNr, " & _ "[A].[LinkURL] as A_LinkURL, " & _ "[A].[Linkdescribtion] as A_Linkdescribtion " & _ " from [Add_Links] A " '------------------------------- '------------------------------- ' Add_Links Open Event begin ' Add_Links 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_Links", "" Parse "Add_LinksNoRecords", False SetVar "Add_LinksNavigator", "" Parse "FormAdd_Links", False exit sub end if '------------------------------- '------------------------------- ' Initialize page counter and records per page '------------------------------- iRecordsPerPage = 10 iCounter = 0 '------------------------------- '------------------------------- ' Process page scroller '------------------------------- iPage = GetParam("FormAdd_Links_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_LinkURL") fldActive = GetValue(rs, "A_Active") fldDestination = GetValue(rs, "A_Destination") fldLinkdescribtion = GetValue(rs, "A_Linkdescribtion") fldLinkURL = GetValue(rs, "A_LinkURL") fldLNr = GetValue(rs, "A_LNr") fldField1= "GO" '------------------------------- ' Add_Links Show begin '------------------------------- '------------------------------- ' Add_Links Show Event begin ' Add_Links Show Event end '------------------------------- '------------------------------- ' Replace Template fields with database values '------------------------------- SetVar "LNr", ToHTML(fldLNr) SetVar "Destination", ToHTML(fldDestination) SetVar "Linkdescribtion", ToHTML(fldLinkdescribtion) SetVar "Field1", fldField1 SetVar "Field1_URLLink", fldField1_URLLink SetVar "LinkURL", ToHTML(fldLinkURL) SetVar "Active", ToHTML(fldActive) Parse "DListAdd_Links", True '------------------------------- ' Add_Links Show end '------------------------------- '------------------------------- ' Move to the next record and increase record counter '------------------------------- rs.MoveNext iCounter = iCounter + 1 wend '------------------------------- '------------------------------- ' Add_Links Navigation begin '------------------------------- bEof = rs.eof if rs.eof and iPage = 1 then SetVar "Add_LinksNavigator", "" else if bEof then SetVar "Add_LinksNavigatorLastPage", "_" else SetVar "NextPage", (iPage + 1) end if if iPage = 1 then SetVar "Add_LinksNavigatorFirstPage", "_" else SetVar "PrevPage", (iPage - 1) end if SetVar "Add_LinksCurrentPage", iPage Parse "Add_LinksNavigator", False end if '------------------------------- ' Add_Links Navigation end '------------------------------- '------------------------------- ' Finish form processing '------------------------------- set rs = nothing SetVar "Add_LinksNoRecords", "" Parse "FormAdd_Links", False '------------------------------- ' Add_Links Close Event begin ' Add_Links Close Event end '------------------------------- End Sub '=============================== %>