NavigateToPrimaryKey Error


Author
Message
Rogerio Mauri
Rogerio Mauri
StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)
Group: StrataFrame Users
Posts: 205, Visits: 629
1) PrimaryBusinessObject: tbCadastroBO1

2) browseDialog1->BusinessObjectType: vwTbCadastroBO
   browseDialog1->BusinessObjectToPopulate: vwTbCadastroBO1

3) After executed the search: Procedure executed inside of the event of closing of the browseDialog1 control.
        private void browseDialog1_BrowseDialogClosed(EventArgs e)
        {
            if (vwTbCadastroBO1.Count == 0)
                return;
            int idCadastro = vwTbCadastroBO1.IdCadastro;
            tbCadastroBO1.FillByView(vwTbCadastroBO1);
            if (tbCadastroBO1.Count > 0)
                this.NavigateToPrimaryKey(idCadastro);

        }

4) Method to populate the Primary Business Object (tbCadastroBO1) from the loaded view BO (vwTbCadastroBO1) in the browseDialog.
        public void FillByView(BDLicitecMasterViewBO.vwTbCadastroBO viewBO)
        {
            if (viewBO.Count == 0)
                return;
            viewBO.MoveFirst();
            string where = string.Empty;
            do
            {
                where += viewBO.IdCadastro + ", ";
            } while (viewBO.MoveNext());
            where = where.Trim();
            where = where.Remove(where.Length - 1);
            this.FillDataTable("SELECT * FROM TbCadastro"
             + " WHERE IdCadastro IN ( " + where + " )");

        }


5) Error: The navigation is executed successfully, however, the controls in the form is not refreshed.

Rogério Mauri Smile



Rogerio Mauri
Rogerio Mauri
StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)
Group: StrataFrame Users
Posts: 205, Visits: 629
PS: The navigation method returns true.

Rogério Mauri Smile

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
Well, I see a couple of things that could be suspect.  First, you are calling a NavigateToPrimaryKey on the BrowseClosed event, which you can do, but you will need to be careful if you are navigating on the BO that was just updated by the BrowseDialog.

From just looking at the code you posted I do not see exactly where it could be failing....but I do see a few "red flags."  If you would like, create a sample that reproduces the problem and I will take a look at it.  But I am pretty condifent that your application code may be working against the BrowseDialog and NavigateToPrimary key logic presenting the error (which a stack trace would be more helpful than the code posted above).  Anytime that you get an error, a stack trace does a lot more for us in trying to diagnose a problem. Smile

Rogerio Mauri
Rogerio Mauri
StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)
Group: StrataFrame Users
Posts: 205, Visits: 629
When I select the register and I choose button OK, the fields are brought up to date. (NavigateToPrimaryKey => OK)

However, when I select the register and I give a double click in the grid, the form closes, but it does not bring up to date the fields. (NavigateToPrimaryKey => it does not execute)
 
I believe that the error is in this point of the function.

Namespace UI.Windows.Forms

    <DefaultEvent("RowPopulating")> _
    <ToolboxBitmap(GetType(IconFinder), "BrowseDialog.bmp")> _
    Public Class BrowseDialog

    Public Class BrowseDialog

       .....

       Public Overridable Function ShowDialog(ByVal PopulateOnShow As Boolean, ByVal ResultsWindowOwner As IWin32Window) As DialogResult
           
            ...


            '-- Refresh the bound controls
            If lnReturn = DialogResult.OK Then
                If loForm.SelectedPrimaryKey Is Nothing Then
                    Me._BusinessObject.Navigate(BusinessNavigationDirection.First)Exclamation
                Else
                    Me._BusinessObject.NavigateToPrimaryKey(CType(loForm.SelectedPrimaryKey, PrimaryKeyValue).GetValues())
                End If

                '-- Indicate that the end-user clocked the OK button
                loCloseReason = BrowseDialogClosedReasons.UserSelectedResult
            Else
                loCloseReason = BrowseDialogClosedReasons.UserCancelled
            End If

            ...
       
        End Function

        .....

    End Class

End Namespace


Rogério Mauri Smile



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

I am sorry, but I think that there is some other logic in your form or BOs that could be having an impact on the results you are seeing.  I have really tried to reproduce this trying both the double-click and clicking the OK.  Everything in our medical application, CRM system, and the samples I have created all work correctly.  I cannot reproduce this. Could you give me a sample and a stack trace?  I really want to help you find your problem here...but I just can't find it with the information you have given me so far....sorry Ermm

Rogerio Mauri
Rogerio Mauri
StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)StrataFrame User (303 reputation)
Group: StrataFrame Users
Posts: 205, Visits: 629
Trent...

Solved problem!

Step by step:

Considering that vwTbCadastroBO1 is an object constructed from a view, it does not have primary key. Then, in the "Business Object Mapper" I configured "Override Primary Key Specification" with the IdCadastro field. ... soon easy...

Of fact the problem occurred because the primary key of the BO was not defined. (the vwTbCadastroBO has its origin in one view in the database).

I wait that my English for AltaVista translator has been intelligible.

Thank you very much BigGrin BigGrin BigGrin

Rogério Mauri Smile



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
Yeah, you do have to have a primary key so that makes sense.  Glad you found the problem. Smile
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