Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multiple Instances of the Same BO
Message
From
22/06/2010 07:21:43
 
 
To
17/06/2010 15:10:07
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01469400
Message ID:
01470152
Views:
54
>>>>Hi,
>>>>
>>>>I'm using MM.NET 3.6
>>>>
>>>>I have a Policy which can have three people associated with it, the Insured, the Owner and the Payor. These three will be based on my "Person" BO. I have a feeling I had earlier encountered problems with having two separate instances based on the same BO in that they stepped on each other's toes. What is the suggested way to allow this? Do I need to make three separate BOs (all exactly the same except named differently)?
>>>>
>>>>Update:
>>>>
>>>>I want to be able to actually add/edit the Insured, Owner & Payor objects while adding/editing the Policy.
>>>
>>>It is not desireable to have more than one Business object class representing the same business object. There are several techniques for updating data in the same business object from more than one selection. If you can give me an example of one of those situations I will see if I can give you an idea of how to best do that.
>>>Tim
>>
>>Hi Tim,
>>
>>I have a form that is displaying the Insured person's details, the Owner's details and the Payors details as well as the Insurance Policy.
>>
>>What I would have done in VFP using Visual MaxFrame is create three different BO instances based on my Person Business Object as well as a BO for the Policy. Then I can add a Policy and add the Insured, Owner and Payor and relate them properly and they wouldn't step on each other (for example if I changed the oInsured.name, this would not overwrite the oOwner.name (which is what I
>>think I experienced earlier when dealing with Clients and their Spouses).
>>
>>So how should I approach this?
>
>I don't think there would be anything preventing you from creating more than one instance of the same BO. My previous posts have always said, it wasn't really best practice to create multiple business object classes that essentially duplicate functionality.
>Contact oOwner = new Contact();
>Contact oPayor = new Contact();
>
>You may very well run into some issues with binding since the BindingSource takes the business object name but you may be able to get around that with an alias; I have not tried. When the data gets stepped on is when you call the same business object instance and call for data a second time without specifiying a different table name. If you use the same business object and get two sets of data you need to specify a table name other than the default for at least one of those calls. You can bind the data with the bo.tablename to specify which table it is bound to. If you don't specify a table name the default table name is used.

Hi Tim,

I've tried to make this work, but am not getting the Owner and Payor data to show. Here's what I have done, maybe you can spot something I missed in there?
    public partial class PolicyEdit : mmBusinessWebPage
    {
        #region Field References

        protected Policy oPolicy;
        protected Client oClient;
        protected Client oOwner;
        protected Client oPayor;
...
        private void RegisterBusinessObjects()
        {
            this.oPolicy = (Policy)this.RegisterPrimaryBizObj(new Policy());
            this.oClient = (Client)this.RegisterBizObj(new Client());

            this.oOwner = (Client)this.RegisterBizObj(new Client());
            this.oOwner.TableName = "Owner";

            this.oPayor = (Client)this.RegisterBizObj(new Client());
            this.oPayor.TableName = "Payor";
I have code in my GetCurrentPolicy() like this:
                // Get the related Owner
                if (this.oPolicy.Entity.OwnerFK != null)
                {
                    this.oOwner.GetClientByClientPK(this.oPolicy.Entity.OwnerFK);
                    Session["dsPolicyOwner"] = this.oOwner.DataSet;
                }
This gets the correct data and puts it in a table called Owner.

Then in my aspx page I have a control defined like this:
<mm:mmTextBox ID="txtOwnerNumber" runat="server" BindingSource="Owner" BindingSourceMember="ClientNumber"
                                        Width="92px" ReadOnly="True"></mm:mmTextBox>
This shows up blank, even though Owner.ClientNumber has a value.

Are you seeing anything that I have missed? Or is this the problem you were alluding to?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform