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

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


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


'===============================
' fac_notificatiejobrecord PageSecurity begin
' fac_notificatiejobrecord PageSecurity end
'===============================

'===============================
' fac_notificatiejobrecord Open Event begin
' fac_notificatiejobrecord Open Event end
'===============================

'===============================
' fac_notificatiejobrecord OpenAnyPage Event begin
' fac_notificatiejobrecord OpenAnyPage Event end
'===============================

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

' fac_notificatiejobrecord 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_notificatiejobrecord Show end

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

' fac_notificatiejobrecord Close Event begin
' fac_notificatiejobrecord 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 sWhere : sWhere = "" 
  Dim bErr : bErr = False
  Dim pPKFAC_NOTIFICATIE_JOB_KEY : pPKFAC_NOTIFICATIE_JOB_KEY = ""
  Dim fldFAC_NOTIFICATIE_JOB_OMS : fldFAC_NOTIFICATIE_JOB_OMS = ""
  Dim fldFAC_NOTIFICATIE_JOB_VIEW : fldFAC_NOTIFICATIE_JOB_VIEW = ""
  Dim fldFAC_NOTIFICATIE_JOB_MODE : fldFAC_NOTIFICATIE_JOB_MODE = ""
  Dim fldFAC_NOTIFICATIE_JOB_INTERVAL : fldFAC_NOTIFICATIE_JOB_INTERVAL = ""
  Dim fldFAC_NOTIFICATIE_JOB_NEXTRUN : fldFAC_NOTIFICATIE_JOB_NEXTRUN = ""
'-------------------------------

'-------------------------------
' NotificatieRecord Action begin
'-------------------------------
  sActionFileName = "fac_notificatiejobgrid.asp"

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

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

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


'-------------------------------
' Load all form fields into variables
'-------------------------------
  fldFAC_NOTIFICATIE_JOB_OMS = GetParam("FAC_NOTIFICATIE_JOB_OMS")
  fldFAC_NOTIFICATIE_JOB_VIEW = GetParam("FAC_NOTIFICATIE_JOB_VIEW")
  fldFAC_NOTIFICATIE_JOB_MODE = GetParam("FAC_NOTIFICATIE_JOB_MODE")
  fldFAC_NOTIFICATIE_JOB_INTERVAL = GetParam("FAC_NOTIFICATIE_JOB_INTERVAL")
  fldFAC_NOTIFICATIE_JOB_NEXTRUN = GetParam("FAC_NOTIFICATIE_JOB_NEXTRUN")

'-------------------------------
' Validate fields
'-------------------------------
  if sAction = "insert" or sAction = "update" then
    if not isNumeric(fldFAC_NOTIFICATIE_JOB_MODE) then
      sNotificatieRecordErr = sNotificatieRecordErr & "De waarde in veld Mode is niet correct.<br>"
    end if
    if not isNumeric(fldFAC_NOTIFICATIE_JOB_INTERVAL) then
      sNotificatieRecordErr = sNotificatieRecordErr & "De waarde in veld Interval (uur) is niet correct.<br>"
    end if
'-------------------------------
' NotificatieRecord Check Event begin
cn.execute "alter session set NLS_DATE_FORMAT='DD-MM-YYYY HH24:MI:SS'"
' 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_NOTIFICATIE_JOB (" & _
          "FAC_NOTIFICATIE_JOB_OMS," & _
          "FAC_NOTIFICATIE_JOB_VIEW," & _
          "FAC_NOTIFICATIE_JOB_MODE," & _
          "FAC_NOTIFICATIE_JOB_INTERVAL," & _
          "FAC_NOTIFICATIE_JOB_NEXTRUN)" & _
          " values (" & _
          ToSQL(fldFAC_NOTIFICATIE_JOB_OMS, "Text") & "," & _
          ToSQL(fldFAC_NOTIFICATIE_JOB_VIEW, "Text") & "," & _
          ToSQL(fldFAC_NOTIFICATIE_JOB_MODE, "Number") & "," & _
          ToSQL(fldFAC_NOTIFICATIE_JOB_INTERVAL, "Number") & "," & _
          ToSQL(fldFAC_NOTIFICATIE_JOB_NEXTRUN, "Date") & _
          ")"
    case "update"
'-------------------------------
' NotificatieRecord Update Event begin
fldFAC_SRTNOTIFICATIE_MODE = CInt(fldBIT0_STATUS) + CInt(fldBIT1_MAIL) + CInt(fldBIT2_SMS) + CInt(fldBIT3_ALERT)
' NotificatieRecord Update Event end
'-------------------------------
      if sSQL = "" then
      sSQL = "update FAC_NOTIFICATIE_JOB set " & _
        "FAC_NOTIFICATIE_JOB_OMS=" & ToSQL(fldFAC_NOTIFICATIE_JOB_OMS, "Text") & _
        ",FAC_NOTIFICATIE_JOB_VIEW=" & ToSQL(fldFAC_NOTIFICATIE_JOB_VIEW, "Text") & _
        ",FAC_NOTIFICATIE_JOB_MODE=" & ToSQL(fldFAC_NOTIFICATIE_JOB_MODE, "Number") & _
        ",FAC_NOTIFICATIE_JOB_INTERVAL=" & ToSQL(fldFAC_NOTIFICATIE_JOB_INTERVAL, "Number") & _
        ",FAC_NOTIFICATIE_JOB_NEXTRUN=" & ToSQL(fldFAC_NOTIFICATIE_JOB_NEXTRUN, "Date")
      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
'-------------------------------
' NotificatieRecord Action end
'-------------------------------
end sub
'===============================

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

'-------------------------------
' Load primary key and form parameters
'-------------------------------
  if sNotificatieRecordErr = "" then
    pFAC_NOTIFICATIE_JOB_KEY = GetParam("FAC_NOTIFICATIE_JOB_KEY")
    SetVar "NotificatieRecordError", ""
  else
    fldFAC_NOTIFICATIE_JOB_KEY = GetParam("FAC_NOTIFICATIE_JOB_KEY")
    fldFAC_NOTIFICATIE_JOB_OMS = GetParam("FAC_NOTIFICATIE_JOB_OMS")
    fldFAC_NOTIFICATIE_JOB_VIEW = GetParam("FAC_NOTIFICATIE_JOB_VIEW")
    fldFAC_NOTIFICATIE_JOB_MODE = GetParam("FAC_NOTIFICATIE_JOB_MODE")
    fldFAC_NOTIFICATIE_JOB_INTERVAL = GetParam("FAC_NOTIFICATIE_JOB_INTERVAL")
    fldFAC_NOTIFICATIE_JOB_NEXTRUN = GetParam("FAC_NOTIFICATIE_JOB_NEXTRUN")
    pFAC_NOTIFICATIE_JOB_KEY = GetParam("PK_FAC_NOTIFICATIE_JOB_KEY")
    SetVar "sNotificatieRecordErr", sNotificatieRecordErr
    SetVar "FormTitle", sFormTitle
    Parse "NotificatieRecordError", False
  end if
'-------------------------------

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

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

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

  if IsEmpty(pFAC_NOTIFICATIE_JOB_KEY) then bPK = False
  
  sWhere = sWhere & "FAC_NOTIFICATIE_JOB_KEY=" & ToSQL(pFAC_NOTIFICATIE_JOB_KEY, "Number")
  SetVar "PK_FAC_NOTIFICATIE_JOB_KEY", pFAC_NOTIFICATIE_JOB_KEY
'-------------------------------
'-------------------------------
' NotificatieRecord Open Event begin
' NotificatieRecord Open Event end
'-------------------------------

  SetVar "FormTitle", sFormTitle

'-------------------------------
' Build SQL statement and open recordset
'-------------------------------
  sSQL = "select * from FAC_NOTIFICATIE_JOB where " & sWhere
  openrs 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_NOTIFICATIE_JOB_KEY = GetValue(rs, "FAC_NOTIFICATIE_JOB_KEY")

'-------------------------------
' Load data from recordset when form displayed first time
'-------------------------------
    if sNotificatieRecordErr = "" then
      fldFAC_NOTIFICATIE_JOB_OMS = GetValue(rs, "FAC_NOTIFICATIE_JOB_OMS")
      fldFAC_NOTIFICATIE_JOB_VIEW = GetValue(rs, "FAC_NOTIFICATIE_JOB_VIEW")
      fldFAC_NOTIFICATIE_JOB_MODE = GetValue(rs, "FAC_NOTIFICATIE_JOB_MODE")
      fldFAC_NOTIFICATIE_JOB_INTERVAL = GetValue(rs, "FAC_NOTIFICATIE_JOB_INTERVAL")
      fldFAC_NOTIFICATIE_JOB_NEXTRUN = GetValue(rs, "FAC_NOTIFICATIE_JOB_NEXTRUN")
    end if
    SetVar "NotificatieRecordDelete", ""
    SetVar "NotificatieRecordInsert", ""
    Parse "NotificatieRecordEdit", False
'-------------------------------
' NotificatieRecord ShowEdit Event begin
' NotificatieRecord ShowEdit Event end
'-------------------------------
  else
    SetVar "NotificatieRecordEdit", ""
    Parse "NotificatieRecordInsert", False
'-------------------------------
' NotificatieRecord ShowInsert Event begin
' NotificatieRecord ShowInsert Event end
'-------------------------------
  end if
  Parse "NotificatieRecordCancel", false
  if sNotificatieRecordErr = "" then
'-------------------------------
' NotificatieRecord Show Event begin
fldBIT0_STATUS = fldFAC_SRTNOTIFICATIE_MODE AND 1 ' &B0001
fldBIT1_MAIL = fldFAC_SRTNOTIFICATIE_MODE AND 2 ' &B0100
fldBIT2_SMS = fldFAC_SRTNOTIFICATIE_MODE AND 4 ' &B0010
fldBIT3_ALERT = fldFAC_SRTNOTIFICATIE_MODE AND 8 ' &B1000
' Maak dd-mm-jjjj hh:mm:ss
if fldFAC_NOTIFICATIE_JOB_NEXTRUN <> "" then
    fldFAC_NOTIFICATIE_JOB_NEXTRUN = FormatDateTime(rs("FAC_NOTIFICATIE_JOB_NEXTRUN"), 2) + " " + _
                                     FormatDateTime(rs("FAC_NOTIFICATIE_JOB_NEXTRUN"), 4)
end if
' NotificatieRecord Show Event end
'-------------------------------
  end if

'-------------------------------
' Show form field
'-------------------------------
      SetVar "FAC_NOTIFICATIE_JOB_KEY", ToHTML(fldFAC_NOTIFICATIE_JOB_KEY)
      SetVar "FAC_NOTIFICATIE_JOB_OMS", ToHTML(fldFAC_NOTIFICATIE_JOB_OMS)
      SetVar "FAC_NOTIFICATIE_JOB_VIEW", ToHTML(fldFAC_NOTIFICATIE_JOB_VIEW)
      SetVar "FAC_NOTIFICATIE_JOB_MODE", ToHTML(fldFAC_NOTIFICATIE_JOB_MODE)
      SetVar "FAC_NOTIFICATIE_JOB_INTERVAL", ToHTML(fldFAC_NOTIFICATIE_JOB_INTERVAL)
      SetVar "FAC_NOTIFICATIE_JOB_NEXTRUN", ToHTML(fldFAC_NOTIFICATIE_JOB_NEXTRUN)
  Parse "FormNotificatieRecord", False

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

Set rs = Nothing

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