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

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


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


'===============================
' fac_srtnotificatierecord PageSecurity begin
' fac_srtnotificatierecord PageSecurity end
'===============================

'===============================
' fac_srtnotificatierecord Open Event begin
' fac_srtnotificatierecord Open Event end
'===============================

'===============================
' fac_srtnotificatierecord OpenAnyPage Event begin
' fac_srtnotificatierecord OpenAnyPage Event end
'===============================

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

' fac_srtnotificatierecord Show begin
'===============================
' Perform the form's action
'-------------------------------
' Initialize error variables
'-------------------------------
sNotificatieRecordErr = ""

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

' fac_srtnotificatierecord Show end

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

' fac_srtnotificatierecord Close Event begin
' fac_srtnotificatierecord Close Event end

cn.Close
Set cn = Nothing
UnloadTemplate
'===============================
'===============================
' Action of the Record Form
'-------------------------------
Sub NotificatieRecordAction(sAction)
'-------------------------------
' Initialize variables  
'-------------------------------
  Dim bExecSQL: bExecSQL = true
  Dim sActionFileName : sActionFileName = ""
  Dim sParams : sParams = "?"
  Dim sWhere : sWhere = "" 
  Dim bErr : bErr = False
  Dim pPKFAC_SRTNOTIFICATIE_KEY : pPKFAC_SRTNOTIFICATIE_KEY = ""
  Dim fldFAC_SRTNOTIFICATIE_OMS : fldFAC_SRTNOTIFICATIE_OMS = ""
  Dim fldFAC_SRTNOTIFICATIE_MODE : fldFAC_SRTNOTIFICATIE_MODE = ""
  Dim fldBIT0_STATUS : fldBIT0_STATUS = ""
  Dim fldBIT1_MAIL : fldBIT1_MAIL = ""
  Dim fldBIT2_SMS : fldBIT2_SMS = ""
  Dim fldBIT4_SUMMARY_XSL : fldBIT4_SUMMARY_XSL = ""
  Dim fldBIT3_ALERT : fldBIT3_ALERT = ""
  Dim fldFAC_SRTNOTIFICATIE_USERMODE : fldFAC_SRTNOTIFICATIE_USERMODE = ""
  Dim fldFAC_SRTNOTIFICATIE_GEBOUW : fldFAC_SRTNOTIFICATIE_GEBOUW = ""
  Dim fldFAC_SRTNOTIFICATIE_DELAY : fldFAC_SRTNOTIFICATIE_DELAY = ""
  Dim fldXMLNODE : fldXMLNODE = ""
'-------------------------------

'-------------------------------
' NotificatieRecord Action begin
'-------------------------------
  sActionFileName = "fac_srtnotificatiesrtgrid.asp"
  sParams = sParams & "sFAC_SRTNOTIFICATIE_OMS=" & ToURL(GetParam("Trn_sFAC_SRTNOTIFICATIE_OMS")) & "&"
  sParams = sParams & "FAC_SRTNOTIFICATIE_XMLNODE=" & ToURL(GetParam("Trn_FAC_SRTNOTIFICATIE_XMLNODE"))

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

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

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


'-------------------------------
' Load all form fields into variables
'-------------------------------
  fldFAC_SRTNOTIFICATIE_OMS = GetParam("FAC_SRTNOTIFICATIE_OMS")
  fldFAC_SRTNOTIFICATIE_MODE = GetParam("FAC_SRTNOTIFICATIE_MODE")
  fldBIT0_STATUS = getCheckBoxValue(GetParam("BIT0_STATUS"), "1", "0", "Number")
  fldBIT1_MAIL = getCheckBoxValue(GetParam("BIT1_MAIL"), "2", "0", "Number")
  fldBIT2_SMS = getCheckBoxValue(GetParam("BIT2_SMS"), "4", "0", "Number")
  fldBIT4_SUMMARY_XSL = getCheckBoxValue(GetParam("BIT4_SUMMARY_XSL"), "16", "0", "Number")
  fldBIT3_ALERT = getCheckBoxValue(GetParam("BIT3_ALERT"), "8", "0", "Number")
  fldFAC_SRTNOTIFICATIE_USERMODE = getCheckBoxValue(GetParam("FAC_SRTNOTIFICATIE_USERMODE"), "1", "0", "Number")
  fldFAC_SRTNOTIFICATIE_GEBOUW = getCheckBoxValue(GetParam("FAC_SRTNOTIFICATIE_GEBOUW"), "1", "0", "Number")
  fldFAC_SRTNOTIFICATIE_DELAY = GetParam("FAC_SRTNOTIFICATIE_DELAY")
  fldXMLNODE = GetParam("XMLNODE")

'-------------------------------
' Validate fields
'-------------------------------
  if sAction = "insert" or sAction = "update" then
    if IsEmpty(fldFAC_SRTNOTIFICATIE_DELAY) then
      sNotificatieRecordErr = sNotificatieRecordErr & "De waarde in veld Verzenden uitstellen (sec) is verplicht.<br>"
    end if
    if not isNumeric(fldFAC_SRTNOTIFICATIE_MODE) then
      sNotificatieRecordErr = sNotificatieRecordErr & "De waarde in veld Mode is niet correct.<br>"
    end if
    if not isNumeric(fldFAC_SRTNOTIFICATIE_DELAY) then
      sNotificatieRecordErr = sNotificatieRecordErr & "De waarde in veld Verzenden uitstellen (sec) is niet correct.<br>"
    end if
'-------------------------------
' NotificatieRecord Check Event begin
' NotificatieRecord Check Event end
'-------------------------------
    If len(sNotificatieRecordErr) > 0 then
      exit sub
    end if
  end if
'-------------------------------


'-------------------------------
' Create SQL statement
'-------------------------------
  select case sAction
    case "insert"
'-------------------------------
' NotificatieRecord Insert Event begin
' NotificatieRecord Insert Event end
'-------------------------------
      sSQL = "insert into FAC_SRTNOTIFICATIE (" & _
          "FAC_SRTNOTIFICATIE_OMS," & _
          "FAC_SRTNOTIFICATIE_MODE," & _
          "FAC_SRTNOTIFICATIE_USERMODE," & _
          "FAC_SRTNOTIFICATIE_GEBOUW," & _
          "FAC_SRTNOTIFICATIE_DELAY)" & _
          " values (" & _
          ToSQL(fldFAC_SRTNOTIFICATIE_OMS, "Text") & "," & _
          ToSQL(fldFAC_SRTNOTIFICATIE_MODE, "Number") & "," & _
          fldFAC_SRTNOTIFICATIE_USERMODE & "," & _
          fldFAC_SRTNOTIFICATIE_GEBOUW & "," & _
          ToSQL(fldFAC_SRTNOTIFICATIE_DELAY, "Number") & _
          ")"
    case "update"
'-------------------------------
' NotificatieRecord Update Event begin
fldFAC_SRTNOTIFICATIE_MODE = CInt(fldBIT0_STATUS) + _
CInt(fldBIT1_MAIL) + CInt(fldBIT2_SMS) + _
CInt(fldBIT3_ALERT) + Cint(fldBIT4_SUMMARY_XSL)
' NotificatieRecord Update Event end
'-------------------------------
      if sSQL = "" then
      sSQL = "update FAC_SRTNOTIFICATIE set " & _
        "FAC_SRTNOTIFICATIE_OMS=" & ToSQL(fldFAC_SRTNOTIFICATIE_OMS, "Text") & _
        ",FAC_SRTNOTIFICATIE_MODE=" & ToSQL(fldFAC_SRTNOTIFICATIE_MODE, "Number") & _
        ",FAC_SRTNOTIFICATIE_USERMODE=" & fldFAC_SRTNOTIFICATIE_USERMODE & _
        ",FAC_SRTNOTIFICATIE_GEBOUW=" & fldFAC_SRTNOTIFICATIE_GEBOUW & _
        ",FAC_SRTNOTIFICATIE_DELAY=" & ToSQL(fldFAC_SRTNOTIFICATIE_DELAY, "Number")
      sSQL = sSQL & " where " & sWhere
      end if
  end select
'-------------------------------
'-------------------------------
' NotificatieRecord BeforeExecute Event begin
' NotificatieRecord BeforeExecute Event end
'-------------------------------

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

'===============================
' Display Record Form
'-------------------------------
Sub NotificatieRecord_Show()
'-------------------------------
' NotificatieRecord Show begin
'-------------------------------
  Dim sWhere : sWhere = ""
  Dim sFormTitle: sFormTitle = "Details notificatie"
  Dim bPK : bPK = True

'-------------------------------
' Load primary key and form parameters
'-------------------------------
  if sNotificatieRecordErr = "" then
    fldFAC_SRTNOTIFICATIE_XMLNODE = GetParam("FAC_SRTNOTIFICATIE_XMLNODE")
    SetVar "Trn_sFAC_SRTNOTIFICATIE_OMS", GetParam("sFAC_SRTNOTIFICATIE_OMS")
    SetVar "Trn_FAC_SRTNOTIFICATIE_XMLNODE", GetParam("FAC_SRTNOTIFICATIE_XMLNODE")
    pFAC_SRTNOTIFICATIE_KEY = GetParam("FAC_SRTNOTIFICATIE_KEY")
    SetVar "NotificatieRecordError", ""
  else
    fldFAC_SRTNOTIFICATIE_OMS = GetParam("FAC_SRTNOTIFICATIE_OMS")
    fldFAC_SRTNOTIFICATIE_MODE = GetParam("FAC_SRTNOTIFICATIE_MODE")
    fldFAC_SRTNOTIFICATIE_USERMODE = getCheckBoxValue(GetParam("FAC_SRTNOTIFICATIE_USERMODE"), "1", "0", "Number")
    fldFAC_SRTNOTIFICATIE_GEBOUW = getCheckBoxValue(GetParam("FAC_SRTNOTIFICATIE_GEBOUW"), "1", "0", "Number")
    fldFAC_SRTNOTIFICATIE_DELAY = GetParam("FAC_SRTNOTIFICATIE_DELAY")
    SetVar "Trn_sFAC_SRTNOTIFICATIE_OMS", GetParam("Trn_sFAC_SRTNOTIFICATIE_OMS")
    SetVar "Trn_FAC_SRTNOTIFICATIE_XMLNODE", GetParam("Trn_FAC_SRTNOTIFICATIE_XMLNODE")
    pFAC_SRTNOTIFICATIE_KEY = GetParam("PK_FAC_SRTNOTIFICATIE_KEY")
    SetVar "sNotificatieRecordErr", sNotificatieRecordErr
    SetVar "FormTitle", sFormTitle
    Parse "NotificatieRecordError", False
  end if
'-------------------------------

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

  fldBIT0_STATUS = GetParam("BIT0_STATUS")
  fldBIT1_MAIL = GetParam("BIT1_MAIL")
  fldBIT2_SMS = GetParam("BIT2_SMS")
  fldBIT4_SUMMARY_XSL = GetParam("BIT4_SUMMARY_XSL")
  fldBIT3_ALERT = GetParam("BIT3_ALERT")
  fldXMLNODE = GetParam("XMLNODE")
'-------------------------------

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

  if IsEmpty(pFAC_SRTNOTIFICATIE_KEY) then bPK = False
  
  sWhere = sWhere & "FAC_SRTNOTIFICATIE_KEY=" & ToSQL(pFAC_SRTNOTIFICATIE_KEY, "Number")
  SetVar "PK_FAC_SRTNOTIFICATIE_KEY", pFAC_SRTNOTIFICATIE_KEY
'-------------------------------
'-------------------------------
' NotificatieRecord Open Event begin
' NotificatieRecord Open Event end
'-------------------------------

  SetVar "FormTitle", sFormTitle

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

'-------------------------------
' Load all fields into variables from recordset or input parameters
'-------------------------------
  if bIsUpdateMode then
    fldFAC_SRTNOTIFICATIE_CODE = GetValue(rs, "FAC_SRTNOTIFICATIE_CODE")
    fldFAC_SRTNOTIFICATIE_GROEP = GetValue(rs, "FAC_SRTNOTIFICATIE_GROEP")
    fldFAC_SRTNOTIFICATIE_KEY = GetValue(rs, "FAC_SRTNOTIFICATIE_KEY")
    fldFAC_SRTNOTIFICATIE_MODE = GetValue(rs, "FAC_SRTNOTIFICATIE_MODE")
    fldFAC_SRTNOTIFICATIE_URL = GetValue(rs, "FAC_SRTNOTIFICATIE_URL")
    fldFAC_SRTNOTIFICATIE_XMLNODE = GetValue(rs, "FAC_SRTNOTIFICATIE_XMLNODE")

'-------------------------------
' Load data from recordset when form displayed first time
'-------------------------------
    if sNotificatieRecordErr = "" then
      fldFAC_SRTNOTIFICATIE_OMS = GetValue(rs, "FAC_SRTNOTIFICATIE_OMS")
      fldFAC_SRTNOTIFICATIE_USERMODE = GetValue(rs, "FAC_SRTNOTIFICATIE_USERMODE")
      fldFAC_SRTNOTIFICATIE_GEBOUW = GetValue(rs, "FAC_SRTNOTIFICATIE_GEBOUW")
      fldFAC_SRTNOTIFICATIE_DELAY = GetValue(rs, "FAC_SRTNOTIFICATIE_DELAY")
    end if
    SetVar "NotificatieRecordDelete", ""
    SetVar "NotificatieRecordInsert", ""
    Parse "NotificatieRecordEdit", False
'-------------------------------
' NotificatieRecord ShowEdit Event begin
' NotificatieRecord ShowEdit Event end
'-------------------------------
  else
    if sNotificatieRecordErr = "" then
      fldFAC_SRTNOTIFICATIE_XMLNODE = ToHTML(GetParam("FAC_SRTNOTIFICATIE_XMLNODE"))
      fldFAC_SRTNOTIFICATIE_URL= "1"
      fldBIT0_STATUS= "0"
      fldBIT1_MAIL= "0"
      fldFAC_SRTNOTIFICATIE_DELAY= "0"
    end if
    SetVar "NotificatieRecordEdit", ""
    Parse "NotificatieRecordInsert", False
'-------------------------------
' NotificatieRecord ShowInsert Event begin
' NotificatieRecord ShowInsert Event end
'-------------------------------
  end if
  Parse "NotificatieRecordCancel", false

'-------------------------------
' Set default values
'-------------------------------
  fldBIT0_STATUS= "0"
  fldBIT1_MAIL= "0"
  if sNotificatieRecordErr = "" then
'-------------------------------
' NotificatieRecord Show Event begin
fldBIT0_STATUS = fldFAC_SRTNOTIFICATIE_MODE AND 1
fldBIT1_MAIL = fldFAC_SRTNOTIFICATIE_MODE AND 2
fldBIT2_SMS = fldFAC_SRTNOTIFICATIE_MODE AND 4
fldBIT3_ALERT = fldFAC_SRTNOTIFICATIE_MODE AND 8
fldBIT4_SUMMARY_XSL = fldFAC_SRTNOTIFICATIE_MODE AND 16


fldXMLNODE = fldFAC_SRTNOTIFICATIE_XMLNODE
' NotificatieRecord Show Event end
'-------------------------------
  end if

'-------------------------------
' Show form field
'-------------------------------
      SetVar "FAC_SRTNOTIFICATIE_KEY", ToHTML(fldFAC_SRTNOTIFICATIE_KEY)
      SetVar "FAC_SRTNOTIFICATIE_CODE", ToHTML(fldFAC_SRTNOTIFICATIE_CODE)
      SetVar "FAC_SRTNOTIFICATIE_OMS", ToHTML(fldFAC_SRTNOTIFICATIE_OMS)
      SetVar "FAC_SRTNOTIFICATIE_XMLNODE", ToHTML(fldFAC_SRTNOTIFICATIE_XMLNODE)
      SetVar "FAC_SRTNOTIFICATIE_URL", ToHTML(fldFAC_SRTNOTIFICATIE_URL)
      SetVar "FAC_SRTNOTIFICATIE_GROEP", ToHTML(fldFAC_SRTNOTIFICATIE_GROEP)
      SetVar "FAC_SRTNOTIFICATIE_MODE", ToHTML(fldFAC_SRTNOTIFICATIE_MODE)
  if (LCase(fldBIT0_STATUS) = LCase("1")) then
    SetVar "BIT0_STATUS_CHECKED", "CHECKED"
  else
    SetVar "BIT0_STATUS_CHECKED", ""
  end if

  if (LCase(fldBIT1_MAIL) = LCase("2")) then
    SetVar "BIT1_MAIL_CHECKED", "CHECKED"
  else
    SetVar "BIT1_MAIL_CHECKED", ""
  end if

  if (LCase(fldBIT2_SMS) = LCase("4")) then
    SetVar "BIT2_SMS_CHECKED", "CHECKED"
  else
    SetVar "BIT2_SMS_CHECKED", ""
  end if

  if (LCase(fldBIT4_SUMMARY_XSL) = LCase("16")) then
    SetVar "BIT4_SUMMARY_XSL_CHECKED", "CHECKED"
  else
    SetVar "BIT4_SUMMARY_XSL_CHECKED", ""
  end if

  if (LCase(fldBIT3_ALERT) = LCase("8")) then
    SetVar "BIT3_ALERT_CHECKED", "CHECKED"
  else
    SetVar "BIT3_ALERT_CHECKED", ""
  end if

  if (LCase(fldFAC_SRTNOTIFICATIE_USERMODE) = LCase("1")) then
    SetVar "FAC_SRTNOTIFICATIE_USERMODE_CHECKED", "CHECKED"
  else
    SetVar "FAC_SRTNOTIFICATIE_USERMODE_CHECKED", ""
  end if

  if (LCase(fldFAC_SRTNOTIFICATIE_GEBOUW) = LCase("1")) then
    SetVar "FAC_SRTNOTIFICATIE_GEBOUW_CHECKED", "CHECKED"
  else
    SetVar "FAC_SRTNOTIFICATIE_GEBOUW_CHECKED", ""
  end if

      SetVar "FAC_SRTNOTIFICATIE_DELAY", ToHTML(fldFAC_SRTNOTIFICATIE_DELAY)
      SetVar "XMLNODE", ToHTML(fldXMLNODE)
  Parse "FormNotificatieRecord", False

'-------------------------------
' NotificatieRecord Close Event begin
' NotificatieRecord Close Event end
'-------------------------------

Set rs = Nothing

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