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

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


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


'===============================
' fin_kenmerkrecord PageSecurity begin
' fin_kenmerkrecord PageSecurity end
'===============================

'===============================
' fin_kenmerkrecord Open Event begin
' fin_kenmerkrecord Open Event end
'===============================

'===============================
' fin_kenmerkrecord OpenAnyPage Event begin
' fin_kenmerkrecord OpenAnyPage Event end
'===============================

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

' fin_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")

' fin_kenmerkrecord Show end

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

' fin_kenmerkrecord Close Event begin
' fin_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 pPKFIN_KENMERK_KEY : pPKFIN_KENMERK_KEY = ""
  Dim fldFIN_KENMERK_VOLGNR : fldFIN_KENMERK_VOLGNR = ""
  Dim fldFIN_KENMERK_OMSCHRIJVING : fldFIN_KENMERK_OMSCHRIJVING = ""
  Dim fldFIN_KENMERK_HINT : fldFIN_KENMERK_HINT = ""
  Dim fldFIN_KENMERK_DIMENSIE : fldFIN_KENMERK_DIMENSIE = ""
  Dim fldFIN_KENMERK_KENMERKTYPE : fldFIN_KENMERK_KENMERKTYPE = ""
  Dim fldFIN_KENMERK_TYPE : fldFIN_KENMERK_TYPE = ""
  Dim fldFIN_KENMERK_VERPLICHT : fldFIN_KENMERK_VERPLICHT = ""
  Dim fldFIN_KENMERK_GROEP : fldFIN_KENMERK_GROEP = ""
  Dim fldFIN_KENMERK_TOONBAAR : fldFIN_KENMERK_TOONBAAR = ""
  Dim fldFIN_KENMERK_SYSTEEM : fldFIN_KENMERK_SYSTEEM = ""
  Dim fldFIN_KENMERK_LENGTE : fldFIN_KENMERK_LENGTE = ""
  Dim fldFIN_KENMERK_DEC : fldFIN_KENMERK_DEC = ""
  Dim fldFIN_KENMERK_NMIN : fldFIN_KENMERK_NMIN = ""
  Dim fldFIN_KENMERK_NMAX : fldFIN_KENMERK_NMAX = ""
  Dim fldFAC_KENMERKDOMEIN_KEY : fldFAC_KENMERKDOMEIN_KEY = ""
  Dim fldFIN_KENMERK_DEFAULT : fldFIN_KENMERK_DEFAULT = ""
  Dim fldFIN_KENMERK_REGEXP : fldFIN_KENMERK_REGEXP = ""
'-------------------------------

'-------------------------------
' KenmerkRecord Action begin
'-------------------------------
  sActionFileName = "fin_kenmerkgrid.asp"
  sParams = sParams & "sFIN_KENMERK_UPPER=" & ToURL(GetParam("Trn_sFIN_KENMERK_UPPER")) & "&"
  sParams = sParams & "sFIN_KENMERK_KENMERKTYPE=" & ToURL(GetParam("Trn_sFIN_KENMERK_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
    pPKFIN_KENMERK_KEY = GetParam("PK_FIN_KENMERK_KEY")
    if IsEmpty(pPKFIN_KENMERK_KEY) then exit sub
    sWhere = "FIN_KENMERK_KEY=" & ToSQL(pPKFIN_KENMERK_KEY, "Number")
  end if
'-------------------------------


'-------------------------------
' Load all form fields into variables
'-------------------------------
  fldFIN_KENMERK_VOLGNR = GetParam("FIN_KENMERK_VOLGNR")
  fldFIN_KENMERK_OMSCHRIJVING = GetParam("FIN_KENMERK_OMSCHRIJVING")
  fldFIN_KENMERK_HINT = GetParam("FIN_KENMERK_HINT")
  fldFIN_KENMERK_DIMENSIE = GetParam("FIN_KENMERK_DIMENSIE")
  fldFIN_KENMERK_KENMERKTYPE = GetParam("FIN_KENMERK_KENMERKTYPE")
  fldFIN_KENMERK_TYPE = GetParam("FIN_KENMERK_TYPE")
  fldFIN_KENMERK_VERPLICHT = GetParam("FIN_KENMERK_VERPLICHT")
  fldFIN_KENMERK_GROEP = GetParam("FIN_KENMERK_GROEP")
  fldFIN_KENMERK_TOONBAAR = getCheckBoxValue(GetParam("FIN_KENMERK_TOONBAAR"), "1", "", "Number")
  fldFIN_KENMERK_SYSTEEM = getCheckBoxValue(GetParam("FIN_KENMERK_SYSTEEM"), "1", "", "Number")
  fldFIN_KENMERK_LENGTE = GetParam("FIN_KENMERK_LENGTE")
  fldFIN_KENMERK_DEC = GetParam("FIN_KENMERK_DEC")
  fldFIN_KENMERK_NMIN = GetParam("FIN_KENMERK_NMIN")
  fldFIN_KENMERK_NMAX = GetParam("FIN_KENMERK_NMAX")
  fldFAC_KENMERKDOMEIN_KEY = GetParam("FAC_KENMERKDOMEIN_KEY")
  fldFIN_KENMERK_DEFAULT = GetParam("FIN_KENMERK_DEFAULT")
  fldFIN_KENMERK_REGEXP = GetParam("FIN_KENMERK_REGEXP")

'-------------------------------
' Validate fields
'-------------------------------
  if sAction = "insert" or sAction = "update" then
    if IsEmpty(fldFIN_KENMERK_VOLGNR) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Volgnummer is verplicht.<br>"
    end if
    if IsEmpty(fldFIN_KENMERK_OMSCHRIJVING) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Omschrijving is verplicht.<br>"
    end if
    if IsEmpty(fldFIN_KENMERK_KENMERKTYPE) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Kenmerktype is verplicht.<br>"
    end if
    if IsEmpty(fldFIN_KENMERK_GROEP) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Groep is verplicht.<br>"
    end if
    if not isNumeric(fldFIN_KENMERK_VOLGNR) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Volgnummer is niet correct.<br>"
    end if
    if not isNumeric(fldFIN_KENMERK_VERPLICHT) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Verplicht is niet correct.<br>"
    end if
    if not isNumeric(fldFIN_KENMERK_GROEP) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Groep is niet correct.<br>"
    end if
    if not isNumeric(fldFIN_KENMERK_LENGTE) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Lengte is niet correct.<br>"
    end if
    if not isNumeric(fldFIN_KENMERK_DEC) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Decimalen is niet correct.<br>"
    end if
    if not isNumeric(fldFIN_KENMERK_NMIN) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Minimum is niet correct.<br>"
    end if
    if not isNumeric(fldFIN_KENMERK_NMAX) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Maximum is niet correct.<br>"
    end if
    if not isNumeric(fldFAC_KENMERKDOMEIN_KEY) then
      sKenmerkRecordErr = sKenmerkRecordErr & "De waarde in veld Kenmerkdomein is niet correct.<br>"
    end if
'-------------------------------
' KenmerkRecord Check Event begin
select case UCase(fldFIN_KENMERK_KENMERKTYPE)
case "C" if fldFIN_KENMERK_LENGTE = "" then sKenmerkRecordErr = sKenmerkRecordErr + "Lengte moet gespecificeerd worden.<br>"
case "N" if fldFIN_KENMERK_LENGTE = "" then sKenmerkRecordErr = sKenmerkRecordErr + "Lengte moet gespecificeerd worden.<br>"
case "R" if fldFAC_KENMERKDOMEIN_KEY = "" then sKenmerkRecordErr = sKenmerkRecordErr + "Kenmerkdomein moet gekozen worden.<br>"
end select
if ((fldFIN_KENMERK_KENMERKTYPE = "C") and (fldFIN_KENMERK_LENGTE > 4000)) then
  sKenmerkRecordErr = sKenmerkRecordErr + "Maximale lengte bij kenmerktype karakter is 4000."
end if
' 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
if (fldFIN_KENMERK_REGEXP <> "") then
	select case fldFIN_KENMERK_KENMERKTYPE
	  case "E", "R", "X", "L", "Q"
	  	sKenmerkRecordErr = sKenmerkRecordError & "Bij dit kenmerktype kan geen formattering gebruikt worden."
	  case "C"
	  	pos = CDbl(fldFIN_KENMERK_LENGTE)
	  	if pos > 50 then
	  	  ' input type=text wel, textarea niet
	  	  sKenmerkRecordErr = sKenmerkRecordErr & "Bij meer dan 50 karakters kan geen formattering worden gebruikt."
	  	end if
	end select
end if

dim tmp_insert_sql
tmp_insert_sql = ""
if (fldFIN_KENMERK_DEFAULT <> "") then
  select case fldFIN_KENMERK_KENMERKTYPE
    case "D"
      tmp_insert_sql = toDate(fldFIN_KENMERK_DEFAULT)
    case "N"
      if not IsNumeric(fldFIN_KENMERK_DEFAULT) then
        sKenmerkRecordErr = sKenmerkRecordErr & "De defaultwaarde moet een nummer zijn!<br>"
      else
        if (fldFIN_KENMERK_LENGTE <> "") then
          max = CDbl(10^CInt(fldFIN_KENMERK_LENGTE))
          if (CDbl(fldFIN_KENMERK_DEFAULT)>max) then
            sKenmerkRecordErr = sKenmerkRecordErr & "De defaultwaarde mag niet meer posities bevatten dan aangegeven bij lengte!<br>"
          end if
        end if
        if (fldFIN_KENMERK_NMIN <> "") then
          min = CDbl(fldFIN_KENMERK_NMIN)
          if CDbl(fldFIN_KENMERK_DEFAULT) < min then
            sKenmerkRecordErr = sKenmerkRecordErr & "Defaultwaarde mag niet kleiner zijn dan het aangegeven minimum!<br>"
          end if
        end if
        if (fldFIN_KENMERK_NMAX <> "") then
          max = CDbl(fldFIN_KENMERK_NMAX)
          if CDbl(fldFIN_KENMERK_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(fldFIN_KENMERK_LENGTE)
      if Len(fldFIN_KENMERK_DEFAULT) > pos then
        sKenmerkRecordErr = sKenmerkRecordErr & "De lengte van de defaultwaarde mag niet groter zijn dan de aangegeven lengte!<br>"
      end if
  end select
end if

' Zet kenmerkniveau op de gewenste waarde en construeer SQL
sSQL = "insert into FIN_KENMERK (" & _
          "FIN_KENMERK_VOLGNR," & _
          "FIN_KENMERK_OMSCHRIJVING," & _
          "FIN_KENMERK_HINT," & _
          "FIN_KENMERK_DIMENSIE," & _
          "FIN_KENMERK_KENMERKTYPE," & _
          "FIN_KENMERK_TYPE," & _
          "FIN_KENMERK_VERPLICHT," & _
          "FIN_KENMERK_GROEP," & _
          "FIN_KENMERK_TOONBAAR," & _
          "FIN_KENMERK_SYSTEEM," & _
          "FIN_KENMERK_LENGTE," & _
          "FIN_KENMERK_DEC," & _
          "FIN_KENMERK_NMIN," & _
          "FIN_KENMERK_NMAX," & _
          "FAC_KENMERKDOMEIN_KEY," &_
          "FIN_KENMERK_DEFAULT," & _
          "FIN_KENMERK_REGEXP)" & _
          " values (" & _
          ToSQL(fldFIN_KENMERK_VOLGNR, "Number") & "," & _
          ToSQL(fldFIN_KENMERK_OMSCHRIJVING, "Text") & "," & _
          ToSQL(fldFIN_KENMERK_HINT, "Text") & "," & _
          ToSQL(fldFIN_KENMERK_DIMENSIE, "Text") & "," & _
          ToSQL(fldFIN_KENMERK_KENMERKTYPE, "Text") & "," & _
          ToSql(fldFIN_KENMERK_TYPE, "Text") & "," & _
          ToSQL(fldFIN_KENMERK_VERPLICHT, "Number") & "," & _
          ToSQL(fldFIN_KENMERK_GROEP, "Number") & "," & _
          fldFIN_KENMERK_TOONBAAR & "," & _
          fldFIN_KENMERK_SYSTEEM & "," & _
          ToSQL(fldFIN_KENMERK_LENGTE, "Number") & "," & _
          ToSQL(fldFIN_KENMERK_DEC, "Number") & "," & _
          ToSQL(fldFIN_KENMERK_NMIN, "Number") & "," & _
          ToSQL(fldFIN_KENMERK_NMAX, "Number") & "," & _
          ToSQL(fldFAC_KENMERKDOMEIN_KEY, "Number") & ","
if (tmp_insert_sql <> "") then
  sSQL = sSQL & tmp_insert_sql & ","
else
  sSQL = sSQL & ToSQL(fldFIN_KENMERK_DEFAULT, "Text") & ","
end if
sSQL = sSQL & ToSQL(fldFIN_KENMERK_REGEXP, "Text")
sSQL = sSQL & ")"
' KenmerkRecord Insert Event end
'-------------------------------
      if sSQL = "" then
      sSQL = "insert into FIN_KENMERK (" & _
          "FIN_KENMERK_VOLGNR," & _
          "FIN_KENMERK_OMSCHRIJVING," & _
          "FIN_KENMERK_HINT," & _
          "FIN_KENMERK_DIMENSIE," & _
          "FIN_KENMERK_KENMERKTYPE," & _
          "FIN_KENMERK_TYPE," & _
          "FIN_KENMERK_VERPLICHT," & _
          "FIN_KENMERK_GROEP," & _
          "FIN_KENMERK_TOONBAAR," & _
          "FIN_KENMERK_SYSTEEM," & _
          "FIN_KENMERK_LENGTE," & _
          "FIN_KENMERK_DEC," & _
          "FIN_KENMERK_NMIN," & _
          "FIN_KENMERK_NMAX," & _
          "FAC_KENMERKDOMEIN_KEY," & _
          "FIN_KENMERK_DEFAULT," & _
          "FIN_KENMERK_REGEXP)" & _
          " values (" & _
          ToSQL(fldFIN_KENMERK_VOLGNR, "Number") & "," & _
          ToSQL(fldFIN_KENMERK_OMSCHRIJVING, "Text") & "," & _
          ToSQL(fldFIN_KENMERK_HINT, "Text") & "," & _
          ToSQL(fldFIN_KENMERK_DIMENSIE, "Text") & "," & _
          ToSQL(fldFIN_KENMERK_KENMERKTYPE, "Text") & "," & _
          ToSQL(fldFIN_KENMERK_TYPE, "Text") & "," & _
          ToSQL(fldFIN_KENMERK_VERPLICHT, "Number") & "," & _
          ToSQL(fldFIN_KENMERK_GROEP, "Number") & "," & _
          fldFIN_KENMERK_TOONBAAR & "," & _
          fldFIN_KENMERK_SYSTEEM & "," & _
          ToSQL(fldFIN_KENMERK_LENGTE, "Number") & "," & _
          ToSQL(fldFIN_KENMERK_DEC, "Number") & "," & _
          ToSQL(fldFIN_KENMERK_NMIN, "Number") & "," & _
          ToSQL(fldFIN_KENMERK_NMAX, "Number") & "," & _
          ToSQL(fldFAC_KENMERKDOMEIN_KEY, "Number") & "," & _
          ToSQL(fldFIN_KENMERK_DEFAULT, "Text") & "," & _
          ToSQL(fldFIN_KENMERK_REGEXP, "Text") & _
          ")"
      end if
    case "update"
'-------------------------------
' KenmerkRecord Update Event begin
if (fldFIN_KENMERK_REGEXP <> "") then
	select case fldFIN_KENMERK_KENMERKTYPE
	  case "E", "R", "X", "L", "Q"
	  	sKenmerkRecordErr = sKenmerkRecordError & "Bij dit kenmerktype kan geen formattering gebruikt worden."
	  case "C"
	  	pos = CDbl(fldFIN_KENMERK_LENGTE)
	  	if pos > 50 then
	  	  ' input type=text wel, textarea niet
	  	  sKenmerkRecordErr = sKenmerkRecordErr & "Bij meer dan 50 karakters kan geen formattering worden gebruikt."
	  	end if
	end select
end if

dim tmp_update_sql
tmp_update_sql = ""
if (fldFIN_KENMERK_DEFAULT <> "") then
  select case fldFIN_KENMERK_KENMERKTYPE
    case "D"
      tmp_update_sql = toDate(fldFIN_KENMERK_DEFAULT)
    case "N"
      if not IsNumeric(fldFIN_KENMERK_DEFAULT) then
        sKenmerkRecordErr = sKenmerkRecordErr & "De defaultwaarde moet een nummer zijn!<br>"
      else
        if (fldFIN_KENMERK_LENGTE <> "") then
          max = CDbl(10^CInt(fldFIN_KENMERK_LENGTE))
          if (CDbl(fldFIN_KENMERK_DEFAULT)>max) then
            sKenmerkRecordErr = sKenmerkRecordErr & "De defaultwaarde mag niet meer posities bevatten dan aangegeven bij lengte!<br>"
          end if
        end if
        if (fldFIN_KENMERK_NMIN <> "") then
          min = CDbl(fldFIN_KENMERK_NMIN)
          if CDbl(fldFIN_KENMERK_DEFAULT) < min then
            sKenmerkRecordErr = sKenmerkRecordErr & "Defaultwaarde mag niet kleiner zijn dan het aangegeven minimum!<br>"
          end if
        end if
        if (fldFIN_KENMERK_NMAX <> "") then
          max = CDbl(fldFIN_KENMERK_NMAX)
          if CDbl(fldFIN_KENMERK_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(fldFIN_KENMERK_LENGTE)
      if Len(fldFIN_KENMERK_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 FIN_KENMERK set " & _
        "FIN_KENMERK_VOLGNR=" & ToSQL(fldFIN_KENMERK_VOLGNR, "Number") & _
        ",FIN_KENMERK_OMSCHRIJVING=" & ToSQL(fldFIN_KENMERK_OMSCHRIJVING, "Text") & _
        ",FIN_KENMERK_HINT=" & ToSQL(fldFIN_KENMERK_HINT, "Text") & _
        ",FIN_KENMERK_DIMENSIE=" & ToSQL(fldFIN_KENMERK_DIMENSIE, "Text") & _
        ",FIN_KENMERK_KENMERKTYPE=" & ToSQL(fldFIN_KENMERK_KENMERKTYPE, "Text") & _
        ",FIN_KENMERK_TYPE=" & toSQL(fldFIN_KENMERK_TYPE, "Text") & _
        ",FIN_KENMERK_VERPLICHT=" & ToSQL(fldFIN_KENMERK_VERPLICHT, "Number") & _
        ",FIN_KENMERK_GROEP=" & ToSQL(fldFIN_KENMERK_GROEP, "Number") & _
        ",FIN_KENMERK_TOONBAAR=" & fldFIN_KENMERK_TOONBAAR & _
        ",FIN_KENMERK_SYSTEEM=" & fldFIN_KENMERK_SYSTEEM & _
        ",FIN_KENMERK_LENGTE=" & ToSQL(fldFIN_KENMERK_LENGTE, "Number") & _
        ",FIN_KENMERK_DEC=" & ToSQL(fldFIN_KENMERK_DEC, "Number") & _
        ",FIN_KENMERK_NMIN=" & ToSQL(fldFIN_KENMERK_NMIN, "Number") & _
        ",FIN_KENMERK_NMAX=" & ToSQL(fldFIN_KENMERK_NMAX, "Number") & _
        ",FAC_KENMERKDOMEIN_KEY=" & ToSQL(fldFAC_KENMERKDOMEIN_KEY, "Number")
  if (tmp_update_sql <> "") then
    sSQL = sSQL & ",FIN_KENMERK_DEFAULT=" & tmp_update_sql
  else
    sSQL = sSQL & ",FIN_KENMERK_DEFAULT=" & ToSQL(fldFIN_KENMERK_DEFAULT, "Text")
  end if
  sSQL = sSQL & ",FIN_KENMERK_REGEXP=" & ToSQL(fldFIN_KENMERK_REGEXP, "Text")
  sSQL = sSQL & " where " & sWhere
end if
' KenmerkRecord Update Event end
'-------------------------------
      if sSQL = "" then
      sSQL = "update FIN_KENMERK set " & _
        "FIN_KENMERK_VOLGNR=" & ToSQL(fldFIN_KENMERK_VOLGNR, "Number") & _
        ",FIN_KENMERK_OMSCHRIJVING=" & ToSQL(fldFIN_KENMERK_OMSCHRIJVING, "Text") & _
        ",FIN_KENMERK_HINT=" & ToSQL(fldFIN_KENMERK_HINT, "Text") & _
        ",FIN_KENMERK_DIMENSIE=" & ToSQL(fldFIN_KENMERK_DIMENSIE, "Text") & _
        ",FIN_KENMERK_KENMERKTYPE=" & ToSQL(fldFIN_KENMERK_KENMERKTYPE, "Text") & _
        ",FIN_KENMERK_TYPE=" & ToSQL(fldFIN_KENMERK_TYPE, "Text") & _
        ",FIN_KENMERK_VERPLICHT=" & ToSQL(fldFIN_KENMERK_VERPLICHT, "Number") & _
        ",FIN_KENMERK_GROEP=" & ToSQL(fldFIN_KENMERK_GROEP, "Number") & _
        ",FIN_KENMERK_TOONBAAR=" & fldFIN_KENMERK_TOONBAAR & _
        ",FIN_KENMERK_SYSTEEM=" & fldFIN_KENMERK_SYSTEEM & _
        ",FIN_KENMERK_LENGTE=" & ToSQL(fldFIN_KENMERK_LENGTE, "Number") & _
        ",FIN_KENMERK_DEC=" & ToSQL(fldFIN_KENMERK_DEC, "Number") & _
        ",FIN_KENMERK_NMIN=" & ToSQL(fldFIN_KENMERK_NMIN, "Number") & _
        ",FIN_KENMERK_NMAX=" & ToSQL(fldFIN_KENMERK_NMAX, "Number") & _
        ",FAC_KENMERKDOMEIN_KEY=" & ToSQL(fldFAC_KENMERKDOMEIN_KEY, "Number") & _
        ",FIN_KENMERK_DEFAULT=" & ToSQL(fldFIN_KENMERK_DEFAULT, "Text") & _
        ",FIN_KENMERK_REGEXP=" & ToSQL(fldFIN_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 FIN_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 sFAC_KENMERKDOMEIN_KEYDisplayValue: sFAC_KENMERKDOMEIN_KEYDisplayValue = ""

'-------------------------------
' Load primary key and form parameters
'-------------------------------
  if sKenmerkRecordErr = "" then
    fldFIN_KENMERK_KEY = GetParam("FIN_KENMERK_KEY")
    SetVar "Trn_sFIN_KENMERK_UPPER", GetParam("sFIN_KENMERK_UPPER")
    SetVar "Trn_sFIN_KENMERK_KENMERKTYPE", GetParam("sFIN_KENMERK_KENMERKTYPE")
    pFIN_KENMERK_KEY = GetParam("FIN_KENMERK_KEY")
    SetVar "KenmerkRecordError", ""
  else
    fldFIN_KENMERK_VOLGNR = GetParam("FIN_KENMERK_VOLGNR")
    fldFIN_KENMERK_OMSCHRIJVING = GetParam("FIN_KENMERK_OMSCHRIJVING")
    fldFIN_KENMERK_HINT = GetParam("FIN_KENMERK_HINT")
    fldFIN_KENMERK_DIMENSIE = GetParam("FIN_KENMERK_DIMENSIE")
    fldFIN_KENMERK_KENMERKTYPE = GetParam("FIN_KENMERK_KENMERKTYPE")
    fldFIN_KENMERK_TYPE = GetParam("FIN_KENMERK_TYPE")
    fldFIN_KENMERK_VERPLICHT = GetParam("FIN_KENMERK_VERPLICHT")
    fldFIN_KENMERK_GROEP = GetParam("FIN_KENMERK_GROEP")
    fldFIN_KENMERK_TOONBAAR = getCheckBoxValue(GetParam("FIN_KENMERK_TOONBAAR"), "1", "", "Number")
    fldFIN_KENMERK_SYSTEEM = getCheckBoxValue(GetParam("FIN_KENMERK_SYSTEEM"), "1", "", "Number")
    fldFIN_KENMERK_LENGTE = GetParam("FIN_KENMERK_LENGTE")
    fldFIN_KENMERK_DEC = GetParam("FIN_KENMERK_DEC")
    fldFIN_KENMERK_NMIN = GetParam("FIN_KENMERK_NMIN")
    fldFIN_KENMERK_NMAX = GetParam("FIN_KENMERK_NMAX")
    fldFAC_KENMERKDOMEIN_KEY = GetParam("FAC_KENMERKDOMEIN_KEY")
    fldFIN_KENMERK_DEFAULT = GetParam("FIN_KENMERK_DEFAULT")
    fldFIN_KENMERK_REGEXP = GetParam("FIN_KENMERK_REGEXP")
    SetVar "Trn_sFIN_KENMERK_UPPER", GetParam("Trn_sFIN_KENMERK_UPPER")
    SetVar "Trn_sFIN_KENMERK_KENMERKTYPE", GetParam("Trn_sFIN_KENMERK_KENMERKTYPE")
    pFIN_KENMERK_KEY = GetParam("PK_FIN_KENMERK_KEY")
    SetVar "sKenmerkRecordErr", sKenmerkRecordErr
    SetVar "FormTitle", sFormTitle
    Parse "KenmerkRecordError", False
  end if
'-------------------------------

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

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

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

  if IsEmpty(pFIN_KENMERK_KEY) then bPK = False
  
  sWhere = sWhere & "FIN_KENMERK_KEY=" & ToSQL(pFIN_KENMERK_KEY, "Number")
  SetVar "PK_FIN_KENMERK_KEY", pFIN_KENMERK_KEY
'-------------------------------
'-------------------------------
' KenmerkRecord Open Event begin
' KenmerkRecord Open Event end
'-------------------------------

  SetVar "FormTitle", sFormTitle

'-------------------------------
' Build SQL statement and open recordset
'-------------------------------
  sSQL = "select * from FIN_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
    fldFIN_KENMERK_KEY = GetValue(rs, "FIN_KENMERK_KEY")

'-------------------------------
' Load data from recordset when form displayed first time
'-------------------------------
    if sKenmerkRecordErr = "" then
      fldFIN_KENMERK_VOLGNR = GetValue(rs, "FIN_KENMERK_VOLGNR")
      fldFIN_KENMERK_OMSCHRIJVING = GetValue(rs, "FIN_KENMERK_OMSCHRIJVING")
      fldFIN_KENMERK_HINT = GetValue(rs, "FIN_KENMERK_HINT")
      fldFIN_KENMERK_DIMENSIE = GetValue(rs, "FIN_KENMERK_DIMENSIE")
      fldFIN_KENMERK_KENMERKTYPE = GetValue(rs, "FIN_KENMERK_KENMERKTYPE")
      fldFIN_KENMERK_TYPE = GetValue(rs, "FIN_KENMERK_TYPE")
      fldFIN_KENMERK_VERPLICHT = GetValue(rs, "FIN_KENMERK_VERPLICHT")
      fldFIN_KENMERK_GROEP = GetValue(rs, "FIN_KENMERK_GROEP")
      fldFIN_KENMERK_TOONBAAR = GetValue(rs, "FIN_KENMERK_TOONBAAR")
      fldFIN_KENMERK_SYSTEEM = GetValue(rs, "FIN_KENMERK_SYSTEEM")
      fldFIN_KENMERK_LENGTE = GetValue(rs, "FIN_KENMERK_LENGTE")
      fldFIN_KENMERK_DEC = GetValue(rs, "FIN_KENMERK_DEC")
      fldFIN_KENMERK_NMIN = GetValue(rs, "FIN_KENMERK_NMIN")
      fldFIN_KENMERK_NMAX = GetValue(rs, "FIN_KENMERK_NMAX")
      fldFAC_KENMERKDOMEIN_KEY = GetValue(rs, "FAC_KENMERKDOMEIN_KEY")
      fldFIN_KENMERK_DEFAULT = GetValue(rs, "FIN_KENMERK_DEFAULT")
      fldFIN_KENMERK_REGEXP = GetValue(rs, "FIN_KENMERK_REGEXP")
    end if
    SetVar "KenmerkRecordInsert", ""
    Parse "KenmerkRecordEdit", False
'-------------------------------
' KenmerkRecord ShowEdit Event begin
' KenmerkRecord ShowEdit Event end
'-------------------------------
  else
    if sKenmerkRecordErr = "" then
      fldFIN_KENMERK_KEY = ToHTML(GetParam("FIN_KENMERK_KEY"))
    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 "FIN_KENMERK_KEY", ToHTML(fldFIN_KENMERK_KEY)
      SetVar "FIN_KENMERK_VOLGNR", ToHTML(fldFIN_KENMERK_VOLGNR)
      SetVar "FIN_KENMERK_OMSCHRIJVING", ToHTML(fldFIN_KENMERK_OMSCHRIJVING)
      SetVar "FIN_KENMERK_HINT", ToHTML(fldFIN_KENMERK_HINT)
      SetVar "FIN_KENMERK_DIMENSIE", ToHTML(fldFIN_KENMERK_DIMENSIE)
      SetVar "KenmerkRecordLBFIN_KENMERK_KENMERKTYPE", ""
      LOV = Split(""&buildKenmerkTypeList(fldALG_KENMERK_KENMERKTYPE)&"", ";")
      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(fldFIN_KENMERK_KENMERKTYPE) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "KenmerkRecordLBFIN_KENMERK_KENMERKTYPE", True
        next
      end if
    
      SetVar "KenmerkRecordLBFIN_KENMERK_TYPE", ""
      LOV = Split("F;Factuur;R;Factuurregel", ";")
      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(fldFIN_KENMERK_TYPE) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "KenmerkRecordLBFIN_KENMERK_TYPE", True
        next
      end if
    
      SetVar "KenmerkRecordLBFIN_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(fldFIN_KENMERK_VERPLICHT) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "KenmerkRecordLBFIN_KENMERK_VERPLICHT", True
        next
      end if
    
      SetVar "KenmerkRecordLBFIN_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(fldFIN_KENMERK_GROEP) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "KenmerkRecordLBFIN_KENMERK_GROEP", True
        next
      end if
    
  if (LCase(fldFIN_KENMERK_TOONBAAR) = LCase("1")) then
    SetVar "FIN_KENMERK_TOONBAAR_CHECKED", "CHECKED"
  else
    SetVar "FIN_KENMERK_TOONBAAR_CHECKED", ""
  end if

  if (LCase(fldFIN_KENMERK_SYSTEEM) = LCase("1")) then
    SetVar "FIN_KENMERK_SYSTEEM_CHECKED", "CHECKED"
  else
    SetVar "FIN_KENMERK_SYSTEEM_CHECKED", ""
  end if

      SetVar "FIN_KENMERK_LENGTE", ToHTML(fldFIN_KENMERK_LENGTE)
      SetVar "FIN_KENMERK_DEC", ToHTML(fldFIN_KENMERK_DEC)
      SetVar "FIN_KENMERK_NMIN", ToHTML(fldFIN_KENMERK_NMIN)
      SetVar "FIN_KENMERK_NMAX", ToHTML(fldFIN_KENMERK_NMAX)
      SetVar "KenmerkRecordLBFAC_KENMERKDOMEIN_KEY", ""
      SetVar "Selected", ""
      SetVar "ID", ""
      SetVar "Value", sFAC_KENMERKDOMEIN_KEYDisplayValue
      Parse "KenmerkRecordLBFAC_KENMERKDOMEIN_KEY", True
      openrs rsFAC_KENMERKDOMEIN_KEY, "select fac_kenmerkdomein_key, fac_kenmerkdomein_omschrijving from fac_kenmerkdomein where fac_kenmerkdomein_verwijder is null and fac_kenmerkdomein_module = 'FIN' order by fac_kenmerkdomein_upper asc"
      while not rsFAC_KENMERKDOMEIN_KEY.EOF
        SetVar "ID", GetValue(rsFAC_KENMERKDOMEIN_KEY, 0) : SetVar "Value", GetValue(rsFAC_KENMERKDOMEIN_KEY, 1)
        if cstr(GetValue(rsFAC_KENMERKDOMEIN_KEY, 0)) = cstr(fldFAC_KENMERKDOMEIN_KEY) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
        Parse "KenmerkRecordLBFAC_KENMERKDOMEIN_KEY", True
        rsFAC_KENMERKDOMEIN_KEY.MoveNext
      wend
      set rsFAC_KENMERKDOMEIN_KEY = nothing
    
      SetVar "FIN_KENMERK_DEFAULT", ToHTML(fldFIN_KENMERK_DEFAULT)
      SetVar "FIN_KENMERK_REGEXP", ToHTML(fldFIN_KENMERK_REGEXP)
  Parse "FormKenmerkRecord", False

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

Set rs = Nothing

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