<% ' ' Filename: cursos.asp ' Generated with CodeCharge 2.0.7 ' ASP 2.0 & Templates.ccp build 11/30/2001 ' '------------------------------- ' cursos CustomIncludes begin %> <% ' cursos CustomIncludes end '------------------------------- '=============================== ' Save Page and File Name available into variables '------------------------------- sFileName = "cursos.asp" sTemplateFileName = "cursos.html" '=============================== '=============================== ' cursos PageSecurity begin ' cursos PageSecurity end '=============================== '=============================== ' cursos Open Event begin ' cursos Open Event end '=============================== '=============================== ' cursos OpenAnyPage Event begin ' cursos OpenAnyPage Event end '=============================== '=============================== 'Save the name of the form and type of action into the variables '------------------------------- sAction = GetParam("FormAction") sForm = GetParam("FormName") '=============================== ' cursos 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 cursos_Show '------------------------------- ' Process page templates '------------------------------- Parse "main", False '------------------------------- ' Output the page to the browser '------------------------------- Response.write PrintVar("main") ' cursos Show end '------------------------------- ' Destroy all object variables '------------------------------- ' cursos Close Event begin ' cursos Close Event end cn.Close Set cn = Nothing UnloadTemplate '=============================== '=============================== ' Display Search Form '------------------------------- Sub Search_Show() Dim sFormTitle: sFormTitle = "Search" Dim sActionFileName: sActionFileName = "cursos.asp" '------------------------------- ' Search Open Event begin ' Search Open Event end '------------------------------- SetVar "FormTitle", sFormTitle SetVar "ActionPage", sActionFileName '------------------------------- ' Set variables with search parameters '------------------------------- fldtitulo = GetParam("titulo") '------------------------------- ' Search Show begin '------------------------------- '------------------------------- ' Search Show Event begin ' Search Show Event end '------------------------------- SetVar "titulo", ToHTML(fldtitulo) '------------------------------- ' Search Show end '------------------------------- '------------------------------- ' Search Close Event begin ' Search Close Event end '------------------------------- Parse "FormSearch", False End Sub '=============================== '=============================== ' Display Grid Form '------------------------------- Sub cursos_Show() '------------------------------- ' Initialize variables '------------------------------- Dim rs Dim sWhere : sWhere = "" Dim sOrder : sOrder = "" Dim sSQL : sSQL = "" Dim sFormTitle: sFormTitle = "cursos" Dim HasParam : HasParam = false Dim iRecordsPerPage : iRecordsPerPage = 10 Dim iCounter : iCounter = 0 Dim iPage : iPage = 0 Dim bEof : bEof = False Dim iTmpI : iTmpI = 0 Dim iTmpJ : iTmpJ = 0 Dim sCountSQL : sCountSQL = "" SetVar "TransitParams", "" SetVar "FormParams", "cursoid=" & ToURL(GetParam("cursoid")) & "&titulo=" & ToURL(GetParam("titulo")) & "&" '------------------------------- ' Build WHERE statement '------------------------------- pcursoid = GetParam("cursoid") if IsNumeric(pcursoid) and not isEmpty(pcursoid) then pcursoid = ToSQL(pcursoid, "Number") else pcursoid = Empty if not isEmpty(pcursoid) then HasParam = true sWhere = sWhere & "c.cursoid=" & pcursoid end if ptitulo = GetParam("titulo") if not isEmpty(ptitulo) then if not (sWhere = "") then sWhere = sWhere & " and " HasParam = true sWhere = sWhere & "c.titulo like '%" & replace(ptitulo, "'", "''") & "%'" end if if HasParam then sWhere = " WHERE (modalidad='CURSOS') AND (" & sWhere & ")" else sWhere = " WHERE modalidad='CURSOS'" end if '------------------------------- ' Build ORDER BY statement '------------------------------- sOrder = " order by c.cursoid Asc" '------------------------------- ' Build base SQL statement '------------------------------- sSQL = "select c.cursoid as c_cursoid, " & _ "c.fechas as c_fechas, " & _ "c.lugar as c_lugar, " & _ "c.memoria as c_memoria, " & _ "c.plazas as c_plazas, " & _ "c.titulo as c_titulo " & _ " from cursos c " '------------------------------- '------------------------------- ' cursos Open Event begin ' cursos Open Event end '------------------------------- '------------------------------- ' Assemble full SQL statement '------------------------------- sSQL = sSQL & sWhere & sOrder if sCountSQL = "" then iTmpI = instr(lcase(sSQL), "select") iTmpJ = instr(lcase(sSQL), "from") - 1 sCountSQL = replace(sSQL, mid(sSQL, iTmpI + 6, iTmpJ - 6), " count(*) ") iTmpI = instr(lcase(sCountSQl), "order by") if iTmpI > 1 then sCountSQL = left(sCountSQL, iTmpI - 1) end if '------------------------------- SetVar "FormTitle", sFormTitle '------------------------------- ' Open the recordset '------------------------------- openrs rs, sSQL '------------------------------- '------------------------------- ' Process empty recordset '------------------------------- if rs.eof then set rs = nothing SetVar "DListcursos", "" Parse "cursosNoRecords", False SetVar "cursosNavigator", "" Parse "Formcursos", False exit sub end if '------------------------------- '------------------------------- ' Initialize page counter and records per page '------------------------------- iRecordsPerPage = 10 iCounter = 0 '------------------------------- '------------------------------- ' Process page scroller '------------------------------- iPage = GetParam("Formcursos_Page") openrs rsCount, sCountSQL dResult = CLng(rsCount.fields(0).value) / iRecordsPerPage iPageCount = int(dResult) if iPageCount < dResult then iPageCount = iPageCount + 1 SetVar "cursosPageCount", iPageCount set rsCount = nothing if IsEmpty(iPage) then iPage = 1 else if iPage = "last" then iPage = iPageCount end if 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 '------------------------------- fldcursoid = GetValue(rs, "c_cursoid") fldfechas = GetValue(rs, "c_fechas") fldlugar = GetValue(rs, "c_lugar") fldmemoria_URLLink = GetValue(rs, "c_memoria") fldmemoria = GetValue(rs, "c_memoria") fldplazas = GetValue(rs, "c_plazas") fldtitulo = GetValue(rs, "c_titulo") '------------------------------- ' cursos Show begin '------------------------------- '------------------------------- ' cursos Show Event begin ' cursos Show Event end '------------------------------- '------------------------------- ' Replace Template fields with database values '------------------------------- SetVar "cursoid", ToHTML(fldcursoid) SetVar "titulo", ToHTML(fldtitulo) SetVar "fechas", ToHTML(fldfechas) SetVar "lugar", ToHTML(fldlugar) SetVar "plazas", ToHTML(fldplazas) SetVar "memoria", fldmemoria SetVar "memoria_URLLink", fldmemoria_URLLink Parse "DListcursos", True '------------------------------- ' cursos Show end '------------------------------- '------------------------------- ' Move to the next record and increase record counter '------------------------------- rs.MoveNext iCounter = iCounter + 1 wend '------------------------------- '------------------------------- ' cursos Navigation begin '------------------------------- bEof = rs.eof if rs.eof and iPage = 1 then SetVar "cursosNavigator", "" else iCounter = 1 iHasPages = iPage iDisplayPages = 0 iNumberOfPages = 5 iHasPages = iPageCount if (iHasPages - iPage) < int(iNumberOfPages/2) then iStartPage = iHasPages - iNumberOfPages else iStartPage = iPage - iNumberOfPages + int(iNumberOfPages/2) end if if iStartPage < 0 then iStartPage = 0 for iPageCount = iStartPage + 1 to iPage - 1 SetVar "NavigatorPageNumber", iPageCount SetVar "NavigatorPageNumberView", iPageCount Parse "cursosNavigatorPages", true iDisplayPages = iDisplayPages + 1 next SetVar "NavigatorPageSwitch", "_" SetVar "NavigatorPageNumber", iPage SetVar "NavigatorPageNumberView", iPage Parse "cursosNavigatorPages", true iDisplayPages = iDisplayPages + 1 SetVar "NavigatorPageSwitch", "" iPageCount = iPage + 1 while iDisplayPages < iNumberOfPages and iStartPage + iDisplayPages < iHasPages SetVar "NavigatorPageNumber", iPageCount SetVar "NavigatorPageNumberView", iPageCount Parse "cursosNavigatorPages", true iDisplayPages = iDisplayPages + 1 iPageCount = iPageCount + 1 wend if bEof then SetVar "cursosNavigatorLastPage", "_" else SetVar "NextPage", (iPage + 1) end if if iPage = 1 then SetVar "cursosNavigatorFirstPage", "_" else SetVar "PrevPage", (iPage - 1) end if SetVar "cursosCurrentPage", iPage Parse "cursosNavigator", False end if '------------------------------- ' cursos Navigation end '------------------------------- '------------------------------- ' Finish form processing '------------------------------- set rs = nothing SetVar "cursosNoRecords", "" Parse "Formcursos", False '------------------------------- ' cursos Close Event begin ' cursos Close Event end '------------------------------- End Sub '=============================== %>