<% ' ' Filename: News_Specials.asp ' Generated with CodeCharge 2.0.5 ' ASP 2.0 & Templates.ccp build 11/30/2001 ' '------------------------------- ' News_Specials CustomIncludes begin %> <% ' News_Specials CustomIncludes end '------------------------------- '=============================== ' Save Page and File Name available into variables '------------------------------- sFileName = "News_Specials.asp" sTemplateFileName = "News_Specials.html" '=============================== '=============================== ' News_Specials PageSecurity begin ' News_Specials PageSecurity end '=============================== '=============================== ' News_Specials Open Event begin ' News_Specials Open Event end '=============================== '=============================== ' News_Specials OpenAnyPage Event begin ' News_Specials OpenAnyPage Event end '=============================== '=============================== 'Save the name of the form and type of action into the variables '------------------------------- sAction = GetParam("FormAction") sForm = GetParam("FormName") '=============================== ' News_Specials 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 '------------------------------- Specials_Show Add_News_Show '------------------------------- ' Process page templates '------------------------------- Parse "main", False '------------------------------- ' Output the page to the browser '------------------------------- Response.write PrintVar("main") ' News_Specials Show end '------------------------------- ' Destroy all object variables '------------------------------- ' News_Specials Close Event begin ' News_Specials Close Event end cn.Close Set cn = Nothing UnloadTemplate '=============================== '=============================== ' Display Grid Form '------------------------------- Sub Add_News_Show() '------------------------------- ' Initialize variables '------------------------------- Dim rs Dim sWhere : sWhere = "" Dim sOrder : sOrder = "" Dim sSQL : sSQL = "" Dim sFormTitle: sFormTitle = "Latest News" Dim HasParam : HasParam = false Dim iSort : iSort = "" Dim iSorted : iSorted = "" Dim sDirection : sDirection = "" Dim sSortParams : sSortParams = "" Dim iRecordsPerPage : iRecordsPerPage = 5 Dim iCounter : iCounter = 0 Dim iPage : iPage = 0 Dim bEof : bEof = False SetVar "TransitParams", "" SetVar "FormParams", "" sWhere = " WHERE Active = True" '------------------------------- ' Build ORDER BY statement '------------------------------- iSort = GetParam("FormAdd_News_Sorting") iSorted = GetParam("FormAdd_News_Sorted") sDirection = "" if IsEmpty(iSort) then SetVar "Form_Sorting", "" else if iSort = iSorted then SetVar "Form_Sorting", "" sDirection = " DESC" sSortParams = "FormAdd_News_Sorting=" & iSort & "&FormAdd_News_Sorted=" & iSort & "&" else SetVar "Form_Sorting", iSort sDirection = " ASC" sSortParams = "FormAdd_News_Sorting=" & iSort & "&FormAdd_News_Sorted=" & "&" end if end if '------------------------------- ' Build base SQL statement '------------------------------- sSQL = "select [A].[Active] as A_Active, " & _ "[A].[NewNr] as A_NewNr, " & _ "[A].[NewsShort] as A_NewsShort " & _ " from [Add_News] A " '------------------------------- '------------------------------- ' Add_News Open Event begin ' Add_News 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_News", "" Parse "Add_NewsNoRecords", False SetVar "Add_NewsNavigator", "" Parse "FormAdd_News", False exit sub end if '------------------------------- '------------------------------- ' Initialize page counter and records per page '------------------------------- iRecordsPerPage = 5 iCounter = 0 '------------------------------- '------------------------------- ' Process page scroller '------------------------------- iPage = GetParam("FormAdd_News_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 = "Add_NewsGrid.asp" fldField1_NewNr = GetValue(rs, "A_NewNr") fldActive = GetValue(rs, "A_Active") fldNewNr = GetValue(rs, "A_NewNr") fldNewsShort = GetValue(rs, "A_NewsShort") fldField1= "Go" '------------------------------- ' Add_News Show begin '------------------------------- '------------------------------- ' Add_News Show Event begin ' Add_News Show Event end '------------------------------- '------------------------------- ' Replace Template fields with database values '------------------------------- SetVar "NewNr", ToHTML(fldNewNr) SetVar "NewsShort", fldNewsShort SetVar "Active", ToHTML(fldActive) SetVar "Field1", ToHTML(fldField1) SetVar "Field1_URLLink", fldField1_URLLink SetVar "PrmField1_NewNr", ToURL(fldField1_NewNr) Parse "DListAdd_News", True '------------------------------- ' Add_News Show end '------------------------------- '------------------------------- ' Move to the next record and increase record counter '------------------------------- rs.MoveNext iCounter = iCounter + 1 wend '------------------------------- '------------------------------- ' Add_News Navigation begin '------------------------------- bEof = rs.eof if rs.eof and iPage = 1 then SetVar "Add_NewsNavigator", "" else if bEof then SetVar "Add_NewsNavigatorLastPage", "_" else SetVar "NextPage", (iPage + 1) end if if iPage = 1 then SetVar "Add_NewsNavigatorFirstPage", "_" else SetVar "PrevPage", (iPage - 1) end if SetVar "Add_NewsCurrentPage", iPage Parse "Add_NewsNavigator", False end if '------------------------------- ' Add_News Navigation end '------------------------------- '------------------------------- ' Finish form processing '------------------------------- set rs = nothing SetVar "Add_NewsNoRecords", "" Parse "FormAdd_News", False '------------------------------- ' Add_News Close Event begin ' Add_News Close Event end '------------------------------- End Sub '=============================== '=============================== ' Display Grid Form '------------------------------- Sub Specials_Show() '------------------------------- ' Initialize variables '------------------------------- Dim rs Dim sWhere : sWhere = "" Dim sOrder : sOrder = "" Dim sSQL : sSQL = "" Dim sFormTitle: sFormTitle = "Specials" Dim HasParam : HasParam = false Dim iSort : iSort = "" Dim iSorted : iSorted = "" Dim sDirection : sDirection = "" Dim sSortParams : sSortParams = "" Dim iRecordsPerPage : iRecordsPerPage = 5 Dim iCounter : iCounter = 0 Dim iPage : iPage = 0 Dim bEof : bEof = False SetVar "TransitParams", "" SetVar "FormParams", "" sWhere = " WHERE Active = True" '------------------------------- ' Build ORDER BY statement '------------------------------- iSort = GetParam("FormSpecials_Sorting") iSorted = GetParam("FormSpecials_Sorted") sDirection = "" if IsEmpty(iSort) then SetVar "Form_Sorting", "" else if iSort = iSorted then SetVar "Form_Sorting", "" sDirection = " DESC" sSortParams = "FormSpecials_Sorting=" & iSort & "&FormSpecials_Sorted=" & iSort & "&" else SetVar "Form_Sorting", iSort sDirection = " ASC" sSortParams = "FormSpecials_Sorting=" & iSort & "&FormSpecials_Sorted=" & "&" end if end if '------------------------------- ' Build base SQL statement '------------------------------- sSQL = "select [A].[Active] as A_Active, " & _ "[A].[SPNr] as A_SPNr, " & _ "[A].[Special_Short] as A_Special_Short " & _ " from [Add_Specials] A " '------------------------------- '------------------------------- ' Specials Open Event begin ' 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 "DListSpecials", "" Parse "SpecialsNoRecords", False SetVar "SpecialsNavigator", "" Parse "FormSpecials", False exit sub end if '------------------------------- '------------------------------- ' Initialize page counter and records per page '------------------------------- iRecordsPerPage = 5 iCounter = 0 '------------------------------- '------------------------------- ' Process page scroller '------------------------------- iPage = GetParam("FormSpecials_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 = "Add_SpecialsGrid.asp" fldField1_SPNr = GetValue(rs, "A_SPNr") fldActive = GetValue(rs, "A_Active") fldSpecial_Short = GetValue(rs, "A_Special_Short") fldSPNr = GetValue(rs, "A_SPNr") fldField1= "Go" '------------------------------- ' Specials Show begin '------------------------------- '------------------------------- ' Specials Show Event begin ' Specials Show Event end '------------------------------- '------------------------------- ' Replace Template fields with database values '------------------------------- SetVar "Special_Short", fldSpecial_Short SetVar "Active", ToHTML(fldActive) SetVar "SPNr", ToHTML(fldSPNr) SetVar "Field1", ToHTML(fldField1) SetVar "Field1_URLLink", fldField1_URLLink SetVar "PrmField1_SPNr", ToURL(fldField1_SPNr) Parse "DListSpecials", True '------------------------------- ' Specials Show end '------------------------------- '------------------------------- ' Move to the next record and increase record counter '------------------------------- rs.MoveNext iCounter = iCounter + 1 wend '------------------------------- '------------------------------- ' Specials Navigation begin '------------------------------- bEof = rs.eof if rs.eof and iPage = 1 then SetVar "SpecialsNavigator", "" else if bEof then SetVar "SpecialsNavigatorLastPage", "_" else SetVar "NextPage", (iPage + 1) end if if iPage = 1 then SetVar "SpecialsNavigatorFirstPage", "_" else SetVar "PrevPage", (iPage - 1) end if SetVar "SpecialsCurrentPage", iPage Parse "SpecialsNavigator", False end if '------------------------------- ' Specials Navigation end '------------------------------- '------------------------------- ' Finish form processing '------------------------------- set rs = nothing SetVar "SpecialsNoRecords", "" Parse "FormSpecials", False '------------------------------- ' Specials Close Event begin ' Specials Close Event end '------------------------------- End Sub '=============================== %>