Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
IsChanged and CheckRules
Message
General information
Forum:
Visual FoxPro
Category:
The Mere Mortals Framework
Title:
IsChanged and CheckRules
Miscellaneous
Thread ID:
00979318
Message ID:
00979318
Views:
41
Kevin,

There are some problems with the Ischanged method and the CheckRules method. Basically the ischanged doesn't work correctly with table buffered views. We changed the ischanged method of the ccursor class to the following:
*--------------------------------------------------
*-- Table buffering is on for this table / cursor
*-- use GETNEXTMODIFIED. Set the llIschanged
*-- flag accordingly.
*--------------------------------------------------
	LOCAL lnRecno, lcAlias, lcFldState

	lcAlias = THIS.GetAlias()

	lnRecno = RECNO(lcAlias) && Save the current record position
	lnNextModified = GETNEXTMODIFIED(0,lcAlias)

*llIsChanged = IIF(lnNextModified = 0, .F., .T.)
*-- CHANGE - WGB - January 21, 2005 - 10:36:24

* Code from Marcia Akins thread #941853
	DO WHILE lnNextModified # 0
		GO m.lnNextModified IN ( lcAlias )
		lcFldState = NVL(THIS.GetFieldState(-1, lcAlias),"") && NVL( GETFLDSTATE( -1, lcALias ), '' )
		IF NOT EMPTY( CHRTRAN( lcFldState, '13', '' ) )
*** Change is real - exit stage left
			llIsChanged = .T.
			EXIT
		ENDIF

		lnNextModified = GETNEXTMODIFIED(lnNextModified,lcAlias)

	ENDDO
	IF BETWEEN(lnRecno, 0, RECCOUNT(lcAlias))
		GOTO lnRecno IN lcAlias
	ENDIF
Also, It doesn't make sense to issue a table update on a record that is new and empty, so the following code was implemented:
	IF !This.IsNewAndEmpty() && JMW 01/21/05
		lnRetVal = loExecutant.SAVE(tlAllRows, tlForce)
	ELSE 
		lnRetVal = FILE_OK
	ENDIF 
It also doesn't make sense to check the rules if there are no changes, so the following was also implemented:
IF TYPE('This.oBizRules') == 'O' AND This.Ischanged() && JMW
  	This.oBizRules.ClearAllRules()
	This.oBizRules.CheckRules()
	llRetVal = This.oBizRules.GetCount() = 0
ENDIF
Should you decide to release another version of the framework, please take these changes under consideration.
Reply
Map
View

Click here to load this message in the networking platform