|
of_save
|
|
Full name
|
pfc_n_cst_dwsrv_linkage.of_save
|
Access
|
protected
|
Extend of
|
integer
|
Return value
|
integer
|
Prototype
|
protected function integer of_save(long,boolean)
|
Name
|
Datatype
|
CANCEL
|
integer
|
lb_updateonly
|
boolean
|
ldw_root
|
u_dw
|
li_checkcolumn
|
integer
|
li_cnt
|
integer
|
li_i
|
integer
|
li_option
|
integer
|
li_rc
|
Integer
|
li_upper
|
integer
|
ll_checkrow
|
long
|
lpo_saveobjects
|
powerobject[]
|
ls_checkcolname
|
string
|
ls_msgparm
|
string[]
|
ls_option
|
string
|
lw_obj
|
w_master
|
NO_UPDATE
|
integer
|
protected function integer of_save (long al_validaterow, boolean ab_prompt);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_Save
//
// Access: protected
//
// Arguments:
// al_validaterow If >0 then the row to be tested.
// if <=0 then there is no row to be tested.
// ab_prompt If the user should be prompted.
//
// Returns: Integer
// 3 if the save operation was cancelled for any reason.
// 2 if the user choose to not have an update and loose
// any pending changes.
// 1 if the save operation was successful.
// 0 if there are no updates pending.
// -1 if an error occurs.
//
// Description:
// Perform the save process.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 6.0 Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////
//constant integer NO_ACTION = 0
constant integer NO_UPDATE = 2
constant integer CANCEL = 3
Integer li_rc
integer li_i
integer li_option
string ls_msgparm[]
string ls_option
long ll_checkrow
integer li_checkcolumn
string ls_checkcolname
boolean lb_updateonly = True
integer li_upper
integer li_cnt
w_master lw_obj
u_dw ldw_root
powerobject lpo_saveobjects[]
// Validate the arguments.
If IsNull(al_validaterow) or IsNull(ab_prompt) Then
Return FAILURE
End if
// Validate the required reference.
If IsNull(idw_requestor) or Not IsValid(idw_requestor) Then
Return FAILURE
End If
// Get the root datawindow.
of_FindRoot(ldw_root)
If IsNull(ldw_root) or NOt IsValid(ldw_root) Then
Return FAILURE
End If
// Get the parent window.
idw_requestor.Function of_GetParentWindow(lw_obj)
If IsNull(lw_obj) or Not IsValid(lw_obj) Then
Return FAILURE
End If
// Make sure all data has been accepted.
li_rc = of_AcceptText (True)
If li_rc <=0 Then
Return CANCEL
End If
// Determine if there are any updates pending.
li_rc = of_GetUpdatesPending ()
If li_rc <0 Then
Return CANCEL
End If
// Check if there are updates pending.
If li_rc = 0 Then
Return NO_ACTION
End If
// -- Updates are pending. --
// Determine, if there is a specific row that needs to be validated.
If al_validaterow > 0 Then
// Check for Missing Required Fields on the row.
ll_checkrow = al_validaterow
li_checkcolumn = 1
li_rc = of_CheckRequired &
(primary!, ll_checkrow, li_checkcolumn, ls_checkcolname, lb_updateonly)
if (li_rc < 0) or (ll_checkrow = al_validaterow) Then
// There was an error or missing data.
Return CANCEL
End If
// Perform dw specific validation.
li_rc = idw_requestor.Event pfc_RowValidation (al_validaterow)
If li_rc <= 0 Then
// There was an error validating the data.
Return CANCEL
End If
End If
// Prompt the user about the change?
If ab_prompt Then
If of_ConfirmOnRowChange() Then
If IsValid(gnv_app.inv_error) Then
li_option = gnv_app.inv_error.of_Message('pfc_dwlinkage_rowchanging', ls_msgparm, &
gnv_app.iapp_object.DisplayName)
Else
li_option = of_MessageBox('pfc_linkage_savenow', gnv_app.iapp_object.DisplayName, &
'Updates are pending. ~r~nSave them now?', Exclamation!, YesNoCancel!, 1)
End If
Else
li_option = 1
End If
If li_option = 2 Then
// 'No button' No update wanted, loose all pending updates.
Return NO_UPDATE
ElseIf li_option >= 3 Then
// 'Cancel button' Don't want to save but keep all pending updates.
Return CANCEL
End If
End If
// Set the objects to be saved by the Window save process.
lpo_saveobjects[1] = ldw_root
// Add any other objects which have been requested for the save.
li_upper = UpperBound (ipo_othersaveobjects)
For li_cnt = 1 to li_upper
lpo_saveobjects[li_cnt +1] = ipo_othersaveobjects[li_cnt]
Next
// Save the requested objects.
li_rc = lw_obj.Event pfc_SaveObjects (lpo_saveobjects)
If li_rc < 0 Then
Return FAILURE
ElseIf li_rc = 0 Then
Return NO_ACTION
End If
// Successfulsave was performed.
If Len(is_savesound) > 0 Then
If IsNull(inv_platform) or Not IsValid(inv_platform) Then
// Start the appropriate platform service.
f_SetPlatform (inv_platform, True)
End If
If IsValid(inv_platform) Then
inv_platform.of_PlaySound(is_savesound, True)
End If
End If
Return SUCCESS
end function