Using the BO.Seek() method to find duplicate record in current view....


Author
Message
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Sorry Juan, I should have read it more carefully.

Have a look at your IF statement:

If IsUniqueCode(Me.IdGuia, Me.NumeroGuia) Then

You are testing if it IS unique. You probably want to test if it is NOT unique. Wink

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 Ivan

Wink You are right. Thanks

Before read this, I take a look to StrataFlix and found the same thing, I just adapt to my own BO and all works. Thanks for you help.

Private Sub GuiasEnviosBO_CheckRulesOnCurrentRow(ByVal e As MicroFour.StrataFrame.Business.CheckRulesEventArgs)

'-- Verifica que si se ingreso el n£mero de gu¡a sea £nico

If Me.NumeroGuia.Length > 0 AndAlso (Not EsGuiaUnica()) Then Me.AddBrokenRule(GuiasEnviosBOFieldNames.NumeroGuia, "El n£mero de gu¡a ya ha sido utilizado.")

End Sub

Private Function EsGuiaUnica() As Boolean

'-- Establish Locals

Dim cmd As New SqlCommand("SELECT COUNT(*) FROM GuiasEnvios WHERE IdGuia != @idGuia AND NumeroGuia = @numeroGuia")

'-- Create the parms

cmd.Parameters.AddWithValue("@idGuia", IdGuia).SqlDbType = SqlDbType.Int

cmd.Parameters.AddWithValue("@numeroGuia", NumeroGuia).SqlDbType = SqlDbType.VarChar

'-- Return the results

Return CType(Me.ExecuteScalar(cmd), Integer) = 0

End Function

Kindest regards

Smile Everything is possible, just keep trying...

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Glad you got it going, Juan!

Just for you to think about, have a look at the Localization & Message Editor. It might be a good idea to start creating your messages with it, and then use it in your application using the message keys, instead of entering an string directly. This way not only you get a centralized editor for all your messages, but are only 1 step away from having a multi-language application.

Have a great weekend. Cool

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
One other thought to cap off this post, all of the server side query information from my posts and others is on target, but if you have the need to query within the BO (uncommitted reecord) as well, call a Select on the CurrentDataTable to get a count of records:

Dim hasDupe As Boolean

hasDupe = MyBo.CurrentDataTable.Select("MyPk <> 1 AND MyLastName = 'Taylor'").Length > 0

You can use this in conjunction with the server side query.  Do one and then the other to make sure that there are no dupes on either side of the committed records.

Also, Ivan's suggestions about the localization records are good...it is a much better way to keep up with your messages, etc.  Especially if you have the need to localize an app!

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

Thanks for you comment. The other solution is in the BO, this validation you mention, Where should it go? I think that in the Validating event of the control, but I'm not sure.

About localization, I'm working in two apps right now. One has localization for every part of it because is English/Spanish, but the other no, that's why I'm using only direct text for messages.

Kindest 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
They would both go in the BO when validating through the CheckRulesOnCurrentRow event.  This was just to show that you may need to query uncommitted records as well in addition to those checked on the server to get 100% coverage.  This isn't always necessary, I just thought I would bring it to your attention.
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