Exclude some fields from record copy


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

Smile Everything is possible, just keep trying...

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

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

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