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

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


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


'===============================
' mld_dienstniveaurecord2 PageSecurity begin
' mld_dienstniveaurecord2 PageSecurity end
'===============================

'===============================
' mld_dienstniveaurecord2 Open Event begin
' mld_dienstniveaurecord2 Open Event end
'===============================

'===============================
' mld_dienstniveaurecord2 OpenAnyPage Event begin
' mld_dienstniveaurecord2 OpenAnyPage Event end
'===============================

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

' mld_dienstniveaurecord2 Show begin
'===============================
' Perform the form's action
'-------------------------------
' Initialize error variables
'-------------------------------
sDienstniveauRecordErr = ""
sdienstpakketRecordErr = ""

'-------------------------------
' Select the FormAction
'-------------------------------
Select Case sForm
  Case "DienstniveauRecord"
    DienstniveauRecordAction(sAction)
  Case "dienstpakketRecord"
    dienstpakketRecordAction(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
'-------------------------------
DienstniveauRecord_Show
dienstpakketRecord_Show
'-------------------------------
' Process page templates
'-------------------------------
Parse "main", False
'-------------------------------
' Output the page to the browser
'-------------------------------
Response.write PrintVar("main")

' mld_dienstniveaurecord2 Show end

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

' mld_dienstniveaurecord2 Close Event begin
' mld_dienstniveaurecord2 Close Event end

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

'-------------------------------
' DienstniveauRecord Action begin
'-------------------------------
  sActionFileName = "mld_dienstniveaugrid.asp"

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

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

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

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

'-------------------------------
' DienstniveauRecord BeforeExecute Event begin
' DienstniveauRecord BeforeExecute Event end
'-------------------------------

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

'===============================
' Display Record Form
'-------------------------------
Sub DienstniveauRecord_Show()
'-------------------------------
' DienstniveauRecord Show begin
'-------------------------------
  Dim sWhere : sWhere = ""
  Dim sFormTitle: sFormTitle = "Details dienstniveau"
  Dim bPK : bPK = True

'-------------------------------
' Load primary key and form parameters
'-------------------------------
  if sDienstniveauRecordErr = "" then
    pMLD_DIENSTNIVEAU_KEY = GetParam("MLD_DIENSTNIVEAU_KEY")
    SetVar "DienstniveauRecordError", ""
  else
    pMLD_DIENSTNIVEAU_KEY = GetParam("PK_MLD_DIENSTNIVEAU_KEY")
    SetVar "sDienstniveauRecordErr", sDienstniveauRecordErr
    SetVar "FormTitle", sFormTitle
    Parse "DienstniveauRecordError", False
  end if
'-------------------------------

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

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

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

  if IsEmpty(pMLD_DIENSTNIVEAU_KEY) then bPK = False
  
  sWhere = sWhere & "MLD_DIENSTNIVEAU_KEY=" & ToSQL(pMLD_DIENSTNIVEAU_KEY, "Number")
  SetVar "PK_MLD_DIENSTNIVEAU_KEY", pMLD_DIENSTNIVEAU_KEY
'-------------------------------
'-------------------------------
' DienstniveauRecord Open Event begin
' DienstniveauRecord Open Event end
'-------------------------------

  SetVar "FormTitle", sFormTitle

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

'-------------------------------
' Load all fields into variables from recordset or input parameters
'-------------------------------
  if bIsUpdateMode then
    fldMLD_DIENSTNIVEAU_KEY = GetValue(rs, "MLD_DIENSTNIVEAU_KEY")
    fldMLD_DIENSTNIVEAU_OMSCHR = GetValue(rs, "MLD_DIENSTNIVEAU_OMSCHR")
    SetVar "DienstniveauRecordDelete", ""
    SetVar "DienstniveauRecordUpdate", ""
    SetVar "DienstniveauRecordInsert", ""
'-------------------------------
' DienstniveauRecord ShowEdit Event begin
' DienstniveauRecord ShowEdit Event end
'-------------------------------
  else
    SetVar "DienstniveauRecordEdit", ""
    SetVar "DienstniveauRecordInsert", ""
'-------------------------------
' DienstniveauRecord ShowInsert Event begin
' DienstniveauRecord ShowInsert Event end
'-------------------------------
  end if
  Parse "DienstniveauRecordCancel", false
'-------------------------------
' DienstniveauRecord Show Event begin
' DienstniveauRecord Show Event end
'-------------------------------

'-------------------------------
' Show form field
'-------------------------------
      SetVar "MLD_DIENSTNIVEAU_KEY", ToHTML(fldMLD_DIENSTNIVEAU_KEY)
      SetVar "MLD_DIENSTNIVEAU_OMSCHR", ToHTML(fldMLD_DIENSTNIVEAU_OMSCHR)
  Parse "FormDienstniveauRecord", False

'-------------------------------
' DienstniveauRecord Close Event begin
' DienstniveauRecord Close Event end
'-------------------------------

Set rs = Nothing

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

'-------------------------------
' dienstpakketRecord Action begin
'-------------------------------
  sActionFileName = "mld_dienstniveaurecord.asp"
  sParams = sParams & "MLD_DIENSTNIVEAU_KEY=" & ToURL(GetParam("Trn_MLD_DIENSTNIVEAU_KEY"))

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

'-------------------------------
' dienstpakketRecord BeforeCancel Event begin
' dienstpakketRecord 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_DIENSTPAKKET_KEY = GetParam("PK_MLD_DIENSTPAKKET_KEY")
    if IsEmpty(pPKMLD_DIENSTPAKKET_KEY) then exit sub
    sWhere = "MLD_DIENSTPAKKET_KEY=" & ToSQL(pPKMLD_DIENSTPAKKET_KEY, "Number")
  end if
'-------------------------------


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

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


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

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

'===============================
' Display Record Form
'-------------------------------
Sub dienstpakketRecord_Show()
'-------------------------------
' dienstpakketRecord Show begin
'-------------------------------
  Dim sWhere : sWhere = ""
  Dim sFormTitle: sFormTitle = "Toevoegen dienstpakket"
  Dim bPK : bPK = True

'-------------------------------
' Load primary key and form parameters
'-------------------------------
  if sdienstpakketRecordErr = "" then
    fldMLD_DIENSTNIVEAU_KEY = GetParam("MLD_DIENSTNIVEAU_KEY")
    SetVar "Trn_MLD_DIENSTNIVEAU_KEY", GetParam("MLD_DIENSTNIVEAU_KEY")
    pMLD_DIENSTPAKKET_KEY = GetParam("MLD_DIENSTPAKKET_KEY")
    SetVar "dienstpakketRecordError", ""
  else
    fldMLD_DIENSTPAKKET_KEY = GetParam("MLD_DIENSTPAKKET_KEY")
    SetVar "Rqd_MLD_DIENSTNIVEAU_KEY", GetParam("Rqd_MLD_DIENSTNIVEAU_KEY")
    fldMLD_DIENSTNIVEAU_KEY = GetParam("Trn_MLD_DIENSTNIVEAU_KEY")
    SetVar "Trn_MLD_DIENSTNIVEAU_KEY", GetParam("Trn_MLD_DIENSTNIVEAU_KEY")
    pMLD_DIENSTPAKKET_KEY = GetParam("PK_MLD_DIENSTPAKKET_KEY")
    SetVar "sdienstpakketRecordErr", sdienstpakketRecordErr
    SetVar "FormTitle", sFormTitle
    Parse "dienstpakketRecordError", False
  end if
'-------------------------------

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

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

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

  if IsEmpty(pMLD_DIENSTPAKKET_KEY) then bPK = False
  
  sWhere = sWhere & "MLD_DIENSTPAKKET_KEY=" & ToSQL(pMLD_DIENSTPAKKET_KEY, "Number")
  SetVar "PK_MLD_DIENSTPAKKET_KEY", pMLD_DIENSTPAKKET_KEY
'-------------------------------
'-------------------------------
' dienstpakketRecord Open Event begin
' dienstpakketRecord Open Event end
'-------------------------------

  SetVar "FormTitle", sFormTitle

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

'-------------------------------
' Load all fields into variables from recordset or input parameters
'-------------------------------
  if bIsUpdateMode then
    fldMLD_DIENSTNIVEAU_KEY = GetValue(rs, "MLD_DIENSTNIVEAU_KEY")
    fldMLD_DIENSTPAKKET_KEY = GetValue(rs, "MLD_DIENSTPAKKET_KEY")
    fldMLD_STDMELDING_KEY = GetValue(rs, "MLD_STDMELDING_KEY")
    SetVar "dienstpakketRecordUpdate", ""
    SetVar "dienstpakketRecordInsert", ""
    Parse "dienstpakketRecordEdit", False
'-------------------------------
' dienstpakketRecord ShowEdit Event begin
' dienstpakketRecord ShowEdit Event end
'-------------------------------
  else
    if sdienstpakketRecordErr = "" then
      fldMLD_DIENSTNIVEAU_KEY = ToHTML(GetParam("MLD_DIENSTNIVEAU_KEY"))
      fldMLD_STDMELDING_KEY= "Alles"
    end if
    SetVar "dienstpakketRecordEdit", ""
    SetVar "dienstpakketRecordInsert", ""
'-------------------------------
' dienstpakketRecord ShowInsert Event begin
' dienstpakketRecord ShowInsert Event end
'-------------------------------
  end if
  Parse "dienstpakketRecordCancel", false

'-------------------------------
' Set lookup fields
'-------------------------------
  fldMLD_DIENSTNIVEAU_KEY = DLookUp("MLD_DIENSTNIVEAU", "MLD_DIENSTNIVEAU_OMSCHR", "MLD_DIENSTNIVEAU_KEY=" & ToSQL(fldMLD_DIENSTNIVEAU_KEY, "Number"))
  fldMLD_STDMELDING_KEY = DLookUp("MLD_STDMELDING", "MLD_STDMELDING_OMSCHRIJVING", "MLD_STDMELDING_KEY=" & ToSQL(fldMLD_STDMELDING_KEY, "Number"))
'-------------------------------
' dienstpakketRecord Show Event begin
' dienstpakketRecord Show Event end
'-------------------------------

'-------------------------------
' Show form field
'-------------------------------
      SetVar "MLD_DIENSTPAKKET_KEY", ToHTML(fldMLD_DIENSTPAKKET_KEY)
      SetVar "MLD_DIENSTNIVEAU_KEY", ToHTML(fldMLD_DIENSTNIVEAU_KEY)
      SetVar "MLD_STDMELDING_KEY", ToHTML(fldMLD_STDMELDING_KEY)
  Parse "FormdienstpakketRecord", False

'-------------------------------
' dienstpakketRecord Close Event begin
' dienstpakketRecord Close Event end
'-------------------------------

Set rs = Nothing

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