StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      


««12

Copy Current RecordExpand / Collapse
Author
Message
Posted 01/23/2008 1:28:46 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 1:30:54 PM
Posts: 437, Visits: 1,754
Ben Chase (01/23/2008)

partsBO1.CurrentRow[mCol] = mCurrentPart.CurrentRow[mCol.ColumnName];

Sorry...I am a bit confused.  A DataRow object doesn't have a CurrentRow property, does it?  I'll try using the CurrentRow of the BO to see if that makes a difference.

Post #13688
Posted 01/24/2008 9:01:58 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 09/26/2008 8:30:36 AM
Posts: 2,685, Visits: 1,886
Woops, didn't look at the sample closely enough... didn't realize you were copying to a new record within the same business object... try this instead:

partsBO1.CurrentRow[mCol] = mCurrentPart[mCol];


www.bungie.net
Post #13703
Posted 01/24/2008 9:28:10 AM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 1:30:54 PM
Posts: 437, Visits: 1,754
Ben Chase (01/24/2008)
try this instead:

partsBO1.CurrentRow[mCol] = mCurrentPart[mCol];

I changed just the BO side per your earlier suggestion.  It seems to work just fine.  I do have the second half looking like this, though:

mCurrentPart[mCol.ColumnName]

I am assuming that ColumnName is the default property to DataColumn object.  So leaving it there or removing it won't matter, eh?

Post #13707
Posted 03/16/2008 8:36:06 PM
Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 12:59:18 AM
Posts: 633, Visits: 2,606
Trent L. Taylor (01/21/2008)
This is probably something we could add to the Tools.Common class, but just haven't as of yet.

Hi Trent,

I am looking for the same functionality here but in VB, was this added to SF?

 
Post #14942
Posted 03/17/2008 10:59:04 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 4:11:57 AM
Posts: 4,586, Visits: 4,570
I guess I don't know what you are referring to.  You can view the previous post I had here that shows how to copy a record: http://forum.strataframe.net/FindPost13606.aspx .  This sample code is in VB.NET.  We haven't added a method to the tools class for this. 

If this isn't what you are looking for then you might elaborate on what functionality you are trying to implement.

Post #14956
Posted 03/17/2008 11:43:35 AM
Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 12:59:18 AM
Posts: 633, Visits: 2,606
Trent L. Taylor (03/17/2008)
I guess I don't know what you are referring to.  You can view the previous post I had here that shows how to copy a record: http://forum.strataframe.net/FindPost13606.aspx .  This sample code is in VB.NET.  We haven't added a method to the tools class for this. 

If this isn't what you are looking for then you might elaborate on what functionality you are trying to implement.

Hi Trent,

Yes I am referring to the following code:

'-- Save off the current row
Dim copyRow As DataRow = MyBo.CurrentRow
MyBo.NewRow()

'-- Now update each of the columns within the new row.  You may want to test
'    on certain column names to be excluded, such as PK fields.
For each col as DataColumn In MyBo.CurrentDataTable.Columns
    MyBo.Items(col.ColumnName) = copyRow.Item(col.ColumnName)       
Next

I just wanted to know if it was added to the framework so I could use it.  I have several address fields which could use this approach to be updated from an existing record.

 
Post #14962
Posted 03/17/2008 1:27:35 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 4:11:57 AM
Posts: 4,586, Visits: 4,570
There is not a framework function to do this....you are really better off creating a shared method on a class somewhere that does this for you so you can "tweak" it to your needs.  When we started to add this method to the framework, we realized that there would have to be a LOT of overloads to try to accomodate this is a generic method.  It is still on our list, but not in the framework yet.  You can do this yourself very easily using the code supplied in the post.  I recommend created a sealed class to house all of your "basics" and then you could add a static (shared) method to that class to do this for you:

Public NotInheritable Class MyBasics
    '-- Seal the class
    Private Sub New()
    End Sub

   Public Shared Function CopyRecord(ByVal sourceRow As DataRow) As DataRow
      '-- Add the logic from the previous post here with your "tweaks"
   End Function
End Class

Post #14971
Posted 03/17/2008 1:54:56 PM
Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 12:59:18 AM
Posts: 633, Visits: 2,606
Thanks again, will follow your advice.

 
Post #14973
Posted 09/05/2008 11:03:42 AM
Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Today @ 12:59:18 AM
Posts: 633, Visits: 2,606
Here is my implementation of copying the current record into the same business object in a ListView control.

Private Sub tsbCopyAndAddRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbCopyAndAddRecord.Click

     '-- If there is not item selected in the list, then

     '-- instruct the user to select a record first.

     If Me.lstItems.SelectedItems.Count = 0 Then

          Me.ShowMessageByKey("SelectRecordToCopy")

 &nbs