StrataFrame Forum

browseDialog

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

By Ian Johnston - 8/9/2010

I have a view as a BO named cert_viewBO this I set as the BussinessObjectToPopulate and BusinessObjectType, I have selected the search fields and the resultlayout but when I run the browsezDialog no results are returned.

Any ideas?

By Ivan George Borges - 8/9/2010

Hi Ian.

For a View, you need to have a Pk into it, and the override the primary key once in the BO Mapper, have a look at this picture:

By Ian Johnston - 8/9/2010

here is the code for the view:

SELECT     dbo.Certificate.Cert_number AS Certificate, dbo.Certificate.Cert_inbound_date AS date, dbo.Certificate.Cert_trans AS Tr, dbo.Certificate.Cert_net AS net,
                      dbo.Customer.cust_name AS Customer, dbo.Certificate.Cert_trk_license, dbo.Certificate.Cert_Front_trl, dbo.Certificate.Cert_Rear_trl,
                      dbo.Commodity.Commod_name AS commodity, Customer_1.cust_name AS Carrier, dbo.Certificate.PK_Certificate
FROM         dbo.Certificate INNER JOIN
                      dbo.Commodity ON dbo.Certificate.FK_Commodity = dbo.Commodity.PK_Commodity INNER JOIN
                      dbo.Customer ON dbo.Certificate.FK_Customer = dbo.Customer.cust_pk INNER JOIN
                      dbo.Customer AS Customer_1 ON dbo.Certificate.FK_Customer2 = Customer_1.cust_pk

In the sql management studio this will return the expected data. dbo.Certificate.PK_Certificate is the primary key in dbo,Certificate, this was the field I specified in the BO mapper, is that correct. Still no results in the browseDialog.

By Ivan George Borges - 8/9/2010

After you set the Primary Key Specification, have you rebuilt the partial for this BO?
By Ian Johnston - 8/9/2010

Yes and rebuilt project.
By Ivan George Borges - 8/9/2010

From what you are showing, it looks correct. Maybe you could write a small sample using the StrataFrameSample database in the way you are doing there so we could have a look. A small detail that you probably did right, but you said you specified dbo.Certificate.PK_Certificate on the "Override Primary Key Specification" at the BO Mapper, but I guess you put only PK_Certificate there, which should be the proper way, right?
By Ivan George Borges - 8/10/2010

Ian, follow this post, maybe there is something there that might help you:

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

By Ian Johnston - 8/10/2010

Correct, I used PK_certificate. Below is the code for the fill of the BO, should it be different when using a view?

public void Fill()

{

string s = "select * from Cert_listing";

FillDataTable(s);

}

Cert_listing is the name of the view on the server.

By Ivan George Borges - 8/10/2010

I'm sorry Ian, I'm a bit lost now. I thought you were using a BrowseDialog to search a view which had been mapped to a BO. The BO Mapper should use SQL Server for the view source. On the post I made reference to you, there was an example on how to use the BD to fetch records from the View which will populate the ViewBO instance dropped on your form and then you can use its PKs for whatever when the BD is closed. If this isn't the case, please bare with me and put me in the right direction. Wink
By Ian Johnston - 8/10/2010

So maybe I am on the wrong track, my thinking was that the BO would be filled with data from the view and then the dialogbrowser would filter that down to just the rows that met the search citeria, am I missing something? If you have multiple search fields but only put search information in one and leave the rest blank will that work?
By Ivan George Borges - 8/10/2010

Nope, it sounds like you are on the right track. You can fill any search field on the BD and it will fetch all records from the view you gave it as the BO type. Once you give it an OK it will then populate the BO you set as the BO to Populate with the results of your search criteria. The BO to populate should be an instance of the BO dropped onto your form, and it should be the type of the BO Type you set the BrowseDialog to work with. When you Close the BD, and you have an event exposed for that, you can then work with the BO instance populated with the contents brought according to your search criteria. If the BO instance you populated is the form's PrimaryBusinessObject, you don't even need to do anything, as it will be already populated and positioned on the record you chose from the BD before you OKed it.
By Ian Johnston - 8/10/2010

OK so how do I populate the view BO?
By Ivan George Borges - 8/10/2010

You don't. If your ViewBO instance is set as the BrowseDialog's BusinessObjectToPopulate, it will be automaticaly populated by the BrowseDialog control as soon as it fetches the records based on your search criteria.
By Ian Johnston - 8/10/2010

In the samples database I deployed the following view:

SELECT     dbo.Customers.cust_pk, dbo.Customers.cust_FirstName, dbo.Customers.cust_LastName, dbo.Customers.cust_City, dbo.Orders.or_ponumber
FROM         dbo.Customers INNER JOIN
                      dbo.Orders ON dbo.Customers.cust_pk = dbo.Orders.or_cust_pk

named it Customer_po

in the Browse dialog example I aded a BO customer_poBO

Set up the BO to be populated from the server

Overrode primary key specification

put Cust_pk

rebuild all

rebuilt application

added BO to the form

changed the browsedialog to look at it and set the search field appropriately

Put the following code in the toolstip cliked

if (this.printToolStripButton.Pressed)

{

}

set a break point

ran the application

In the object viewer for each field in the BO it says This.(whichever field) threw an exception of type'MicroFour.StratFrame.Business.businessLayerException'

Can you duplicate this?

By Ivan George Borges - 8/10/2010

Please, post your sample and I will have a look.
By Ivan George Borges - 8/10/2010

And sorry, I meant zip your sample solution and attach it to a post so I can download it.
By Ian Johnston - 8/10/2010

What to post and where
By Ian Johnston - 8/10/2010

How do you attach to a post?
By Ian Johnston - 8/10/2010

Please see ttached
By Ivan George Borges - 8/11/2010

OK, some considerations:

You mapped your view to Customer_poBO, which is fine, and the cust_pk is been returned, perfect.

Your Customer_poBO has a fill method selecting records from the Customers table, I guess it should be from your Customer_po view. Although you won't need to fill this BO to have it working with the BrowseDialog. The BrowseDialog will fill it with the results it gets depending on your search criteria.

Your form has the CustomersBO1 as the PrimaryBusinessObject and your controls are bound to this BO properties. This is just fine.

But then, your BrowseDialog has the Customer_poBO1 as the BusinessObjectToPopulate. This is not a problem, but once your BrowseDialog brings your search results, this is the BO that will be populated, and not your form's BO, CustomersBO1.

Still on your BrowseDialog, you haven't set the SearchFields, and this will definetely throw an error at run time. You need to set them:

Once you get this working, you will have your Customer_poBO1 populated as soon as you Close the BrowseDialog after having your search results listed and pressing OK. At this stage, you need to use the BrowseDialogClosed event as I have tried to show you earlier on this following post:

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

Why that? Because your results will have the Customer's PKs that you want to show on your form, so you need to get all the PKs from your populated view and fill your form's primary BO with the records that match this list of PKs from your view.

There might be some concepts you could be missing on how the BrowseDialog works. If you haven't done so, the Tutorial on the Help files could help you get a general idea of it. It is under "Application Framework / Getting Started / Tutorials / Creating a WinForms App"

Hope it helps. Wink

By Ian Johnston - 8/11/2010

Thanks for looking at it. It is working in that the browse window opens and when I do a search it says 1000 records found but no results are displayed but the rows are there in the grid.
By Ivan George Borges - 8/11/2010

Great, we are getting there. Your issue now seems to be with your CustomerBrowseDetails InformationPanel.

You are dealing with its RowChanged event, you are on the right path there, but remember you are not dealing with the Customers BO at this moment, but with the view instead. You can use the current view row PK to go to the Customers table and get the info you are looking for, though. For the sake of making your BrowseDialog work first and get the idea of it, try to comment those lines and focus on getting the BD work and populate your form's primary BO with the rows from your BD results. I did it over here and the BD list populated just fine from the view.

By Ian Johnston - 8/11/2010

I had to comment out the code from CustomerBrowseDetails to get it to work, that was the original code in the sample. When you run the browse you are seeing the actual names and not just blank rows?
By Ivan George Borges - 8/11/2010

Yep.

By Ivan George Borges - 8/11/2010

Sorry for the question, Ian... but once you entered the BrowseDialog, did you click the Search button?
By Ian Johnston - 8/11/2010

Tongue Yes, don't blame you for asking! Very strange, I am wondering if it is a permission issue on the server. I am getting the exact same result in the app I am working on using a view, no visible result even though it says it found records.
By Ivan George Borges - 8/11/2010

I asked that just because it happens to me all the time! BigGrin

Strange result you are getting there... over here, I have created the same view you did over there and haven't done anything to your sample besides creating an enter to the BrowseDialog SearchFields property with the cust_FirstName.

By Ian Johnston - 8/11/2010

Was working and now I just tried to runand got the error in the attachment.
By Ivan George Borges - 8/11/2010

Just open your form's code and get rid of the RowPopulating event handler. Let's deal with this part later.
By Ian Johnston - 8/12/2010

Just curious but what is your development platform, I am using Vista ultimate service pack 2 and Visual studio 2008 version 9.0.30729.1 SP .Net Framework version 3.5 SP1. I believe the BO is loading it is just not displaying, I tried using the view BO in a listview in my applicaton and get the same result.
By Ivan George Borges - 8/12/2010

Right now I am on a Win7 64 Professional with VS2008. But I also have machines with Vista and with XP Pro. I don't think this is the issue. Have you had success building a plain BrowseDialog on a normal table?
By Ian Johnston - 8/15/2010

Browse dialog in the sample form works. What version of stratafarme & SQL server?
By Ivan George Borges - 8/16/2010

Well, that is a good sign then. It should work just as well with your views, and as a matter of fact I used the sample you posted and it worked over here. I am currently on StrataFrame 1.7.0.7 and SQL Server 2008.
By Ian Johnston - 8/16/2010

I tried my code on the same plaform as you, same result - still not displaying the items in the browse. I am not going to use the browse dialog in the application, Thanks for taking the time to look at it but I am up against a deadline.
By Ivan George Borges - 8/16/2010

I understand. But as soon as you want to come back to this, let us know.