Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to establish a Parent/Child relationship
Message
De
28/02/2004 00:18:20
Larry Long
ProgRes (Programming Resources)
Georgie, États-Unis
 
 
À
27/02/2004 18:21:25
Jason Mesches
Ocean Systems Engineering Corporation
Carlsbad, Californie, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
00881543
Message ID:
00881753
Vues:
20
TY!

>Larry,
>
>Typically, we would create 2 separate business objects -- one for each backend table. The form instantiates both, then uses RegisterChildBizObj() of the header to set the relationship at the object level:
>
>
>SalesOrderHeader OH = (SalesOrderHeader)this.RegisterPrimaryBizObj(new SalesOrderHeader());
>SalesOrderDetail OD = (SalesOrderDetail)this.RegisterPrimaryBizObj(new SalesOrderDetail());
>
>//There are overloads of this method.  You may want to use one of them...
>OH.RegisterChildBizObj(OD);
>
>
>Then, if you look at mmBusinessObject.cs, you'll see there are Hook methods that the child uses to respond when its parent raises certain events. In this case, you'll be interested in HookParentNavigated and HookParentRetrieved. Both have a mmBusinessStateChangeEventArgs parameter with PrimaryKey or PrimaryKeys fields populated with the parent's primary key information. You'll use that to retrieve the child's dataset:
>
>
>//This would be in the child business object.
>protected override void HookParentNavigated(mmBusinessObject bizObj, mmBusinessStateChangeEventArgs e)
>{
>   //There's a section in the devguide that explains how to send parameters.
>   //This isn't how you want to do it, just an illustration of the concept!
>   this.FillDataSet(this.GetCurrentDataSet(), "SELECT * FROM ChildTable WHERE FKField = " + e.PrimaryKey.ToString() + "'";
>}
>
>
>Hope that helps,
>---J
>
>>What's the best way to create a BO that establishes a parent/child relationship...for example Sales Order Header and Details? I have defined a single BO that will instantiate the 2 datasets. Each dataset accepts a parameter (Customer ID and Sales Order, respectively).
>>
>>In my form I have 2 grids defined, one for each dataset, and I want to show the details for a sales order based on whichever row is selected in the header grid. I know I need to use the SelectedIndexChanged method to refresh the child grid, but I don't know how to send the Order number to the child's GetDataSet method.
>>
>>private void Orders_SelectedIndexChanged(object sender, System.EventArgs e)
>>{
>>string cSono = ????;
>>this.oDetails = (SalesOrderDetails)this.RegisterBizObj(new SalesOrderDetails());
>>this.oDetails.GetSalesOrderDetails(cSono);
>>this.BindControl(this.DetailGrid);
>>}
>>
>>Am I on the right track or is there a better way?
>>
>>TIA
L.A.Long
ProgRes
lalong1@charter.net
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform