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

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


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


'===============================
' mld_vrije_dagenrecord PageSecurity begin
' mld_vrije_dagenrecord PageSecurity end
'===============================

'===============================
' mld_vrije_dagenrecord Open Event begin
' mld_vrije_dagenrecord Open Event end
'===============================

'===============================
' mld_vrije_dagenrecord OpenAnyPage Event begin
' mld_vrije_dagenrecord OpenAnyPage Event end
'===============================

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

' mld_vrije_dagenrecord Show begin
'===============================
' Perform the form's action
'-------------------------------
' Initialize error variables
'-------------------------------
sVrijeDagenRecordErr = ""

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

' mld_vrije_dagenrecord Show end

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

' mld_vrije_dagenrecord Close Event begin
' mld_vrije_dagenrecord Close Event end

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

'-------------------------------
' VrijeDagenRecord Action begin
'-------------------------------
  sActionFileName = "mld_vrije_dagengrid.asp"
  sParams = sParams & "sMLD_VRIJE_DAGEN_DATUM=" & ToURL(GetParam("Trn_sMLD_VRIJE_DAGEN_DATUM"))

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

'-------------------------------
' VrijeDagenRecord BeforeCancel Event begin
' VrijeDagenRecord 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_VRIJE_DAGEN_KEY = GetParam("PK_MLD_VRIJE_DAGEN_KEY")
    if IsEmpty(pPKMLD_VRIJE_DAGEN_KEY) then exit sub
    sWhere = "MLD_VRIJE_DAGEN_KEY=" & ToSQL(pPKMLD_VRIJE_DAGEN_KEY, "Number")
  end if
'-------------------------------


'-------------------------------
' Load all form fields into variables
'-------------------------------
  fldMLD_VRIJE_DAGEN_DATUM = GetParam("MLD_VRIJE_DAGEN_DATUM")

'-------------------------------
' Validate fields
'-------------------------------
  if sAction = "insert" or sAction = "update" then
    if IsEmpty(fldMLD_VRIJE_DAGEN_DATUM) then
      sVrijeDagenRecordErr = sVrijeDagenRecordErr & "De waarde in veld Datum (dd-mm-jjjj) is verplicht.<br>"
    end if
'-------------------------------
' VrijeDagenRecord Check Event begin
' VrijeDagenRecord Check Event end
'-------------------------------
    If len(sVrijeDagenRecordErr) > 0 then
      exit sub
    end if
  end if
'-------------------------------


'-------------------------------
' Create SQL statement
'-------------------------------
  select case sAction
    case "insert"
'-------------------------------
' VrijeDagenRecord Insert Event begin
sSQL = "INSERT INTO MLD_VRIJE_DAGEN (MLD_VRIJE_DAGEN_DATUM) "&_
       "VALUES ("&ToDate(fldMLD_VRIJE_DAGEN_DATUM)&")"
' VrijeDagenRecord Insert Event end
'-------------------------------
      if sSQL = "" then
      sSQL = "insert into MLD_VRIJE_DAGEN (" & _
          "MLD_VRIJE_DAGEN_DATUM)" & _
          " values (" & _
          ToSQL(fldMLD_VRIJE_DAGEN_DATUM, "Date") & _
          ")"
      end if
    case "update"
'-------------------------------
' VrijeDagenRecord Update Event begin
if (oude_datum <> fldMLD_VRIJE_DAGEN_DATUM) then
  sSQL = "UPDATE MLD_VRIJE_DAGEN SET MLD_VRIJE_DAGEN_DATUM="&toDate(fldMLD_VRIJE_DAGEN_DATUM)&" WHERE MLD_VRIJE_DAGEN_KEY = "&pPKMLD_VRIJE_DAGEN_KEY
else
  Set cn = Nothing
  response.redirect sActionFileName
end if
' VrijeDagenRecord Update Event end
'-------------------------------
      if sSQL = "" then
      sSQL = "update MLD_VRIJE_DAGEN set " & _
        "MLD_VRIJE_DAGEN_DATUM=" & ToSQL(fldMLD_VRIJE_DAGEN_DATUM, "Date")
      sSQL = sSQL & " where " & sWhere
      end if
    case "delete"
'-------------------------------
' VrijeDagenRecord Delete Event begin
' VrijeDagenRecord Delete Event end
'-------------------------------
      sSQL = "delete from MLD_VRIJE_DAGEN where " & sWhere
  end select
'-------------------------------
'-------------------------------
' VrijeDagenRecord BeforeExecute Event begin
' VrijeDagenRecord BeforeExecute Event end
'-------------------------------

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

'===============================
' Display Record Form
'-------------------------------
Sub VrijeDagenRecord_Show()
'-------------------------------
' VrijeDagenRecord Show begin
'-------------------------------
  Dim sWhere : sWhere = ""
  Dim sFormTitle: sFormTitle = "Details vrije dag"
  Dim bPK : bPK = True

'-------------------------------
' Load primary key and form parameters
'-------------------------------
  if sVrijeDagenRecordErr = "" then
    SetVar "Trn_sMLD_VRIJE_DAGEN_DATUM", GetParam("sMLD_VRIJE_DAGEN_DATUM")
    pMLD_VRIJE_DAGEN_KEY = GetParam("MLD_VRIJE_DAGEN_KEY")
    SetVar "VrijeDagenRecordError", ""
  else
    fldMLD_VRIJE_DAGEN_KEY = GetParam("MLD_VRIJE_DAGEN_KEY")
    fldMLD_VRIJE_DAGEN_DATUM = GetParam("MLD_VRIJE_DAGEN_DATUM")
    SetVar "Trn_sMLD_VRIJE_DAGEN_DATUM", GetParam("Trn_sMLD_VRIJE_DAGEN_DATUM")
    pMLD_VRIJE_DAGEN_KEY = GetParam("PK_MLD_VRIJE_DAGEN_KEY")
    SetVar "sVrijeDagenRecordErr", sVrijeDagenRecordErr
    SetVar "FormTitle", sFormTitle
    Parse "VrijeDagenRecordError", False
  end if
'-------------------------------

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

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

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

  if IsEmpty(pMLD_VRIJE_DAGEN_KEY) then bPK = False
  
  sWhere = sWhere & "MLD_VRIJE_DAGEN_KEY=" & ToSQL(pMLD_VRIJE_DAGEN_KEY, "Number")
  SetVar "PK_MLD_VRIJE_DAGEN_KEY", pMLD_VRIJE_DAGEN_KEY
'-------------------------------
'-------------------------------
' VrijeDagenRecord Open Event begin
' VrijeDagenRecord Open Event end
'-------------------------------

  SetVar "FormTitle", sFormTitle

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

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

'-------------------------------
' Load data from recordset when form displayed first time
'-------------------------------
    if sVrijeDagenRecordErr = "" then
      fldMLD_VRIJE_DAGEN_DATUM = GetValue(rs, "MLD_VRIJE_DAGEN_DATUM")
    end if
    SetVar "VrijeDagenRecordInsert", ""
    Parse "VrijeDagenRecordEdit", False
'-------------------------------
' VrijeDagenRecord ShowEdit Event begin
dim ouwe_datum
ouwe_datum = fldMLD_VRIJE_DAGEN_DATUM
' VrijeDagenRecord ShowEdit Event end
'-------------------------------
  else
    SetVar "VrijeDagenRecordEdit", ""
    Parse "VrijeDagenRecordInsert", False
'-------------------------------
' VrijeDagenRecord ShowInsert Event begin
' VrijeDagenRecord ShowInsert Event end
'-------------------------------
  end if
  Parse "VrijeDagenRecordCancel", false
'-------------------------------
' VrijeDagenRecord Show Event begin
' VrijeDagenRecord Show Event end
'-------------------------------

'-------------------------------
' Show form field
'-------------------------------
      SetVar "MLD_VRIJE_DAGEN_KEY", ToHTML(fldMLD_VRIJE_DAGEN_KEY)
      SetVar "MLD_VRIJE_DAGEN_DATUM", ToHTML(fldMLD_VRIJE_DAGEN_DATUM)
  Parse "FormVrijeDagenRecord", False

'-------------------------------
' VrijeDagenRecord Close Event begin
' VrijeDagenRecord Close Event end
'-------------------------------

Set rs = Nothing

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