File: D:/web/secure/csl/bam/admin/edit.asp
<%Option Explicit%>
<%
Session("MenuShowMain") = True ' (SS,3/3/03)
%>
<!--#include virtual="bam1/dbfunctions.asp"-->
<!--#include virtual="bam1/commonutils.asp"-->
<!--#include file="apputils.asp"-->
<!--#include file="editutils.asp"-->
<!--#include file="heading.asp"-->
<!--#include file="authenticate.asp"-->
<%
' (SS,22/10/15) added CanUpdate
If gbAuthenticated And CanUpdate Then
Dim gsEditID, gsKey, gsError, gsButton, gsForceMode, gsFormName
Dim gsShowRecordsID, gsShowRecordsField, gsShowRecordsStart, gsShowRecordsEnd
Dim gbEditRetry, gbIncludeDateValidation
gsEditID = ""
gsKey = ""
gsError = ""
gsForceMode = ""
gsFormName = ""
gbEditRetry = False
gbIncludeDateValidation = False
gsEditID = Request.QueryString("id")
If gsEditID = "" Then gsEditID = Request.Form("id")
gsKey = Request.QueryString("key")
If gsKey = "" Then gsKey = Request.Form("key")
gsFormName = Request.Form("uFormName")
gsShowRecordsID = Session("ShowRecordsID")
'gsShowRecordsField = Session("ShowRecordsField")
'gsShowRecordsStart = Session("ShowRecordsStart")
'gsShowRecordsEnd = Session("ShowRecordsEnd")
gsButton = Request.Form("uButton")
gsShowRecordsField = Request.Form("ShowRecordsField")
gsShowRecordsStart = Request.Form("ShowRecordsStart")
gsShowRecordsEnd = Request.Form("ShowRecordsEnd")
' if ShowRecordsID has a value then save all values in Session
If gsShowRecordsID <> "" Then
' if previously not "TableView" form then get values from session
If gsFormName <> "TableView" Then
gsShowRecordsField = Session("ShowRecordsField")
gsShowRecordsStart = Session("ShowRecordsStart")
gsShowRecordsEnd = Session("ShowRecordsEnd")
Else
Session("ShowRecordsID") = gsShowRecordsID
Session("ShowRecordsField") = gsShowRecordsField
Session("ShowRecordsStart") = gsShowRecordsStart
Session("ShowRecordsEnd") = gsShowRecordsEnd
End If
End If
Dim gsTableName, gsKeyField, gbShowAll, gbAllowView, gbAllowEdit, gbAllowAdd, gbAllowDelete, gnColumns
Dim gnAccessView, gnAccessEdit, gnAccessAdd, gnAccessDelete, gsViewOrderBy, gsViewTable
Const MAXFIELDS = 32
' used 32 in following because CONST MAXFIELDS doesn't work
Dim gasFieldName(32), gasPromptName(32), ganWidth(32), gabLink(32)
Dim gasFieldType(32), gasEditType(32), gasReadOnly(32), gasLookupID(32), ganHeight(32)
Dim gabRequired(32), gasValidation(32), gasPicture(32)
' (SS,6/12/14) added gasLKDisplayFieldName(32), allows string to be displayed and ID to be stored
Dim gasLKFieldName(32), gasLKDisplayFieldName(32), gasLKTableName(32), gabLKAllowBlank(32), gasFieldValue(32)
' --- GET EDIT DETAILS FROM SETTINGS DATABASE ---
If gsEditID <> "" Then
GetEditSettings(False)
End If
' --- END OF EDIT DETAILS FROM SETTINGS DATABASE ---
' if a button was pressed, e.g. Add, Save, Cancel, Delete
If gsButton <> "" Then
gsErrorMessage = ""
If gsButton = "Save" Then
SaveRecord
If gsADOErrors <> "" Then
Response.Write("<BR><BR>" + gsADOErrors)
gsForceMode = "EDITFORM" ' *** go back to EDIT FORM mode, need to sort what it displays
gbEditRetry = True ' to retry with previous values as defaults
' if previously it was a new record then assume the same again so readonly fields are editable
If Request.Form("uIsNewRecord") = "True" Then
gsButton = "Add"
End If
Else
Response.Write("<BR><BR>Record has been saved.")
End If
ElseIf gsButton = "Delete" Then
DeleteRecord
If gsADOErrors <> "" Then
Response.Write("<BR><BR>" + gsADOErrors)
ElseIf gsErrorMessage <> "" Then ' (SS,8/12/14) if gsErrorMessage is set when related record check finds record and record isn't deleted
Response.Write("<BR><BR>Record deletion failed.")
Else
Response.Write("<BR><BR>Record has been deleted.")
End If
End If
' show error message if defined
If gsErrorMessage <> "" Then
Response.Write("<BR><BR><Strong>" + gsErrorMessage + "</Strong>")
End If
End If
' --- DISPLAY TABLE VIEW ---
If gsEditID <> "" And gsKey = "" And gsError = "" And gsForceMode <> "EDITFORM" And gsButton <> "Add" Then
GetEditSettings(True) ' get view details *** need to tidy this, because it called earlier unnecessarily
' if allowed to view then show
If gnAccessLevel >= gnAccessView Then
Response.Write("<BR><BR><Strong><font size=""4"">" + gsTableName + "</font></Strong>")
ShowTableView
Else
Response.Write("<BR><BR><Strong>You do not have permission to view this table.</Strong>")
End if
End If
' --- END OF DISPLAY TABLE VIEW ---
' --- DISPLAY EDIT FORM ---
If (gsForceMode = "EDITFORM") or (gsButton = "Add") or (gsEditID <> "" And gsKey <> "" And gsError = "") Then
Response.Write("<BR><BR><Strong><font size=""4"">" + gsTableName + "</font></Strong>")
If gsButton = "Add" Then
ShowEditForm(True)
Else
ShowEditForm(False)
End If
End If
' --- END OF DISPLAY EDIT FORM ---
End If 'If gbAuthenticated Then
%>
<!--#include file="footing.asp"-->