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

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


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


'===============================
' mld_srtdisciplinerecord3 PageSecurity begin
' mld_srtdisciplinerecord3 PageSecurity end
'===============================

'===============================
' mld_srtdisciplinerecord3 Open Event begin
' mld_srtdisciplinerecord3 Open Event end
'===============================

'===============================
' mld_srtdisciplinerecord3 OpenAnyPage Event begin
' mld_srtdisciplinerecord3 OpenAnyPage Event end
'===============================

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

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

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

' mld_srtdisciplinerecord3 Show end

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

' mld_srtdisciplinerecord3 Close Event begin
' mld_srtdisciplinerecord3 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_OMSCHRIJVING : fldINS_SRTDISCIPLINE_OMSCHRIJVING = ""
  Dim fldINS_SRTDISCIPLINE_PREFIX : fldINS_SRTDISCIPLINE_PREFIX = ""
  Dim fldINS_SRTDISCIPLINE_ALG : fldINS_SRTDISCIPLINE_ALG = ""
  Dim fldINS_SRTDISCIPLINE_INS : fldINS_SRTDISCIPLINE_INS = ""
  Dim fldINS_SRTDISCIPLINE_BES : fldINS_SRTDISCIPLINE_BES = ""
  Dim fldINS_SRTDISCIPLINE_KOSTENKLANT : fldINS_SRTDISCIPLINE_KOSTENKLANT = ""
'-------------------------------

'-------------------------------
' 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_OMSCHRIJVING = GetParam("INS_SRTDISCIPLINE_OMSCHRIJVING")
  fldINS_SRTDISCIPLINE_PREFIX = GetParam("INS_SRTDISCIPLINE_PREFIX")
  fldINS_SRTDISCIPLINE_ALG = GetParam("INS_SRTDISCIPLINE_ALG")
  fldINS_SRTDISCIPLINE_INS = getCheckBoxValue(GetParam("INS_SRTDISCIPLINE_INS"), "1", "0", "Number")
  fldINS_SRTDISCIPLINE_BES = getCheckBoxValue(GetParam("INS_SRTDISCIPLINE_BES"), "1", "0", "Number")
  fldINS_SRTDISCIPLINE_KOSTENKLANT = GetParam("INS_SRTDISCIPLINE_KOSTENKLANT")

'-------------------------------
' Validate fields
'-------------------------------
  if sAction = "insert" or sAction = "update" then
    if IsEmpty(fldINS_SRTDISCIPLINE_OMSCHRIJVING) then
      sSrtDisciplineRecordErr = sSrtDisciplineRecordErr & "De waarde in veld Omschrijving is verplicht.<br>"
    end if
    if not isNumeric(fldINS_SRTDISCIPLINE_ALG) then
      sSrtDisciplineRecordErr = sSrtDisciplineRecordErr & "De waarde in veld Plaatsgegevens is niet correct.<br>"
    end if
    if not isNumeric(fldINS_SRTDISCIPLINE_KOSTENKLANT) then
      sSrtDisciplineRecordErr = sSrtDisciplineRecordErr & "De waarde in veld Defaultwaarde kosten klant 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
'-------------------------------


'-------------------------------
' Create SQL statement
'-------------------------------
  select case sAction
    case "insert"
'-------------------------------
' SrtDisciplineRecord Insert Event begin
' SrtDisciplineRecord Insert Event end
'-------------------------------
      sSQL = "insert into INS_SRTDISCIPLINE (" & _
          "INS_SRTDISCIPLINE_MODULE," & _
          "INS_SRTDISCIPLINE_OMSCHRIJVING," & _
          "INS_SRTDISCIPLINE_PREFIX," & _
          "INS_SRTDISCIPLINE_ALG," & _
          "INS_SRTDISCIPLINE_INS," & _
          "INS_SRTDISCIPLINE_BES," & _
          "INS_SRTDISCIPLINE_KOSTENKLANT)" & _
          " values (" & _
          ToSQL(fldINS_SRTDISCIPLINE_MODULE, "Text") & "," & _
          ToSQL(fldINS_SRTDISCIPLINE_OMSCHRIJVING, "Text") & "," & _
          ToSQL(fldINS_SRTDISCIPLINE_PREFIX, "Text") & "," & _
          ToSQL(fldINS_SRTDISCIPLINE_ALG, "Number") & "," & _
          fldINS_SRTDISCIPLINE_INS & "," & _
          fldINS_SRTDISCIPLINE_BES & "," & _
          ToSQL(fldINS_SRTDISCIPLINE_KOSTENKLANT, "Number") & _
          ")"
  end select
'-------------------------------
'-------------------------------
' 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_OMSCHRIJVING = GetParam("INS_SRTDISCIPLINE_OMSCHRIJVING")
    fldINS_SRTDISCIPLINE_PREFIX = GetParam("INS_SRTDISCIPLINE_PREFIX")
    fldINS_SRTDISCIPLINE_ALG = GetParam("INS_SRTDISCIPLINE_ALG")
    fldINS_SRTDISCIPLINE_INS = getCheckBoxValue(GetParam("INS_SRTDISCIPLINE_INS"), "1", "0", "Number")
    fldINS_SRTDISCIPLINE_BES = getCheckBoxValue(GetParam("INS_SRTDISCIPLINE_BES"), "1", "0", "Number")
    fldINS_SRTDISCIPLINE_KOSTENKLANT = GetParam("INS_SRTDISCIPLINE_KOSTENKLANT")
    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_KEY = GetValue(rs, "INS_SRTDISCIPLINE_KEY")
    fldINS_SRTDISCIPLINE_MODULE = GetValue(rs, "INS_SRTDISCIPLINE_MODULE")

'-------------------------------
' Load data from recordset when form displayed first time
'-------------------------------
    if sSrtDisciplineRecordErr = "" then
      fldINS_SRTDISCIPLINE_OMSCHRIJVING = GetValue(rs, "INS_SRTDISCIPLINE_OMSCHRIJVING")
      fldINS_SRTDISCIPLINE_PREFIX = GetValue(rs, "INS_SRTDISCIPLINE_PREFIX")
      fldINS_SRTDISCIPLINE_ALG = GetValue(rs, "INS_SRTDISCIPLINE_ALG")
      fldINS_SRTDISCIPLINE_INS = GetValue(rs, "INS_SRTDISCIPLINE_INS")
      fldINS_SRTDISCIPLINE_BES = GetValue(rs, "INS_SRTDISCIPLINE_BES")
      fldINS_SRTDISCIPLINE_KOSTENKLANT = GetValue(rs, "INS_SRTDISCIPLINE_KOSTENKLANT")
    end if
    SetVar "SrtDisciplineRecordDelete", ""
    SetVar "SrtDisciplineRecordUpdate", ""
    SetVar "SrtDisciplineRecordInsert", ""
'-------------------------------
' SrtDisciplineRecord ShowEdit Event begin
' SrtDisciplineRecord ShowEdit Event end
'-------------------------------
  else
    if sSrtDisciplineRecordErr = "" then
      fldINS_SRTDISCIPLINE_MODULE= "MLD"
      fldINS_SRTDISCIPLINE_KOSTENKLANT= "0"
    end if
    SetVar "SrtDisciplineRecordEdit", ""
    Parse "SrtDisciplineRecordInsert", False
'-------------------------------
' SrtDisciplineRecord ShowInsert Event begin
' SrtDisciplineRecord ShowInsert Event end
'-------------------------------
  end if
  Parse "SrtDisciplineRecordCancel", false
'-------------------------------
' SrtDisciplineRecord Show Event begin
' SrtDisciplineRecord Show Event end
'-------------------------------

'-------------------------------
' 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
    
  if (LCase(fldINS_SRTDISCIPLINE_INS) = LCase("1")) then
    SetVar "INS_SRTDISCIPLINE_INS_CHECKED", "CHECKED"
  else
    SetVar "INS_SRTDISCIPLINE_INS_CHECKED", ""
  end if

  if (LCase(fldINS_SRTDISCIPLINE_BES) = LCase("1")) then
    SetVar "INS_SRTDISCIPLINE_BES_CHECKED", "CHECKED"
  else
    SetVar "INS_SRTDISCIPLINE_BES_CHECKED", ""
  end if

      SetVar "SrtDisciplineRecordLBINS_SRTDISCIPLINE_KOSTENKLANT", ""
      LOV = Split(""&FCLTLCL("0;Standaard uit;1;Standaard aan;2;Kostenplaats niet tonen")&"", ";")
      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_KOSTENKLANT) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "SrtDisciplineRecordLBINS_SRTDISCIPLINE_KOSTENKLANT", True
        next
      end if
    
  Parse "FormSrtDisciplineRecord", False

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

Set rs = Nothing

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