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

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


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


'===============================
' prs_kostensoortgrprecord PageSecurity begin
' prs_kostensoortgrprecord PageSecurity end
'===============================

'===============================
' prs_kostensoortgrprecord Open Event begin
' prs_kostensoortgrprecord Open Event end
'===============================

'===============================
' prs_kostensoortgrprecord OpenAnyPage Event begin
' prs_kostensoortgrprecord OpenAnyPage Event end
'===============================

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

' prs_kostensoortgrprecord Show begin
'===============================
' Perform the form's action
'-------------------------------
' Initialize error variables
'-------------------------------
sKostensoortgrpRecordErr = ""

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

' prs_kostensoortgrprecord Show end

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

' prs_kostensoortgrprecord Close Event begin
' prs_kostensoortgrprecord Close Event end

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

'-------------------------------
' KostensoortgrpRecord Action begin
'-------------------------------
  sActionFileName = "prs_kostensoortgrpgrid.asp"

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

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

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


'-------------------------------
' Load all form fields into variables
'-------------------------------
  fldPRS_KOSTENSOORTGRP_OMS = GetParam("PRS_KOSTENSOORTGRP_OMS")
  fldPRS_KOSTENSOORTGRP_ALTCODE = GetParam("PRS_KOSTENSOORTGRP_ALTCODE")

'-------------------------------
' Validate fields
'-------------------------------
  if sAction = "insert" or sAction = "update" then
    if IsEmpty(fldPRS_KOSTENSOORTGRP_OMS) then
      sKostensoortgrpRecordErr = sKostensoortgrpRecordErr & "De waarde in veld Omschrijving is verplicht.<br>"
    end if
'-------------------------------
' KostensoortgrpRecord Check Event begin
' KostensoortgrpRecord Check Event end
'-------------------------------
    If len(sKostensoortgrpRecordErr) > 0 then
      exit sub
    end if
  end if
'-------------------------------


'-------------------------------
' Create SQL statement
'-------------------------------
  select case sAction
    case "insert"
'-------------------------------
' KostensoortgrpRecord Insert Event begin
' KostensoortgrpRecord Insert Event end
'-------------------------------
      sSQL = "insert into PRS_KOSTENSOORTGRP (" & _
          "PRS_KOSTENSOORTGRP_OMS," & _
          "PRS_KOSTENSOORTGRP_ALTCODE)" & _
          " values (" & _
          ToSQL(fldPRS_KOSTENSOORTGRP_OMS, "Text") & "," & _
          ToSQL(fldPRS_KOSTENSOORTGRP_ALTCODE, "Text") & _
          ")"
    case "update"
'-------------------------------
' KostensoortgrpRecord Update Event begin
' KostensoortgrpRecord Update Event end
'-------------------------------
      sSQL = "update PRS_KOSTENSOORTGRP set " & _
        "PRS_KOSTENSOORTGRP_OMS=" & ToSQL(fldPRS_KOSTENSOORTGRP_OMS, "Text") & _
        ",PRS_KOSTENSOORTGRP_ALTCODE=" & ToSQL(fldPRS_KOSTENSOORTGRP_ALTCODE, "Text")
      sSQL = sSQL & " where " & sWhere
    case "delete"
'-------------------------------
' KostensoortgrpRecord Delete Event begin
' KostensoortgrpRecord Delete Event end
'-------------------------------
      sSQL = "delete from PRS_KOSTENSOORTGRP where " & sWhere
  end select
'-------------------------------
'-------------------------------
' KostensoortgrpRecord BeforeExecute Event begin
' KostensoortgrpRecord BeforeExecute Event end
'-------------------------------

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

'===============================
' Display Record Form
'-------------------------------
Sub KostensoortgrpRecord_Show()
'-------------------------------
' KostensoortgrpRecord Show begin
'-------------------------------
  Dim sWhere : sWhere = ""
  Dim sFormTitle: sFormTitle = "Details kostensoortgroep"
  Dim bPK : bPK = True

'-------------------------------
' Load primary key and form parameters
'-------------------------------
  if sKostensoortgrpRecordErr = "" then
    pPRS_KOSTENSOORTGRP_KEY = GetParam("PRS_KOSTENSOORTGRP_KEY")
    SetVar "KostensoortgrpRecordError", ""
  else
    fldPRS_KOSTENSOORTGRP_OMS = GetParam("PRS_KOSTENSOORTGRP_OMS")
    fldPRS_KOSTENSOORTGRP_ALTCODE = GetParam("PRS_KOSTENSOORTGRP_ALTCODE")
    pPRS_KOSTENSOORTGRP_KEY = GetParam("PK_PRS_KOSTENSOORTGRP_KEY")
    SetVar "sKostensoortgrpRecordErr", sKostensoortgrpRecordErr
    SetVar "FormTitle", sFormTitle
    Parse "KostensoortgrpRecordError", False
  end if
'-------------------------------

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

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

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

  if IsEmpty(pPRS_KOSTENSOORTGRP_KEY) then bPK = False
  
  sWhere = sWhere & "PRS_KOSTENSOORTGRP_KEY=" & ToSQL(pPRS_KOSTENSOORTGRP_KEY, "Number")
  SetVar "PK_PRS_KOSTENSOORTGRP_KEY", pPRS_KOSTENSOORTGRP_KEY
'-------------------------------
'-------------------------------
' KostensoortgrpRecord Open Event begin
' KostensoortgrpRecord Open Event end
'-------------------------------

  SetVar "FormTitle", sFormTitle

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

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

'-------------------------------
' Load data from recordset when form displayed first time
'-------------------------------
    if sKostensoortgrpRecordErr = "" then
      fldPRS_KOSTENSOORTGRP_OMS = GetValue(rs, "PRS_KOSTENSOORTGRP_OMS")
      fldPRS_KOSTENSOORTGRP_ALTCODE = GetValue(rs, "PRS_KOSTENSOORTGRP_ALTCODE")
    end if
    SetVar "KostensoortgrpRecordInsert", ""
    Parse "KostensoortgrpRecordEdit", False
'-------------------------------
' KostensoortgrpRecord ShowEdit Event begin
' KostensoortgrpRecord ShowEdit Event end
'-------------------------------
  else
    SetVar "KostensoortgrpRecordEdit", ""
    Parse "KostensoortgrpRecordInsert", False
'-------------------------------
' KostensoortgrpRecord ShowInsert Event begin
' KostensoortgrpRecord ShowInsert Event end
'-------------------------------
  end if
  Parse "KostensoortgrpRecordCancel", false
'-------------------------------
' KostensoortgrpRecord Show Event begin
' KostensoortgrpRecord Show Event end
'-------------------------------

'-------------------------------
' Show form field
'-------------------------------
      SetVar "PRS_KOSTENSOORTGRP_KEY", ToHTML(fldPRS_KOSTENSOORTGRP_KEY)
      SetVar "PRS_KOSTENSOORTGRP_OMS", ToHTML(fldPRS_KOSTENSOORTGRP_OMS)
      SetVar "PRS_KOSTENSOORTGRP_ALTCODE", ToHTML(fldPRS_KOSTENSOORTGRP_ALTCODE)
  Parse "FormKostensoortgrpRecord", False

'-------------------------------
' KostensoortgrpRecord Close Event begin
' KostensoortgrpRecord Close Event end
'-------------------------------

Set rs = Nothing

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