<% ' ' Filename: SchedeList.asp ' Generated with CodeCharge 2.0.5 ' ASP 2.0 & Templates.ccp build 11/30/2001 ' '------------------------------- ' SchedeList CustomIncludes begin %> <% ' SchedeList CustomIncludes end '------------------------------- '=============================== ' Save Page and File Name available into variables '------------------------------- sFileName = "SchedeList.asp" sTemplateFileName = "SchedeList.html" '=============================== '=============================== ' SchedeList PageSecurity begin ' SchedeList PageSecurity end '=============================== '=============================== ' SchedeList Open Event begin ' SchedeList Open Event end '=============================== '=============================== ' SchedeList OpenAnyPage Event begin ' SchedeList OpenAnyPage Event end '=============================== '=============================== 'Save the name of the form and type of action into the variables '------------------------------- sAction = GetParam("FormAction") sForm = GetParam("FormName") '=============================== ' SchedeList 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 '------------------------------- Titolo_Show Schede_Show Form1_Show Form2_Show Form3_Show Ricerca_Show '------------------------------- ' Process page templates '------------------------------- Parse "main", False '------------------------------- ' Output the page to the browser '------------------------------- Response.write PrintVar("main") ' SchedeList Show end '------------------------------- ' Destroy all object variables '------------------------------- ' SchedeList Close Event begin ' SchedeList Close Event end cn.Close Set cn = Nothing UnloadTemplate '=============================== '=============================== ' Display Search Form '------------------------------- Sub Ricerca_Show() Dim sFormTitle: sFormTitle = "Ricerca" Dim sActionFileName: sActionFileName = "SchedeList.asp" '------------------------------- ' Ricerca Open Event begin ' Ricerca Open Event end '------------------------------- SetVar "FormTitle", sFormTitle SetVar "ActionPage", sActionFileName '------------------------------- ' Set variables with search parameters '------------------------------- flds_Titolo = GetParam("s_Titolo") flds_Descrizione = GetParam("s_Descrizione") flds_Testo = GetParam("s_Testo") '------------------------------- ' Ricerca Show begin '------------------------------- '------------------------------- ' Ricerca Show Event begin ' Ricerca Show Event end '------------------------------- SetVar "s_Titolo", ToHTML(flds_Titolo) SetVar "s_Descrizione", ToHTML(flds_Descrizione) SetVar "s_Testo", ToHTML(flds_Testo) '------------------------------- ' Ricerca Show end '------------------------------- '------------------------------- ' Ricerca Close Event begin ' Ricerca Close Event end '------------------------------- Parse "FormRicerca", False End Sub '=============================== '=============================== ' Display Grid Form '------------------------------- Sub Schede_Show() '------------------------------- ' Initialize variables '------------------------------- Dim rs Dim sWhere : sWhere = "" Dim sOrder : sOrder = "" Dim sSQL : sSQL = "" Dim sFormTitle: sFormTitle = "Da leggere" Dim HasParam : HasParam = false Dim iSort : iSort = "" Dim iSorted : iSorted = "" Dim sDirection : sDirection = "" Dim sSortParams : sSortParams = "" Dim iRecordsPerPage : iRecordsPerPage = 20 Dim iCounter : iCounter = 0 Dim iPage : iPage = 0 Dim bEof : bEof = False SetVar "TransitParams", "codcateg=" & ToURL(GetParam("codcateg")) & "&s_Descrizione=" & ToURL(GetParam("s_Descrizione")) & "&s_Testo=" & ToURL(GetParam("s_Testo")) & "&s_Titolo=" & ToURL(GetParam("s_Titolo")) & "&" SetVar "FormParams", "codcateg=" & ToURL(GetParam("codcateg")) & "&s_Descrizione=" & ToURL(GetParam("s_Descrizione")) & "&s_Testo=" & ToURL(GetParam("s_Testo")) & "&s_Titolo=" & ToURL(GetParam("s_Titolo")) & "&" '------------------------------- ' Build WHERE statement '------------------------------- pcodcateg = GetParam("codcateg") if IsNumeric(pcodcateg) and not isEmpty(pcodcateg) then pcodcateg = ToSQL(pcodcateg, "Number") else pcodcateg = Empty if not isEmpty(pcodcateg) then HasParam = true sWhere = sWhere & "S.[codcateg]=" & pcodcateg end if ps_Descrizione = GetParam("s_Descrizione") if not isEmpty(ps_Descrizione) then if not (sWhere = "") then sWhere = sWhere & " and " HasParam = true sWhere = sWhere & "S.[Descrizione] like '%" & replace(ps_Descrizione, "'", "''") & "%'" end if ps_Testo = GetParam("s_Testo") if not isEmpty(ps_Testo) then if not (sWhere = "") then sWhere = sWhere & " and " HasParam = true sWhere = sWhere & "S.[Testo] like '%" & replace(ps_Testo, "'", "''") & "%'" end if ps_Titolo = GetParam("s_Titolo") if not isEmpty(ps_Titolo) then if not (sWhere = "") then sWhere = sWhere & " and " HasParam = true sWhere = sWhere & "S.[Titolo] like '%" & replace(ps_Titolo, "'", "''") & "%'" end if if HasParam then sWhere = " WHERE (" & sWhere & ")" end if '------------------------------- ' Build ORDER BY statement '------------------------------- sOrder = " order by S.Titolo Asc" iSort = GetParam("FormSchede_Sorting") iSorted = GetParam("FormSchede_Sorted") sDirection = "" if IsEmpty(iSort) then SetVar "Form_Sorting", "" else if iSort = iSorted then SetVar "Form_Sorting", "" sDirection = " DESC" sSortParams = "FormSchede_Sorting=" & iSort & "&FormSchede_Sorted=" & iSort & "&" else SetVar "Form_Sorting", iSort sDirection = " ASC" sSortParams = "FormSchede_Sorting=" & iSort & "&FormSchede_Sorted=" & "&" end if if iSort = 1 then sOrder = " order by S.[Titolo]" & sDirection if iSort = 2 then sOrder = " order by S.[Descrizione]" & sDirection end if '------------------------------- ' Build base SQL statement '------------------------------- sSQL = "select [S].[Descrizione] as S_Descrizione, " & _ "[S].[Testo] as S_Testo, " & _ "[S].[Titolo] as S_Titolo, " & _ "[S].[codcateg] as S_codcateg, " & _ "[S].[id] as S_id " & _ " from [Schede] S " '------------------------------- '------------------------------- ' Schede Open Event begin ' Schede 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 '------------------------------- openrs rs, sSQL '------------------------------- '------------------------------- ' Process empty recordset '------------------------------- if rs.eof then set rs = nothing SetVar "DListSchede", "" Parse "SchedeNoRecords", False SetVar "SchedeNavigator", "" Parse "FormSchede", False exit sub end if '------------------------------- '------------------------------- ' Initialize page counter and records per page '------------------------------- iRecordsPerPage = 20 iCounter = 0 '------------------------------- '------------------------------- ' Process page scroller '------------------------------- iPage = GetParam("FormSchede_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 '------------------------------- fldDescrizione = GetValue(rs, "S_Descrizione") fldid = GetValue(rs, "S_id") fldTitolo_URLLink = "SchedeView.asp" fldTitolo_id = GetValue(rs, "S_id") fldTitolo = GetValue(rs, "S_Titolo") '------------------------------- ' Schede Show begin '------------------------------- '------------------------------- ' Schede Show Event begin ' Schede Show Event end '------------------------------- '------------------------------- ' Replace Template fields with database values '------------------------------- SetVar "id", ToHTML(fldid) SetVar "Titolo", ToHTML(fldTitolo) SetVar "Titolo_URLLink", fldTitolo_URLLink SetVar "PrmTitolo_id", ToURL(fldTitolo_id) SetVar "Descrizione", ToHTML(fldDescrizione) Parse "DListSchede", True '------------------------------- ' Schede Show end '------------------------------- '------------------------------- ' Move to the next record and increase record counter '------------------------------- rs.MoveNext iCounter = iCounter + 1 wend '------------------------------- '------------------------------- ' Schede Navigation begin '------------------------------- bEof = rs.eof if rs.eof and iPage = 1 then SetVar "SchedeNavigator", "" else if bEof then SetVar "SchedeNavigatorLastPage", "_" else SetVar "NextPage", (iPage + 1) end if if iPage = 1 then SetVar "SchedeNavigatorFirstPage", "_" else SetVar "PrevPage", (iPage - 1) end if SetVar "SchedeCurrentPage", iPage Parse "SchedeNavigator", False end if '------------------------------- ' Schede Navigation end '------------------------------- '------------------------------- ' Finish form processing '------------------------------- set rs = nothing SetVar "SchedeNoRecords", "" Parse "FormSchede", False '------------------------------- ' Schede Close Event begin ' Schede Close Event end '------------------------------- End Sub '=============================== '=============================== ' Display Menu Form '------------------------------- Sub Titolo_Show() Dim sFormTitle: sFormTitle = "" '------------------------------- ' Titolo Open Event begin ' Titolo Open Event end '------------------------------- '------------------------------- ' Set URLs '------------------------------- fldTitolo = "" '------------------------------- ' Titolo Show begin '------------------------------- SetVar "FormTitle", sFormTitle '------------------------------- ' Titolo BeforeShow Event begin fldTitolo = DLookup("Categorie", "Categoria", "ID= " & GetParam("codcateg")) ' Titolo BeforeShow Event end '------------------------------- '------------------------------- ' Show fields '------------------------------- SetVar "Titolo", fldTitolo Parse "FormTitolo", False '------------------------------- ' Titolo Show end '------------------------------- End Sub '=============================== '=============================== ' Display Menu Form '------------------------------- Sub Form3_Show() Dim sFormTitle: sFormTitle = "" '------------------------------- ' Form3 Open Event begin ' Form3 Open Event end '------------------------------- '------------------------------- ' Set URLs '------------------------------- '------------------------------- ' Form3 Show begin '------------------------------- SetVar "FormTitle", sFormTitle '------------------------------- ' Form3 BeforeShow Event begin ' Form3 BeforeShow Event end '------------------------------- '------------------------------- ' Show fields '------------------------------- Parse "FormForm3", False '------------------------------- ' Form3 Show end '------------------------------- End Sub '=============================== '=============================== ' Display Menu Form '------------------------------- Sub Form2_Show() Dim sFormTitle: sFormTitle = "" '------------------------------- ' Form2 Open Event begin ' Form2 Open Event end '------------------------------- '------------------------------- ' Set URLs '------------------------------- '------------------------------- ' Form2 Show begin '------------------------------- SetVar "FormTitle", sFormTitle '------------------------------- ' Form2 BeforeShow Event begin ' Form2 BeforeShow Event end '------------------------------- '------------------------------- ' Show fields '------------------------------- Parse "FormForm2", False '------------------------------- ' Form2 Show end '------------------------------- End Sub '=============================== '=============================== ' Display Menu Form '------------------------------- Sub Form1_Show() Dim sFormTitle: sFormTitle = "" '------------------------------- ' Form1 Open Event begin ' Form1 Open Event end '------------------------------- '------------------------------- ' Set URLs '------------------------------- '------------------------------- ' Form1 Show begin '------------------------------- SetVar "FormTitle", sFormTitle '------------------------------- ' Form1 BeforeShow Event begin ' Form1 BeforeShow Event end '------------------------------- '------------------------------- ' Show fields '------------------------------- Parse "FormForm1", False '------------------------------- ' Form1 Show end '------------------------------- End Sub '=============================== %>