StrataFrame Forum

Exclude some fields from record copy

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

By Juan Carlos Pazos - 3/28/2009

Hi Trent

I use a routine from this post http://forum.strataframe.net/Topic13603-6-3.aspx for duplicate a record. In one windows I have a Maintenance form, and after duplicate I manually remove text form some fields that must have differente information.

My problem is that in another Window I use a ListView, when users select a row can copy to a new record and then the edit form opens, but I need to exclude some fields than must contain new information

How do I exclude some fields from being copied?

If col.ColumnName = Me.PublicacionesBO1.PrimaryKeyField Then

Continue For

End If

If col.ColumnName = Me.PublicacionesBO1.Ofertas Then

 Continue For

End If

... some other fields here

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

Do you have some ideas?

Regards

By Trent L. Taylor - 3/30/2009

Within any application you should have a shared ot static class that you place common methods.  THis would be a good place to do that.  So you would want to create a method that accepts two BOs and a list of columns to include/exclude.

Public Sub CopySomeFields(ByVal sourceBo As BusinessLayer, ByVal destBo As BusinessLayer, ByVal columnsToInclude As String())

     For Each bo As BusinessLayer in sourceBo.GetEnumerable()
           '-- Create the new row within the destBO
           destBo.NewRow()

           '-- Cycle through the columns
           For Each colName As String in columnsToInclude
                  destRow.CurrentRow.Items(colName) = bo.CurrentRow.Items(colName)
           Next
     Next

End Sub

This is just a quick sample and this code could be optimized.  But this should get you going down the right path and may spark some ideas.

By Juan Carlos Pazos - 3/30/2009

Trent



If you take a look to the code I enter or to the original post, the copy function it's already working, the problem is that - need to exclude some fields.



In the code you suggest I do not see what's the difference. In your code I need one line with the name of the column for each data field?



Regards