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

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


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


'===============================
' mld_srtdisciplinerecord2 PageSecurity begin
' mld_srtdisciplinerecord2 PageSecurity end
'===============================

'===============================
' mld_srtdisciplinerecord2 Open Event begin
' mld_srtdisciplinerecord2 Open Event end
'===============================

'===============================
' mld_srtdisciplinerecord2 OpenAnyPage Event begin
' mld_srtdisciplinerecord2 OpenAnyPage Event end
'===============================

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

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

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

'===============================
' Display page
'-------------------------------
' Load HTML template for this page
'-------------------------------
LoadTemplate sAppPath & sTemplateFileName, "main"
'-------------------------------
' Load HTML template of Header and Footer
'-------------------------------
'-------------------------------
SetVar "FileName", sFileName


'-------------------------------
' Step through each form
'-------------------------------
SrtDisciplineRecord_Show
TypeOpdrRecord_Show
'-------------------------------
' Process page templates
'-------------------------------
Parse "main", False
'-------------------------------
' Output the page to the browser
'-------------------------------
Response.write PrintVar("main")

' mld_srtdisciplinerecord2 Show end

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

' mld_srtdisciplinerecord2 Close Event begin
' mld_srtdisciplinerecord2 Close Event end

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

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

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

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

'-------------------------------
' Load all form fields into variables
'-------------------------------
  fldINS_SRTDISCIPLINE_MODULE = GetParam("INS_SRTDISCIPLINE_MODULE")
  fldINS_SRTDISCIPLINE_ALG = GetParam("INS_SRTDISCIPLINE_ALG")

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

'-------------------------------
' SrtDisciplineRecord BeforeExecute Event begin
' SrtDisciplineRecord BeforeExecute Event end
'-------------------------------

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

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

'-------------------------------
' Load primary key and form parameters
'-------------------------------
  if sSrtDisciplineRecordErr = "" then
    pINS_SRTDISCIPLINE_KEY = GetParam("INS_SRTDISCIPLINE_KEY")
    SetVar "SrtDisciplineRecordError", ""
  else
    fldINS_SRTDISCIPLINE_MODULE = GetParam("INS_SRTDISCIPLINE_MODULE")
    fldINS_SRTDISCIPLINE_ALG = GetParam("INS_SRTDISCIPLINE_ALG")
    pINS_SRTDISCIPLINE_KEY = GetParam("PK_INS_SRTDISCIPLINE_KEY")
    SetVar "sSrtDisciplineRecordErr", sSrtDisciplineRecordErr
    SetVar "FormTitle", sFormTitle
    Parse "SrtDisciplineRecordError", False
  end if
'-------------------------------

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

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

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

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

  SetVar "FormTitle", sFormTitle

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

'-------------------------------
' Load all fields into variables from recordset or input parameters
'-------------------------------
  if bIsUpdateMode then
    fldINS_SRTDISCIPLINE_BES = GetValue(rs, "INS_SRTDISCIPLINE_BES")
    fldINS_SRTDISCIPLINE_INS = GetValue(rs, "INS_SRTDISCIPLINE_INS")
    fldINS_SRTDISCIPLINE_KEY = GetValue(rs, "INS_SRTDISCIPLINE_KEY")
    fldINS_SRTDISCIPLINE_MODULE = GetValue(rs, "INS_SRTDISCIPLINE_MODULE")
    fldINS_SRTDISCIPLINE_OMSCHRIJVING = GetValue(rs, "INS_SRTDISCIPLINE_OMSCHRIJVING")
    fldINS_SRTDISCIPLINE_PREFIX = GetValue(rs, "INS_SRTDISCIPLINE_PREFIX")

'-------------------------------
' Load data from recordset when form displayed first time
'-------------------------------
    if sSrtDisciplineRecordErr = "" then
      fldINS_SRTDISCIPLINE_ALG = GetValue(rs, "INS_SRTDISCIPLINE_ALG")
    end if
    SetVar "SrtDisciplineRecordDelete", ""
    SetVar "SrtDisciplineRecordUpdate", ""
    SetVar "SrtDisciplineRecordInsert", ""
'-------------------------------
' SrtDisciplineRecord ShowEdit Event begin
' SrtDisciplineRecord ShowEdit Event end
'-------------------------------
  else
    if sSrtDisciplineRecordErr = "" then
      fldINS_SRTDISCIPLINE_MODULE= "MLD"
    end if
    SetVar "SrtDisciplineRecordEdit", ""
    SetVar "SrtDisciplineRecordInsert", ""
'-------------------------------
' SrtDisciplineRecord ShowInsert Event begin
' SrtDisciplineRecord ShowInsert Event end
'-------------------------------
  end if
  Parse "SrtDisciplineRecordCancel", false
  if sSrtDisciplineRecordErr = "" then
'-------------------------------
' SrtDisciplineRecord Show Event begin
if fldINS_SRTDISCIPLINE_INS = "0" then
  fldINS_SRTDISCIPLINE_INS = "Nee"
elseif fldINS_SRTDISCIPLINE_INS = "1" then
  fldINS_SRTDISCIPLINE_INS = "Ja"
end if

if fldINS_SRTDISCIPLINE_BES = "0" then
  fldINS_SRTDISCIPLINE_BES = "Nee"
elseif fldINS_SRTDISCIPLINE_BES = "1" then
  fldINS_SRTDISCIPLINE_BES = "Ja"
end if
' SrtDisciplineRecord Show Event end
'-------------------------------
  end if

'-------------------------------
' Show form field
'-------------------------------
      SetVar "INS_SRTDISCIPLINE_KEY", ToHTML(fldINS_SRTDISCIPLINE_KEY)
      SetVar "INS_SRTDISCIPLINE_MODULE", ToHTML(fldINS_SRTDISCIPLINE_MODULE)
      SetVar "INS_SRTDISCIPLINE_OMSCHRIJVING", ToHTML(fldINS_SRTDISCIPLINE_OMSCHRIJVING)
      SetVar "INS_SRTDISCIPLINE_PREFIX", ToHTML(fldINS_SRTDISCIPLINE_PREFIX)
      SetVar "SrtDisciplineRecordLBINS_SRTDISCIPLINE_ALG", ""
      LOV = Split(""&FCLTLCL("0;Niet tonen;7;Locatie;5;Gebouw;3;Verdieping;1;Ruimte")&"", ";")
      if (ubound(LOV) mod 2) = 1 then
        for i = 0 to ubound(LOV) step 2
          SetVar "ID", LOV(i) : SetVar "Value", LOV(i+1)
          if cstr(LOV(i)) = cstr(fldINS_SRTDISCIPLINE_ALG) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "SrtDisciplineRecordLBINS_SRTDISCIPLINE_ALG", True
        next
      end if
    
      SetVar "INS_SRTDISCIPLINE_INS", ToHTML(fldINS_SRTDISCIPLINE_INS)
      SetVar "INS_SRTDISCIPLINE_BES", ToHTML(fldINS_SRTDISCIPLINE_BES)
  Parse "FormSrtDisciplineRecord", False

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

Set rs = Nothing

'-------------------------------
' SrtDisciplineRecord Show end
'-------------------------------
End Sub
'===============================
'===============================
' Action of the Record Form
'-------------------------------
Sub TypeOpdrRecordAction(sAction)
'-------------------------------
' Initialize variables  
'-------------------------------
  Dim bExecSQL: bExecSQL = true
  Dim sActionFileName : sActionFileName = ""
  Dim sParams : sParams = "?"
  Dim sWhere : sWhere = "" 
  Dim bErr : bErr = False
  Dim pPKMLD_TYPEOPDR_SRTDISCIPLINE_KEY : pPKMLD_TYPEOPDR_SRTDISCIPLINE_KEY = ""
'-------------------------------

'-------------------------------
' TypeOpdrRecord Action begin
'-------------------------------
  sActionFileName = "mld_srtdisciplinerecord.asp"
  sParams = sParams & "INS_SRTDISCIPLINE_KEY=" & ToURL(GetParam("Trn_INS_SRTDISCIPLINE_KEY"))

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

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

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


'-------------------------------
' Load all form fields into variables
'-------------------------------

'-------------------------------
' Validate fields
'-------------------------------
  if sAction = "insert" or sAction = "update" then
'-------------------------------
' TypeOpdrRecord Check Event begin
' TypeOpdrRecord Check Event end
'-------------------------------
    If len(sTypeOpdrRecordErr) > 0 then
      exit sub
    end if
  end if
'-------------------------------


'-------------------------------
' Create SQL statement
'-------------------------------
  select case sAction
    case "delete"
'-------------------------------
' TypeOpdrRecord Delete Event begin
' TypeOpdrRecord Delete Event end
'-------------------------------
      sSQL = "delete from MLD_TYPEOPDR_SRTDISCIPLINE where " & sWhere
  end select
'-------------------------------
'-------------------------------
' TypeOpdrRecord BeforeExecute Event begin
' TypeOpdrRecord BeforeExecute Event end
'-------------------------------

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

'===============================
' Display Record Form
'-------------------------------
Sub TypeOpdrRecord_Show()
'-------------------------------
' TypeOpdrRecord Show begin
'-------------------------------
  Dim sWhere : sWhere = ""
  Dim sFormTitle: sFormTitle = "Toevoegen opdrachttype"
  Dim bPK : bPK = True

'-------------------------------
' Load primary key and form parameters
'-------------------------------
  if sTypeOpdrRecordErr = "" then
    fldINS_SRTDISCIPLINE_KEY = GetParam("INS_SRTDISCIPLINE_KEY")
    SetVar "Trn_INS_SRTDISCIPLINE_KEY", GetParam("INS_SRTDISCIPLINE_KEY")
    pMLD_TYPEOPDR_SRTDISCIPLINE_KEY = GetParam("MLD_TYPEOPDR_SRTDISCIPLINE_KEY")
    SetVar "TypeOpdrRecordError", ""
  else
    fldMLD_TYPEOPDR_SRTDISCIPLINE_KEY = GetParam("MLD_TYPEOPDR_SRTDISCIPLINE_KEY")
    SetVar "Rqd_INS_SRTDISCIPLINE_KEY", GetParam("Rqd_INS_SRTDISCIPLINE_KEY")
    SetVar "Trn_INS_SRTDISCIPLINE_KEY", GetParam("Trn_INS_SRTDISCIPLINE_KEY")
    pMLD_TYPEOPDR_SRTDISCIPLINE_KEY = GetParam("PK_MLD_TYPEOPDR_SRTDISCIPLINE_KEY")
    SetVar "sTypeOpdrRecordErr", sTypeOpdrRecordErr
    SetVar "FormTitle", sFormTitle
    Parse "TypeOpdrRecordError", False
  end if
'-------------------------------

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

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

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

  if IsEmpty(pMLD_TYPEOPDR_SRTDISCIPLINE_KEY) then bPK = False
  
  sWhere = sWhere & "MLD_TYPEOPDR_SRTDISCIPLINE_KEY=" & ToSQL(pMLD_TYPEOPDR_SRTDISCIPLINE_KEY, "Number")
  SetVar "PK_MLD_TYPEOPDR_SRTDISCIPLINE_KEY", pMLD_TYPEOPDR_SRTDISCIPLINE_KEY
'-------------------------------
'-------------------------------
' TypeOpdrRecord Open Event begin
' TypeOpdrRecord Open Event end
'-------------------------------

  SetVar "FormTitle", sFormTitle

'-------------------------------
' Build SQL statement and open recordset
'-------------------------------
  sSQL = "select * from MLD_TYPEOPDR_SRTDISCIPLINE where " & sWhere
  openrs rs, sSQL
  bIsUpdateMode = (bPK and not(sAction = "insert" and sForm = "TypeOpdrRecord") 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")
    fldMLD_TYPEOPDR_KEY = GetValue(rs, "MLD_TYPEOPDR_KEY")
    fldMLD_TYPEOPDR_SRTDISCIPLINE_KEY = GetValue(rs, "MLD_TYPEOPDR_SRTDISCIPLINE_KEY")
    SetVar "TypeOpdrRecordUpdate", ""
    SetVar "TypeOpdrRecordInsert", ""
    Parse "TypeOpdrRecordEdit", False
'-------------------------------
' TypeOpdrRecord ShowEdit Event begin
' TypeOpdrRecord ShowEdit Event end
'-------------------------------
  else
    if sTypeOpdrRecordErr = "" then
      fldINS_DISCIPLINE_KEY= "Alles"
    end if
    SetVar "TypeOpdrRecordEdit", ""
    SetVar "TypeOpdrRecordInsert", ""
'-------------------------------
' TypeOpdrRecord ShowInsert Event begin
' TypeOpdrRecord ShowInsert Event end
'-------------------------------
  end if
  Parse "TypeOpdrRecordCancel", false

'-------------------------------
' Set lookup fields
'-------------------------------
  fldMLD_TYPEOPDR_KEY = DLookUp("MLD_TYPEOPDR", "MLD_TYPEOPDR_OMSCHRIJVING", "MLD_TYPEOPDR_KEY=" & ToSQL(fldMLD_TYPEOPDR_KEY, "Number"))
  fldINS_DISCIPLINE_KEY = DLookUp("INS_TAB_DISCIPLINE", "INS_DISCIPLINE_OMSCHRIJVING", "INS_DISCIPLINE_KEY=" & ToSQL(fldINS_DISCIPLINE_KEY, "Number"))
'-------------------------------
' TypeOpdrRecord Show Event begin
' TypeOpdrRecord Show Event end
'-------------------------------

'-------------------------------
' Show form field
'-------------------------------
      SetVar "MLD_TYPEOPDR_SRTDISCIPLINE_KEY", ToHTML(fldMLD_TYPEOPDR_SRTDISCIPLINE_KEY)
      SetVar "MLD_TYPEOPDR_KEY", ToHTML(fldMLD_TYPEOPDR_KEY)
      SetVar "INS_DISCIPLINE_KEY", ToHTML(fldINS_DISCIPLINE_KEY)
  Parse "FormTypeOpdrRecord", False

'-------------------------------
' TypeOpdrRecord Close Event begin
' TypeOpdrRecord Close Event end
'-------------------------------

Set rs = Nothing

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