Basic FK data populate on Maintenance Forms


Author
Message
Alex M. Lana
Alex M. Lana
StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)
Group: Forum Members
Posts: 20, Visits: 264
Greetings,

Maybe this is a simple and basic question, but as we're new to SF, here it goes.



ProdutcTable (ProductBO)

- ProdCod (PK)

- VendorCod (FK) --> VendorTable (VendorBO)



Have a Maintenance Form with ProductBO(form bind) and VendorBO,

have also a Dialog to browse Vendors binded to VendorBO.



My question is how can I fill the VendorBO "on Navigate" so the info binded to it will follow it's parent FK.

The form contains no grids. Just binded fields.

I need the form to understand the relation and fetch the FKs data on ProductBO Navigate.



Thanks,



Alex



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

Have you had a look at the help file, under "Defining a Relationship Between Business Objects" ?

Also, to have a practical example, open the SampleCRMApplication, probably under C:\Program Files\MicroFour\StrataFrame\VB.NET Samples\CRMApplication, and open the CustomerMaintenance.vb, check the Customers and CustomerCreditCards BOs. Also, individualy open the CustomerBO and check its ParentRelationship property.

Let me know if you need something else.

Abraços.

 

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
Also, individualy open the CustomerBO and check its ParentRelationship property.

Sorry, I meant the CustomerCreditCardsBO...

Alex M. Lana
Alex M. Lana
StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)
Group: Forum Members
Posts: 20, Visits: 264
Hello Ivan,

The BOs are already configured like CRM sample app.

Our question is not how this relation works, but how to fetch data on Navigate, how to trigger the fetch of data on Navigate, as the original post.



My question is how can I fill the VendorBO "on Navigate"so the info binded to it will follow it's parent FK.

The form contains no grids. Just binded fields.

I need the form to understand the relation and fetch the FKs data on ProductBO Navigate.




And also I have lots of products without vendors, and in this case it will produce an error, because the framework tries to set an wrong equal statement (where int = string). This happens when the FK on the parent table is blank.

So our needs are:



01) Fetch child BO data from database only on parent BO navigation or

02) Avoid wrong where statements when child FK information is not present on parent BO.



Thanks,



Alex
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Alex,



I think what you want is to handle the parent BO's navigated event. In that event, test if the FK is present and either load the child or clear it. E.g. If you have a ProductBO and an VendorBO, your Navigated event handler might look something like this:



Private Sub ProductBO_Navigated(e As NavigatedEventArgs)

'-- Test if the product has a vendor, assuming that the VendorID has

' has been setup to be zero if it's null in the db...you could also use a

' nullable type and the appropriate test with that data type.

If Me.ProductBO.VendorID > 0 Then

'-- Load the vendor associated with this product

Me.VendorBO.FillByPrimaryKey(Me.ProductBO.VendorID)

Else

'-- No vendor, so clear vendor Bo

Me.VendorBO.Clear()

End If

End Sub




Hope that helps!
Peter Denton
Peter Denton
StrataFrame Novice (109 reputation)StrataFrame Novice (109 reputation)StrataFrame Novice (109 reputation)StrataFrame Novice (109 reputation)StrataFrame Novice (109 reputation)StrataFrame Novice (109 reputation)StrataFrame Novice (109 reputation)StrataFrame Novice (109 reputation)StrataFrame Novice (109 reputation)
Group: Forum Members
Posts: 77, Visits: 787
G'day

It may be that I'm not understanding what you are trying to do, but I was looking for answers to similar problems a few months ago until the lightbulb came on. When you define the parent-child relationship (as indicated by Ivan) you then fill both the parent and child BOs with all the records from the related table/view when the form loads and SF takes care of it from there, you don't have to refresh the child BO. If there is too much data then you will have to do as Greg suggested.

Peter

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

Guess Greg has direct you already.

But, still, give a good look at the SampleCRMApplication's CustomerMaintenance code. Maybe you have already and I am being redundant here... if so, sorry! Blush

In there, you will find many interesting guys: Customers_EditingStateChanged, Customers_Navigated, FillByParentPrimaryKey, SeekToPrimaryKey...

Um ótimo dia! Wink

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Peter Denton (10/31/2007)
G'day



It may be that I'm not understanding what you are trying to do, but I was looking for answers to similar problems a few months ago until the lightbulb came on. When you define the parent-child relationship (as indicated by Ivan)you then fill both the parent and child BOs with all the recordsfrom the related table/view when the form loads and SF takes care of it from there, you don't have to refresh the child BO. If there is too much data then you will have to do as Greg suggested.



Peter




Yeah, the method I suggested is definitely directed toward reducing the data pulled across the network. Most of my users are remote Crying
Alex M. Lana
Alex M. Lana
StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)
Group: Forum Members
Posts: 20, Visits: 264
Hi Greg, thanks for your reply.

In the meantime I've already done the same, but my problem is to construct the navigated object in C#.

I'm doing like this:

// Fetch Child Data on Parent BO Navigation

private void sysProdutoBO1_Navigated(MicroFour.StrataFrame.Business.NavigatedEventArgs currNavig)

{

if (this.sysProdutoBO1.for_cod > 0)

{

this.sysFornecedorBO1.FillByPrimaryKey(this.sysProdutoBO1.for_cod);

}

}


The question I have now is how to construct it at Designer.cs

this.sysProdutoBO1.Navigated += new MicroFour.StrataFrame.Business.NavigatedEventArgs(this.sysProdutoBO1_Navigated);


I don't know which parameters to send, and if is this the right way to grab the event in C#.



Thanks everyone for the attention, regards,



Alex
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yep, that is the correct way to attach to an event in C#.  The AddHandler and RemoveHandler keywords are not available in C#, so the overload of the +/- operators is used to add/remove method calls to delegate variables (events).  So, to add the event:

obj.EventName += new EventHandlerType(EventHandlerMethodName);

and to remove the event handler, it's the - operator.  I honestly can't remember whether you have to save off the created delegate in a variable to remove it or if you can just use the line above and swap the + for a -... not sure.

Also note that C# does not have the Handles keyword or WithEvents keyword like VB does, so when you double-click a button in the designer and it creates the Click handler method for you, it is explicitly adding the line above for the event handler within the .designer.cs file for the form.

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