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

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


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


'===============================
' cnt_kenmerkrecord PageSecurity begin
' cnt_kenmerkrecord PageSecurity end
'===============================

'===============================
' cnt_kenmerkrecord Open Event begin
' cnt_kenmerkrecord Open Event end
'===============================

'===============================
' cnt_kenmerkrecord OpenAnyPage Event begin
' cnt_kenmerkrecord OpenAnyPage Event end
'===============================

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

' cnt_kenmerkrecord Show begin
'===============================
' Perform the form's action
'-------------------------------
' Initialize error variables
'-------------------------------
sKenmerkRecordErr = ""

'-------------------------------
' Select the FormAction
'-------------------------------
Select Case sForm
  Case "KenmerkRecord"
    KenmerkRecordAction(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
'-------------------------------
KenmerkRecord_Show
'-------------------------------
' Process page templates
'-------------------------------
Parse "main", False
'-------------------------------
' Output the page to the browser
'-------------------------------
Response.write PrintVar("main")

' cnt_kenmerkrecord Show end

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

' cnt_kenmerkrecord Close Event begin
' cnt_kenmerkrecord Close Event end

cn.Close
Set cn = Nothing
UnloadTemplate
'===============================
'===============================
' Action of the Record Form
'-------------------------------
Sub KenmerkRecordAction(sAction)
'-------------------------------
' Initialize variables  
'-------------------------------
  Dim bExecSQL: bExecSQL = true
  Dim sActionFileName : sActionFileName = ""
  Dim sParams : sParams = "?"
  Dim sWhere : sWhere = "" 
  Dim bErr : bErr = False
  Dim pPKCNT_KENMERK_KEY : pPKCNT_KENMERK_KEY = ""
  Dim fldCNT_SRTKENMERK_KEY : fldCNT_SRTKENMERK_KEY = ""
  Dim fldCNT_SRTCONTRACT_KEY : fldCNT_SRTCONTRACT_KEY = ""
  Dim fldCNT_KENMERK_NIVEAU : fldCNT_KENMERK_NIVEAU = ""
  Dim fldCNT_KENMERK_VOLGNUMMER : fldCNT_KENMERK_VOLGNUMMER = ""
  Dim fldCNT_KENMERK_LOCATIEKOLOM : fldCNT_KENMERK_LOCATIEKOLOM = ""
  Dim fldCNT_KENMERK_VERPLICHT : fldCNT_KENMERK_VERPLICHT = ""
  Dim fldCNT_KENMERK_GROEP : fldCNT_KENMERK_GROEP = ""
  Dim fldCNT_KENMERK_TOONBAAR : fldCNT_KENMERK_TOONBAAR = ""
  Dim fldCNT_KENMERK_DEFAULT : fldCNT_KENMERK_DEFAULT = ""
  Dim fldCNT_KENMERK_HINT : fldCNT_KENMERK_HINT = ""
  Dim fldCNT_KENMERK_REGEXP : fldCNT_KENMERK_REGEXP = ""
'-------------------------------

'-------------------------------
' KenmerkRecord Action begin
'-------------------------------
  sActionFileName = "cnt_kenmerkgrid.asp"
  sParams = sParams & "CNT_SRTCONTRACT_KEY=" & ToURL(GetParam("Trn_CNT_SRTCONTRACT_KEY")) & "&"
  sParams = sParams & "CNT_SRTKENMERK_KEY=" & ToURL(GetParam("Trn_CNT_SRTKENMERK_KEY")) & "&"
  sParams = sParams & "sCNT_SRTKENMERK_KENMERKTYPE=" & ToURL(GetParam("Trn_sCNT_SRTKENMERK_KENMERKTYPE"))

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

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

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


'-------------------------------
' Load all form fields into variables
'-------------------------------
  fldCNT_SRTKENMERK_KEY = GetParam("CNT_SRTKENMERK_KEY")
  fldCNT_SRTCONTRACT_KEY = GetParam("CNT_SRTCONTRACT_KEY")
  fldCNT_KENMERK_NIVEAU = GetParam("CNT_KENMERK_NIVEAU")
  fldCNT_KENMERK_VOLGNUMMER = GetParam("CNT_KENMERK_VOLGNUMMER")
  fldCNT_KENMERK_LOCATIEKOLOM = GetParam("CNT_KENMERK_LOCATIEKOLOM")
  fldCNT_KENMERK_VERPLICHT = GetParam("CNT_KENMERK_VERPLICHT")
  fldCNT_KENMERK_GROEP = GetParam("CNT_KENMERK_GROEP")
  fldCNT_KENMERK_TOONBAAR = getCheckBoxValue(GetParam("CNT_KENMERK_TOONBAAR"), "1", "", "Number")
  fldCNT_KENMERK_DEFAULT = GetParam("CNT_KENMERK_DEFAULT")
  fldCNT_KENMERK_HINT = GetParam("CNT_KENMERK_HINT")
  fldCNT_KENMERK_REGEXP = GetParam("CNT_KENMERK_REGEXP")

'-------------------------------
' Validate fields
'-------------------------------
  if sAction = "insert" or sAction = "update" then
    if IsEmpty(fldCNT_SRTKENMERK_KEY) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Kenmerksoort is verplicht.<br>"
    end if
    if IsEmpty(fldCNT_SRTCONTRACT_KEY) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Soort contract is verplicht.<br>"
    end if
    if IsEmpty(fldCNT_KENMERK_VOLGNUMMER) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Volgnummer is verplicht.<br>"
    end if
    if IsEmpty(fldCNT_KENMERK_GROEP) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Groep is verplicht.<br>"
    end if
    if not isNumeric(fldCNT_SRTKENMERK_KEY) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Kenmerksoort is niet correct.<br>"
    end if
    if not isNumeric(fldCNT_SRTCONTRACT_KEY) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Soort contract is niet correct.<br>"
    end if
    if not isNumeric(fldCNT_KENMERK_VOLGNUMMER) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Volgnummer is niet correct.<br>"
    end if
    if not isNumeric(fldCNT_KENMERK_VERPLICHT) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Verplicht is niet correct.<br>"
    end if
    if not isNumeric(fldCNT_KENMERK_GROEP) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Groep is niet correct.<br>"
    end if
'-------------------------------
' KenmerkRecord Check Event begin
' KenmerkRecord Check Event end
'-------------------------------
    If len(sKenmerkRecordErr) > 0 then
      exit sub
    end if
  end if
'-------------------------------


'-------------------------------
' Create SQL statement
'-------------------------------
  select case sAction
    case "insert"
'-------------------------------
' KenmerkRecord Insert Event begin
dim tmp_insert_sql, default, nmin, nmax, kenmerktype,lengte
default = fldCNT_KENMERK_DEFAULT
openrs rs,"select * from CNT_SRTKENMERK where CNT_SRTKENMERK_key = " & ToSQL(fldCNT_SRTKENMERK_KEY, "Number")
nmin = getValue(rs,"CNT_SRTKENMERK_NMIN")
nmax = getValue(rs,"CNT_SRTKENMERK_NMAX")
lengte = getValue(rs,"CNT_SRTKENMERK_LENGTE")
kenmerktype = getValue(rs,"CNT_SRTKENMERK_KENMERKTYPE")
tmp_insert_sql = ""
if (default <> "") then
  select case kenmerktype
    case "D"
      tmp_insert_sql = toDate(default)
    case "N"
      if not IsNumeric(default) then
        sKenmerkRecordErr = sKenmerkRecordErr & "De defaultwaarde moet een nummer zijn!<br>"
      else
        if (lengte <> "") then
          max = CDbl(10^CInt(lengte))
          if (CDbl(default)>max) then
            sKenmerkRecordErr = sKenmerkRecordErr & "De defaultwaarde mag niet meer posities bevatten dan aangegeven bij lengte!<br>"
          end if
        end if
        if (nmin <> "") then
          min = CDbl(nmin)
          if CDbl(default) < min then
            sKenmerkRecordErr = sKenmerkRecordErr & "Defaultwaarde mag niet kleiner zijn dan het aangegeven minimum!<br>"
          end if
        end if
        if (nmax <> "") then
          max = CDbl(nmax)
          if CDbl(default) > max then
            sKenmerkRecordErr = sKenmerkRecordErr & "Defaultwaarde mag niet groter zijn dan het aangegeven maximum!<br>"
          end if
        end if
      end if
    case "C"
      if (lengte <> "") then
        pos = CDbl(lengte)
        if Len(default) > pos then
          sKenmerkRecordErr = sKenmerkRecordErr & "De lengte van de defaultwaarde mag niet groter zijn dan de aangegeven lengte!<br>"
        end if
      end if
  end select
end if

' Zet kenmerkniveau op de gewenste waarde en construeer SQL
sSQL = "insert into CNT_KENMERK (" & _
          "CNT_SRTKENMERK_KEY," & _
          "CNT_SRTCONTRACT_KEY," & _
          "CNT_KENMERK_NIVEAU," & _
          "CNT_KENMERK_VOLGNUMMER," & _
          "CNT_KENMERK_LOCATIEKOLOM," & _
          "CNT_KENMERK_VERPLICHT," & _
          "CNT_KENMERK_GROEP," & _
          "CNT_KENMERK_TOONBAAR," & _
          "CNT_KENMERK_DEFAULT," & _
          "CNT_KENMERK_HINT," & _
          "CNT_KENMERK_REGEXP)" & _
          " values (" & _
          ToSQL(fldCNT_SRTKENMERK_KEY, "Number") & "," & _
          ToSQL(fldCNT_SRTCONTRACT_KEY, "Number") & "," & _
          ToSQL(fldCNT_KENMERK_NIVEAU, "Text") & "," & _
          ToSQL(fldCNT_KENMERK_VOLGNUMMER, "Number") & "," & _
          ToSQL(fldCNT_KENMERK_LOCATIEKOLOM, "Text") & "," & _
          ToSQL(fldCNT_KENMERK_VERPLICHT, "Number") & "," & _
          ToSQL(fldCNT_KENMERK_GROEP, "Number") & "," & _
          fldCNT_KENMERK_TOONBAAR & ","
if (tmp_insert_sql <> "") then
  sSQL = sSQL & tmp_insert_sql & ","
else
  sSQL = sSQL & ToSQL(default, "Text") & ","
end if
sSQL = sSQL & ToSQL(fldCNT_KENMERK_HINT, "Text") & ","
sSQL = sSQL & ToSQL(fldCNT_KENMERK_REGEXP, "Text")
sSQL = sSQL & ")"
' KenmerkRecord Insert Event end
'-------------------------------
      if sSQL = "" then
      sSQL = "insert into CNT_KENMERK (" & _
          "CNT_SRTKENMERK_KEY," & _
          "CNT_SRTCONTRACT_KEY," & _
          "CNT_KENMERK_NIVEAU," & _
          "CNT_KENMERK_VOLGNUMMER," & _
          "CNT_KENMERK_LOCATIEKOLOM," & _
          "CNT_KENMERK_VERPLICHT," & _
          "CNT_KENMERK_GROEP," & _
          "CNT_KENMERK_TOONBAAR," & _
          "CNT_KENMERK_DEFAULT," & _
          "CNT_KENMERK_HINT," & _
          "CNT_KENMERK_REGEXP)" & _
          " values (" & _
          ToSQL(fldCNT_SRTKENMERK_KEY, "Number") & "," & _
          ToSQL(fldCNT_SRTCONTRACT_KEY, "Number") & "," & _
          ToSQL(fldCNT_KENMERK_NIVEAU, "Text") & "," & _
          ToSQL(fldCNT_KENMERK_VOLGNUMMER, "Number") & "," & _
          ToSQL(fldCNT_KENMERK_LOCATIEKOLOM, "Text") & "," & _
          ToSQL(fldCNT_KENMERK_VERPLICHT, "Number") & "," & _
          ToSQL(fldCNT_KENMERK_GROEP, "Number") & "," & _
          fldCNT_KENMERK_TOONBAAR & "," & _
          ToSQL(fldCNT_KENMERK_DEFAULT, "Text") & "," & _
          ToSQL(fldCNT_KENMERK_HINT, "Text") & "," & _
          ToSQL(fldCNT_KENMERK_REGEXP, "Text") & _
          ")"
      end if
    case "update"
'-------------------------------
' KenmerkRecord Update Event begin
dim tmp_update_sql
tmp_update_sql = ""
openrs rs,"select * from cnt_srtkenmerk where cnt_srtkenmerk_key = " & ToSQL(fldCNT_SRTKENMERK_KEY, "Number")
lengte = getValue(rs,"CNT_SRTKENMERK_LENGTE")
nmin = getValue(rs,"CNT_SRTKENMERK_NMIN")
nmax = getValue(rs,"CNT_SRTKENMERK_NMAX")
default = fldCNT_KENMERK_DEFAULT
kenmerktype = getValue(rs,"CNT_SRTKENMERK_KENMERKTYPE")
if (default <> "") then
  select case kenmerktype
    case "D"
      tmp_update_sql = toDate(default)
    case "N"
      if not IsNumeric(default) then
        sKenmerkRecordErr = sKenmerkRecordErr & "De defaultwaarde moet een nummer zijn!<br>"
      else
        if (lengte <> "") then
          max = CDbl(10^CInt(lengte))
          if (CDbl(default)>max) then
            sKenmerkRecordErr = sKenmerkRecordErr & "De defaultwaarde mag niet meer posities bevatten dan aangegeven bij lengte!<br>"
          end if
        end if
        if (nmin <> "") then
          min = CDbl(nmin)
          if CDbl(default) < min then
            sKenmerkRecordErr = sKenmerkRecordErr & "Defaultwaarde mag niet kleiner zijn dan het aangegeven minimum!<br>"
          end if
        end if
        if (nmax <> "") then
          max = CDbl(nmax)
          if CDbl(default) > max then
            sKenmerkRecordErr = sKenmerkRecordErr & "Defaultwaarde mag niet groter zijn dan het aangegeven maximum!<br>"
          end if
        end if
      end if
    case "C"
      pos = CDbl(lengte)
      if Len(default) > pos then
        sKenmerkRecordErr = sKenmerkRecordErr & "De lengte van de defaultwaarde mag niet groter zijn dan de aangegeven lengte!<br>"
      end if
  end select

  sSQL = "update CNT_KENMERK set " & _
        "CNT_SRTKENMERK_KEY=" & ToSQL(fldCNT_SRTKENMERK_KEY, "Number") & _
        ",CNT_SRTCONTRACT_KEY=" & ToSQL(fldCNT_SRTCONTRACT_KEY, "Number") & _
        ",CNT_KENMERK_NIVEAU=" & ToSQL(fldCNT_KENMERK_NIVEAU, "Text") & _
        ",CNT_KENMERK_VOLGNUMMER=" & ToSQL(fldCNT_KENMERK_VOLGNUMMER, "Number") & _
        ",CNT_KENMERK_LOCATIEKOLOM=" & ToSQL(fldCNT_KENMERK_LOCATIEKOLOM, "Text") & _
        ",CNT_KENMERK_VERPLICHT=" & ToSQL(fldCNT_KENMERK_VERPLICHT, "Number") & _
        ",CNT_KENMERK_GROEP=" & ToSQL(fldCNT_KENMERK_GROEP, "Number") & _
        ",CNT_KENMERK_TOONBAAR=" & fldCNT_KENMERK_TOONBAAR
  if (tmp_update_sql <> "") then
    sSQL = sSQL & ",CNT_KENMERK_DEFAULT=" & tmp_update_sql
  else
    sSQL = sSQL & ",CNT_KENMERK_DEFAULT=" & ToSQL(default, "Text")
  end if
  sSQL = sSQL & ",CNT_KENMERK_HINT=" & ToSQL(fldCNT_KENMERK_HINT, "Text")
  sSQL = sSQL & ",CNT_KENMERK_REGEXP=" & ToSQL(fldCNT_KENMERK_REGEXP, "Text")
  sSQL = sSQL & " where " & sWhere
end if
' KenmerkRecord Update Event end
'-------------------------------
      if sSQL = "" then
      sSQL = "update CNT_KENMERK set " & _
        "CNT_SRTKENMERK_KEY=" & ToSQL(fldCNT_SRTKENMERK_KEY, "Number") & _
        ",CNT_SRTCONTRACT_KEY=" & ToSQL(fldCNT_SRTCONTRACT_KEY, "Number") & _
        ",CNT_KENMERK_NIVEAU=" & ToSQL(fldCNT_KENMERK_NIVEAU, "Text") & _
        ",CNT_KENMERK_VOLGNUMMER=" & ToSQL(fldCNT_KENMERK_VOLGNUMMER, "Number") & _
        ",CNT_KENMERK_LOCATIEKOLOM=" & ToSQL(fldCNT_KENMERK_LOCATIEKOLOM, "Text") & _
        ",CNT_KENMERK_VERPLICHT=" & ToSQL(fldCNT_KENMERK_VERPLICHT, "Number") & _
        ",CNT_KENMERK_GROEP=" & ToSQL(fldCNT_KENMERK_GROEP, "Number") & _
        ",CNT_KENMERK_TOONBAAR=" & fldCNT_KENMERK_TOONBAAR & _
        ",CNT_KENMERK_DEFAULT=" & ToSQL(fldCNT_KENMERK_DEFAULT, "Text") & _
        ",CNT_KENMERK_HINT=" & ToSQL(fldCNT_KENMERK_HINT, "Text") & _
        ",CNT_KENMERK_REGEXP=" & ToSQL(fldCNT_KENMERK_REGEXP, "Text")
      sSQL = sSQL & " where " & sWhere
      end if
    case "delete"
'-------------------------------
' KenmerkRecord Delete Event begin
dim tmpkey
tmpkey = "PK_"&strToTable(sActionFileName)&"_KEY"
sSql = customFacDelete(sActionFileName,getParam(tmpkey))
set tmpkey = Nothing
' KenmerkRecord Delete Event end
'-------------------------------
      if sSQL = "" then
      sSQL = "delete from CNT_KENMERK where " & sWhere
      end if
  end select
'-------------------------------
'-------------------------------
' KenmerkRecord BeforeExecute Event begin
' KenmerkRecord BeforeExecute Event end
'-------------------------------

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

'===============================
' Display Record Form
'-------------------------------
Sub KenmerkRecord_Show()
'-------------------------------
' KenmerkRecord Show begin
'-------------------------------
  Dim sWhere : sWhere = ""
  Dim sFormTitle: sFormTitle = "Details kenmerk"
  Dim bPK : bPK = True
  Dim sCNT_SRTKENMERK_KEYDisplayValue: sCNT_SRTKENMERK_KEYDisplayValue = ""
  Dim sCNT_SRTCONTRACT_KEYDisplayValue: sCNT_SRTCONTRACT_KEYDisplayValue = ""

'-------------------------------
' Load primary key and form parameters
'-------------------------------
  if sKenmerkRecordErr = "" then
    fldCNT_SRTCONTRACT_KEY = GetParam("CNT_SRTCONTRACT_KEY")
    fldCNT_SRTKENMERK_KEY = GetParam("CNT_SRTKENMERK_KEY")
    SetVar "Trn_CNT_SRTCONTRACT_KEY", GetParam("CNT_SRTCONTRACT_KEY")
    SetVar "Trn_CNT_SRTKENMERK_KEY", GetParam("CNT_SRTKENMERK_KEY")
    SetVar "Trn_sCNT_SRTKENMERK_KENMERKTYPE", GetParam("sCNT_SRTKENMERK_KENMERKTYPE")
    pCNT_KENMERK_KEY = GetParam("CNT_KENMERK_KEY")
    SetVar "KenmerkRecordError", ""
  else
    fldCNT_SRTKENMERK_KEY = GetParam("CNT_SRTKENMERK_KEY")
    fldCNT_SRTCONTRACT_KEY = GetParam("CNT_SRTCONTRACT_KEY")
    fldCNT_KENMERK_NIVEAU = GetParam("CNT_KENMERK_NIVEAU")
    fldCNT_KENMERK_VOLGNUMMER = GetParam("CNT_KENMERK_VOLGNUMMER")
    fldCNT_KENMERK_LOCATIEKOLOM = GetParam("CNT_KENMERK_LOCATIEKOLOM")
    fldCNT_KENMERK_VERPLICHT = GetParam("CNT_KENMERK_VERPLICHT")
    fldCNT_KENMERK_GROEP = GetParam("CNT_KENMERK_GROEP")
    fldCNT_KENMERK_TOONBAAR = getCheckBoxValue(GetParam("CNT_KENMERK_TOONBAAR"), "1", "", "Number")
    fldCNT_KENMERK_DEFAULT = GetParam("CNT_KENMERK_DEFAULT")
    fldCNT_KENMERK_HINT = GetParam("CNT_KENMERK_HINT")
    fldCNT_KENMERK_REGEXP = GetParam("CNT_KENMERK_REGEXP")
    SetVar "Trn_CNT_SRTCONTRACT_KEY", GetParam("Trn_CNT_SRTCONTRACT_KEY")
    SetVar "Trn_CNT_SRTKENMERK_KEY", GetParam("Trn_CNT_SRTKENMERK_KEY")
    SetVar "Trn_sCNT_SRTKENMERK_KENMERKTYPE", GetParam("Trn_sCNT_SRTKENMERK_KENMERKTYPE")
    pCNT_KENMERK_KEY = GetParam("PK_CNT_KENMERK_KEY")
    SetVar "sKenmerkRecordErr", sKenmerkRecordErr
    SetVar "FormTitle", sFormTitle
    Parse "KenmerkRecordError", False
  end if
'-------------------------------

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

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

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

  if IsEmpty(pCNT_KENMERK_KEY) then bPK = False
  
  sWhere = sWhere & "CNT_KENMERK_KEY=" & ToSQL(pCNT_KENMERK_KEY, "Number")
  SetVar "PK_CNT_KENMERK_KEY", pCNT_KENMERK_KEY
'-------------------------------
'-------------------------------
' KenmerkRecord Open Event begin
' KenmerkRecord Open Event end
'-------------------------------

  SetVar "FormTitle", sFormTitle

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

'-------------------------------
' Load all fields into variables from recordset or input parameters
'-------------------------------
  if bIsUpdateMode then
    fldCNT_KENMERK_KEY = GetValue(rs, "CNT_KENMERK_KEY")
    fldCNT_KENMERK_LOCATIEKOLOM = GetValue(rs, "CNT_KENMERK_LOCATIEKOLOM")
    fldCNT_KENMERK_NIVEAU = GetValue(rs, "CNT_KENMERK_NIVEAU")

'-------------------------------
' Load data from recordset when form displayed first time
'-------------------------------
    if sKenmerkRecordErr = "" then
      fldCNT_SRTKENMERK_KEY = GetValue(rs, "CNT_SRTKENMERK_KEY")
      fldCNT_SRTCONTRACT_KEY = GetValue(rs, "CNT_SRTCONTRACT_KEY")
      fldCNT_KENMERK_VOLGNUMMER = GetValue(rs, "CNT_KENMERK_VOLGNUMMER")
      fldCNT_KENMERK_VERPLICHT = GetValue(rs, "CNT_KENMERK_VERPLICHT")
      fldCNT_KENMERK_GROEP = GetValue(rs, "CNT_KENMERK_GROEP")
      fldCNT_KENMERK_TOONBAAR = GetValue(rs, "CNT_KENMERK_TOONBAAR")
      fldCNT_KENMERK_DEFAULT = GetValue(rs, "CNT_KENMERK_DEFAULT")
      fldCNT_KENMERK_HINT = GetValue(rs, "CNT_KENMERK_HINT")
      fldCNT_KENMERK_REGEXP = GetValue(rs, "CNT_KENMERK_REGEXP")
    end if
    SetVar "KenmerkRecordInsert", ""
    Parse "KenmerkRecordEdit", False
'-------------------------------
' KenmerkRecord ShowEdit Event begin
' KenmerkRecord ShowEdit Event end
'-------------------------------
  else
    if sKenmerkRecordErr = "" then
      fldCNT_SRTKENMERK_KEY = ToHTML(GetParam("CNT_SRTKENMERK_KEY"))
      fldCNT_SRTCONTRACT_KEY = ToHTML(GetParam("CNT_SRTCONTRACT_KEY"))
      fldCNT_KENMERK_NIVEAU= "S"
    end if
    SetVar "KenmerkRecordEdit", ""
    Parse "KenmerkRecordInsert", False
'-------------------------------
' KenmerkRecord ShowInsert Event begin
' KenmerkRecord ShowInsert Event end
'-------------------------------
  end if
  Parse "KenmerkRecordCancel", false
'-------------------------------
' KenmerkRecord Show Event begin
' KenmerkRecord Show Event end
'-------------------------------

'-------------------------------
' Show form field
'-------------------------------
      SetVar "CNT_KENMERK_KEY", ToHTML(fldCNT_KENMERK_KEY)
      SetVar "KenmerkRecordLBCNT_SRTKENMERK_KEY", ""
      SetVar "Selected", ""
      SetVar "ID", ""
      SetVar "Value", sCNT_SRTKENMERK_KEYDisplayValue
      Parse "KenmerkRecordLBCNT_SRTKENMERK_KEY", True
      openrs rsCNT_SRTKENMERK_KEY, "select cnt_srtkenmerk_key, cnt_srtkenmerk_omschrijving from cnt_srtkenmerk where cnt_srtkenmerk_verwijder is null order by cnt_srtkenmerk_upper"
      while not rsCNT_SRTKENMERK_KEY.EOF
        SetVar "ID", GetValue(rsCNT_SRTKENMERK_KEY, 0) : SetVar "Value", GetValue(rsCNT_SRTKENMERK_KEY, 1)
        if cstr(GetValue(rsCNT_SRTKENMERK_KEY, 0)) = cstr(fldCNT_SRTKENMERK_KEY) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
        Parse "KenmerkRecordLBCNT_SRTKENMERK_KEY", True
        rsCNT_SRTKENMERK_KEY.MoveNext
      wend
      set rsCNT_SRTKENMERK_KEY = nothing
    
      SetVar "KenmerkRecordLBCNT_SRTCONTRACT_KEY", ""
      SetVar "Selected", ""
      SetVar "ID", ""
      SetVar "Value", sCNT_SRTCONTRACT_KEYDisplayValue
      Parse "KenmerkRecordLBCNT_SRTCONTRACT_KEY", True
      openrs rsCNT_SRTCONTRACT_KEY, "select ins_discipline_key, ins_discipline_omschrijving from cnt_discipline where ins_discipline_verwijder is null  order by ins_discipline_omschrijving asc"
      while not rsCNT_SRTCONTRACT_KEY.EOF
        SetVar "ID", GetValue(rsCNT_SRTCONTRACT_KEY, 0) : SetVar "Value", GetValue(rsCNT_SRTCONTRACT_KEY, 1)
        if cstr(GetValue(rsCNT_SRTCONTRACT_KEY, 0)) = cstr(fldCNT_SRTCONTRACT_KEY) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
        Parse "KenmerkRecordLBCNT_SRTCONTRACT_KEY", True
        rsCNT_SRTCONTRACT_KEY.MoveNext
      wend
      set rsCNT_SRTCONTRACT_KEY = nothing
    
      SetVar "CNT_KENMERK_NIVEAU", ToHTML(fldCNT_KENMERK_NIVEAU)
      SetVar "CNT_KENMERK_VOLGNUMMER", ToHTML(fldCNT_KENMERK_VOLGNUMMER)
      SetVar "CNT_KENMERK_LOCATIEKOLOM", ToHTML(fldCNT_KENMERK_LOCATIEKOLOM)
      SetVar "KenmerkRecordLBCNT_KENMERK_VERPLICHT", ""
      LOV = Split(""&BuildVerplichtingList&"", ";")
      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(fldCNT_KENMERK_VERPLICHT) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "KenmerkRecordLBCNT_KENMERK_VERPLICHT", True
        next
      end if
    
      SetVar "KenmerkRecordLBCNT_KENMERK_GROEP", ""
      LOV = Split(""&BuildGroepsverplichtingList&"", ";")
      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(fldCNT_KENMERK_GROEP) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "KenmerkRecordLBCNT_KENMERK_GROEP", True
        next
      end if
    
  if (LCase(fldCNT_KENMERK_TOONBAAR) = LCase("1")) then
    SetVar "CNT_KENMERK_TOONBAAR_CHECKED", "CHECKED"
  else
    SetVar "CNT_KENMERK_TOONBAAR_CHECKED", ""
  end if

      SetVar "CNT_KENMERK_DEFAULT", ToHTML(fldCNT_KENMERK_DEFAULT)
      SetVar "CNT_KENMERK_HINT", ToHTML(fldCNT_KENMERK_HINT)
      SetVar "CNT_KENMERK_REGEXP", ToHTML(fldCNT_KENMERK_REGEXP)
  Parse "FormKenmerkRecord", False

'-------------------------------
' KenmerkRecord Close Event begin
' KenmerkRecord Close Event end
'-------------------------------

Set rs = Nothing

'-------------------------------
' KenmerkRecord Show end
'-------------------------------
End Sub
'===============================
%>