StrataFrame Forum

BO.CopyDataFrom() for new records

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

By Edhy Rijo - 6/6/2009

Trent,



I am adding new record to a temporary BO, then from the MainBO I use the MainBO.CopyDataFrom(TempBO, AppendDataToTableFromDefaultView) to move those records to the main BO, I noticed from the help file that the row state of the TemporaryBO are accepted, then those records needs to be identify and modified in the MainBO in order to change their state, I have the following code witch works, but I wonder if there is any shortcut to avoid having to enumerate the MainBO:





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

'-- Move the new record to the BizTransactionItemsStock1 BO

' and clear the temporary BO

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

If Me.BizTransactionItemsStock_ForNewRecords.Count > 0 Then

'-- Reset filter condition to show all selected cards.

Me.BizTransactionItemsStock1.Filter = ""



'-- Copy new records to the main Stock BO

Me.BizTransactionItemsStock1.CopyDataFrom(Me.BizTransactionItemsStock_ForNewRecords, BusinessCloneDataType.AppendDataToTableFromDefaultView)

Me.BizTransactionItemsStock_ForNewRecords.Clear()



'-- Loop through all new records as set their state as Added.

Me.BizTransactionItemsStock1.Filter = "PK_TransactionItemsStock < 0"

For Each StockBO As bizTransactionItemsStock In Me.BizTransactionItemsStock1.GetEnumerable

StockBO.CurrentRow.SetAdded()

Next



End If

By Trent L. Taylor - 6/6/2009

If you are wanting the row states to be "Added" then what you are doing will work great since, as you mentioned, the Row State will be "Unchanged."  Long term an additional option may be helpful here to allow the RowStates to be left intact.
By Edhy Rijo - 6/6/2009

Trent L. Taylor (06/06/2009)
Long term an additional option may be helpful here to allow the RowStates to be left intact.


Are you a mind reader also? Tongue



With that option, probably you may just condition the "CurrentRow.AcceptChanges()" in the BusinessLayer.vb class.



P.S.

I am also falling in love with the BO.Filter functionality, in this project I have to do a lot of data manipulation and from my young experience with SF/.NET this has been much more easier than working with VFP cursors.



Thanks again!
By Trent L. Taylor - 6/6/2009

Are you a mind reader also?

LOL...I have my moments! BigGrin

I am also falling in love with the BO.Filter functionality, in this project I have to do a lot of data manipulation and from my young experience with SF/.NET this has been much more easier than working with VFP cursors.

Thanks!  I am really glad to hear that it is meeting your needs!!! Smile