runtime business object creation


Author
Message
Fabian R Silva, -
Fabian R Silva, -
StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)
Group: StrataFrame Users
Posts: 153, Visits: 1.2K
Hi guys, I try to make a generic ABM, on it I dropped a "copy" button and it must copy the current record of the primary business object on a private business object



example: I'm retrieving on the ABM a product's table, my currentrowindex is 23 and I like to copy this on a temporary business object with only this record, I not sure how to declare the private variable



private _boCopy as XXXXXX



XXXXX mean that I known what is the primary object (the form property say it) but I don't known how to say something like

dim _boCopy as (the type of Myform.PrimaryBusinessObject)



Thanks and sorry for me newbie questions w00t
Fabian R Silva, -
Fabian R Silva, -
StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)
Group: StrataFrame Users
Posts: 153, Visits: 1.2K
I not sure if I clear on the last post, I try to make something like the VFP "scat memo" / appe blank / "gath memo" to copy a record into another new record, I not sure if a temporal 1-row business object is the correct stuff to do

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Well, a business object has a CopyDataFrom method that allows data from one BO to be copied to another.  This also has some overloads and parms that allow you to specify whether you want to copy the filtered BO (DefaultView) or the CurrentDataTable which ignores the filter.  So if you want to copy a single record, apply a filter to the source BO then call the CopyDataFrom on the destination BO using a DefaultView option.

SourceBO.Filter = "MyPK = " & SourceBO.MyPk.ToString()
DestBO.CopyDataFrom(SourceBO,ClearAndFillFromDefaultView)

Fabian R Silva, -
Fabian R Silva, -
StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)
Group: StrataFrame Users
Posts: 153, Visits: 1.2K
thanks for reply, my question I think is more a .net question about object types, I don't sure how to define the destination object in run time without known what type of BO it is



Example:I have a me.PrimaryBusinessObject, when I press a "Copy" button I handle it....



Sub Copy_Click

' I like to copy the current record on the me.Primarybusinessobject to a variable

' called _CopyBO (it can be testbo1, otherBo1 or another BO)

dim _CopyBO as XXXXXXX '<--- how I declare the type of the primarybusinessobject here?

'Copy the row from XXXBO1 to _CopyNO....

' some code here....

end sub



--------------------

Thanks Smile
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
You will want to use the base class which would be BusinessLayer:

Dim _CopyBO As MicroFour.StrataFrame.Business.BusinessLayer

This will allow any BO to be passed into that variable while giving you the ability to reference all of the base classes.  If you want to have the type of BO passed in then you will want to take a more technical approach using Generics.  This is a more length explanation as Generics are a wonderful tool but they require more explanation.

Fabian R Silva, -
Fabian R Silva, -
StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)
Group: StrataFrame Users
Posts: 153, Visits: 1.2K
Trent L. Taylor (09/24/2007)
Well, a business object has a CopyDataFrom method that allows data from one BO to be copied to another. This also has some overloads and parms that allow you to specify whether you want to copy the filtered BO (DefaultView) or the CurrentDataTable which ignores the filter. So if you want to copy a single record, apply a filter to the source BO then call the CopyDataFrom on the destination BO using a DefaultView option.



SourceBO.Filter = "MyPK = " & SourceBO.MyPk.ToString()

DestBO.CopyDataFrom(SourceBO,ClearAndFillFromDefaultView)




how I can say something like "MyPK = " & SourceBO.MyPK.Tostring() in a general manner to filter the current record? I say something like:



me.primarybusinessObject.filter = me.primarybusinessObject.PrimaryKeyField.Tostring() & "=" & me.primarybusinessobject.(me.PrimaryBusinessObject.PrimaryKeyField.tostring())



Thanks and sorry for all the questions w00t
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yes, Fabian, that will work, but you'll need to make sure that you remove the filter when you're done or you won't be able to Navigate or Move to any new records.
Fabian R Silva, -
Fabian R Silva, -
StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)
Group: StrataFrame Users
Posts: 153, Visits: 1.2K
How To obtain the current record from the PrimaryBusinessObject of a Form



in the last post I try to obtain the current record but I don't known how to set the filter



I try with



me.primarybusinessObject.filter = me.primarybusinessObject.PrimaryKeyField.Tostring() & "=" & me.primarybusinessobject.(me.PrimaryBusinessObject.PrimaryKeyField.tostring())



but this doesn't work, after some googling I see that I can use:





Me.PrimaryBusinessObject.Filter = Me.PrimaryBusinessObject.PrimaryKeyField & " = " & Me.PrimaryBusinessObject(Me.PrimaryBusinessObject.PrimaryKeyField)





Sorry for all those questions and thanks for all Smile
Fabian R Silva, -
Fabian R Silva, -
StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)
Group: StrataFrame Users
Posts: 153, Visits: 1.2K
I say "Victory" too fast



when I set

Private _CopyBO As MicroFour.StrataFrame.Business.BusinessLayer



when I try to use _CopyBO, VB.net say that I have to instantiate the class



then, I set

Private _CopyBO As New MicroFour.StrataFrame.Business.BusinessLayer



When I try to use

_CopyBO.CopyDataFrom(Me.PrimaryBusinessObject, MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable)



a message "The class "Microfour...BussinesLayer" must override the property "Tablename" since it derives from Microf.....Businesslayer





What Can I do?



My "full" code:

--------------

Private _RegistroEnMemoriaBO As New MicroFour.StrataFrame.Business.BusinessLayer

Dim sFiltroAnterior As String = Me.PrimaryBusinessObject.Filter

Dim _CurrentRowIndex As Integer = Me.PrimaryBusinessObject.CurrentRowIndex



Me.PrimaryBusinessObject.Filter = Me.PrimaryBusinessObject.PrimaryKeyField & " = " & Me.PrimaryBusinessObject(Me.PrimaryBusinessObject.PrimaryKeyField)



'-- at this line the "tablename" error ocurrs

_RegistroEnMemoriaBO.CopyDataFrom(Me.PrimaryBusinessObject, MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable)



Me.PrimaryBusinessObject.Filter = sFiltroAnterior

Me.NavigateToPrimaryKey(_RegistroEnMemoriaBO(_RegistroEnMemoriaBO.PrimaryKeyField))



Thanks!

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Have you built the partial class for the BO you are working with?
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search