<%
'
'    Filename: faq_kenmerkgrid.asp
'    Generated with CodeCharge 2.0.5
'    ASP 2.0 & Templates.ccp build 11/30/2001
'

'-------------------------------
' 
' faq_kenmerkgrid CustomIncludes Event begin
%>
<!-- #INCLUDE FILE="Common.asp" -->
<%
' faq_kenmerkgrid CustomIncludes Event end


'===============================
' Save Page and File Name available into variables
'-------------------------------
sFileName = "faq_kenmerkgrid.asp"
sTemplateFileName = "faq_kenmerkgrid.html"
'===============================


'===============================
' faq_kenmerkgrid PageSecurity begin
' faq_kenmerkgrid PageSecurity end
'===============================

'===============================
' faq_kenmerkgrid Open Event begin
' faq_kenmerkgrid Open Event end
'===============================

'===============================
' faq_kenmerkgrid OpenAnyPage Event begin
' faq_kenmerkgrid OpenAnyPage Event end
'===============================

'===============================
'Save the name of the form and type of action into the variables
'-------------------------------
sAction = GetParam("FormAction")
sForm = GetParam("FormName")
'===============================

' faq_kenmerkgrid 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
'-------------------------------
KenmerkSearch_Show
KenmerkGrid_Show
'-------------------------------
' Process page templates
'-------------------------------
Parse "main", False
'-------------------------------
' Output the page to the browser
'-------------------------------
Response.write PrintVar("main")

' faq_kenmerkgrid Show end

'-------------------------------
' Destroy all object variables
'-------------------------------

' faq_kenmerkgrid Close Event begin
' faq_kenmerkgrid Close Event end

cn.Close
Set cn = Nothing
UnloadTemplate
'===============================

'===============================
' Display Grid Form
'-------------------------------
Sub KenmerkGrid_Show()
'-------------------------------
' Initialize variables  
'-------------------------------
  Dim rs
  Dim sWhere : sWhere = ""
  Dim sOrder : sOrder = ""
  Dim sSQL : sSQL = ""
  Dim sFormTitle: sFormTitle = "Kenmerken"
  Dim HasParam : HasParam = false
  Dim iSort : iSort = ""
  Dim iSorted : iSorted = ""
  Dim sDirection : sDirection = ""
  Dim sSortParams : sSortParams = ""
  Dim iRecordsPerPage : iRecordsPerPage = 25
  Dim iCounter : iCounter = 0
  Dim iPage : iPage = 0
  Dim bEof : bEof = False
  Dim iTmpI : iTmpI = 0
  Dim iTmpJ : iTmpJ = 0
  Dim sCountSQL : sCountSQL = ""
  Dim sActionFileName : sActionFileName = "faq_kenmerkrecord.asp"

  SetVar "TransitParams", "sFAQ_KENMERK_KENMERKTYPE=" & ToURL(GetParam("sFAQ_KENMERK_KENMERKTYPE")) & "&sFAQ_KENMERK_UPPER=" & ToURL(GetParam("sFAQ_KENMERK_UPPER")) & "&"
  SetVar "FormParams", "sFAQ_KENMERK_KENMERKTYPE=" & ToURL(GetParam("sFAQ_KENMERK_KENMERKTYPE")) & "&sFAQ_KENMERK_UPPER=" & ToURL(GetParam("sFAQ_KENMERK_UPPER")) & "&"

'-------------------------------
' Build WHERE statement
'-------------------------------


  sWhere = " WHERE faq_kenmerk_verwijder IS NULL"
  
'-------------------------------
' Build ORDER BY statement
'-------------------------------
  sOrder = " order by F.FAQ_KENMERK_VOLGNR Asc"
  iSort = GetParam("FormKenmerkGrid_Sorting")
  iSorted = GetParam("FormKenmerkGrid_Sorted")
  sDirection = ""
  if IsEmpty(iSort) then
    SetVar "Form_Sorting", ""
  else
    if iSort = iSorted then 
      SetVar "Form_Sorting", ""
      sDirection = " DESC"
      sSortParams = "FormKenmerkGrid_Sorting=" & iSort & "&FormKenmerkGrid_Sorted=" & iSort & "&"
    else
      SetVar "Form_Sorting", iSort
      sDirection = " ASC"
      sSortParams = "FormKenmerkGrid_Sorting=" & iSort & "&FormKenmerkGrid_Sorted=" & "&"
    end if
    if iSort = 1 then sOrder = " order by F.FAQ_KENMERK_KEY" & sDirection
    if iSort = 2 then sOrder = " order by F.FAQ_KENMERK_VOLGNR" & sDirection
    if iSort = 3 then sOrder = " order by F.FAQ_KENMERK_OMSCHRIJVING" & sDirection
    if iSort = 4 then sOrder = " order by F.FAQ_KENMERK_KENMERKTYPE" & sDirection
  end if

'-------------------------------
' Build base SQL statement
'-------------------------------
  sSQL = "select F.FAQ_KENMERK_KENMERKTYPE as F_FAQ_KENMERK_KENMERKTYPE, " & _
    "F.FAQ_KENMERK_KEY as F_FAQ_KENMERK_KEY, " & _
    "F.FAQ_KENMERK_OMSCHRIJVING as F_FAQ_KENMERK_OMSCHRIJVING, " & _
    "F.FAQ_KENMERK_VOLGNR as F_FAQ_KENMERK_VOLGNR " & _
    " from FAQ_KENMERK F "
'-------------------------------

'-------------------------------
' KenmerkGrid Open Event begin
tmpWhere = ""
pFAQ_KENMERK_UPPER = getParam("sFAQ_KENMERK_UPPER")
pFAQ_KENMERK_KENMERKTYPE = getParam("sFAQ_KENMERK_KENMERKTYPE")
if not isEmpty(pFAQ_KENMERK_UPPER) then
  hasParam = true
  tmpWhere = tmpWhere & " AND FAQ_KENMERK_UPPER like " & ToSQL("%"& UCase(pFAQ_KENMERK_UPPER) &"%", "Text")
end if

if not isEmpty(pFAQ_KENMERK_KENMERKTYPE) then
  HasParam = true
  tmpWhere = tmpWhere & " AND FAQ_KENMERK_KENMERKTYPE = " & ToSQL(pFAQ_KENMERK_KENMERKTYPE, "Text")
end if

if HasParam then
  sWhere = sWhere & tmpWhere
end if
' KenmerkGrid 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 link to the record page
'-------------------------------
  SetVar "FormAction", sActionFileName
'-------------------------------

'-------------------------------
' 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 "DListKenmerkGrid", ""
    Parse "KenmerkGridNoRecords", False
    SetVar "KenmerkGridNavigator", ""
    Parse "FormKenmerkGrid", False
    exit sub
  end if
'-------------------------------

'-------------------------------
' Initialize page counter and records per page
'-------------------------------
  iRecordsPerPage = 25
  iCounter = 0
'-------------------------------

'-------------------------------
' Process page scroller
'-------------------------------
  iPage = GetParam("FormKenmerkGrid_Page")
  openrs rsCount, sCountSQL
  dResult = CLng(rsCount.fields(0).value) / iRecordsPerPage
  iPageCount = int(dResult)
  if iPageCount < dResult then iPageCount = iPageCount + 1
  SetVar "KenmerkGridPageCount", 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
'-------------------------------
    fldFAQ_KENMERK_KENMERKTYPE_URLLink = "faq_kenmerkrecord.asp"
    fldFAQ_KENMERK_KENMERKTYPE_FAQ_KENMERK_KEY = GetValue(rs, "F_FAQ_KENMERK_KEY")
    fldFAQ_KENMERK_KENMERKTYPE = GetValue(rs, "F_FAQ_KENMERK_KENMERKTYPE")
    fldFAQ_KENMERK_KEY = GetValue(rs, "F_FAQ_KENMERK_KEY")
    fldFAQ_KENMERK_OMSCHRIJVING_URLLink = "faq_kenmerkrecord.asp"
    fldFAQ_KENMERK_OMSCHRIJVING_FAQ_KENMERK_KEY = GetValue(rs, "F_FAQ_KENMERK_KEY")
    fldFAQ_KENMERK_OMSCHRIJVING = GetValue(rs, "F_FAQ_KENMERK_OMSCHRIJVING")
    fldFAQ_KENMERK_VOLGNR_URLLink = "faq_kenmerkrecord.asp"
    fldFAQ_KENMERK_VOLGNR_FAQ_KENMERK_KEY = GetValue(rs, "F_FAQ_KENMERK_KEY")
    fldFAQ_KENMERK_VOLGNR = GetValue(rs, "F_FAQ_KENMERK_VOLGNR")
'-------------------------------
' KenmerkGrid Show begin
'-------------------------------

'-------------------------------
' KenmerkGrid Show Event begin
fldFAQ_KENMERK_KENMERKTYPE = decodeKenmerkType(fldFAQ_KENMERK_KENMERKTYPE)
' KenmerkGrid Show Event end
'-------------------------------

'-------------------------------
' Replace Template fields with database values
'-------------------------------
    
      SetVar "FAQ_KENMERK_KEY", ToHTML(fldFAQ_KENMERK_KEY)
      SetVar "FAQ_KENMERK_VOLGNR", ToHTML(fldFAQ_KENMERK_VOLGNR)
      SetVar "FAQ_KENMERK_VOLGNR_URLLink", fldFAQ_KENMERK_VOLGNR_URLLink
      SetVar "PrmFAQ_KENMERK_VOLGNR_FAQ_KENMERK_KEY", ToURL(fldFAQ_KENMERK_VOLGNR_FAQ_KENMERK_KEY)
      SetVar "FAQ_KENMERK_OMSCHRIJVING", ToHTML(fldFAQ_KENMERK_OMSCHRIJVING)
      SetVar "FAQ_KENMERK_OMSCHRIJVING_URLLink", fldFAQ_KENMERK_OMSCHRIJVING_URLLink
      SetVar "PrmFAQ_KENMERK_OMSCHRIJVING_FAQ_KENMERK_KEY", ToURL(fldFAQ_KENMERK_OMSCHRIJVING_FAQ_KENMERK_KEY)
      SetVar "FAQ_KENMERK_KENMERKTYPE", ToHTML(fldFAQ_KENMERK_KENMERKTYPE)
      SetVar "FAQ_KENMERK_KENMERKTYPE_URLLink", fldFAQ_KENMERK_KENMERKTYPE_URLLink
      SetVar "PrmFAQ_KENMERK_KENMERKTYPE_FAQ_KENMERK_KEY", ToURL(fldFAQ_KENMERK_KENMERKTYPE_FAQ_KENMERK_KEY)
    Parse "DListKenmerkGrid", True

'-------------------------------
' KenmerkGrid Show end
'-------------------------------

'-------------------------------
' Move to the next record and increase record counter
'-------------------------------
    rs.MoveNext
    iCounter = iCounter + 1
  wend
'-------------------------------


'-------------------------------
' KenmerkGrid Navigation begin
'-------------------------------
  bEof = rs.eof
  if rs.eof and iPage = 1 then
	SetVar "KenmerkGridNavigator", ""
  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 "KenmerkGridNavigatorPages", true
      iDisplayPages = iDisplayPages + 1
    next
    SetVar "NavigatorPageSwitch", "_"
    SetVar "NavigatorPageNumber", iPage
    SetVar "NavigatorPageNumberView", iPage
    Parse "KenmerkGridNavigatorPages", true
    iDisplayPages = iDisplayPages + 1
    SetVar "NavigatorPageSwitch", ""
    iPageCount = iPage + 1
    while iDisplayPages < iNumberOfPages and iStartPage + iDisplayPages < iHasPages
      SetVar "NavigatorPageNumber", iPageCount
      SetVar "NavigatorPageNumberView", iPageCount
      Parse "KenmerkGridNavigatorPages", true
      iDisplayPages = iDisplayPages + 1
      iPageCount = iPageCount + 1
    wend
    if bEof then
      SetVar "KenmerkGridNavigatorLastPage", "_"
    else
      SetVar "NextPage", (iPage + 1)
    end if
    if iPage = 1 then
      SetVar "KenmerkGridNavigatorFirstPage", "_"
    else
      SetVar "PrevPage", (iPage - 1)
    end if
    SetVar "KenmerkGridCurrentPage", iPage
    Parse "KenmerkGridNavigator", False
  end if
'-------------------------------
' KenmerkGrid Navigation end
'-------------------------------

'-------------------------------
' Finish form processing
'-------------------------------
  set rs = nothing
  SetVar "KenmerkGridNoRecords", ""
  Parse "FormKenmerkGrid", False

'-------------------------------
' KenmerkGrid Close Event begin
' KenmerkGrid Close Event end
'-------------------------------
End Sub
'===============================


'===============================
' Display Search Form
'-------------------------------
Sub KenmerkSearch_Show()
  Dim sFormTitle: sFormTitle = ""
  Dim sActionFileName: sActionFileName = "faq_kenmerkgrid.asp"

'-------------------------------
' KenmerkSearch Open Event begin
' KenmerkSearch Open Event end
'-------------------------------
      SetVar "FormTitle", sFormTitle
      SetVar "ActionPage", sActionFileName

'-------------------------------
' Set variables with search parameters
'-------------------------------
      fldsFAQ_KENMERK_UPPER = GetParam("sFAQ_KENMERK_UPPER")
      fldsFAQ_KENMERK_KENMERKTYPE = GetParam("sFAQ_KENMERK_KENMERKTYPE")

'-------------------------------
' KenmerkSearch Show begin
'-------------------------------


'-------------------------------
' KenmerkSearch Show Event begin
' KenmerkSearch Show Event end
'-------------------------------
      SetVar "sFAQ_KENMERK_UPPER", ToHTML(fldsFAQ_KENMERK_UPPER)
      SetVar "KenmerkSearchLBsFAQ_KENMERK_KENMERKTYPE", ""
      LOV = Split(""&buildKenmerkTypeSearch()&"", ";")
      if (ubound(LOV) mod 2) = 1 then
        for i = 0 to ubound(LOV) step 2
          SetVar "ID", LOV(i) : SetVar "Value", LOV(i+1)
          if cstr(LOV(i)) = cstr(fldsFAQ_KENMERK_KENMERKTYPE) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "KenmerkSearchLBsFAQ_KENMERK_KENMERKTYPE", True
        next
      end if
    

'-------------------------------
' KenmerkSearch Show end
'-------------------------------

'-------------------------------
' KenmerkSearch Close Event begin
' KenmerkSearch Close Event end
'-------------------------------
      Parse "FormKenmerkSearch", False
End Sub
'===============================

%>