StrataFrame Forum

When does the editing state get changed to editing state adding?

http://forum.strataframe.net/Topic12356.aspx

By Paul Chase - 11/1/2007

When adding a record when should the editing state change to adding?

I am handling the set default values event of a business object however the editing state is idle.. I would think that is should be adding??

Anyways for now I am can set my own property so I know that values that are set from the set default value event. below

Private Sub BoWoLineItem1_SetDefaultValues() Handles BoWoLineItem1.SetDefaultValues

With BoWoLineItem1

.woi_PayRate = Me.BoWorkOrderHeader1.woh_PayRate

.End With

End Sub

Private Sub BOWoLineItem_FieldPropertyChanged(ByVal sender As Object, ByVal e As BOWoLineItemFieldChangedEventArgs) Handles Me.FieldPropertyChanged

Select Case e.FieldChanged

Case BOWoLineItemFieldNames.woi_PayRate

'-----------------------------------------------

'

'--- Update Check Item Details Reg and OT Hours

'

'-----------------------------------------------

'Check to see if this value was changed due to the set defaul values

If Me.EditingState = MicroFour.StrataFrame.Business.BusinessEditingState.Adding Then

 -> doesnt work replace with custom property?

'bail

Exit Select

End If

By Trent L. Taylor - 11/5/2007

You may want to test on the row state of the BO rather than the editing state.  For example:

If Me.CurrentRow.RowState = Adding Then
   '-- add your logic
End If

This will provide a more granular depiction as to what is going on within the record itself.  But the editing state gets set after the row has been added and the default values event has been raised.  So if you have just called the Add() method, it will call the NewRow within the BusinessLayer which raises the OnSetDefaultValues() and the last call it makes is the SetEditingState. 

By Paul Chase - 11/6/2007

I didnt see this before. thats perfect thanks trent
By Trent L. Taylor - 11/6/2007

No problem Smile