<% ' ' Filename: alumnicontacts.asp ' Generated with CodeCharge 2.0.7 ' ASP 2.0 & Templates.ccp build 11/30/2001 ' '------------------------------- ' alumnicontacts CustomIncludes begin %> <% ' alumnicontacts CustomIncludes end '------------------------------- '=============================== ' Save Page and File Name available into variables '------------------------------- sFileName = "alumnicontacts.asp" sTemplateFileName = "alumnicontacts.html" '=============================== '=============================== ' alumnicontacts PageSecurity begin ' alumnicontacts PageSecurity end '=============================== '=============================== ' alumnicontacts Open Event begin ' alumnicontacts Open Event end '=============================== '=============================== ' alumnicontacts OpenAnyPage Event begin ' alumnicontacts OpenAnyPage Event end '=============================== '=============================== 'Save the name of the form and type of action into the variables '------------------------------- sAction = GetParam("FormAction") sForm = GetParam("FormName") '=============================== ' alumnicontacts 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 UMC_Alumni_Contacts_Show '------------------------------- ' Process page templates '------------------------------- Parse "main", False '------------------------------- ' Output the page to the browser '------------------------------- Response.write PrintVar("main") ' alumnicontacts Show end '------------------------------- ' Destroy all object variables '------------------------------- ' alumnicontacts Close Event begin ' alumnicontacts Close Event end cn.Close Set cn = Nothing UnloadTemplate '=============================== '=============================== ' Display Search Form '------------------------------- Sub Search_Show() Dim sFormTitle: sFormTitle = "Search" Dim sActionFileName: sActionFileName = "alumnicontacts.asp" '------------------------------- ' Search Open Event begin ' Search Open Event end '------------------------------- SetVar "FormTitle", sFormTitle SetVar "ActionPage", sActionFileName '------------------------------- ' Set variables with search parameters '------------------------------- flds_Name = GetParam("s_Name") flds_Year_Graduation_Degree = GetParam("s_Year_Graduation_Degree") '------------------------------- ' Search Show begin '------------------------------- '------------------------------- ' Search Show Event begin ' Search Show Event end '------------------------------- SetVar "s_Name", ToHTML(flds_Name) SetVar "s_Year_Graduation_Degree", ToHTML(flds_Year_Graduation_Degree) '------------------------------- ' Search Show end '------------------------------- '------------------------------- ' Search Close Event begin ' Search Close Event end '------------------------------- Parse "FormSearch", False End Sub '=============================== '=============================== ' Display Grid Form '------------------------------- Sub UMC_Alumni_Contacts_Show() '------------------------------- ' Initialize variables '------------------------------- Dim rs Dim sWhere : sWhere = "" Dim sOrder : sOrder = "" Dim sSQL : sSQL = "" Dim sFormTitle: sFormTitle = "UMC_Alumni_Contacts" 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 Dim iTmpI : iTmpI = 0 Dim iTmpJ : iTmpJ = 0 Dim sCountSQL : sCountSQL = "" SetVar "TransitParams", "s_Name=" & ToURL(GetParam("s_Name")) & "&s_Year_Graduation_Degree=" & ToURL(GetParam("s_Year_Graduation_Degree")) & "&" SetVar "FormParams", "s_Name=" & ToURL(GetParam("s_Name")) & "&s_Year_Graduation_Degree=" & ToURL(GetParam("s_Year_Graduation_Degree")) & "&" '------------------------------- ' Build WHERE statement '------------------------------- ps_Name = GetParam("s_Name") if not isEmpty(ps_Name) then HasParam = true sWhere = sWhere & "U.[Name] like '%" & replace(ps_Name, "'", "''") & "%'" end if ps_Year_Graduation_Degree = GetParam("s_Year_Graduation_Degree") if not isEmpty(ps_Year_Graduation_Degree) then if not (sWhere = "") then sWhere = sWhere & " and " HasParam = true sWhere = sWhere & "U.[Year_Graduation_Degree] like '%" & replace(ps_Year_Graduation_Degree, "'", "''") & "%'" end if if HasParam then sWhere = " WHERE (" & sWhere & ")" end if '------------------------------- ' Build ORDER BY statement '------------------------------- iSort = GetParam("FormUMC_Alumni_Contacts_Sorting") iSorted = GetParam("FormUMC_Alumni_Contacts_Sorted") sDirection = "" if IsEmpty(iSort) then SetVar "Form_Sorting", "" else if iSort = iSorted then SetVar "Form_Sorting", "" sDirection = " DESC" sSortParams = "FormUMC_Alumni_Contacts_Sorting=" & iSort & "&FormUMC_Alumni_Contacts_Sorted=" & iSort & "&" else SetVar "Form_Sorting", iSort sDirection = " ASC" sSortParams = "FormUMC_Alumni_Contacts_Sorting=" & iSort & "&FormUMC_Alumni_Contacts_Sorted=" & "&" end if if iSort = 1 then sOrder = " order by U.[Name]" & sDirection if iSort = 2 then sOrder = " order by U.[Year_Graduation_Degree]" & sDirection if iSort = 3 then sOrder = " order by U.[Email_Address]" & sDirection end if '------------------------------- ' Build base SQL statement '------------------------------- sSQL = "select [U].[Email_Address] as U_Email_Address, " & _ "[U].[ID] as U_ID, " & _ "[U].[Name] as U_Name, " & _ "[U].[Year_Graduation_Degree] as U_Year_Graduation_Degree " & _ " from [UMC_Alumni_Contacts] U " '------------------------------- '------------------------------- ' UMC_Alumni_Contacts Open Event begin ' UMC_Alumni_Contacts 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 '------------------------------- ' 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 "DListUMC_Alumni_Contacts", "" Parse "UMC_Alumni_ContactsNoRecords", False SetVar "UMC_Alumni_ContactsNavigator", "" Parse "FormUMC_Alumni_Contacts", False exit sub end if '------------------------------- '------------------------------- ' Initialize page counter and records per page '------------------------------- iRecordsPerPage = 20 iCounter = 0 '------------------------------- '------------------------------- ' Process page scroller '------------------------------- iPage = GetParam("FormUMC_Alumni_Contacts_Page") openrs rsCount, sCountSQL dResult = CLng(rsCount.fields(0).value) / iRecordsPerPage iPageCount = int(dResult) if iPageCount < dResult then iPageCount = iPageCount + 1 SetVar "UMC_Alumni_ContactsPageCount", 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 '------------------------------- fldEmail_Address = GetValue(rs, "U_Email_Address") fldID = GetValue(rs, "U_ID") fldName = GetValue(rs, "U_Name") fldYear_Graduation_Degree = GetValue(rs, "U_Year_Graduation_Degree") '------------------------------- ' UMC_Alumni_Contacts Show begin '------------------------------- '------------------------------- ' UMC_Alumni_Contacts Show Event begin ' UMC_Alumni_Contacts Show Event end '------------------------------- '------------------------------- ' Replace Template fields with database values '------------------------------- SetVar "ID", ToHTML(fldID) SetVar "Name", ToHTML(fldName) SetVar "Year_Graduation_Degree", ToHTML(fldYear_Graduation_Degree) SetVar "Email_Address", ToHTML(fldEmail_Address) Parse "DListUMC_Alumni_Contacts", True '------------------------------- ' UMC_Alumni_Contacts Show end '------------------------------- '------------------------------- ' Move to the next record and increase record counter '------------------------------- rs.MoveNext iCounter = iCounter + 1 wend '------------------------------- '------------------------------- ' UMC_Alumni_Contacts Navigation begin '------------------------------- bEof = rs.eof if rs.eof and iPage = 1 then SetVar "UMC_Alumni_ContactsNavigator", "" else iCounter = 1 iHasPages = iPage iDisplayPages = 0 iNumberOfPages = 10 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 "UMC_Alumni_ContactsNavigatorPages", true iDisplayPages = iDisplayPages + 1 next SetVar "NavigatorPageSwitch", "_" SetVar "NavigatorPageNumber", iPage SetVar "NavigatorPageNumberView", iPage Parse "UMC_Alumni_ContactsNavigatorPages", true iDisplayPages = iDisplayPages + 1 SetVar "NavigatorPageSwitch", "" iPageCount = iPage + 1 while iDisplayPages < iNumberOfPages and iStartPage + iDisplayPages < iHasPages SetVar "NavigatorPageNumber", iPageCount SetVar "NavigatorPageNumberView", iPageCount Parse "UMC_Alumni_ContactsNavigatorPages", true iDisplayPages = iDisplayPages + 1 iPageCount = iPageCount + 1 wend if bEof then SetVar "UMC_Alumni_ContactsNavigatorLastPage", "_" else SetVar "NextPage", (iPage + 1) end if if iPage = 1 then SetVar "UMC_Alumni_ContactsNavigatorFirstPage", "_" else SetVar "PrevPage", (iPage - 1) end if SetVar "UMC_Alumni_ContactsCurrentPage", iPage Parse "UMC_Alumni_ContactsNavigator", False end if '------------------------------- ' UMC_Alumni_Contacts Navigation end '------------------------------- '------------------------------- ' Finish form processing '------------------------------- set rs = nothing SetVar "UMC_Alumni_ContactsNoRecords", "" Parse "FormUMC_Alumni_Contacts", False '------------------------------- ' UMC_Alumni_Contacts Close Event begin ' UMC_Alumni_Contacts Close Event end '------------------------------- End Sub '=============================== %>