of_update


pfcapsrv.pbl   >   pfc_n_cst_tvsrv_levelsource   >   of_update   

Full name pfc_n_cst_tvsrv_levelsource.of_update
Access public
Extend of integer
Return value integer
Prototype public function integer of_update(integer,boolean,boolean)

Name Datatype
No Data

Name Datatype
lb_focusonerror boolean
lds_updatearray n_ds[]
li_Cnt Integer
li_Index Integer
li_rc Integer
li_Start Integer
lpo_pending powerobject[]

public function integer of_update (integer ai_level, boolean ab_accepttext, boolean ab_resetflags);//////////////////////////////////////////////////////////////////////////////
//
//	Function:	of_Update
//
//	Access:		public
//
//	Arguments:
//	ai_Level			The level for which to update its DataStore.
//							If ai_Level is 0, all DataStores will be updated.
//							NOTE:  There is only one DataStore for all 
//							recursive levels.  So if ai_Level is a recursive level, 
//							all levels using that DataStore will be updated.
//	ab_AcceptText	True - (default) perform an AcceptText prior to the update,
//						False - do not perform an AcceptText.
//	ab_ResetFlags	True - (default) reset the status flags,
//						False - do not reset the flags.
//
//	Returns:		Integer
//					 1	- the level was updated successfully
//					-1	- an error occurred
//
//	Description:	Update the DataStore associated with a level of the TreeView.
//
//////////////////////////////////////////////////////////////////////////////
//
//	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.
//
//////////////////////////////////////////////////////////////////////////////

boolean	lb_focusonerror = False
Integer	li_Index, li_Start, li_Cnt, li_rc
n_ds		lds_updatearray[]
powerobject lpo_pending[]

// Verify passed arguments.
IF IsNull ( ab_AcceptText ) Or IsNull ( ab_ResetFlags ) THEN Return -1 
If IsNull ( ai_level ) or (ai_level < 0) Then Return -1
If IsNull (itv_requestor) or Not IsValid(itv_requestor) Then Return -1

/// Make sure the Object is updateable.
If not itv_requestor.of_IsUpdateable() Then
	return 0
End If

li_Index = UpperBound(inv_attrib)
If ai_Level = 0 Then
	// Update all DataStores
	li_Start = 1
Else
	If ai_Level > li_Index Then
		// If level > li_Index then inv_attrib[li_Index] must be recursive
		If Not inv_attrib[li_Index].ib_Recursive Then Return -1
		ai_Level = li_Index
	End If
	
	li_Start = ai_Level
End If

// Build the Update object list
For li_Cnt = li_Start To li_Index
	If IsValid(inv_attrib[li_Cnt].ids_obj) Then
		lds_updatearray[li_Cnt] = inv_attrib[li_Cnt].ids_obj
	End If
Next

// Perform AcceptText processing (all datastores) prior to update.
IF ab_AcceptText THEN 
	IF itv_requestor.event pfc_accepttext(lds_updatearray, lb_focusonerror) <> 1 THEN Return -1
END IF

// Perform the appropriate update sequence.
CHOOSE CASE ii_updatestyle
	CASE TOPDOWN	
		li_rc = of_Update(lds_updatearray, TOPDOWN, True, True, True ) 	
	CASE BOTTOMUP 
		li_rc = of_Update(lds_updatearray, BOTTOMUP, True, True, True )
	CASE TOPDOWN_BOTTOMUP
		// -- First loop thru the array; top-level datawindow going down the chain.
		//    Performing Inserts and Updates only.  --
		IF of_Update(lds_updatearray, TOPDOWN, True, True, False ) <> 1 Then Return -1
		// -- Second loop thru the array; bottom-level datawindow going up the chain.
		//    Performing Deletes only. --
		li_rc = of_Update(lds_updatearray, BOTTOMUP, False, False, True )
	CASE BOTTOMUP_TOPDOWN
		// -- First loop thru the array; bottom-level datawindow going up the chain.
		//    Performing Deletes only. --
		IF of_Update(lds_updatearray, BOTTOMUP, False, False, True ) <> 1 Then Return -1
		// -- Second loop thru the array; top-level datawindow going down the chain.
		//    Performing Inserts and Updates only.  --
		li_rc = of_Update(lds_updatearray, TOPDOWN, True, True, False )
	CASE CUSTOM
		// perform the specified custom update style
		li_rc = of_UpdateCustom(ii_customupdate)			
	CASE ELSE
		li_rc = -1
END CHOOSE

// Note: One may want to confirm all other updates are succesful 
//	prior to clearing any flags.
IF li_rc = 1 AND ab_ResetFlags THEN 
	li_rc = of_ResetUpdate(ai_level) 
END IF

return 1

end function

     
Name Owner
pfc_n_cst_tvsrv_levelsource.of_update pfc_n_cst_tvsrv_levelsource

     
Name Owner
systemfunctions.isnull systemfunctions
systemfunctions.isvalid systemfunctions
systemfunctions.upperbound systemfunctions
pfc_n_cst_tvsrv_levelsource.of_resetupdate pfc_n_cst_tvsrv_levelsource
pfc_n_cst_tvsrv_levelsource.of_updatecustom pfc_n_cst_tvsrv_levelsource
pfc_n_cst_tvsrv_levelsource.of_update pfc_n_cst_tvsrv_levelsource
pfc_u_tvs.of_isupdateable pfc_u_tvs
pfc_u_tvs.pfc_accepttext pfc_u_tvs

     
Full name
No Data

     
Name Scope
No Data