Copy Current Record


Author
Message
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
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.

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
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];

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
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?

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
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?

Edhy Rijo

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
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.

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
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.

Edhy Rijo

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
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


Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Thanks again, will follow your advice.

Edhy Rijo

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
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")

          Exit Sub    

     End If

     Try

          '-- Save off the current row

          Dim copyRow As DataRow = Me.BizItems1.CurrentRow

          If Me.BizItems1.NewRow() Then

               '-- Now update each of the columns within the new row.

               For Each col As DataColumn In Me.BizItems1.CurrentDataTable.Columns

                    '-- Skip the Primary Field, since the field is autoincremented or

                    '-- a generated GUID

                    If col.ColumnName = Me.BizItems1.PrimaryKeyField Then

                         Continue For

                    End If

                    '-- Do the actual copy of each field or column here.

                    Me.BizItems1.CurrentRow(col) = copyRow(col)

               Next

               '-- Show the ChildForm for the copied record.

               Me.EditChildRecord()

          End If

     Catch ex As Exception

     End Try

End Sub

In the above code I am using a method EditChildRecord() that I created from the source code of the listview, which I requested an enhancement to make this method public or shared here http://forum.strataframe.net/Topic19108-9-1.aspx for this kind of functionality.  I am not including my version here since I hope it will be made available to use in the framework.

Edhy Rijo

Juan Carlos Pazos
Juan Carlos Pazos
StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)
Group: Forum Members
Posts: 144, Visits: 227
Hi Edhy

Thanks for your commentes. Can you post a sample of how to make the EditChildRecord?

Regards

Smile Everything is possible, just keep trying...

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