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

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


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


'===============================
' mld_srtkenmerkrecord PageSecurity begin
' mld_srtkenmerkrecord PageSecurity end
'===============================

'===============================
' mld_srtkenmerkrecord Open Event begin
' mld_srtkenmerkrecord Open Event end
'===============================

'===============================
' mld_srtkenmerkrecord OpenAnyPage Event begin
' mld_srtkenmerkrecord OpenAnyPage Event end
'===============================

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

' mld_srtkenmerkrecord Show begin
'===============================
' Perform the form's action
'-------------------------------
' Initialize error variables
'-------------------------------
sSrtKenmerkRecordErr = ""

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

' mld_srtkenmerkrecord Show end

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

' mld_srtkenmerkrecord Close Event begin
' mld_srtkenmerkrecord Close Event end

cn.Close
Set cn = Nothing
UnloadTemplate
'===============================
'===============================
' Action of the Record Form
'-------------------------------
Sub SrtKenmerkRecordAction(sAction)
'-------------------------------
' Initialize variables  
'-------------------------------
  Dim bExecSQL: bExecSQL = true
  Dim sActionFileName : sActionFileName = ""
  Dim sParams : sParams = "?"
  Dim sWhere : sWhere = "" 
  Dim bErr : bErr = False
  Dim pPKMLD_SRTKENMERK_KEY : pPKMLD_SRTKENMERK_KEY = ""
  Dim fldMLD_SRTKENMERK_OMSCHRIJVING : fldMLD_SRTKENMERK_OMSCHRIJVING = ""
  Dim fldMLD_SRTKENMERK_KENMERKTYPE : fldMLD_SRTKENMERK_KENMERKTYPE = ""
  Dim fldMLD_SRTKENMERK_DIMENSIE : fldMLD_SRTKENMERK_DIMENSIE = ""
  Dim fldMLD_SRTKENMERK_SYSTEEM : fldMLD_SRTKENMERK_SYSTEEM = ""
  Dim fldMLD_SRTKENMERK_LENGTE : fldMLD_SRTKENMERK_LENGTE = ""
  Dim fldMLD_SRTKENMERK_DEC : fldMLD_SRTKENMERK_DEC = ""
  Dim fldMLD_SRTKENMERK_NMIN : fldMLD_SRTKENMERK_NMIN = ""
  Dim fldMLD_SRTKENMERK_NMAX : fldMLD_SRTKENMERK_NMAX = ""
  Dim fldFAC_KENMERKDOMEIN_KEY : fldFAC_KENMERKDOMEIN_KEY = ""
'-------------------------------

'-------------------------------
' SrtKenmerkRecord Action begin
'-------------------------------
  sActionFileName = "mld_srtkenmerkgrid.asp"
  sParams = sParams & "sMLD_SRTKENMERK_UPPER=" & ToURL(GetParam("Trn_sMLD_SRTKENMERK_UPPER")) & "&"
  sParams = sParams & "sMLD_SRTKENMERK_KENMERKTYPE=" & ToURL(GetParam("Trn_sMLD_SRTKENMERK_KENMERKTYPE"))

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

'-------------------------------
' SrtKenmerkRecord BeforeCancel Event begin
' SrtKenmerkRecord 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_SRTKENMERK_KEY = GetParam("PK_MLD_SRTKENMERK_KEY")
    if IsEmpty(pPKMLD_SRTKENMERK_KEY) then exit sub
    sWhere = "MLD_SRTKENMERK_KEY=" & ToSQL(pPKMLD_SRTKENMERK_KEY, "Number")
  end if
'-------------------------------


'-------------------------------
' Load all form fields into variables
'-------------------------------
  fldMLD_SRTKENMERK_OMSCHRIJVING = GetParam("MLD_SRTKENMERK_OMSCHRIJVING")
  fldMLD_SRTKENMERK_KENMERKTYPE = GetParam("MLD_SRTKENMERK_KENMERKTYPE")
  fldMLD_SRTKENMERK_DIMENSIE = GetParam("MLD_SRTKENMERK_DIMENSIE")
  fldMLD_SRTKENMERK_SYSTEEM = getCheckBoxValue(GetParam("MLD_SRTKENMERK_SYSTEEM"), "1", "", "Number")
  fldMLD_SRTKENMERK_LENGTE = GetParam("MLD_SRTKENMERK_LENGTE")
  fldMLD_SRTKENMERK_DEC = GetParam("MLD_SRTKENMERK_DEC")
  fldMLD_SRTKENMERK_NMIN = GetParam("MLD_SRTKENMERK_NMIN")
  fldMLD_SRTKENMERK_NMAX = GetParam("MLD_SRTKENMERK_NMAX")
  fldFAC_KENMERKDOMEIN_KEY = GetParam("FAC_KENMERKDOMEIN_KEY")

'-------------------------------
' Validate fields
'-------------------------------
  if sAction = "insert" or sAction = "update" then
    if IsEmpty(fldMLD_SRTKENMERK_OMSCHRIJVING) then
      sSrtKenmerkRecordErr = sSrtKenmerkRecordErr & "De waarde in veld Omschrijving is verplicht.<br>"
    end if
    if IsEmpty(fldMLD_SRTKENMERK_KENMERKTYPE) then
      sSrtKenmerkRecordErr = sSrtKenmerkRecordErr & "De waarde in veld Kenmerktype is verplicht.<br>"
    end if
    if not isNumeric(fldMLD_SRTKENMERK_LENGTE) then
      sSrtKenmerkRecordErr = sSrtKenmerkRecordErr & "De waarde in veld Lengte is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_SRTKENMERK_DEC) then
      sSrtKenmerkRecordErr = sSrtKenmerkRecordErr & "De waarde in veld Decimalen is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_SRTKENMERK_NMIN) then
      sSrtKenmerkRecordErr = sSrtKenmerkRecordErr & "De waarde in veld Minimum is niet correct.<br>"
    end if
    if not isNumeric(fldMLD_SRTKENMERK_NMAX) then
      sSrtKenmerkRecordErr = sSrtKenmerkRecordErr & "De waarde in veld Maximum is niet correct.<br>"
    end if
    if not isNumeric(fldFAC_KENMERKDOMEIN_KEY) then
      sSrtKenmerkRecordErr = sSrtKenmerkRecordErr & "De waarde in veld Kenmerkdomein is niet correct.<br>"
    end if
'-------------------------------
' SrtKenmerkRecord Check Event begin
select case UCase(fldMLD_SRTKENMERK_KENMERKTYPE)
case "C" if fldMLD_SRTKENMERK_LENGTE = "" then sSrtKenmerkRecordErr = sSrtKenmerkRecordErr + "Lengte moet gespecificeerd worden.<br>"
case "N" if fldMLD_SRTKENMERK_LENGTE = "" then sSrtKenmerkRecordErr = sSrtKenmerkRecordErr + "Lengte moet gespecificeerd worden.<br>"
case "R" if fldFAC_KENMERKDOMEIN_KEY = "" then sSrtKenmerkRecordErr = sSrtKenmerkRecordErr + "Kenmerkdomein moet gekozen worden.<br>"
end select
if ((fldMLD_SRTKENMERK_KENMERKTYPE = "C") and (fldMLD_SRTKENMERK_LENGTE > 4000)) then
  sSrtKenmerkRecordErr = sSrtKenmerkRecordErr + "Maximale lengte bij kenmerktype karakter is 4000."
end if
' SrtKenmerkRecord Check Event end
'-------------------------------
    If len(sSrtKenmerkRecordErr) > 0 then
      exit sub
    end if
  end if
'-------------------------------


'-------------------------------
' Create SQL statement
'-------------------------------
  select case sAction
    case "insert"
'-------------------------------
' SrtKenmerkRecord Insert Event begin
' SrtKenmerkRecord Insert Event end
'-------------------------------
      sSQL = "insert into MLD_SRTKENMERK (" & _
          "MLD_SRTKENMERK_OMSCHRIJVING," & _
          "MLD_SRTKENMERK_KENMERKTYPE," & _
          "MLD_SRTKENMERK_DIMENSIE," & _
          "MLD_SRTKENMERK_SYSTEEM," & _
          "MLD_SRTKENMERK_LENGTE," & _
          "MLD_SRTKENMERK_DEC," & _
          "MLD_SRTKENMERK_NMIN," & _
          "MLD_SRTKENMERK_NMAX," & _
          "FAC_KENMERKDOMEIN_KEY)" & _
          " values (" & _
          ToSQL(fldMLD_SRTKENMERK_OMSCHRIJVING, "Text") & "," & _
          ToSQL(fldMLD_SRTKENMERK_KENMERKTYPE, "Text") & "," & _
          ToSQL(fldMLD_SRTKENMERK_DIMENSIE, "Text") & "," & _
          fldMLD_SRTKENMERK_SYSTEEM & "," & _
          ToSQL(fldMLD_SRTKENMERK_LENGTE, "Number") & "," & _
          ToSQL(fldMLD_SRTKENMERK_DEC, "Number") & "," & _
          ToSQL(fldMLD_SRTKENMERK_NMIN, "Number") & "," & _
          ToSQL(fldMLD_SRTKENMERK_NMAX, "Number") & "," & _
          ToSQL(fldFAC_KENMERKDOMEIN_KEY, "Number") & _
          ")"
    case "update"
'-------------------------------
' SrtKenmerkRecord Update Event begin
' SrtKenmerkRecord Update Event end
'-------------------------------
      sSQL = "update MLD_SRTKENMERK set " & _
        "MLD_SRTKENMERK_OMSCHRIJVING=" & ToSQL(fldMLD_SRTKENMERK_OMSCHRIJVING, "Text") & _
        ",MLD_SRTKENMERK_KENMERKTYPE=" & ToSQL(fldMLD_SRTKENMERK_KENMERKTYPE, "Text") & _
        ",MLD_SRTKENMERK_DIMENSIE=" & ToSQL(fldMLD_SRTKENMERK_DIMENSIE, "Text") & _
        ",MLD_SRTKENMERK_SYSTEEM=" & fldMLD_SRTKENMERK_SYSTEEM & _
        ",MLD_SRTKENMERK_LENGTE=" & ToSQL(fldMLD_SRTKENMERK_LENGTE, "Number") & _
        ",MLD_SRTKENMERK_DEC=" & ToSQL(fldMLD_SRTKENMERK_DEC, "Number") & _
        ",MLD_SRTKENMERK_NMIN=" & ToSQL(fldMLD_SRTKENMERK_NMIN, "Number") & _
        ",MLD_SRTKENMERK_NMAX=" & ToSQL(fldMLD_SRTKENMERK_NMAX, "Number") & _
        ",FAC_KENMERKDOMEIN_KEY=" & ToSQL(fldFAC_KENMERKDOMEIN_KEY, "Number")
      sSQL = sSQL & " where " & sWhere
    case "delete"
'-------------------------------
' SrtKenmerkRecord Delete Event begin
dim tmpkey
tmpkey = "PK_"&strToTable(sActionFileName)&"_KEY"
sSql = customFacDelete(sActionFileName,getParam(tmpkey))
set tmpkey = Nothing
' SrtKenmerkRecord Delete Event end
'-------------------------------
      if sSQL = "" then
      sSQL = "delete from MLD_SRTKENMERK where " & sWhere
      end if
  end select
'-------------------------------
'-------------------------------
' SrtKenmerkRecord BeforeExecute Event begin
' SrtKenmerkRecord BeforeExecute Event end
'-------------------------------

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

'===============================
' Display Record Form
'-------------------------------
Sub SrtKenmerkRecord_Show()
'-------------------------------
' SrtKenmerkRecord Show begin
'-------------------------------
  Dim sWhere : sWhere = ""
  Dim sFormTitle: sFormTitle = "Details kenmerksoort"
  Dim bPK : bPK = True
  Dim sFAC_KENMERKDOMEIN_KEYDisplayValue: sFAC_KENMERKDOMEIN_KEYDisplayValue = ""

'-------------------------------
' Load primary key and form parameters
'-------------------------------
  if sSrtKenmerkRecordErr = "" then
    SetVar "Trn_sMLD_SRTKENMERK_UPPER", GetParam("sMLD_SRTKENMERK_UPPER")
    SetVar "Trn_sMLD_SRTKENMERK_KENMERKTYPE", GetParam("sMLD_SRTKENMERK_KENMERKTYPE")
    pMLD_SRTKENMERK_KEY = GetParam("MLD_SRTKENMERK_KEY")
    SetVar "SrtKenmerkRecordError", ""
  else
    fldMLD_SRTKENMERK_OMSCHRIJVING = GetParam("MLD_SRTKENMERK_OMSCHRIJVING")
    fldMLD_SRTKENMERK_KENMERKTYPE = GetParam("MLD_SRTKENMERK_KENMERKTYPE")
    fldMLD_SRTKENMERK_DIMENSIE = GetParam("MLD_SRTKENMERK_DIMENSIE")
    fldMLD_SRTKENMERK_SYSTEEM = getCheckBoxValue(GetParam("MLD_SRTKENMERK_SYSTEEM"), "1", "", "Number")
    fldMLD_SRTKENMERK_LENGTE = GetParam("MLD_SRTKENMERK_LENGTE")
    fldMLD_SRTKENMERK_DEC = GetParam("MLD_SRTKENMERK_DEC")
    fldMLD_SRTKENMERK_NMIN = GetParam("MLD_SRTKENMERK_NMIN")
    fldMLD_SRTKENMERK_NMAX = GetParam("MLD_SRTKENMERK_NMAX")
    fldFAC_KENMERKDOMEIN_KEY = GetParam("FAC_KENMERKDOMEIN_KEY")
    SetVar "Trn_sMLD_SRTKENMERK_UPPER", GetParam("Trn_sMLD_SRTKENMERK_UPPER")
    SetVar "Trn_sMLD_SRTKENMERK_KENMERKTYPE", GetParam("Trn_sMLD_SRTKENMERK_KENMERKTYPE")
    pMLD_SRTKENMERK_KEY = GetParam("PK_MLD_SRTKENMERK_KEY")
    SetVar "sSrtKenmerkRecordErr", sSrtKenmerkRecordErr
    SetVar "FormTitle", sFormTitle
    Parse "SrtKenmerkRecordError", False
  end if
'-------------------------------

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

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

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

  if IsEmpty(pMLD_SRTKENMERK_KEY) then bPK = False
  
  sWhere = sWhere & "MLD_SRTKENMERK_KEY=" & ToSQL(pMLD_SRTKENMERK_KEY, "Number")
  SetVar "PK_MLD_SRTKENMERK_KEY", pMLD_SRTKENMERK_KEY
'-------------------------------
'-------------------------------
' SrtKenmerkRecord Open Event begin
' SrtKenmerkRecord Open Event end
'-------------------------------

  SetVar "FormTitle", sFormTitle

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

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

'-------------------------------
' Load data from recordset when form displayed first time
'-------------------------------
    if sSrtKenmerkRecordErr = "" then
      fldMLD_SRTKENMERK_OMSCHRIJVING = GetValue(rs, "MLD_SRTKENMERK_OMSCHRIJVING")
      fldMLD_SRTKENMERK_KENMERKTYPE = GetValue(rs, "MLD_SRTKENMERK_KENMERKTYPE")
      fldMLD_SRTKENMERK_DIMENSIE = GetValue(rs, "MLD_SRTKENMERK_DIMENSIE")
      fldMLD_SRTKENMERK_SYSTEEM = GetValue(rs, "MLD_SRTKENMERK_SYSTEEM")
      fldMLD_SRTKENMERK_LENGTE = GetValue(rs, "MLD_SRTKENMERK_LENGTE")
      fldMLD_SRTKENMERK_DEC = GetValue(rs, "MLD_SRTKENMERK_DEC")
      fldMLD_SRTKENMERK_NMIN = GetValue(rs, "MLD_SRTKENMERK_NMIN")
      fldMLD_SRTKENMERK_NMAX = GetValue(rs, "MLD_SRTKENMERK_NMAX")
      fldFAC_KENMERKDOMEIN_KEY = GetValue(rs, "FAC_KENMERKDOMEIN_KEY")
    end if
    SetVar "SrtKenmerkRecordInsert", ""
    Parse "SrtKenmerkRecordEdit", False
'-------------------------------
' SrtKenmerkRecord ShowEdit Event begin
' SrtKenmerkRecord ShowEdit Event end
'-------------------------------
  else
    SetVar "SrtKenmerkRecordEdit", ""
    Parse "SrtKenmerkRecordInsert", False
'-------------------------------
' SrtKenmerkRecord ShowInsert Event begin
' SrtKenmerkRecord ShowInsert Event end
'-------------------------------
  end if
  Parse "SrtKenmerkRecordCancel", false
'-------------------------------
' SrtKenmerkRecord Show Event begin
' SrtKenmerkRecord Show Event end
'-------------------------------

'-------------------------------
' Show form field
'-------------------------------
      SetVar "MLD_SRTKENMERK_KEY", ToHTML(fldMLD_SRTKENMERK_KEY)
      SetVar "MLD_SRTKENMERK_OMSCHRIJVING", ToHTML(fldMLD_SRTKENMERK_OMSCHRIJVING)
      SetVar "SrtKenmerkRecordLBMLD_SRTKENMERK_KENMERKTYPE", ""
      LOV = Split(""&buildKenmerkTypeList(fldMLD_SRTKENMERK_KENMERKTYPE)&"", ";")
      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(fldMLD_SRTKENMERK_KENMERKTYPE) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
          Parse "SrtKenmerkRecordLBMLD_SRTKENMERK_KENMERKTYPE", True
        next
      end if
    
      SetVar "MLD_SRTKENMERK_DIMENSIE", ToHTML(fldMLD_SRTKENMERK_DIMENSIE)
  if (LCase(fldMLD_SRTKENMERK_SYSTEEM) = LCase("1")) then
    SetVar "MLD_SRTKENMERK_SYSTEEM_CHECKED", "CHECKED"
  else
    SetVar "MLD_SRTKENMERK_SYSTEEM_CHECKED", ""
  end if

      SetVar "MLD_SRTKENMERK_LENGTE", ToHTML(fldMLD_SRTKENMERK_LENGTE)
      SetVar "MLD_SRTKENMERK_DEC", ToHTML(fldMLD_SRTKENMERK_DEC)
      SetVar "MLD_SRTKENMERK_NMIN", ToHTML(fldMLD_SRTKENMERK_NMIN)
      SetVar "MLD_SRTKENMERK_NMAX", ToHTML(fldMLD_SRTKENMERK_NMAX)
      SetVar "SrtKenmerkRecordLBFAC_KENMERKDOMEIN_KEY", ""
      SetVar "Selected", ""
      SetVar "ID", ""
      SetVar "Value", sFAC_KENMERKDOMEIN_KEYDisplayValue
      Parse "SrtKenmerkRecordLBFAC_KENMERKDOMEIN_KEY", True
      openrs rsFAC_KENMERKDOMEIN_KEY, "select fac_kenmerkdomein_key, fac_kenmerkdomein_omschrijving from fac_kenmerkdomein where fac_kenmerkdomein_verwijder is null and fac_kenmerkdomein_module = 'MLD' order by fac_kenmerkdomein_upper asc"
      while not rsFAC_KENMERKDOMEIN_KEY.EOF
        SetVar "ID", GetValue(rsFAC_KENMERKDOMEIN_KEY, 0) : SetVar "Value", GetValue(rsFAC_KENMERKDOMEIN_KEY, 1)
        if cstr(GetValue(rsFAC_KENMERKDOMEIN_KEY, 0)) = cstr(fldFAC_KENMERKDOMEIN_KEY) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
        Parse "SrtKenmerkRecordLBFAC_KENMERKDOMEIN_KEY", True
        rsFAC_KENMERKDOMEIN_KEY.MoveNext
      wend
      set rsFAC_KENMERKDOMEIN_KEY = nothing
    
  Parse "FormSrtKenmerkRecord", False

'-------------------------------
' SrtKenmerkRecord Close Event begin
' SrtKenmerkRecord Close Event end
'-------------------------------

Set rs = Nothing

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