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

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


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


'===============================
' mld_srtdisciplinerecord PageSecurity begin
' mld_srtdisciplinerecord PageSecurity end
'===============================

'===============================
' mld_srtdisciplinerecord Open Event begin
' mld_srtdisciplinerecord Open Event end
'===============================

'===============================
' mld_srtdisciplinerecord OpenAnyPage Event begin
' mld_srtdisciplinerecord OpenAnyPage Event end
'===============================

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

' mld_srtdisciplinerecord Show begin
'===============================
' Perform the form's action
'-------------------------------
' Initialize error variables
'-------------------------------
sSrtDisciplineRecordErr = ""

'-------------------------------
' Select the FormAction
'-------------------------------
Select Case sForm
  Case "SrtDisciplineRecord"
    SrtDisciplineRecordAction(sAction)
end select
'===============================

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

' mld_srtdisciplinerecord Show end

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

' mld_srtdisciplinerecord Close Event begin
' mld_srtdisciplinerecord Close Event end

cn.Close
Set cn = Nothing
UnloadTemplate
'===============================
'===============================
' Action of the Record Form
'-------------------------------
Sub SrtDisciplineRecordAction(sAction)
'-------------------------------
' Initialize variables  
'-------------------------------
  Dim bExecSQL: bExecSQL = true
  Dim sActionFileName : sActionFileName = ""
  Dim sWhere : sWhere = "" 
  Dim bErr : bErr = False
  Dim pPKINS_SRTDISCIPLINE_KEY : pPKINS_SRTDISCIPLINE_KEY = ""
  Dim fldINS_SRTDISCIPLINE_MODULE : fldINS_SRTDISCIPLINE_MODULE = ""
  Dim fldINS_SRTDISCIPLINE_OMSCHRIJVING : fldINS_SRTDISCIPLINE_OMSCHRIJVING = ""
  Dim fldINS_SRTDISCIPLINE_PREFIX : fldINS_SRTDISCIPLINE_PREFIX = ""
  Dim fldINS_SRTDISCIPLINE_ALG : fldINS_SRTDISCIPLINE_ALG = ""
  Dim fldINS_SRTDISCIPLINE_INS : fldINS_SRTDISCIPLINE_INS = ""
  Dim fldINS_SRTDISCIPLINE_BES : fldINS_SRTDISCIPLINE_BES = ""
  Dim fldINS_SRTDISCIPLINE_KOSTENKLANT : fldINS_SRTDISCIPLINE_KOSTENKLANT = ""
  Dim fldINS_SRTDISCIPLINE_OPMERKING : fldINS_SRTDISCIPLINE_OPMERKING = ""
'-------------------------------

'-------------------------------
' SrtDisciplineRecord Action begin
'-------------------------------
  sActionFileName = "mld_srtdisciplinegrid.asp"

'-------------------------------
' CANCEL action
'-------------------------------
  if sAction = "cancel" then

'-------------------------------
' SrtDisciplineRecord BeforeCancel Event begin
' SrtDisciplineRecord BeforeCancel Event end
'-------------------------------
    cn.Close
    Set cn = Nothing
    response.redirect sActionFileName
  end if
'-------------------------------

'-------------------------------
' Build WHERE statement
'-------------------------------
  if sAction = "update" or sAction = "delete" then
    pPKINS_SRTDISCIPLINE_KEY = GetParam("PK_INS_SRTDISCIPLINE_KEY")
    if IsEmpty(pPKINS_SRTDISCIPLINE_KEY) then exit sub
    sWhere = "INS_SRTDISCIPLINE_KEY=" & ToSQL(pPKINS_SRTDISCIPLINE_KEY, "Number")
  end if
'-------------------------------


'-------------------------------
' Load all form fields into variables
'-------------------------------
  fldINS_SRTDISCIPLINE_MODULE = GetParam("INS_SRTDISCIPLINE_MODULE")
  fldINS_SRTDISCIPLINE_OMSCHRIJVING = GetParam("INS_SRTDISCIPLINE_OMSCHRIJVING")
  fldINS_SRTDISCIPLINE_PREFIX = GetParam("INS_SRTDISCIPLINE_PREFIX")
  fldINS_SRTDISCIPLINE_ALG = GetParam("INS_SRTDISCIPLINE_ALG")
  fldINS_SRTDISCIPLINE_INS = getCheckBoxValue(GetParam("INS_SRTDISCIPLINE_INS"), "1", "0", "Number")
  fldINS_SRTDISCIPLINE_BES = getCheckBoxValue(GetParam("INS_SRTDISCIPLINE_BES"), "1", "0", "Number")
  fldINS_SRTDISCIPLINE_KOSTENKLANT = GetParam("INS_SRTDISCIPLINE_KOSTENKLANT")
  fldINS_SRTDISCIPLINE_OPMERKING = GetParam("INS_SRTDISCIPLINE_OPMERKING")

'-------------------------------
' Validate fields
'-------------------------------
  if sAction = "insert" or sAction = "update" then
    if IsEmpty(fldINS_SRTDISCIPLINE_OMSCHRIJVING) then
      sSrtDisciplineRecordErr = sSrtDisciplineRecordErr & "De waarde in veld Omschrijving is verplicht.<br>"
    end if
    if not isNumeric(fldINS_SRTDISCIPLINE_ALG) then
      sSrtDisciplineRecordErr = sSrtDisciplineRecordErr & "De waarde in veld Plaatsgegevens is niet correct.<br>"
    end if
    if not isNumeric(fldINS_SRTDISCIPLINE_KOSTENKLANT) then
      sSrtDisciplineRecordErr = sSrtDisciplineRecordErr & "De waarde in veld Defaultwaarde kosten klant is niet correct.<br>"
    end if
'-------------------------------
' SrtDisciplineRecord Check Event begin
' SrtDisciplineRecord Check Event end
'-------------------------------
    If len(sSrtDisciplineRecordErr) > 0 then
      exit sub
    end if
  end if
'-------------------------------


'-------------------------------
' Create SQL statement
'-------------------------------
  select case sAction
    case "insert"
'-------------------------------
' SrtDisciplineRecord Insert Event begin
' SrtDisciplineRecord Insert Event end
'-------------------------------
      sSQL = "insert into INS_SRTDISCIPLINE (" & _
          "INS_SRTDISCIPLINE_MODULE," & _
          "INS_SRTDISCIPLINE_OMSCHRIJVING," & _
          "INS_SRTDISCIPLINE_PREFIX," & _
          "INS_SRTDISCIPLINE_ALG," & _
          "INS_SRTDISCIPLINE_INS," & _
          "INS_SRTDISCIPLINE_BES," & _
          "INS_SRTDISCIPLINE_KOSTENKLANT," & _
          "INS_SRTDISCIPLINE_OPMERKING)" & _
          " values (" & _
          ToSQL(fldINS_SRTDISCIPLINE_MODULE, "Text") & "," & _
          ToSQL(fldINS_SRTDISCIPLINE_OMSCHRIJVING, "Text") & "," & _
          ToSQL(fldINS_SRTDISCIPLINE_PREFIX, "Text") & "," & _
          ToSQL(fldINS_SRTDISCIPLINE_ALG, "Number") & "," & _
          fldINS_SRTDISCIPLINE_INS & "," & _
          fldINS_SRTDISCIPLINE_BES & "," & _
          ToSQL(fldINS_SRTDISCIPLINE_KOSTENKLANT, "Number") & "," & _
          ToSQL(fldINS_SRTDISCIPLINE_OPMERKING, "Text") & _
          ")"
    case "update"
'-------------------------------
' SrtDisciplineRecord Update Event begin
' SrtDisciplineRecord Update Event end
'-------------------------------
      sSQL = "update INS_SRTDISCIPLINE set " & _
        "INS_SRTDISCIPLINE_MODULE=" & ToSQL(fldINS_SRTDISCIPLINE_MODULE, "Text") & _
        ",INS_SRTDISCIPLINE_OMSCHRIJVING=" & ToSQL(fldINS_SRTDISCIPLINE_OMSCHRIJVING, "Text") & _
        ",INS_SRTDISCIPLINE_PREFIX=" & ToSQL(fldINS_SRTDISCIPLINE_PREFIX, "Text") & _
        ",INS_SRTDISCIPLINE_ALG=" & ToSQL(fldINS_SRTDISCIPLINE_ALG, "Number") & _
        ",INS_SRTDISCIPLINE_INS=" & fldINS_SRTDISCIPLINE_INS & _
        ",INS_SRTDISCIPLINE_BES=" & fldINS_SRTDISCIPLINE_BES & _
        ",INS_SRTDISCIPLINE_KOSTENKLANT=" & ToSQL(fldINS_SRTDISCIPLINE_KOSTENKLANT, "Number") & _
        ",INS_SRTDISCIPLINE_OPMERKING=" & ToSQL(fldINS_SRTDISCIPLINE_OPMERKING, "Text")
      sSQL = sSQL & " where " & sWhere
    case "delete"
'-------------------------------
' SrtDisciplineRecord Delete Event begin
sSql = "update ins_srtdiscipline "&_
       "set ins_srtdiscipline_verwijder = "&sysdate&" "&_
       "where ins_srtdiscipline_key="&pPKINS_SRTDISCIPLINE_KEY
' SrtDisciplineRecord Delete Event end
'-------------------------------
      if sSQL = "" then
      sSQL = "delete from INS_SRTDISCIPLINE where " & sWhere
      end if
  end select
'-------------------------------
'-------------------------------
' SrtDisciplineRecord BeforeExecute Event begin
' SrtDisciplineRecord BeforeExecute Event end
'-------------------------------

'-------------------------------
' Execute SQL statement
'-------------------------------
if len(sSrtDisciplineRecordErr) > 0 then Exit Sub
  on error resume next
  if bExecSQL then 
    cn.execute sSQL
  end if
  sSrtDisciplineRecordErr = ProcessError
  on error goto 0
  if len(sSrtDisciplineRecordErr) > 0 then Exit Sub
  cn.Close
  Set cn = Nothing
  response.redirect sActionFileName
'-------------------------------
' SrtDisciplineRecord Action end
'-------------------------------
end sub
'===============================

'===============================
' Display Record Form
'-------------------------------
Sub SrtDisciplineRecord_Show()
'-------------------------------
' SrtDisciplineRecord Show begin
'-------------------------------
  Dim sWhere : sWhere = ""
  Dim sFormTitle: sFormTitle = "Details vakgroeptype"
  Dim bPK : bPK = True

'-------------------------------
' Load primary key and form parameters
'-------------------------------
  if sSrtDisciplineRecordErr = "" then
    pINS_SRTDISCIPLINE_KEY = GetParam("INS_SRTDISCIPLINE_KEY")
    SetVar "SrtDisciplineRecordError", ""
  else
    fldINS_SRTDISCIPLINE_MODULE = GetParam("INS_SRTDISCIPLINE_MODULE")
    fldINS_SRTDISCIPLINE_OMSCHRIJVING = GetParam("INS_SRTDISCIPLINE_OMSCHRIJVING")
    fldINS_SRTDISCIPLINE_PREFIX = GetParam("INS_SRTDISCIPLINE_PREFIX")
    fldINS_SRTDISCIPLINE_ALG = GetParam("INS_SRTDISCIPLINE_ALG")
    fldINS_SRTDISCIPLINE_INS = getCheckBoxValue(GetParam("INS_SRTDISCIPLINE_INS"), "1", "0", "Number")
    fldINS_SRTDISCIPLINE_BES = getCheckBoxValue(GetParam("INS_SRTDISCIPLINE_BES"), "1", "0", "Number")
    fldINS_SRTDISCIPLINE_KOSTENKLANT = GetParam("INS_SRTDISCIPLINE_KOSTENKLANT")
    fldINS_SRTDISCIPLINE_OPMERKING = GetParam("INS_SRTDISCIPLINE_OPMERKING")
    pINS_SRTDISCIPLINE_KEY = GetParam("PK_INS_SRTDISCIPLINE_KEY")
    SetVar "sSrtDisciplineRecordErr", sSrtDisciplineRecordErr
    SetVar "FormTitle", sFormTitle
    Parse "SrtDisciplineRecordError", False
  end if
'-------------------------------

'-------------------------------
' Load all form fields

'-------------------------------

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

  if IsEmpty(pINS_SRTDISCIPLINE_KEY) then bPK = False
  
  sWhere = sWhere & "INS_SRTDISCIPLINE_KEY=" & ToSQL(pINS_SRTDISCIPLINE_KEY, "Number")
  SetVar "PK_INS_SRTDISCIPLINE_KEY", pINS_SRTDISCIPLINE_KEY
'-------------------------------
'-------------------------------
' SrtDisciplineRecord Open Event begin
' SrtDisciplineRecord Open Event end
'-------------------------------

  SetVar "FormTitle", sFormTitle

'-------------------------------
' Build SQL statement and open recordset
'-------------------------------
  sSQL = "select * from INS_SRTDISCIPLINE where " & sWhere
  openrs rs, sSQL
  bIsUpdateMode = (bPK and not(sAction = "insert" and sForm = "SrtDisciplineRecord") and not rs.eof)
'-------------------------------

'-------------------------------
' Load all fields into variables from recordset or input parameters
'-------------------------------
  if bIsUpdateMode then
    fldINS_SRTDISCIPLINE_KEY = GetValue(rs, "INS_SRTDISCIPLINE_KEY")
    fldINS_SRTDISCIPLINE_MODULE = GetValue(rs, "INS_SRTDISCIPLINE_MODULE")

'-------------------------------
' Load data from recordset when form displayed first time
'-------------------------------
    if sSrtDisciplineRecordErr = "" then
      fldINS_SRTDISCIPLINE_OMSCHRIJVING = GetValue(rs, "INS_SRTDISCIPLINE_OMSCHRIJVING")
      fldINS_SRTDISCIPLINE_PREFIX = GetValue(rs, "INS_SRTDISCIPLINE_PREFIX")
      fldINS_SRTDISCIPLINE_ALG = GetValue(rs, "INS_SRTDISCIPLINE_ALG")
      fldINS_SRTDISCIPLINE_INS = GetValue(rs, "INS_SRTDISCIPLINE_INS")
      fldINS_SRTDISCIPLINE_BES = GetValue(rs, "INS_SRTDISCIPLINE_BES")
      fldINS_SRTDISCIPLINE_KOSTENKLANT = GetValue(rs, "INS_SRTDISCIPLINE_KOSTENKLANT")
      fldINS_SRTDISCIPLINE_OPMERKING = GetValue(rs, "INS_SRTDISCIPLINE_OPMERKING")
    end if
    SetVar "SrtDisciplineRecordInsert", ""
    Parse "SrtDisciplineRecordEdit", False
'-------------------------------
' SrtDisciplineRecord ShowEdit Event begin
' SrtDisciplineRecord ShowEdit Event end
'-------------------------------
  else
    if sSrtDisciplineRecordErr = "" then
      fldINS_SRTDISCIPLINE_MODULE= "MLD"
      fldINS_SRTDISCIPLINE_KOSTENKLANT= "0"
    end if
    SetVar "SrtDisciplineRecordEdit", ""
    Parse "SrtDisciplineRecordInsert", False
'-------------------------------
' SrtDisciplineRecord ShowInsert Event begin
' SrtDisciplineRecord ShowInsert Event end
'-------------------------------
  end if
  Parse "SrtDisciplineRecordCancel", false
  if sSrtDisciplineRecordErr = "" then
'-------------------------------
' SrtDisciplineRecord Show Event begin
if fldINS_SRTDISCIPLINE_INS = "0" then
  setvar "ins_disabled", "disabled"
  parse "ins_disabled", True
end if

if fldINS_SRTDISCIPLINE_BES = "0" then
  setvar "bes_disabled", "disabled"
  parse "bes_disabled", True
end if
' SrtDisciplineRecord Show Event end
'-------------------------------
  end if

'-------------------------------
' Show form field
'-------------------------------
      SetVar "INS_SRTDISCIPLINE_KEY", ToHTML(fldINS_SRTDISCIPLINE_KEY)
      SetVar "INS_SRTDISCIPLINE_MODULE", ToHTML(fldINS_SRTDISCIPLINE_MODULE)
      SetVar "INS_SRTDISCIPLINE_OMSCHRIJVING", ToHTML(fldINS_SRTDISCIPLINE_OMSCHRIJVING)
      SetVar "INS_SRTDISCIPLINE_PREFIX", ToHTML(fldINS_SRTDISCIPLINE_PREFIX)
      SetVar "SrtDisciplineRecordLBINS_SRTDISCIPLINE_ALG", ""
      LOV = Split(""&FCLTLCL("0;Niet tonen;7;Locatie;5;Gebouw;3;Verdieping;1;Ruimte")&"", ";")
      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(fldINS_SRTDISCIPLINE_ALG) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "SrtDisciplineRecordLBINS_SRTDISCIPLINE_ALG", True
        next
      end if
    
  if (LCase(fldINS_SRTDISCIPLINE_INS) = LCase("1")) then
    SetVar "INS_SRTDISCIPLINE_INS_CHECKED", "CHECKED"
  else
    SetVar "INS_SRTDISCIPLINE_INS_CHECKED", ""
  end if

  if (LCase(fldINS_SRTDISCIPLINE_BES) = LCase("1")) then
    SetVar "INS_SRTDISCIPLINE_BES_CHECKED", "CHECKED"
  else
    SetVar "INS_SRTDISCIPLINE_BES_CHECKED", ""
  end if

      SetVar "SrtDisciplineRecordLBINS_SRTDISCIPLINE_KOSTENKLANT", ""
      LOV = Split(""&FCLTLCL("0;Standaard uit;1;Standaard aan;2;Kostenplaats niet tonen")&"", ";")
      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(fldINS_SRTDISCIPLINE_KOSTENKLANT) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "SrtDisciplineRecordLBINS_SRTDISCIPLINE_KOSTENKLANT", True
        next
      end if
    
      SetVar "INS_SRTDISCIPLINE_OPMERKING", ToHTML(fldINS_SRTDISCIPLINE_OPMERKING)
  Parse "FormSrtDisciplineRecord", False

'-------------------------------
' SrtDisciplineRecord Close Event begin
' SrtDisciplineRecord Close Event end
'-------------------------------

Set rs = Nothing

'-------------------------------
' SrtDisciplineRecord Show end
'-------------------------------
End Sub
'===============================

'===============================
' Display Grid Form
'-------------------------------
Sub TypeOpdrGrid_Show()
'-------------------------------
' Initialize variables  
'-------------------------------
  Dim rs
  Dim sWhere : sWhere = ""
  Dim sOrder : sOrder = ""
  Dim sSQL : sSQL = ""
  Dim sFormTitle: sFormTitle = "Opdrachttypen"
  Dim HasParam : HasParam = false
  Dim bReq : bReq = true
  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 = "mld_srtdisciplinerecord1.asp"

  SetVar "TransitParams", "INS_SRTDISCIPLINE_KEY=" & ToURL(GetParam("INS_SRTDISCIPLINE_KEY")) & "&"
  SetVar "FormParams", "INS_SRTDISCIPLINE_KEY=" & ToURL(GetParam("INS_SRTDISCIPLINE_KEY")) & "&"

'-------------------------------
' Build WHERE statement
'-------------------------------
  pINS_SRTDISCIPLINE_KEY = GetParam("INS_SRTDISCIPLINE_KEY")
  if IsNumeric(pINS_SRTDISCIPLINE_KEY) and not isEmpty(pINS_SRTDISCIPLINE_KEY) then pINS_SRTDISCIPLINE_KEY = ToSQL(pINS_SRTDISCIPLINE_KEY, "Number") else pINS_SRTDISCIPLINE_KEY = Empty
  if not isEmpty(pINS_SRTDISCIPLINE_KEY) then
    HasParam = true
    sWhere = sWhere & "INS_SRTDISCIPLINE_KEY=" & pINS_SRTDISCIPLINE_KEY
  else
    bReq = false
  end if


  if HasParam then
    sWhere = " AND (" & sWhere & ")"
  end if

'-------------------------------
' Build base SQL statement
'-------------------------------
  sSQL = "SELECT   ts.mld_typeopdr_srtdiscipline_key,   ts.mld_typeopdr_key,   ts.ins_srtdiscipline_key,   ts.ins_discipline_key,   t.mld_typeopdr_omschrijving,   nvl(ids.ins_discipline_omschrijving,'"&FCLTLCL("Alles")&"')  ins_discipline_omschrijving FROM   MLD_TYPEOPDR_SRTDISCIPLINE ts,   MLD_TYPEOPDR t,        (select ins_discipline_key, ins_discipline_omschrijving         from INS_TAB_DISCIPLINE          ) ids WHERE ts.mld_typeopdr_key = t.mld_typeopdr_key AND ts.ins_discipline_key = ids.ins_discipline_key(+)"
  sOrder = " ORDER BY 6, t.mld_typeopdr_omschrijving"
'-------------------------------

'-------------------------------
' TypeOpdrGrid Open Event begin
' TypeOpdrGrid 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 if form has all required parameter
'-------------------------------
  if not bReq then
    SetVar "DListTypeOpdrGrid", ""
    Parse "TypeOpdrGridNoRecords", False
    SetVar "TypeOpdrGridNavigator", ""
    Parse "FormTypeOpdrGrid", False
    exit sub
  end if
'-------------------------------

'-------------------------------
' Open the recordset
'-------------------------------
  openrs rs, sSQL
'-------------------------------

'-------------------------------
' Process empty recordset
'-------------------------------
  if rs.eof then
    set rs = nothing
    SetVar "DListTypeOpdrGrid", ""
    Parse "TypeOpdrGridNoRecords", False
    SetVar "TypeOpdrGridNavigator", ""
    Parse "FormTypeOpdrGrid", False
    exit sub
  end if
'-------------------------------

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

'-------------------------------
' Process page scroller
'-------------------------------
  iPage = GetParam("FormTypeOpdrGrid_Page")
  openrs rsCount, sCountSQL
  dResult = CLng(rsCount.fields(0).value) / iRecordsPerPage
  iPageCount = int(dResult)
  if iPageCount < dResult then iPageCount = iPageCount + 1
  SetVar "TypeOpdrGridPageCount", 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
'-------------------------------
    fldINS_DISCIPLINE_OMSCHRIJVING = GetValue(rs, "INS_DISCIPLINE_OMSCHRIJVING")
    fldINS_SRTDISCIPLINE_KEY = GetValue(rs, "INS_SRTDISCIPLINE_KEY")
    fldMLD_TYPEOPDR_OMSCHRIJVING_URLLink = "mld_srtdisciplinerecord2.asp"
    fldMLD_TYPEOPDR_OMSCHRIJVING_MLD_TYPEOPDR_SRTDISCIPLINE_KEY = GetValue(rs, "MLD_TYPEOPDR_SRTDISCIPLINE_KEY")
    fldMLD_TYPEOPDR_OMSCHRIJVING = GetValue(rs, "MLD_TYPEOPDR_OMSCHRIJVING")
    fldMLD_TYPEOPDR_SRTDISCIPLINE_KEY = GetValue(rs, "MLD_TYPEOPDR_SRTDISCIPLINE_KEY")
'-------------------------------
' TypeOpdrGrid Show begin
'-------------------------------

'-------------------------------
' TypeOpdrGrid Show Event begin
' TypeOpdrGrid Show Event end
'-------------------------------

'-------------------------------
' Replace Template fields with database values
'-------------------------------
    
      SetVar "MLD_TYPEOPDR_SRTDISCIPLINE_KEY", ToHTML(fldMLD_TYPEOPDR_SRTDISCIPLINE_KEY)
      SetVar "INS_SRTDISCIPLINE_KEY", ToHTML(fldINS_SRTDISCIPLINE_KEY)
      SetVar "INS_DISCIPLINE_OMSCHRIJVING", ToHTML(fldINS_DISCIPLINE_OMSCHRIJVING)
      SetVar "MLD_TYPEOPDR_OMSCHRIJVING", ToHTML(fldMLD_TYPEOPDR_OMSCHRIJVING)
      SetVar "MLD_TYPEOPDR_OMSCHRIJVING_URLLink", fldMLD_TYPEOPDR_OMSCHRIJVING_URLLink
      SetVar "PrmMLD_TYPEOPDR_OMSCHRIJVING_MLD_TYPEOPDR_SRTDISCIPLINE_KEY", ToURL(fldMLD_TYPEOPDR_OMSCHRIJVING_MLD_TYPEOPDR_SRTDISCIPLINE_KEY)
    Parse "DListTypeOpdrGrid", True

'-------------------------------
' TypeOpdrGrid Show end
'-------------------------------

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


'-------------------------------
' TypeOpdrGrid Navigation begin
'-------------------------------
  bEof = rs.eof
  if rs.eof and iPage = 1 then
	SetVar "TypeOpdrGridNavigator", ""
  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 "TypeOpdrGridNavigatorPages", true
      iDisplayPages = iDisplayPages + 1
    next
    SetVar "NavigatorPageSwitch", "_"
    SetVar "NavigatorPageNumber", iPage
    SetVar "NavigatorPageNumberView", iPage
    Parse "TypeOpdrGridNavigatorPages", true
    iDisplayPages = iDisplayPages + 1
    SetVar "NavigatorPageSwitch", ""
    iPageCount = iPage + 1
    while iDisplayPages < iNumberOfPages and iStartPage + iDisplayPages < iHasPages
      SetVar "NavigatorPageNumber", iPageCount
      SetVar "NavigatorPageNumberView", iPageCount
      Parse "TypeOpdrGridNavigatorPages", true
      iDisplayPages = iDisplayPages + 1
      iPageCount = iPageCount + 1
    wend
    if bEof then
      SetVar "TypeOpdrGridNavigatorLastPage", "_"
    else
      SetVar "NextPage", (iPage + 1)
    end if
    if iPage = 1 then
      SetVar "TypeOpdrGridNavigatorFirstPage", "_"
    else
      SetVar "PrevPage", (iPage - 1)
    end if
    SetVar "TypeOpdrGridCurrentPage", iPage
    Parse "TypeOpdrGridNavigator", False
  end if
'-------------------------------
' TypeOpdrGrid Navigation end
'-------------------------------

'-------------------------------
' Finish form processing
'-------------------------------
  set rs = nothing
  SetVar "TypeOpdrGridNoRecords", ""
  Parse "FormTypeOpdrGrid", False

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

%>