<% ' ' Filename: Add_SpecialsLong.asp ' Generated with CodeCharge 2.0.5 ' ASP 2.0 & Templates.ccp build 11/30/2001 ' '------------------------------- ' Add_SpecialsLong CustomIncludes begin %> <% ' Add_SpecialsLong CustomIncludes end '------------------------------- '=============================== ' Save Page and File Name available into variables '------------------------------- sFileName = "Add_SpecialsLong.asp" sTemplateFileName = "Add_SpecialsLong.html" '=============================== '=============================== ' Add_SpecialsLong PageSecurity begin ' Add_SpecialsLong PageSecurity end '=============================== '=============================== ' Add_SpecialsLong Open Event begin ' Add_SpecialsLong Open Event end '=============================== '=============================== ' Add_SpecialsLong OpenAnyPage Event begin ' Add_SpecialsLong OpenAnyPage Event end '=============================== '=============================== 'Save the name of the form and type of action into the variables '------------------------------- sAction = GetParam("FormAction") sForm = GetParam("FormName") '=============================== ' Add_SpecialsLong 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 '------------------------------- Add_Specials_Show '------------------------------- ' Process page templates '------------------------------- Parse "main", False '------------------------------- ' Output the page to the browser '------------------------------- Response.write PrintVar("main") ' Add_SpecialsLong Show end '------------------------------- ' Destroy all object variables '------------------------------- ' Add_SpecialsLong Close Event begin ' Add_SpecialsLong Close Event end cn.Close Set cn = Nothing UnloadTemplate '=============================== '=============================== ' Display Grid Form '------------------------------- Sub Add_Specials_Show() '------------------------------- ' Initialize variables '------------------------------- Dim rs Dim sWhere : sWhere = "" Dim sOrder : sOrder = "" Dim sSQL : sSQL = "" Dim sFormTitle: sFormTitle = "Enjoy our Specials" 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", "" SetVar "FormParams", "" sWhere = " WHERE Active = True" '------------------------------- ' Build ORDER BY statement '------------------------------- sOrder = " order by A.Destination Asc" iSort = GetParam("FormAdd_Specials_Sorting") iSorted = GetParam("FormAdd_Specials_Sorted") sDirection = "" if IsEmpty(iSort) then SetVar "Form_Sorting", "" else if iSort = iSorted then SetVar "Form_Sorting", "" sDirection = " DESC" sSortParams = "FormAdd_Specials_Sorting=" & iSort & "&FormAdd_Specials_Sorted=" & iSort & "&" else SetVar "Form_Sorting", iSort sDirection = " ASC" sSortParams = "FormAdd_Specials_Sorting=" & iSort & "&FormAdd_Specials_Sorted=" & "&" end if if iSort = 1 then sOrder = " order by A.[Date]" & sDirection if iSort = 2 then sOrder = " order by A.[Destination]" & sDirection end if '------------------------------- ' Build base SQL statement '------------------------------- sSQL = "select [A].[Active] as A_Active, " & _ "[A].[Date] as A_Date, " & _ "[A].[Destination] as A_Destination, " & _ "[A].[SPNr] as A_SPNr, " & _ "[A].[Special_Describtion] as A_Special_Describtion " & _ " from [Add_Specials] A " '------------------------------- '------------------------------- ' Add_Specials Open Event begin ' Add_Specials 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_Specials", "" Parse "Add_SpecialsNoRecords", False SetVar "Add_SpecialsNavigator", "" Parse "FormAdd_Specials", False exit sub end if '------------------------------- '------------------------------- ' Initialize page counter and records per page '------------------------------- iRecordsPerPage = 10 iCounter = 0 '------------------------------- '------------------------------- ' Process page scroller '------------------------------- iPage = GetParam("FormAdd_Specials_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 '------------------------------- fldActive = GetValue(rs, "A_Active") fldDate = GetValue(rs, "A_Date") fldDestination = GetValue(rs, "A_Destination") fldSpecial_Describtion = GetValue(rs, "A_Special_Describtion") fldSPNr = GetValue(rs, "A_SPNr") '------------------------------- ' Add_Specials Show begin '------------------------------- '------------------------------- ' Add_Specials Show Event begin ' Add_Specials Show Event end '------------------------------- '------------------------------- ' Replace Template fields with database values '------------------------------- SetVar "SPNr", ToHTML(fldSPNr) SetVar "Date", ToHTML(fldDate) SetVar "Destination", ToHTML(fldDestination) SetVar "Special_Describtion", ToHTML(fldSpecial_Describtion) SetVar "Active", ToHTML(fldActive) Parse "DListAdd_Specials", True '------------------------------- ' Add_Specials Show end '------------------------------- '------------------------------- ' Move to the next record and increase record counter '------------------------------- rs.MoveNext iCounter = iCounter + 1 wend '------------------------------- '------------------------------- ' Add_Specials Navigation begin '------------------------------- bEof = rs.eof if rs.eof and iPage = 1 then SetVar "Add_SpecialsNavigator", "" else if bEof then SetVar "Add_SpecialsNavigatorLastPage", "_" else SetVar "NextPage", (iPage + 1) end if if iPage = 1 then SetVar "Add_SpecialsNavigatorFirstPage", "_" else SetVar "PrevPage", (iPage - 1) end if SetVar "Add_SpecialsCurrentPage", iPage Parse "Add_SpecialsNavigator", False end if '------------------------------- ' Add_Specials Navigation end '------------------------------- '------------------------------- ' Finish form processing '------------------------------- set rs = nothing SetVar "Add_SpecialsNoRecords", "" Parse "FormAdd_Specials", False '------------------------------- ' Add_Specials Close Event begin ' Add_Specials Close Event end '------------------------------- End Sub '=============================== %>