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

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


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


'===============================
' mld_behandelgroeprecord PageSecurity begin
' mld_behandelgroeprecord PageSecurity end
'===============================

'===============================
' mld_behandelgroeprecord Open Event begin
' mld_behandelgroeprecord Open Event end
'===============================

'===============================
' mld_behandelgroeprecord OpenAnyPage Event begin
' mld_behandelgroeprecord OpenAnyPage Event end
'===============================

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

' mld_behandelgroeprecord Show begin
'===============================
' Perform the form's action
'-------------------------------
' Initialize error variables
'-------------------------------
sBehandelGroepRecordErr = ""

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

' mld_behandelgroeprecord Show end

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

' mld_behandelgroeprecord Close Event begin
' mld_behandelgroeprecord Close Event end

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

'-------------------------------
' BehandelGroepRecord Action begin
'-------------------------------
  sActionFileName = "mld_behandelgroepgrid.asp"

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

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

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


'-------------------------------
' Load all form fields into variables
'-------------------------------
  fldMLD_BEHANDELGROEP_NAAM = GetParam("MLD_BEHANDELGROEP_NAAM")
  fldMLD_BEHANDELGROEP_OMS = GetParam("MLD_BEHANDELGROEP_OMS")

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


'-------------------------------
' Create SQL statement
'-------------------------------
  select case sAction
    case "insert"
'-------------------------------
' BehandelGroepRecord Insert Event begin
' BehandelGroepRecord Insert Event end
'-------------------------------
      sSQL = "insert into MLD_BEHANDELGROEP (" & _
          "MLD_BEHANDELGROEP_NAAM," & _
          "MLD_BEHANDELGROEP_OMS)" & _
          " values (" & _
          ToSQL(fldMLD_BEHANDELGROEP_NAAM, "Text") & "," & _
          ToSQL(fldMLD_BEHANDELGROEP_OMS, "Text") & _
          ")"
    case "update"
'-------------------------------
' BehandelGroepRecord Update Event begin
' BehandelGroepRecord Update Event end
'-------------------------------
      sSQL = "update MLD_BEHANDELGROEP set " & _
        "MLD_BEHANDELGROEP_NAAM=" & ToSQL(fldMLD_BEHANDELGROEP_NAAM, "Text") & _
        ",MLD_BEHANDELGROEP_OMS=" & ToSQL(fldMLD_BEHANDELGROEP_OMS, "Text")
      sSQL = sSQL & " where " & sWhere
    case "delete"
'-------------------------------
' BehandelGroepRecord Delete Event begin
' BehandelGroepRecord Delete Event end
'-------------------------------
      sSQL = "delete from MLD_BEHANDELGROEP where " & sWhere
  end select
'-------------------------------
'-------------------------------
' BehandelGroepRecord BeforeExecute Event begin
' BehandelGroepRecord BeforeExecute Event end
'-------------------------------

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

'===============================
' Display Record Form
'-------------------------------
Sub BehandelGroepRecord_Show()
'-------------------------------
' BehandelGroepRecord Show begin
'-------------------------------
  Dim sWhere : sWhere = ""
  Dim sFormTitle: sFormTitle = "Details behandelgroep"
  Dim bPK : bPK = True

'-------------------------------
' Load primary key and form parameters
'-------------------------------
  if sBehandelGroepRecordErr = "" then
    pMLD_BEHANDELGROEP_KEY = GetParam("MLD_BEHANDELGROEP_KEY")
    SetVar "BehandelGroepRecordError", ""
  else
    fldMLD_BEHANDELGROEP_KEY = GetParam("MLD_BEHANDELGROEP_KEY")
    fldMLD_BEHANDELGROEP_NAAM = GetParam("MLD_BEHANDELGROEP_NAAM")
    fldMLD_BEHANDELGROEP_OMS = GetParam("MLD_BEHANDELGROEP_OMS")
    pMLD_BEHANDELGROEP_KEY = GetParam("PK_MLD_BEHANDELGROEP_KEY")
    SetVar "sBehandelGroepRecordErr", sBehandelGroepRecordErr
    SetVar "FormTitle", sFormTitle
    Parse "BehandelGroepRecordError", False
  end if
'-------------------------------

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

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

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

  if IsEmpty(pMLD_BEHANDELGROEP_KEY) then bPK = False
  
  sWhere = sWhere & "MLD_BEHANDELGROEP_KEY=" & ToSQL(pMLD_BEHANDELGROEP_KEY, "Number")
  SetVar "PK_MLD_BEHANDELGROEP_KEY", pMLD_BEHANDELGROEP_KEY
'-------------------------------
'-------------------------------
' BehandelGroepRecord Open Event begin
' BehandelGroepRecord Open Event end
'-------------------------------

  SetVar "FormTitle", sFormTitle

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

'-------------------------------
' Load all fields into variables from recordset or input parameters
'-------------------------------
  if bIsUpdateMode then
    fldMLD_BEHANDELGROEP_KEY = GetValue(rs, "MLD_BEHANDELGROEP_KEY")

'-------------------------------
' Load data from recordset when form displayed first time
'-------------------------------
    if sBehandelGroepRecordErr = "" then
      fldMLD_BEHANDELGROEP_NAAM = GetValue(rs, "MLD_BEHANDELGROEP_NAAM")
      fldMLD_BEHANDELGROEP_OMS = GetValue(rs, "MLD_BEHANDELGROEP_OMS")
    end if
    SetVar "BehandelGroepRecordInsert", ""
    Parse "BehandelGroepRecordEdit", False
'-------------------------------
' BehandelGroepRecord ShowEdit Event begin
' BehandelGroepRecord ShowEdit Event end
'-------------------------------
  else
    SetVar "BehandelGroepRecordEdit", ""
    Parse "BehandelGroepRecordInsert", False
'-------------------------------
' BehandelGroepRecord ShowInsert Event begin
' BehandelGroepRecord ShowInsert Event end
'-------------------------------
  end if
  Parse "BehandelGroepRecordCancel", false
'-------------------------------
' BehandelGroepRecord Show Event begin
' BehandelGroepRecord Show Event end
'-------------------------------

'-------------------------------
' Show form field
'-------------------------------
      SetVar "MLD_BEHANDELGROEP_KEY", ToHTML(fldMLD_BEHANDELGROEP_KEY)
      SetVar "MLD_BEHANDELGROEP_NAAM", ToHTML(fldMLD_BEHANDELGROEP_NAAM)
      SetVar "MLD_BEHANDELGROEP_OMS", ToHTML(fldMLD_BEHANDELGROEP_OMS)
  Parse "FormBehandelGroepRecord", False

'-------------------------------
' BehandelGroepRecord Close Event begin
' BehandelGroepRecord Close Event end
'-------------------------------

Set rs = Nothing

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