//*******************************************************************************
// Verify Optimistic Record
Locking and Lock (Allocate) Records Pending Update
//*******************************************************************************
BegSr LockRecordsPendingUpdate
DclSrParm
intContactUniqueID Type(*integer4)
By(*reference)
DclSrParm
boolErrors
Type(*boolean)
By(*reference)
DclSrParm
boolProceedWithUpdate Type(*boolean) By(*reference)
boolProceedWithUpdate = *true
// error message html table is not visible
DclFld
boolCursorPosReqd Type(*boolean)
// confirm we are in update mode
if (ViewState["vsv_ProcessingMode"].ToString() =
"Update")
// open DB files to update
open ContactsByUnqContactID
open updcustomer
// open "memory files" (external data
structures whose record format contains all
// relevent fields requiring
concurrency)(could be combined into one)
open memfilContactUpdFlds
open memfilCustomerUpdFlds
// access by key and lock record to update in each
file
jcsky =
intContactUniqueID // input parameter
chain ContactsByUnqContactID key(jcsky) err(*extended) access(*dft)
// using jcstmr, jctype from ContactsByUnqContactID
chain updcustomer key(jcstmr,
jctype) err(*extended)
access(*dft)
// write/add a record to each memory file/dataset
with the current values
write memfilContactUpdFlds
write memfilCustomerUpdFlds
// check whether contact record has changed since
initially displayed for update
if (ContactsByUnqContactID.IsEof) *or +
(memfilContactUpdFlds.DataSet.GetXml().ToString() <> +
ViewState["vsv_strB4ContactRcdXML"].ToString())
boolProceedWithUpdate = *false
// write an error message row to a html table
// position cursor & highlight background color
in UI textbox control, tbCtcName
*base.srWrtErrorMsgRow(*ByRef tblErrorList1, +
"Someone has updated your contact information since you first accessed
this +
web page. It is likely someone from our corporate office +
has made the update. We apologize for the +
inconvenience. If you still wish to change your
information, +
please click on the Refresh button and then re-enter your changes.", +
*ByRef boolCursorPosReqd, *ByRef boolErrors, tbCtcName *as WebControl, +
*nothing, *nothing,
*nothing)
else
if (updcustomer.IsEof) *or +
(memfilCustomerUpdFlds.DataSet.GetXml().ToString() <> +
ViewState["vsv_strB4CustomerRcdXML"].ToString())
boolProceedWithUpdate = *false
*base.srWrtErrorMsgRow(*ByRef tblErrorList1, +
"Someone has updated your customer level information since you first +
accessed this web page. It is likely someone from our +
corporate office has made the update. We apologize for +
the inconvenience. If you still wish to change your +
information, please click on the Refresh button and then re-enter +
your changes.", +
*ByRef boolCursorPosReqd, *ByRef boolErrors, +
tbCtcName *as WebControl, *nothing, *nothing,
*nothing)
endif
endif
close memfilContactUpdFlds
close memfilCustomerUpdFlds
//***********
// if not proceeding with update, begin process to
reverse update process
//***********
if (NOT boolProceedWithUpdate)
// if record no longer exists (shouldn't) or the
record has changed, unlock it
if (ContactsByUnqContactID.IsFound)
unlock ContactsByUnqContactID
endif
close ContactsByUnqContactID
if (updcustomer.IsFound)
unlock updcustomer
endif
close updcustomer
btnRefresh.Visible = *true
LeaveSr
endif
//*******
// proceeding with update, boolProceedWithUpdate
remains = *true
//*******
endif
endsr
|