Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Default value changes to KBizObj
Message
From
21/05/2001 11:52:46
Rex Mahel
Realm Software, Llc
Ohio, United States
 
 
To
21/05/2001 11:47:55
Rex Mahel
Realm Software, Llc
Ohio, United States
General information
Forum:
Visual FoxPro
Category:
The Mere Mortals Framework
Miscellaneous
Thread ID:
00509507
Message ID:
00509510
Views:
22
Kevin,

Sorry, I missed a couple of methods:

* Program....: KBizObj.PreSaveHook
* Version....: 1.0
* Author.....: Rex L. Mahel
* Date.......: February 28, 2001
* Notice.....: Copyright (c) 2001 Realm Software, Inc., All Rights Reserved.
* Compiler...: Visual FoxPro 06.00.8961.00 for Windows
* Abstract...:
* Changes....:
IF CURSORGETPROP("SOURCETYPE") <> DB_SRCTABLE
*--------------------------------------------
*--- If cursor is table buffered, scan all
*--- records, and set the state of the
*--- primary key field to "Edited"
*--------------------------------------------
IF CURSORGETPROP('BUFFERING') = DB_BUFOPTTABLE
SCAN
IF IsAdding(ALIAS())
This.SetFKDefault()
ENDIF
ENDSCAN
GOTO TOP
ELSE
IF IsAdding(ALIAS())
This.SetFKDefault()
ENDIF
ENDIF
ENDIF


In KBizObj.OnNew:

Add:

This.SetDefaultValues()

befoe:

IF NOT EMPTY(lcSaveDBC)
SET DATABASE TO (lcSaveDBC)
ENDIF


Thanks again

Rex



>Kevin,
>
>Could you make the following changes to KbizObj to allow setting default value in the OnNew method and setting foreign key values in the PreSaveHook method.
>
>Add the following properties:
>
>ADefaultValues[1,2]: An array property that contains default value info for the Business Object's InitialSelectedAlias. Row 1 contains the field name, row 2 contains the expression that sets the value for that field. PostInitHook is a good place to populate this array.
>
>AFKDefaultValues[1,2]:An array property that contains default value info for the Business Object's InitialSelectedAlias. Row 1 contains the field name, row 2 contains the expression that sets the value for that field. PostInitHook is a good place to populate this array.
>
>
>Add the following methods:
>
>AddDefaultValue():
>
>* Program....: KBizObj.AddDefaultValue
>* Version....: 1.0
>* Author.....: Rex L. Mahel
>* Date.......: February 23, 2001
>* Notice.....: Copyright (c) 2001 Realm Software, Inc., All Rights Reserved.
>* Compiler...: Visual FoxPro 06.00.8862.00 for Windows
>* Abstract...: Populate the aDefaultValue array for later use.
>* Changes....:
>LPARAMETER tcName, tcExpr
>LOCAL ;
> lnRows
>
>lnRows = ALEN(This.aDefaultValues,1)
>
>*!*************************************************
>*!* If this is not the first view parameter to be
>*!* added, add a new row to the array property
>*!*************************************************
>IF ! EMPTY(This.aDefaultValues[1,1])
> lnRows = lnRows + 1
> DIMENSION This.aDefaultValues[lnRows,2]
>ENDIF
>
>*!*****************************************************
>*!* Store the specified valaues in the array property
>*!*****************************************************
>This.aDefaultValues[lnRows,1] = tcName
>This.aDefaultValues[lnRows,2] = tcExpr
>
>
>SetDefaultValues():
>
>* Program....: KBizObj.SetDefaultValues
>* Version....: 1.0
>* Author.....: Rex L. Mahel
>* Date.......: February 23, 2001
>* Notice.....: Copyright (c) 2001 Realm Software, Inc., All Rights Reserved.
>* Compiler...: Visual FoxPro 06.00.8862.00 for Windows
>* Abstract...: Populate new record fields with values from supplied expression.
>* Changes....:
>IF ! This.HasDefaultValues()
> RETURN
>ENDIF
>
>LOCAL ;
> loSelect,;
> lcField,;
> lcExpr,;
> lcFieldState
>
>loSelect = This.SelectAlias()
>
>*-------------------------------------
>*--- Set all default values (if any)
>*-------------------------------------
>FOR lnCount = 1 TO ALEN(This.aDefaultValues,1)
> lcField = This.aDefaultValues[lnCount,1]
> lcExpr = This.aDefaultValues[lnCount,2]
> REPLACE (lcField) WITH &lcExpr
>ENDFOR
>
>
>HasDefaultValues():
>* Program....: RKBizObj.HasDefaultValues
>* Version....: 1.0
>* Author.....: Rex L. Mahel
>* Date.......: February 26, 2001
>* Notice.....: Copyright (c) 2001 Realm Software, Inc., All Rights Reserved.
>* Compiler...: Visual FoxPro 06.00.8862.00 for Windows
>* Abstract...: Does this business object have any default values defined?
>* Changes....:
>RETURN ! EMPTY(This.aDefaultValues[1,1])
>
>
>SetDefaultValueState():
>* Program....: RKBizObj.SetDefaultValueState
>* Version....: 1.0
>* Author.....: Rex L. Mahel
>* Date.......: February 23, 2001
>* Notice.....: Copyright (c) 2001 Realm Software, Inc., All Rights Reserved.
>* Compiler...: Visual FoxPro 06.00.8862.00 for Windows
>* Abstract...: Sets the default value field's state so they will be saved to the base table
>* Changes....:
>IF ! This.HasDefaultValues()
> RETURN
>ENDIF
>
>LOCAL ;
> llTableBuffered,;
> liCount,;
> lcField
>
>llTableBuffered = INLIST(CURSORGETPROP('Buffering'),DB_BUFLOCKTABLE,DB_BUFOPTTABLE)
>
>*-----------------------------------
>*--- Set all default field states
>*-----------------------------------
>FOR liCount = 1 TO ALEN(This.aDefaultValues,1)
> lcField = This.aDefaultValues[liCount,1]
> IF llTableBuffered
> SCAN
> IF IsAdding(ALIAS())
> This.SetFldState(lcField)
> ENDIF
> ENDSCAN
> ELSE
> IF IsAdding(ALIAS())
> This.SetFldState(lcField)
> ENDIF
> ENDIF
>ENDFOR
>
>
>
>
>AddFKDefaultValue():
>
>* Program....: KBizObj.AddDefaultValue
>* Version....: 1.0
>* Author.....: Rex L. Mahel
>* Date.......: February 23, 2001
>* Notice.....: Copyright (c) 2001 Realm Software, Inc., All Rights Reserved.
>* Compiler...: Visual FoxPro 06.00.8862.00 for Windows
>* Abstract...: Adds foreign key default values for later replacement
>* Changes....:
>LPARAMETER tcName, tcExpr
>LOCAL ;
> lnRows
>
>lnRows = ALEN(This.aFKDefaultValues,1)
>
>*!*************************************************
>*!* If this is not the first view parameter to be
>*!* added, add a new row to the array property
>*!*************************************************
>IF ! EMPTY(This.aFKDefaultValues[1,1])
> lnRows = lnRows + 1
> DIMENSION This.aFKDefaultValues[lnRows,2]
>ENDIF
>
>*!*****************************************************
>*!* Store the specified valaues in the array property
>*!*****************************************************
>This.aFKDefaultValues[lnRows,1] = tcName
>This.aFKDefaultValues[lnRows,2] = tcExpr
>
>
>
>
>
>
>
>
>SetFKDefault():
>
>* Program....: KBizObj.SetFKDefault
>* Version....: 1.0
>* Author.....: Rex L. Mahel
>* Date.......: February 23, 2001
>* Notice.....: Copyright (c) 2001 Realm Software, Inc., All Rights Reserved.
>* Compiler...: Visual FoxPro 06.00.8862.00 for Windows
>* Abstract...: Populates the foreign key default fields from the aFKDefault array
>* Changes....:
>IF ! This.HasFKDefault()
> RETURN
>ENDIF
>
>LOCAL ;
> lnCount,;
> lcField,;
> lcExpr,;
> liGetFldState
>
>*-----------------------------------------
>*--- Set all foreign key values (if any)
>*-----------------------------------------
>llTableBuffered = INLIST(CURSORGETPROP('Buffering'),DB_BUFLOCKTABLE,DB_BUFOPTTABLE)
>
>*-------------------------------------
>*--- Set all foreign key values (if any)
>*-------------------------------------
>FOR lnCount = 1 TO ALEN(This.aFKDefaultValues,1)
> lcField = This.aFKDefaultValues[lnCount,1]
> lcExpr = This.aFKDefaultValues[lnCount,2]
> IF llTableBuffered
> SCAN
> IF IsAdding(ALIAS())
> REPLACE (lcField) WITH &lcExpr
> ENDIF
> ENDSCAN
> GO TOP
> ELSE
> IF IsAdding(ALIAS())
> REPLACE (lcField) WITH &lcExpr
> ENDIF
> ENDIF
>ENDFOR
>
>
>HasFKDefault()
>
>* Program....: KBizObj.HasFKDefault
>* Version....: 1.0
>* Author.....: Rex L. Mahel
>* Date.......: February 27, 2001
>* Notice.....: Copyright (c) 2001 Realm Software, Inc., All Rights Reserved.
>* Compiler...: Visual FoxPro 06.00.8961.00 for Windows
>* Abstract...: Does this business object have any foreign keys defined?
>* Changes....:
>RETURN ! EMPTY(This.aFKDefaultValues[1,1])
>
>
>SetFldState():
>* Program....: RkBizObj.SetFldState
>* Version....: 1.0
>* Author.....: Rex L. Mahel
>* Date.......: February 28, 2001
>* Notice.....: Copyright (c) 2001 Realm Software, Inc., All Rights Reserved.
>* Compiler...: Visual FoxPro 06.00.8961.00 for Windows
>* Abstract...: Sets the field state for the given field
>* Changes....:
>LPARAMETER tcField
>
>LOCAL ;
> lcFieldState,;
> lcFieldStateD
>
>lcFieldState = GETFLDSTATE(tcField)
>lcFieldStateD = ;
> IIF(INLIST(lcFieldState,2,4),lcFieldState,;
> IIF(lcFieldState = 1,2,4))
>
>SETFLDSTATE(tcField,lcFieldStateD)
>
>
>Note that SetDefaultValueState is not being used. It changes the state of the given field after the value is changed, so if the user presses ESCAPE, the edit will stop without an “Are you wure?” message.
>
>I subclassed my KbizObj class first and added the above, but I want the functionality in such objects as KmoverObj and other Kevin created objects.
>
>Thanks
>
>Rex
Previous
Reply
Map
View

Click here to load this message in the networking platform