StrataFrame Forum

BO not getting Dirty...

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

By Edhy Rijo - 3/31/2009

I have a form with 2 BO Parent and Child, I have done this many time using a ChildFormDialog, what have changed in this case is that in the ChildForm I need to add many records at the same time, not just one as usual in a ChildFormDialog situation. So I have done is in the child form I added another instance of the child BO and add all the records there, then I use the BO.CopyFrom to update the translated child BO, but at this stage the translated child bo does not get dirty, so when saving, all those records are not saved.



This is the code in the "OK" commandbutton of the child form:



Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click

Me.BizInventoryItems1.Filter = ""

Me.BizInventoryItems1.CopyDataFrom(Me.BizInventoryItemsForListView, MicroFour.StrataFrame.Business.BusinessCloneDataType.AppendDataToTableFromDefaultView)



DialogResult = Windows.Forms.DialogResult.OK

End Sub




What am I missing here that will not set the me.BizInventoryItems1 bo dirty so it can be properly saved at the parent form?
By Trent L. Taylor - 3/31/2009

If you set this same BO on the parent form, does it become dirty (in other words not translated)?  I bet it will which means that the actual reference object that you are dealing with is probably the one on the child form not the reference of the one on the parent.  You may want to put a debug in the OnLoad after the MyBase.OnLoad() is called and see if they are the same reference object...that would be the first place I would look so I could at least determine if this is my issue.
By Edhy Rijo - 4/1/2009

Let me clarify this a bit more:

In the parent form I have the following BOs:



bizInventory1 -> Parent

bizInventoryItems1 -> Child



These BOs are translated via a ChildDialog into a child form which have the following BOs:



bizInventory1 -> Parent

bizInventoryItems1 -> Child

bizInventoryItemsForListView -> This is the same type of the child BO bizInventoryItems1, all new records are added to this bo and when done, the records are copied to the bizInventoryItems1, the form is close and in the parent form the bizInventoryItems1 has all records added in the child form, but the bizInventoryItems1.IsDirty is False and when I try to save the data, the child records are not saved.





I am doing it this way because in the parent form the child bo bizInventoryItems1 may have previous records that I do not want to be shown in the child form when adding more records. I tried calling the Let me clarify this a bit more:

In the parent form I have the following BOs:



bizInventory1 -> Parent

bizInventoryItems1 -> Child



These BOs are translated via a ChildDialog into a child form which have the following BOs:



bizInventory1 -> Parent

bizInventoryItems1 -> Child

bizInventoryItemsForListView -> This is the same type of the child BO bizInventoryItems1, all new records are added to this bo and when done, the records are copied to the bizInventoryItems1, the form is close and in the parent form the bizInventoryItems1 has all records added in the child form, but the bizInventoryItems1.IsDirty is False and when I try to save the data, the child records are not saved.





I am doing it this way because in the parent form the child bo bizInventoryItems1 may have previous records that I do not want to be shown in the child form when adding more records.

.Edit() in the listview.ChildFormResults() but did not made a difference, any of the new added records are never saved to the database.



Any other idea where I may start looking?