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

'-------------------------------
' 
' mld_disciplinerecord CustomIncludes Event begin
%>
<!-- #include file="common.asp" -->
<%

pINS_SRTDISCIPLINE_KEY = getParam("INS_SRTDISCIPLINE_KEY")
Dim myINS_DISCIPLINE_KEY
myINS_DISCIPLINE_KEY = GetParam("PK_INS_DISCIPLINE_KEY")
' mld_disciplinerecord CustomIncludes Event end


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


'===============================
' mld_disciplinerecord PageSecurity begin
' mld_disciplinerecord PageSecurity end
'===============================

'===============================
' mld_disciplinerecord Open Event begin
' mld_disciplinerecord Open Event end
'===============================

'===============================
' mld_disciplinerecord OpenAnyPage Event begin
' mld_disciplinerecord OpenAnyPage Event end
'===============================

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

' mld_disciplinerecord Show begin
'===============================
' Perform the form's action
'-------------------------------
' Initialize error variables
'-------------------------------
sDisciplineRecordErr = ""

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

' mld_disciplinerecord Show end

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

' mld_disciplinerecord Close Event begin
' mld_disciplinerecord Close Event end

cn.Close
Set cn = Nothing
UnloadTemplate
'===============================
'===============================
' Action of the Record Form
'-------------------------------
Sub DisciplineRecordAction(sAction)
'-------------------------------
' Initialize variables  
'-------------------------------
  Dim bExecSQL: bExecSQL = true
  Dim sActionFileName : sActionFileName = ""
  Dim sParams : sParams = "?"
  Dim sWhere : sWhere = "" 
  Dim bErr : bErr = False
  Dim pPKINS_DISCIPLINE_KEY : pPKINS_DISCIPLINE_KEY = ""
  Dim fldINS_SRTDISCIPLINE_KEY : fldINS_SRTDISCIPLINE_KEY = ""
  Dim fldINS_DISCIPLINE_OMSCHRIJVING : fldINS_DISCIPLINE_OMSCHRIJVING = ""
  Dim fldMLD_BEHANDELGROEP_KEY : fldMLD_BEHANDELGROEP_KEY = ""
  Dim fldPRS_KOSTENSOORT_KEY : fldPRS_KOSTENSOORT_KEY = ""
  Dim fldINS_DISCIPLINE_KPNVERPLICHT : fldINS_DISCIPLINE_KPNVERPLICHT = ""
  Dim fldMLD_DISC_PARAMS_BESTELLIMIET : fldMLD_DISC_PARAMS_BESTELLIMIET = ""
  Dim fldMLD_DISC_PARAMS_BESTELLIMIET2 : fldMLD_DISC_PARAMS_BESTELLIMIET2 = ""
  Dim fldMLD_DISC_PARAMS_BESTELLIMIET3 : fldMLD_DISC_PARAMS_BESTELLIMIET3 = ""
  Dim fldMLD_DISC_PARAMS_BESTELLIMIET4 : fldMLD_DISC_PARAMS_BESTELLIMIET4 = ""
  Dim fldMLD_DISC_PARAMS_BESTELLIMIET5 : fldMLD_DISC_PARAMS_BESTELLIMIET5 = ""
  Dim fldMLD_DISC_PARAMS_PGB : fldMLD_DISC_PARAMS_PGB = ""
  Dim fldMLD_DISC_PARAMS_STARTDATUM : fldMLD_DISC_PARAMS_STARTDATUM = ""
  Dim fldMLD_DISC_PARAMS_DIRECTKLAAR : fldMLD_DISC_PARAMS_DIRECTKLAAR = ""
  Dim fldMLD_DISC_PARAMS_KETEN : fldMLD_DISC_PARAMS_KETEN = ""
  Dim fldMLD_DISC_PARAMS_FRONTENDPRIO : fldMLD_DISC_PARAMS_FRONTENDPRIO = ""
  Dim fldMLD_DISC_PARAMS_EIGEN_KP : fldMLD_DISC_PARAMS_EIGEN_KP = ""
  Dim fldINS_DISCIPLINE_MODULE : fldINS_DISCIPLINE_MODULE = ""
  Dim fldMLD_DISC_PARAMS_FACTUURPCT : fldMLD_DISC_PARAMS_FACTUURPCT = ""
  Dim fldMLD_DISC_PARAMS_FACTUURMARGE : fldMLD_DISC_PARAMS_FACTUURMARGE = ""
  Dim fldMLD_DISC_PARAMS_FACTMATCHMODE : fldMLD_DISC_PARAMS_FACTMATCHMODE = ""
  Dim fldMLD_DISC_PARAMS_FACTUURAPPR : fldMLD_DISC_PARAMS_FACTUURAPPR = ""
  Dim fldMLD_DISC_PARAMS_FACTUURGRENS : fldMLD_DISC_PARAMS_FACTUURGRENS = ""
  Dim fldMLD_DISC_PARAMS_BONOTIFY : fldMLD_DISC_PARAMS_BONOTIFY = ""
  Dim fldMLD_DISC_PARAMS_BENOTIFY : fldMLD_DISC_PARAMS_BENOTIFY = ""
  Dim fldMLD_DISC_PARAMS_NOTIFY : fldMLD_DISC_PARAMS_NOTIFY = ""
  Dim fldMLD_DISC_PARAMS_NOTI_DAGEN : fldMLD_DISC_PARAMS_NOTI_DAGEN = ""
  Dim fldMLD_DISC_PARAMS_OPDR_KOSTEN : fldMLD_DISC_PARAMS_OPDR_KOSTEN = ""
  Dim fldFAC_ACTIVITEIT_KEY : fldFAC_ACTIVITEIT_KEY = ""
  Dim fldINS_DISCIPLINE_EMAIL : fldINS_DISCIPLINE_EMAIL = ""
  Dim fldINS_DISCIPLINE_KTOPERCENTAGE : fldINS_DISCIPLINE_KTOPERCENTAGE = ""
  Dim fldINS_DISCIPLINE_KTODREMPEL : fldINS_DISCIPLINE_KTODREMPEL = ""
  Dim fldMLD_DISC_PARAMS_OFFERTEAUTO : fldMLD_DISC_PARAMS_OFFERTEAUTO = ""
  Dim fldMLD_DISC_PARAMS_FENOTES : fldMLD_DISC_PARAMS_FENOTES = ""
'-------------------------------

'-------------------------------
' DisciplineRecord Action begin
'-------------------------------
  sActionFileName = "mld_disciplinegrid.asp"
  sParams = sParams & "INS_SRTDISCIPLINE_KEY=" & ToURL(GetParam("Trn_INS_SRTDISCIPLINE_KEY")) & "&"
  sParams = sParams & "sINS_DISCIPLINE_OMSCHRIJVING=" & ToURL(GetParam("Trn_sINS_DISCIPLINE_OMSCHRIJVING"))

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

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

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


'-------------------------------
' Load all form fields into variables
'-------------------------------
  fldINS_SRTDISCIPLINE_KEY = GetParam("INS_SRTDISCIPLINE_KEY")
  fldINS_DISCIPLINE_OMSCHRIJVING = GetParam("INS_DISCIPLINE_OMSCHRIJVING")
  fldMLD_BEHANDELGROEP_KEY = GetParam("MLD_BEHANDELGROEP_KEY")
  fldPRS_KOSTENSOORT_KEY = GetParam("PRS_KOSTENSOORT_KEY")
  fldINS_DISCIPLINE_KPNVERPLICHT = getCheckBoxValue(GetParam("INS_DISCIPLINE_KPNVERPLICHT"), "1", "0", "Number")
  fldMLD_DISC_PARAMS_BESTELLIMIET = GetParam("MLD_DISC_PARAMS_BESTELLIMIET")
  fldMLD_DISC_PARAMS_BESTELLIMIET2 = GetParam("MLD_DISC_PARAMS_BESTELLIMIET2")
  fldMLD_DISC_PARAMS_BESTELLIMIET3 = GetParam("MLD_DISC_PARAMS_BESTELLIMIET3")
  fldMLD_DISC_PARAMS_BESTELLIMIET4 = GetParam("MLD_DISC_PARAMS_BESTELLIMIET4")
  fldMLD_DISC_PARAMS_BESTELLIMIET5 = GetParam("MLD_DISC_PARAMS_BESTELLIMIET5")
  fldMLD_DISC_PARAMS_PGB = GetParam("MLD_DISC_PARAMS_PGB")
  fldMLD_DISC_PARAMS_STARTDATUM = getCheckBoxValue(GetParam("MLD_DISC_PARAMS_STARTDATUM"), "1", "0", "Number")
  fldMLD_DISC_PARAMS_DIRECTKLAAR = GetParam("MLD_DISC_PARAMS_DIRECTKLAAR")
  fldMLD_DISC_PARAMS_KETEN = getCheckBoxValue(GetParam("MLD_DISC_PARAMS_KETEN"), "1", "0", "Number")
  fldMLD_DISC_PARAMS_FRONTENDPRIO = getCheckBoxValue(GetParam("MLD_DISC_PARAMS_FRONTENDPRIO"), "1", "0", "Number")
  fldMLD_DISC_PARAMS_EIGEN_KP = getCheckBoxValue(GetParam("MLD_DISC_PARAMS_EIGEN_KP"), "1", "0", "Number")
  fldINS_DISCIPLINE_MODULE = GetParam("INS_DISCIPLINE_MODULE")
  fldMLD_DISC_PARAMS_FACTUURPCT = GetParam("MLD_DISC_PARAMS_FACTUURPCT")
  fldMLD_DISC_PARAMS_FACTUURMARGE = GetParam("MLD_DISC_PARAMS_FACTUURMARGE")
  fldMLD_DISC_PARAMS_FACTMATCHMODE = GetParam("MLD_DISC_PARAMS_FACTMATCHMODE")
  fldMLD_DISC_PARAMS_FACTUURAPPR = getCheckBoxValue(GetParam("MLD_DISC_PARAMS_FACTUURAPPR"), "1", "0", "Number")
  fldMLD_DISC_PARAMS_FACTUURGRENS = GetParam("MLD_DISC_PARAMS_FACTUURGRENS")
  fldMLD_DISC_PARAMS_BONOTIFY = GetParam("MLD_DISC_PARAMS_BONOTIFY")
  fldMLD_DISC_PARAMS_BENOTIFY = getCheckBoxValue(GetParam("MLD_DISC_PARAMS_BENOTIFY"), "1", "0", "Number")
  fldMLD_DISC_PARAMS_NOTIFY = GetParam("MLD_DISC_PARAMS_NOTIFY")
  fldMLD_DISC_PARAMS_NOTI_DAGEN = GetParam("MLD_DISC_PARAMS_NOTI_DAGEN")
  fldMLD_DISC_PARAMS_OPDR_KOSTEN = GetParam("MLD_DISC_PARAMS_OPDR_KOSTEN")
  fldFAC_ACTIVITEIT_KEY = GetParam("FAC_ACTIVITEIT_KEY")
  fldINS_DISCIPLINE_EMAIL = GetParam("INS_DISCIPLINE_EMAIL")
  fldINS_DISCIPLINE_KTOPERCENTAGE = GetParam("INS_DISCIPLINE_KTOPERCENTAGE")
  fldINS_DISCIPLINE_KTODREMPEL = GetParam("INS_DISCIPLINE_KTODREMPEL")
  fldMLD_DISC_PARAMS_OFFERTEAUTO = getCheckBoxValue(GetParam("MLD_DISC_PARAMS_OFFERTEAUTO"), "1", "0", "Number")
  fldMLD_DISC_PARAMS_FENOTES = GetParam("MLD_DISC_PARAMS_FENOTES")

'-------------------------------
' Validate fields
'-------------------------------
  if sAction = "insert" or sAction = "update" then
    if IsEmpty(fldINS_SRTDISCIPLINE_KEY) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Vakgroeptype is verplicht.<br>"
    end if
    if IsEmpty(fldINS_DISCIPLINE_OMSCHRIJVING) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Omschrijving is verplicht.<br>"
    end if
    if not isNumeric(fldINS_SRTDISCIPLINE_KEY) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Vakgroeptype is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_BEHANDELGROEP_KEY) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Behandelgroep is niet correct.<br>"
    end if
    if not isNumeric(fldPRS_KOSTENSOORT_KEY) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Kostensoort is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_DISC_PARAMS_BESTELLIMIET) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Backoffice bestellimiet is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_DISC_PARAMS_BESTELLIMIET2) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Backoffice bestellimiet2 is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_DISC_PARAMS_BESTELLIMIET3) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Backoffice bestellimiet3 is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_DISC_PARAMS_BESTELLIMIET4) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Backoffice bestellimiet4 is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_DISC_PARAMS_BESTELLIMIET5) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Backoffice bestellimiet5 is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_DISC_PARAMS_PGB) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Ten laste van PGB en/of AGB is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_DISC_PARAMS_DIRECTKLAAR) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Kan door frontoffice worden behandeld is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_DISC_PARAMS_FACTUURPCT) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Factuurmarge percentage is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_DISC_PARAMS_FACTUURMARGE) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Factuurmarge EURO is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_DISC_PARAMS_FACTUURGRENS) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Factuur accoord beneden € is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_DISC_PARAMS_BONOTIFY) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Backoffice notificeren (MLD2BO/MLD2B3) is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_DISC_PARAMS_NOTIFY) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Melder notificeren is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_DISC_PARAMS_NOTI_DAGEN) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Aantal dagen tbv. herinnering is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_DISC_PARAMS_OPDR_KOSTEN) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Verplicht opdrachtbedrag vanaf is niet correct.<br>"
    end if
    if not isNumeric(fldINS_DISCIPLINE_KTOPERCENTAGE) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Klanttevredenheidsmeting percentage is niet correct.<br>"
    end if
    if not isNumeric(fldINS_DISCIPLINE_KTODREMPEL) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Klanttevredenheidsmeting drempel is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_DISC_PARAMS_FENOTES) then
      sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Interactie met FE mogelijk is niet correct.<br>"
    end if
'-------------------------------
' DisciplineRecord Check Event begin
fldMLD_DISC_PARAMS_BESTELLIMIET  = SafeToDouble(fldMLD_DISC_PARAMS_BESTELLIMIET)
fldMLD_DISC_PARAMS_BESTELLIMIET2 = SafeToDouble(fldMLD_DISC_PARAMS_BESTELLIMIET2)
fldMLD_DISC_PARAMS_BESTELLIMIET3 = SafeToDouble(fldMLD_DISC_PARAMS_BESTELLIMIET3)
fldMLD_DISC_PARAMS_BESTELLIMIET4 = SafeToDouble(fldMLD_DISC_PARAMS_BESTELLIMIET4)
fldMLD_DISC_PARAMS_BESTELLIMIET5 = SafeToDouble(fldMLD_DISC_PARAMS_BESTELLIMIET5)
fldMLD_DISC_PARAMS_FACTUURPCT    = SafeToDouble(fldMLD_DISC_PARAMS_FACTUURPCT)
fldMLD_DISC_PARAMS_FACTUURMARGE  = SafeToDouble(fldMLD_DISC_PARAMS_FACTUURMARGE)
fldMLD_DISC_PARAMS_FACTUURGRENS  = SafeToDouble(fldMLD_DISC_PARAMS_FACTUURGRENS)
fldMLD_DISC_PARAMS_NOTI_DAGEN    = SafeToDouble(fldMLD_DISC_PARAMS_NOTI_DAGEN)
fldINS_DISCIPLINE_KTOPERCENTAGE  = SafeToDouble(fldINS_DISCIPLINE_KTOPERCENTAGE)
fldINS_DISCIPLINE_KTODREMPEL     = SafeToDouble(fldINS_DISCIPLINE_KTODREMPEL)

    if fldINS_DISCIPLINE_KTOPERCENTAGE <> "" then
      if ((fldINS_DISCIPLINE_KTOPERCENTAGE > 100) or (fldINS_DISCIPLINE_KTOPERCENTAGE < 0)) then
        sDisciplineRecordErr = sDisciplineRecordErr & "De waarde in veld Klanttevredenheidsmeting percentage is niet correct.<br>"
      end if
    end if
' DisciplineRecord Check Event end
'-------------------------------
    If len(sDisciplineRecordErr) > 0 then
      exit sub
    end if
  end if
'-------------------------------


'-------------------------------
' Create SQL statement
'-------------------------------
  select case sAction
    case "insert"
'-------------------------------
' DisciplineRecord Insert Event begin
' DisciplineRecord Insert Event end
'-------------------------------
      sSQL = "insert into INS_TAB_DISCIPLINE (" & _
          "INS_SRTDISCIPLINE_KEY," & _
          "INS_DISCIPLINE_OMSCHRIJVING," & _
          "PRS_KOSTENSOORT_KEY," & _
          "INS_DISCIPLINE_KPNVERPLICHT," & _
          "INS_DISCIPLINE_MODULE," & _
          "INS_DISCIPLINE_EMAIL," & _
          "INS_DISCIPLINE_KTOPERCENTAGE," & _
          "INS_DISCIPLINE_KTODREMPEL)" & _
          " values (" & _
          ToSQL(fldINS_SRTDISCIPLINE_KEY, "Number") & "," & _
          ToSQL(fldINS_DISCIPLINE_OMSCHRIJVING, "Text") & "," & _
          ToSQL(fldPRS_KOSTENSOORT_KEY, "Number") & "," & _
          fldINS_DISCIPLINE_KPNVERPLICHT & "," & _
          ToSQL(fldINS_DISCIPLINE_MODULE, "Text") & "," & _
          ToSQL(fldINS_DISCIPLINE_EMAIL, "Text") & "," & _
          ToSQL(fldINS_DISCIPLINE_KTOPERCENTAGE, "Number") & "," & _
          ToSQL(fldINS_DISCIPLINE_KTODREMPEL, "Number") & _
          ")"
    case "update"
'-------------------------------
' DisciplineRecord Update Event begin
' DisciplineRecord Update Event end
'-------------------------------
      sSQL = "update INS_TAB_DISCIPLINE set " & _
        "INS_SRTDISCIPLINE_KEY=" & ToSQL(fldINS_SRTDISCIPLINE_KEY, "Number") & _
        ",INS_DISCIPLINE_OMSCHRIJVING=" & ToSQL(fldINS_DISCIPLINE_OMSCHRIJVING, "Text") & _
        ",PRS_KOSTENSOORT_KEY=" & ToSQL(fldPRS_KOSTENSOORT_KEY, "Number") & _
        ",INS_DISCIPLINE_KPNVERPLICHT=" & fldINS_DISCIPLINE_KPNVERPLICHT & _
        ",INS_DISCIPLINE_MODULE=" & ToSQL(fldINS_DISCIPLINE_MODULE, "Text") & _
        ",INS_DISCIPLINE_EMAIL=" & ToSQL(fldINS_DISCIPLINE_EMAIL, "Text") & _
        ",INS_DISCIPLINE_KTOPERCENTAGE=" & ToSQL(fldINS_DISCIPLINE_KTOPERCENTAGE, "Number") & _
        ",INS_DISCIPLINE_KTODREMPEL=" & ToSQL(fldINS_DISCIPLINE_KTODREMPEL, "Number")
      sSQL = sSQL & " where " & sWhere
    case "delete"
'-------------------------------
' DisciplineRecord Delete Event begin
sSql = "UPDATE INS_TAB_DISCIPLINE SET INS_DISCIPLINE_VERWIJDER="+sysdate+" WHERE INS_DISCIPLINE_KEY = " & ToSQL(GetParam("PK_INS_DISCIPLINE_KEY"), "Number")
' DisciplineRecord Delete Event end
'-------------------------------
      if sSQL = "" then
      sSQL = "delete from INS_TAB_DISCIPLINE where " & sWhere
      end if
  end select
'-------------------------------
'-------------------------------
' DisciplineRecord BeforeExecute Event begin
' DisciplineRecord BeforeExecute Event end
'-------------------------------

'-------------------------------
' Execute SQL statement
'-------------------------------
if len(sDisciplineRecordErr) > 0 then Exit Sub
  on error resume next
  if bExecSQL then 
    cn.execute sSQL
  end if
  sDisciplineRecordErr = ProcessError
  on error goto 0
  if len(sDisciplineRecordErr) > 0 then Exit Sub
  select case sAction
    case "insert"
'-------------------------------
' DisciplineRecord AfterInsert Event begin
'En voeg de params toe aan MLD_disc
'Zoek eerst de key op.
DiscSql = "SELECT MAX(INS_DISCIPLINE_KEY) INS_DISCIPLINE_KEY"&_
          "  FROM MLD_V_AANWEZIGDISCIPLINE "&_
          " WHERE INS_DISCIPLINE_OMSCHRIJVING="&ToSql(fldINS_DISCIPLINE_OMSCHRIJVING,"Text")
openrs rsDisc, DiscSql
if not rsDisc.EOF then
  ins_discipline_key = getValue(rsDisc,"INS_DISCIPLINE_KEY")
  DiscSql = "INSERT INTO MLD_DISC_PARAMS "&_
            "(  MLD_INS_DISCIPLINE_KEY"&_
            ",  MLD_DISC_PARAMS_FACTUURPCT"&_
            ",  MLD_DISC_PARAMS_FACTUURMARGE"&_
            ",  MLD_DISC_PARAMS_FACTUURGRENS"&_
            ",  MLD_DISC_PARAMS_FACTUURAPPR"&_
            ",  MLD_DISC_PARAMS_FACTMATCHMODE"&_
            ",  MLD_DISC_PARAMS_NOTIFY"&_
            ",  MLD_DISC_PARAMS_BONOTIFY"&_
            ",  MLD_DISC_PARAMS_BENOTIFY"&_
            ",  MLD_DISC_PARAMS_OPDR_KOSTEN"&_
            ",  MLD_DISC_PARAMS_NOTI_DAGEN"&_
            ",  MLD_DISC_PARAMS_DIRECTKLAAR"&_
            ",  MLD_DISC_PARAMS_FRONTENDPRIO"&_
            ",  MLD_DISC_PARAMS_EIGEN_KP"&_
            ",  MLD_DISC_PARAMS_STARTDATUM"&_
            ",  MLD_DISC_PARAMS_BESTELLIMIET"&_
            ",  MLD_DISC_PARAMS_BESTELLIMIET2"&_
            ",  MLD_DISC_PARAMS_BESTELLIMIET3"&_
            ",  MLD_DISC_PARAMS_BESTELLIMIET4"&_
            ",  MLD_DISC_PARAMS_BESTELLIMIET5"&_
            ",  MLD_DISC_PARAMS_OFFERTEAUTO"&_
            ",  MLD_DISC_PARAMS_FENOTES"&_
            ",  MLD_DISC_PARAMS_KETEN"&_
            ",  MLD_DISC_PARAMS_PGB"&_
            ",  MLD_BEHANDELGROEP_KEY"&_
            ",  FAC_ACTIVITEIT_KEY"&_
            ") VALUES " &_
            "("& ToSql(ins_discipline_key,"Number") &_
            ","& ToSql(fldMLD_DISC_PARAMS_FACTUURPCT,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_FACTUURMARGE,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_FACTUURGRENS,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_FACTUURAPPR,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_FACTUURMATCHMODE,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_NOTIFY,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_BONOTIFY,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_BENOTIFY,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_OPDR_KOSTEN,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_NOTI_DAGEN,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_DIRECTKLAAR,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_FRONTENDPRIO,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_EIGEN_KP,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_STARTDATUM,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_BESTELLIMIET,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_BESTELLIMIET2,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_BESTELLIMIET3,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_BESTELLIMIET4,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_BESTELLIMIET5,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_OFFERTEAUTO,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_FENOTES,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_KETEN,"Number")&_
            ","& ToSql(fldMLD_DISC_PARAMS_PGB,"Number")&_
            ","& ToSql(fldMLD_BEHANDELGROEP_KEY,"Number")&_
            ","& ToSql(fldFAC_ACTIVITEIT_KEY,"Number")&_
            ")"
on error resume next
  if bExecSQL then
    cn.execute DiscSQL
  end if
  sDisciplineRecordErr = ProcessError
  on error goto 0
  if len(sDisciplineRecordErr) > 0 then
         cn.execute "DELETE FROM MLD_V_AANWEZIGDISCIPLINE " &_
                    " WHERE INS_DISCIPLINE_KEY = " & ToSql(ins_discipline_key,"Number")
         Exit Sub
      End If
end if
rsDisc.Close
' DisciplineRecord AfterInsert Event end
'-------------------------------
    case "update"
'-------------------------------
' DisciplineRecord AfterUpdate Event begin
'En update de params in MLD_disc
DiscSql = "UPDATE MLD_DISC_PARAMS SET "&_
          "  MLD_DISC_PARAMS_FACTUURPCT="&ToSql(fldMLD_DISC_PARAMS_FACTUURPCT,"Number")&","&_
          "  MLD_DISC_PARAMS_FACTUURMARGE="&ToSql(fldMLD_DISC_PARAMS_FACTUURMARGE,"Number")&","&_
          "  MLD_DISC_PARAMS_FACTUURGRENS="&ToSql(fldMLD_DISC_PARAMS_FACTUURGRENS,"Number")&","&_
          "  MLD_DISC_PARAMS_FACTUURAPPR="&ToSql(fldMLD_DISC_PARAMS_FACTUURAPPR,"Number")&","&_
          "  MLD_DISC_PARAMS_FACTMATCHMODE="&ToSql(fldMLD_DISC_PARAMS_FACTMATCHMODE,"Number")&","&_
          "  MLD_DISC_PARAMS_NOTIFY="&ToSql(fldMLD_DISC_PARAMS_NOTIFY,"Number")&","&_
          "  MLD_DISC_PARAMS_BONOTIFY="&ToSql(fldMLD_DISC_PARAMS_BONOTIFY,"Number")&","&_
          "  MLD_DISC_PARAMS_BENOTIFY="&ToSql(fldMLD_DISC_PARAMS_BENOTIFY,"Number")&","&_
          "  MLD_DISC_PARAMS_OPDR_KOSTEN="&ToSql(fldMLD_DISC_PARAMS_OPDR_KOSTEN,"Number")&","&_
          "  MLD_DISC_PARAMS_NOTI_DAGEN="&ToSql(fldMLD_DISC_PARAMS_NOTI_DAGEN,"Number")&","&_
          "  MLD_DISC_PARAMS_DIRECTKLAAR="&ToSql(fldMLD_DISC_PARAMS_DIRECTKLAAR,"Number")&","&_
          "  MLD_DISC_PARAMS_FRONTENDPRIO="&ToSql(fldMLD_DISC_PARAMS_FRONTENDPRIO,"Number")&","&_
          "  MLD_DISC_PARAMS_EIGEN_KP="&ToSql(fldMLD_DISC_PARAMS_EIGEN_KP,"Number")&","&_
          "  MLD_DISC_PARAMS_STARTDATUM="&ToSql(fldMLD_DISC_PARAMS_STARTDATUM,"Number")&","&_
          "  MLD_DISC_PARAMS_BESTELLIMIET="&ToSql(fldMLD_DISC_PARAMS_BESTELLIMIET,"Number")&","&_
          "  MLD_DISC_PARAMS_BESTELLIMIET2="&ToSql(fldMLD_DISC_PARAMS_BESTELLIMIET2,"Number")&","&_
          "  MLD_DISC_PARAMS_BESTELLIMIET3="&ToSql(fldMLD_DISC_PARAMS_BESTELLIMIET3,"Number")&","&_
          "  MLD_DISC_PARAMS_BESTELLIMIET4="&ToSql(fldMLD_DISC_PARAMS_BESTELLIMIET4,"Number")&","&_
          "  MLD_DISC_PARAMS_BESTELLIMIET5="&ToSql(fldMLD_DISC_PARAMS_BESTELLIMIET5,"Number")&","&_
          "  MLD_DISC_PARAMS_OFFERTEAUTO="&ToSql(fldMLD_DISC_PARAMS_OFFERTEAUTO,"Number")&","&_
          "  MLD_DISC_PARAMS_FENOTES="&ToSql(fldMLD_DISC_PARAMS_FENOTES,"Number")&","&_
          "  MLD_DISC_PARAMS_KETEN="&ToSql(fldMLD_DISC_PARAMS_KETEN,"Number")&","&_
          "  MLD_DISC_PARAMS_PGB="&ToSql(fldMLD_DISC_PARAMS_PGB,"Number")&","&_
          "  MLD_BEHANDELGROEP_KEY="&ToSql(fldMLD_BEHANDELGROEP_KEY,"Number")&","&_
          "  FAC_ACTIVITEIT_KEY="&ToSql(fldFAC_ACTIVITEIT_KEY,"Number")&" "&_
          "WHERE MLD_INS_DISCIPLINE_KEY="&pPKINS_DISCIPLINE_KEY
on error resume next
if bExecSQL then
  cn.execute DiscSQL
end if
sDisciplineRecordErr = ProcessError
on error goto 0
if len(sDisciplineRecordErr) > 0 then Exit Sub
' DisciplineRecord AfterUpdate Event end
'-------------------------------
  end select
  cn.Close
  Set cn = Nothing
  response.redirect sActionFileName & sParams
'-------------------------------
' DisciplineRecord Action end
'-------------------------------
end sub
'===============================

'===============================
' Display Record Form
'-------------------------------
Sub DisciplineRecord_Show()
'-------------------------------
' DisciplineRecord Show begin
'-------------------------------
  Dim sWhere : sWhere = ""
  Dim sFormTitle: sFormTitle = "Details vakgroep"
  Dim bPK : bPK = True
  Dim sMLD_BEHANDELGROEP_KEYDisplayValue: sMLD_BEHANDELGROEP_KEYDisplayValue = ""
  Dim sPRS_KOSTENSOORT_KEYDisplayValue: sPRS_KOSTENSOORT_KEYDisplayValue = ""
  Dim sFAC_ACTIVITEIT_KEYDisplayValue: sFAC_ACTIVITEIT_KEYDisplayValue = ""

'-------------------------------
' Load primary key and form parameters
'-------------------------------
  if sDisciplineRecordErr = "" then
    SetVar "Trn_INS_SRTDISCIPLINE_KEY", GetParam("INS_SRTDISCIPLINE_KEY")
    SetVar "Trn_sINS_DISCIPLINE_OMSCHRIJVING", GetParam("sINS_DISCIPLINE_OMSCHRIJVING")
    pINS_DISCIPLINE_KEY = GetParam("INS_DISCIPLINE_KEY")
    SetVar "DisciplineRecordError", ""
  else
    fldINS_SRTDISCIPLINE_KEY = GetParam("INS_SRTDISCIPLINE_KEY")
    fldINS_DISCIPLINE_OMSCHRIJVING = GetParam("INS_DISCIPLINE_OMSCHRIJVING")
    fldPRS_KOSTENSOORT_KEY = GetParam("PRS_KOSTENSOORT_KEY")
    fldINS_DISCIPLINE_KPNVERPLICHT = getCheckBoxValue(GetParam("INS_DISCIPLINE_KPNVERPLICHT"), "1", "0", "Number")
    fldINS_DISCIPLINE_MODULE = GetParam("INS_DISCIPLINE_MODULE")
    fldINS_DISCIPLINE_EMAIL = GetParam("INS_DISCIPLINE_EMAIL")
    fldINS_DISCIPLINE_KTOPERCENTAGE = GetParam("INS_DISCIPLINE_KTOPERCENTAGE")
    fldINS_DISCIPLINE_KTODREMPEL = GetParam("INS_DISCIPLINE_KTODREMPEL")
    SetVar "Trn_INS_SRTDISCIPLINE_KEY", GetParam("Trn_INS_SRTDISCIPLINE_KEY")
    SetVar "Trn_sINS_DISCIPLINE_OMSCHRIJVING", GetParam("Trn_sINS_DISCIPLINE_OMSCHRIJVING")
    pINS_DISCIPLINE_KEY = GetParam("PK_INS_DISCIPLINE_KEY")
    SetVar "sDisciplineRecordErr", sDisciplineRecordErr
    SetVar "FormTitle", sFormTitle
    Parse "DisciplineRecordError", False
  end if
'-------------------------------

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

  fldMLD_BEHANDELGROEP_KEY = GetParam("MLD_BEHANDELGROEP_KEY")
  fldMLD_DISC_PARAMS_BESTELLIMIET = GetParam("MLD_DISC_PARAMS_BESTELLIMIET")
  fldMLD_DISC_PARAMS_BESTELLIMIET2 = GetParam("MLD_DISC_PARAMS_BESTELLIMIET2")
  fldMLD_DISC_PARAMS_BESTELLIMIET3 = GetParam("MLD_DISC_PARAMS_BESTELLIMIET3")
  fldMLD_DISC_PARAMS_BESTELLIMIET4 = GetParam("MLD_DISC_PARAMS_BESTELLIMIET4")
  fldMLD_DISC_PARAMS_BESTELLIMIET5 = GetParam("MLD_DISC_PARAMS_BESTELLIMIET5")
  fldMLD_DISC_PARAMS_PGB = GetParam("MLD_DISC_PARAMS_PGB")
  fldMLD_DISC_PARAMS_STARTDATUM = GetParam("MLD_DISC_PARAMS_STARTDATUM")
  fldMLD_DISC_PARAMS_DIRECTKLAAR = GetParam("MLD_DISC_PARAMS_DIRECTKLAAR")
  fldMLD_DISC_PARAMS_KETEN = GetParam("MLD_DISC_PARAMS_KETEN")
  fldMLD_DISC_PARAMS_FRONTENDPRIO = GetParam("MLD_DISC_PARAMS_FRONTENDPRIO")
  fldMLD_DISC_PARAMS_EIGEN_KP = GetParam("MLD_DISC_PARAMS_EIGEN_KP")
  fldMLD_DISC_PARAMS_FACTUURPCT = GetParam("MLD_DISC_PARAMS_FACTUURPCT")
  fldMLD_DISC_PARAMS_FACTUURMARGE = GetParam("MLD_DISC_PARAMS_FACTUURMARGE")
  fldMLD_DISC_PARAMS_FACTMATCHMODE = GetParam("MLD_DISC_PARAMS_FACTMATCHMODE")
  fldMLD_DISC_PARAMS_FACTUURAPPR = GetParam("MLD_DISC_PARAMS_FACTUURAPPR")
  fldMLD_DISC_PARAMS_FACTUURGRENS = GetParam("MLD_DISC_PARAMS_FACTUURGRENS")
  fldMLD_DISC_PARAMS_BONOTIFY = GetParam("MLD_DISC_PARAMS_BONOTIFY")
  fldMLD_DISC_PARAMS_BENOTIFY = GetParam("MLD_DISC_PARAMS_BENOTIFY")
  fldMLD_DISC_PARAMS_NOTIFY = GetParam("MLD_DISC_PARAMS_NOTIFY")
  fldMLD_DISC_PARAMS_NOTI_DAGEN = GetParam("MLD_DISC_PARAMS_NOTI_DAGEN")
  fldMLD_DISC_PARAMS_OPDR_KOSTEN = GetParam("MLD_DISC_PARAMS_OPDR_KOSTEN")
  fldFAC_ACTIVITEIT_KEY = GetParam("FAC_ACTIVITEIT_KEY")
  fldMLD_DISC_PARAMS_OFFERTEAUTO = GetParam("MLD_DISC_PARAMS_OFFERTEAUTO")
  fldMLD_DISC_PARAMS_FENOTES = GetParam("MLD_DISC_PARAMS_FENOTES")
'-------------------------------

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

  if IsEmpty(pINS_DISCIPLINE_KEY) then bPK = False
  
  sWhere = sWhere & "INS_DISCIPLINE_KEY=" & ToSQL(pINS_DISCIPLINE_KEY, "Number")
  SetVar "PK_INS_DISCIPLINE_KEY", pINS_DISCIPLINE_KEY
'-------------------------------
'-------------------------------
' DisciplineRecord Open Event begin
if Not IsEmpty(pINS_DISCIPLINE_KEY) then
  sqlINS_SRTDISCIPLINE_KEY = "SELECT s2.ins_srtdiscipline_key, s2.ins_srtdiscipline_omschrijving "&_
    "FROM ins_srtdiscipline s1, ins_srtdiscipline s2, ins_tab_discipline d "&_
    "WHERE d.ins_discipline_key = "&ToSQL(pINS_DISCIPLINE_KEY, "Number") &" "&_
    " AND s1.ins_srtdiscipline_module = s2.ins_srtdiscipline_module "&_
    " AND s1.ins_srtdiscipline_module = 'MLD' "&_
    " AND d.ins_srtdiscipline_key  = s1.ins_srtdiscipline_key "&_
    " AND s2.ins_srtdiscipline_ins <= s1.ins_srtdiscipline_ins "&_
    " AND s2.ins_srtdiscipline_alg <= s1.ins_srtdiscipline_alg "&_
    " AND s2.ins_srtdiscipline_bes <= s1.ins_srtdiscipline_bes "&_
    " AND s2.ins_srtdiscipline_verwijder is null "&_
    "ORDER BY s2.ins_srtdiscipline_omschrijving asc"
else
  sqlINS_SRTDISCIPLINE_KEY = "select ins_srtdiscipline_key, ins_srtdiscipline_omschrijving "&_
    "from ins_srtdiscipline "&_
    "where ins_srtdiscipline_module = 'MLD' "&_
    "  and ins_srtdiscipline_verwijder is null "&_
    "order by ins_srtdiscipline_omschrijving asc"
end if
' DisciplineRecord Open Event end
'-------------------------------

  SetVar "FormTitle", sFormTitle

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

'-------------------------------
' Load all fields into variables from recordset or input parameters
'-------------------------------
  if bIsUpdateMode then
    fldINS_DISCIPLINE_KEY = GetValue(rs, "INS_DISCIPLINE_KEY")
    fldINS_DISCIPLINE_MODULE = GetValue(rs, "INS_DISCIPLINE_MODULE")

'-------------------------------
' Load data from recordset when form displayed first time
'-------------------------------
    if sDisciplineRecordErr = "" then
      fldINS_SRTDISCIPLINE_KEY = GetValue(rs, "INS_SRTDISCIPLINE_KEY")
      fldINS_DISCIPLINE_OMSCHRIJVING = GetValue(rs, "INS_DISCIPLINE_OMSCHRIJVING")
      fldPRS_KOSTENSOORT_KEY = GetValue(rs, "PRS_KOSTENSOORT_KEY")
      fldINS_DISCIPLINE_KPNVERPLICHT = GetValue(rs, "INS_DISCIPLINE_KPNVERPLICHT")
      fldINS_DISCIPLINE_EMAIL = GetValue(rs, "INS_DISCIPLINE_EMAIL")
      fldINS_DISCIPLINE_KTOPERCENTAGE = GetValue(rs, "INS_DISCIPLINE_KTOPERCENTAGE")
      fldINS_DISCIPLINE_KTODREMPEL = GetValue(rs, "INS_DISCIPLINE_KTODREMPEL")
    end if
    SetVar "DisciplineRecordInsert", ""
    Parse "DisciplineRecordEdit", False
'-------------------------------
' DisciplineRecord ShowEdit Event begin
' DisciplineRecord ShowEdit Event end
'-------------------------------
  else
    if sDisciplineRecordErr = "" then
      fldMLD_DISC_PARAMS_DIRECTKLAAR= "0"
      fldMLD_DISC_PARAMS_KETEN= "0"
      fldINS_DISCIPLINE_MODULE= "MLD"
      fldMLD_DISC_PARAMS_OFFERTEAUTO= "1"
    end if
    SetVar "DisciplineRecordEdit", ""
    Parse "DisciplineRecordInsert", False
'-------------------------------
' DisciplineRecord ShowInsert Event begin
' DisciplineRecord ShowInsert Event end
'-------------------------------
  end if
  Parse "DisciplineRecordCancel", false

'-------------------------------
' Set default values
'-------------------------------
  fldMLD_DISC_PARAMS_DIRECTKLAAR= "0"
  fldMLD_DISC_PARAMS_KETEN= "0"
  fldMLD_DISC_PARAMS_OFFERTEAUTO= "1"
  if sDisciplineRecordErr = "" then
'-------------------------------
' DisciplineRecord Show Event begin
if fldINS_DISCIPLINE_KEY = "" then
  fldINS_SRTDISCIPLINE_KEY = pINS_SRTDISCIPLINE_KEY
end if
'Laad de records uit MLD_disc_params indien van toepassing
if fldINS_DISCIPLINE_KEY <> "" then
  DiscSql = "SELECT MLD_DISC_PARAMS_FACTUURPCT, "&_
            "  MLD_DISC_PARAMS_FACTUURMARGE, "&_
            "  MLD_DISC_PARAMS_FACTUURGRENS, "&_
            "  MLD_DISC_PARAMS_FACTUURAPPR, "&_
            "  MLD_DISC_PARAMS_FACTMATCHMODE, "&_
            "  MLD_DISC_PARAMS_NOTIFY, "&_
            "  MLD_DISC_PARAMS_BONOTIFY, "&_
            "  MLD_DISC_PARAMS_BENOTIFY, "&_
            "  MLD_DISC_PARAMS_OPDR_KOSTEN, "&_
            "  MLD_DISC_PARAMS_NOTI_DAGEN, "&_
            "  MLD_DISC_PARAMS_DIRECTKLAAR, "&_
            "  MLD_DISC_PARAMS_FRONTENDPRIO, "&_
            "  MLD_DISC_PARAMS_EIGEN_KP, "&_
            "  MLD_DISC_PARAMS_STARTDATUM, "&_
            "  MLD_DISC_PARAMS_BESTELLIMIET, "&_
            "  MLD_DISC_PARAMS_BESTELLIMIET2, "&_
            "  MLD_DISC_PARAMS_BESTELLIMIET3, "&_
            "  MLD_DISC_PARAMS_BESTELLIMIET4, "&_
            "  MLD_DISC_PARAMS_BESTELLIMIET5, "&_
            "  MLD_DISC_PARAMS_OFFERTEAUTO, "&_
            "  MLD_DISC_PARAMS_FENOTES, "&_
            "  MLD_DISC_PARAMS_KETEN, "&_
            "  MLD_DISC_PARAMS_PGB, "& _
            "  MLD_BEHANDELGROEP_KEY, "&_
            "  FAC_ACTIVITEIT_KEY "&_
            "FROM MLD_DISC_PARAMS "&_
            "WHERE MLD_INS_DISCIPLINE_key = " & ToSQL(fldINS_DISCIPLINE_KEY, "Number")
  openrs rsDisc, DiscSql
  if not rsDisc.EOF then
    fldMLD_DISC_PARAMS_FACTUURPCT= getValue(rsDisc,"MLD_DISC_PARAMS_FACTUURPCT")
    fldMLD_DISC_PARAMS_FACTUURMARGE= getValue(rsDisc,"MLD_DISC_PARAMS_FACTUURMARGE")
    fldMLD_DISC_PARAMS_FACTUURGRENS= getValue(rsDisc,"MLD_DISC_PARAMS_FACTUURGRENS")
    fldMLD_DISC_PARAMS_FACTUURAPPR= getValue(rsDisc,"MLD_DISC_PARAMS_FACTUURAPPR")
    fldMLD_DISC_PARAMS_FACTMATCHMODE= getValue(rsDisc,"MLD_DISC_PARAMS_FACTMATCHMODE")
    fldMLD_DISC_PARAMS_NOTIFY= getValue(rsDisc,"MLD_DISC_PARAMS_NOTIFY")
    fldMLD_DISC_PARAMS_BONOTIFY= getValue(rsDisc,"MLD_DISC_PARAMS_BONOTIFY")
    fldMLD_DISC_PARAMS_BENOTIFY= getValue(rsDisc,"MLD_DISC_PARAMS_BENOTIFY")
    fldMLD_DISC_PARAMS_OPDR_KOSTEN= getValue(rsDisc,"MLD_DISC_PARAMS_OPDR_KOSTEN")
    fldMLD_DISC_PARAMS_NOTI_DAGEN= getValue(rsDisc,"MLD_DISC_PARAMS_NOTI_DAGEN")
    fldMLD_DISC_PARAMS_DIRECTKLAAR= getValue(rsDisc,"MLD_DISC_PARAMS_DIRECTKLAAR")
    fldMLD_DISC_PARAMS_FRONTENDPRIO= getValue(rsDisc,"MLD_DISC_PARAMS_FRONTENDPRIO")
    fldMLD_DISC_PARAMS_EIGEN_KP= getValue(rsDisc,"MLD_DISC_PARAMS_EIGEN_KP")
    fldMLD_DISC_PARAMS_STARTDATUM= getValue(rsDisc,"MLD_DISC_PARAMS_STARTDATUM")
    fldMLD_DISC_PARAMS_BESTELLIMIET= getValue(rsDisc,"MLD_DISC_PARAMS_BESTELLIMIET")
    fldMLD_DISC_PARAMS_BESTELLIMIET2= getValue(rsDisc,"MLD_DISC_PARAMS_BESTELLIMIET2")
    fldMLD_DISC_PARAMS_BESTELLIMIET3= getValue(rsDisc,"MLD_DISC_PARAMS_BESTELLIMIET3")
    fldMLD_DISC_PARAMS_BESTELLIMIET4= getValue(rsDisc,"MLD_DISC_PARAMS_BESTELLIMIET4")
    fldMLD_DISC_PARAMS_BESTELLIMIET5= getValue(rsDisc,"MLD_DISC_PARAMS_BESTELLIMIET5")
    fldMLD_DISC_PARAMS_OFFERTEAUTO= getValue(rsDisc,"MLD_DISC_PARAMS_OFFERTEAUTO")
    fldMLD_DISC_PARAMS_FENOTES= getValue(rsDisc,"MLD_DISC_PARAMS_FENOTES")
    fldMLD_DISC_PARAMS_KETEN= getValue(rsDisc,"MLD_DISC_PARAMS_KETEN")
    fldMLD_DISC_PARAMS_PGB= getValue(rsDisc,"MLD_DISC_PARAMS_PGB")
    fldMLD_BEHANDELGROEP_KEY= getValue(rsDisc,"MLD_BEHANDELGROEP_KEY")
    fldFAC_ACTIVITEIT_KEY = getValue(rsDisc,"FAC_ACTIVITEIT_KEY")
  end if
  rsDisc.Close
end if
' Voor selectie FAC_ACTIVITEIT_KEY
myINS_DISCIPLINE_KEY=fldINS_DISCIPLINE_KEY
if (myINS_DISCIPLINE_KEY="") Then myINS_DISCIPLINE_KEY=-1
' DisciplineRecord Show Event end
'-------------------------------
  end if

'-------------------------------
' Show form field
'-------------------------------
      SetVar "INS_DISCIPLINE_KEY", ToHTML(fldINS_DISCIPLINE_KEY)
      SetVar "DisciplineRecordLBINS_SRTDISCIPLINE_KEY", ""
      openrs rsINS_SRTDISCIPLINE_KEY, ""&sqlINS_SRTDISCIPLINE_KEY&""
      while not rsINS_SRTDISCIPLINE_KEY.EOF
        SetVar "ID", GetValue(rsINS_SRTDISCIPLINE_KEY, 0) : SetVar "Value", GetValue(rsINS_SRTDISCIPLINE_KEY, 1)
        if cstr(GetValue(rsINS_SRTDISCIPLINE_KEY, 0)) = cstr(fldINS_SRTDISCIPLINE_KEY) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
        Parse "DisciplineRecordLBINS_SRTDISCIPLINE_KEY", True
        rsINS_SRTDISCIPLINE_KEY.MoveNext
      wend
      set rsINS_SRTDISCIPLINE_KEY = nothing
    
      SetVar "INS_DISCIPLINE_OMSCHRIJVING", ToHTML(fldINS_DISCIPLINE_OMSCHRIJVING)
      SetVar "DisciplineRecordLBMLD_BEHANDELGROEP_KEY", ""
      SetVar "Selected", ""
      SetVar "ID", ""
      SetVar "Value", sMLD_BEHANDELGROEP_KEYDisplayValue
      Parse "DisciplineRecordLBMLD_BEHANDELGROEP_KEY", True
      openrs rsMLD_BEHANDELGROEP_KEY, "select MLD_BEHANDELGROEP_KEY, MLD_BEHANDELGROEP_NAAM from MLD_BEHANDELGROEP order by 2"
      while not rsMLD_BEHANDELGROEP_KEY.EOF
        SetVar "ID", GetValue(rsMLD_BEHANDELGROEP_KEY, 0) : SetVar "Value", GetValue(rsMLD_BEHANDELGROEP_KEY, 1)
        if cstr(GetValue(rsMLD_BEHANDELGROEP_KEY, 0)) = cstr(fldMLD_BEHANDELGROEP_KEY) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
        Parse "DisciplineRecordLBMLD_BEHANDELGROEP_KEY", True
        rsMLD_BEHANDELGROEP_KEY.MoveNext
      wend
      set rsMLD_BEHANDELGROEP_KEY = nothing
    
      SetVar "DisciplineRecordLBPRS_KOSTENSOORT_KEY", ""
      SetVar "Selected", ""
      SetVar "ID", ""
      SetVar "Value", sPRS_KOSTENSOORT_KEYDisplayValue
      Parse "DisciplineRecordLBPRS_KOSTENSOORT_KEY", True
      openrs rsPRS_KOSTENSOORT_KEY, "select PRS_KOSTENSOORT_KEY, PRS_KOSTENSOORT_OMS from PRS_KOSTENSOORT order by 2"
      while not rsPRS_KOSTENSOORT_KEY.EOF
        SetVar "ID", GetValue(rsPRS_KOSTENSOORT_KEY, 0) : SetVar "Value", GetValue(rsPRS_KOSTENSOORT_KEY, 1)
        if cstr(GetValue(rsPRS_KOSTENSOORT_KEY, 0)) = cstr(fldPRS_KOSTENSOORT_KEY) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
        Parse "DisciplineRecordLBPRS_KOSTENSOORT_KEY", True
        rsPRS_KOSTENSOORT_KEY.MoveNext
      wend
      set rsPRS_KOSTENSOORT_KEY = nothing
    
  if (LCase(fldINS_DISCIPLINE_KPNVERPLICHT) = LCase("1")) then
    SetVar "INS_DISCIPLINE_KPNVERPLICHT_CHECKED", "CHECKED"
  else
    SetVar "INS_DISCIPLINE_KPNVERPLICHT_CHECKED", ""
  end if

      SetVar "MLD_DISC_PARAMS_BESTELLIMIET", ToHTML(fldMLD_DISC_PARAMS_BESTELLIMIET)
      SetVar "MLD_DISC_PARAMS_BESTELLIMIET2", ToHTML(fldMLD_DISC_PARAMS_BESTELLIMIET2)
      SetVar "MLD_DISC_PARAMS_BESTELLIMIET3", ToHTML(fldMLD_DISC_PARAMS_BESTELLIMIET3)
      SetVar "MLD_DISC_PARAMS_BESTELLIMIET4", ToHTML(fldMLD_DISC_PARAMS_BESTELLIMIET4)
      SetVar "MLD_DISC_PARAMS_BESTELLIMIET5", ToHTML(fldMLD_DISC_PARAMS_BESTELLIMIET5)
      SetVar "DisciplineRecordLBMLD_DISC_PARAMS_PGB", ""
      LOV = Split(""&FCLTLCL("0;Nee;1;PGB;2;AGB;3;Beide")&"", ";")
      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(fldMLD_DISC_PARAMS_PGB) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "DisciplineRecordLBMLD_DISC_PARAMS_PGB", True
        next
      end if
    
  if (LCase(fldMLD_DISC_PARAMS_STARTDATUM) = LCase("1")) then
    SetVar "MLD_DISC_PARAMS_STARTDATUM_CHECKED", "CHECKED"
  else
    SetVar "MLD_DISC_PARAMS_STARTDATUM_CHECKED", ""
  end if

      SetVar "DisciplineRecordLBMLD_DISC_PARAMS_DIRECTKLAAR", ""
      LOV = Split(""&FCLTLCL("0;Nee;1;Ja;2;Initieel ook eerst naar de front office")&"", ";")
      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(fldMLD_DISC_PARAMS_DIRECTKLAAR) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "DisciplineRecordLBMLD_DISC_PARAMS_DIRECTKLAAR", True
        next
      end if
    
  if (LCase(fldMLD_DISC_PARAMS_KETEN) = LCase("1")) then
    SetVar "MLD_DISC_PARAMS_KETEN_CHECKED", "CHECKED"
  else
    SetVar "MLD_DISC_PARAMS_KETEN_CHECKED", ""
  end if

  if (LCase(fldMLD_DISC_PARAMS_FRONTENDPRIO) = LCase("1")) then
    SetVar "MLD_DISC_PARAMS_FRONTENDPRIO_CHECKED", "CHECKED"
  else
    SetVar "MLD_DISC_PARAMS_FRONTENDPRIO_CHECKED", ""
  end if

  if (LCase(fldMLD_DISC_PARAMS_EIGEN_KP) = LCase("1")) then
    SetVar "MLD_DISC_PARAMS_EIGEN_KP_CHECKED", "CHECKED"
  else
    SetVar "MLD_DISC_PARAMS_EIGEN_KP_CHECKED", ""
  end if

      SetVar "INS_DISCIPLINE_MODULE", ToHTML(fldINS_DISCIPLINE_MODULE)
      SetVar "MLD_DISC_PARAMS_FACTUURPCT", ToHTML(fldMLD_DISC_PARAMS_FACTUURPCT)
      SetVar "MLD_DISC_PARAMS_FACTUURMARGE", ToHTML(fldMLD_DISC_PARAMS_FACTUURMARGE)
      SetVar "DisciplineRecordLBMLD_DISC_PARAMS_FACTMATCHMODE", ""
      LOV = Split(""&FCLTLCL("2;2-weg;3;3-weg")&"", ";")
      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(fldMLD_DISC_PARAMS_FACTMATCHMODE) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "DisciplineRecordLBMLD_DISC_PARAMS_FACTMATCHMODE", True
        next
      end if
    
  if (LCase(fldMLD_DISC_PARAMS_FACTUURAPPR) = LCase("1")) then
    SetVar "MLD_DISC_PARAMS_FACTUURAPPR_CHECKED", "CHECKED"
  else
    SetVar "MLD_DISC_PARAMS_FACTUURAPPR_CHECKED", ""
  end if

      SetVar "MLD_DISC_PARAMS_FACTUURGRENS", ToHTML(fldMLD_DISC_PARAMS_FACTUURGRENS)
      SetVar "DisciplineRecordLBMLD_DISC_PARAMS_BONOTIFY", ""
      LOV = Split(""&FCLTLCL("0;Niet;1;BOF;2;BO3;3;BO3 en dan BOF")&"", ";")
      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(fldMLD_DISC_PARAMS_BONOTIFY) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "DisciplineRecordLBMLD_DISC_PARAMS_BONOTIFY", True
        next
      end if
    
  if (LCase(fldMLD_DISC_PARAMS_BENOTIFY) = LCase("1")) then
    SetVar "MLD_DISC_PARAMS_BENOTIFY_CHECKED", "CHECKED"
  else
    SetVar "MLD_DISC_PARAMS_BENOTIFY_CHECKED", ""
  end if

      SetVar "DisciplineRecordLBMLD_DISC_PARAMS_NOTIFY", ""
      LOV = Split(""&FCLTLCL("0;Nooit;1;Altijd;2;Afhankelijk van melding")&"", ";")
      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(fldMLD_DISC_PARAMS_NOTIFY) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "DisciplineRecordLBMLD_DISC_PARAMS_NOTIFY", True
        next
      end if
    
      SetVar "MLD_DISC_PARAMS_NOTI_DAGEN", ToHTML(fldMLD_DISC_PARAMS_NOTI_DAGEN)
      SetVar "DisciplineRecordLBMLD_DISC_PARAMS_OPDR_KOSTEN", ""
      LOV = Split(""&FCLTLCL("0;Niet verplicht;7;Aanmaak;6;Afmelden;4;Afronden")&"", ";")
      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(fldMLD_DISC_PARAMS_OPDR_KOSTEN) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "DisciplineRecordLBMLD_DISC_PARAMS_OPDR_KOSTEN", True
        next
      end if
    
      SetVar "DisciplineRecordLBFAC_ACTIVITEIT_KEY", ""
      SetVar "Selected", ""
      SetVar "ID", ""
      SetVar "Value", sFAC_ACTIVITEIT_KEYDisplayValue
      Parse "DisciplineRecordLBFAC_ACTIVITEIT_KEY", True
      openrs rsFAC_ACTIVITEIT_KEY, "SELECT opdr.fac_activiteit_key, mld_opdr_omschrijving   FROM MLD_OPDR opdr, MLD_MELDING mld, mld_stdmelding sm  WHERE opdr.fac_activiteit_key is not null    AND opdr.mld_melding_key = mld.mld_melding_key    AND sm.mld_stdmelding_key = mld.mld_stdmelding_key    AND opdr.mld_melding_key = mld.mld_melding_key    AND sm.MLD_INS_DISCIPLINE_KEY = "&ToSql(myINS_DISCIPLINE_KEY,"number")&""
      while not rsFAC_ACTIVITEIT_KEY.EOF
        SetVar "ID", GetValue(rsFAC_ACTIVITEIT_KEY, 0) : SetVar "Value", GetValue(rsFAC_ACTIVITEIT_KEY, 1)
        if cstr(GetValue(rsFAC_ACTIVITEIT_KEY, 0)) = cstr(fldFAC_ACTIVITEIT_KEY) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
        Parse "DisciplineRecordLBFAC_ACTIVITEIT_KEY", True
        rsFAC_ACTIVITEIT_KEY.MoveNext
      wend
      set rsFAC_ACTIVITEIT_KEY = nothing
    
      SetVar "INS_DISCIPLINE_EMAIL", ToHTML(fldINS_DISCIPLINE_EMAIL)
      SetVar "INS_DISCIPLINE_KTOPERCENTAGE", ToHTML(fldINS_DISCIPLINE_KTOPERCENTAGE)
      SetVar "INS_DISCIPLINE_KTODREMPEL", ToHTML(fldINS_DISCIPLINE_KTODREMPEL)
  if (LCase(fldMLD_DISC_PARAMS_OFFERTEAUTO) = LCase("1")) then
    SetVar "MLD_DISC_PARAMS_OFFERTEAUTO_CHECKED", "CHECKED"
  else
    SetVar "MLD_DISC_PARAMS_OFFERTEAUTO_CHECKED", ""
  end if

      SetVar "DisciplineRecordLBMLD_DISC_PARAMS_FENOTES", ""
      LOV = Split(""&FCLTLCL("0;default niet zichtbaar voor FE;1;default wel zichtbaar voor FE;2;per notitie, default niet zichtbaar voor FE;3;per notitie, default wel zichtbaar voor FE")&"", ";")
      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(fldMLD_DISC_PARAMS_FENOTES) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "DisciplineRecordLBMLD_DISC_PARAMS_FENOTES", True
        next
      end if
    
  Parse "FormDisciplineRecord", False

'-------------------------------
' DisciplineRecord Close Event begin
' DisciplineRecord Close Event end
'-------------------------------

Set rs = Nothing

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