| | | 
StrataFrame Novice
       
Group: StrataFrame Users Last Login: 09/19/2008 3:57:14 PM Posts: 114, Visits: 669 |
| 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 |
| | | | 
StrataFrame Novice
       
Group: StrataFrame Users Last Login: 09/19/2008 3:57:14 PM Posts: 114, Visits: 669 |
| 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 |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Today @ 4:52:53 AM Posts: 4,586, Visits: 4,571 |
| | 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) |
| | | | 
StrataFrame Novice
       
Group: StrataFrame Users Last Login: 09/19/2008 3:57:14 PM Posts: 114, Visits: 669 |
| 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 |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Today @ 4:52:53 AM Posts: 4,586, Visits: 4,571 |
| | 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. |
| | | | 
StrataFrame Novice
       
Group: StrataFrame Users Last Login: 09/19/2008 3:57:14 PM Posts: 114, Visits: 669 |
| 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 |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: 09/26/2008 8:30:36 AM Posts: 2,685, Visits: 1,886 |
| 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.
www.bungie.net |
| | | | 
StrataFrame Novice
       
Group: StrataFrame Users Last Login: 09/19/2008 3:57:14 PM Posts: 114, Visits: 669 |
| 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 |
| | | | | |
|