Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
UI or BO code?
Message
 
À
25/08/2010 16:25:53
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Divers
Thread ID:
01478134
Message ID:
01478508
Vues:
18
>>>>Hi Frank,
>>>>
>>>>Yes, that is what I meant and I see no reason what you did wouldn't work fine.
>>>>Tim
>>>>
>>>
>>>Hi Tim,
>>>
>>>I've been trying this out and am getting a bit lost.
>>>
>>>My UI code is this:
>>>
>>>
this.oPolicy.GetPolicyByPolicyPK(this.PolicyPK);
>>>
>>>The code in my BO is this:
>>>
>>>
        public PolicyEntity GetPolicyByPolicyPK(Guid policyPK)
>>>        {
>>>            //return this.GetEntity("PoliciesSelectByPK",
>>>            //    this.CreateParameter("@PolicyPK", policyPK));
>>>            
>>>            // get the requested entity
>>>            PolicyEntity oPolicyEntity = this.GetEntity("PoliciesSelectByPK",
>>>                            this.CreateParameter("@PolicyPK", policyPK));
>>>            // check its status
>>>            if (oPolicyEntity.StatusFK != (int)StatusCode.Pending)
>>>            {
>>>                // if it is not Pending then create a new entity, copy the data from the original entity 
>>>                PolicyEntity oNewPolicyEntity = new PolicyEntity();
>>>                //CopyPolicyEntity(oPolicyEntity, oNewPolicyEntity);
>>>
>>>                // return the new entity
>>>                return oNewPolicyEntity;
>>>            }
>>>            else
>>>                return oPolicyEntity;
>>>        }
>>>
>>>Stepping through the code shows me that oNewPolicyEntity is getting returned. This has no values set in it (I have not done the code to copy anything yet), yet when I return to the UI my oPolicy has the values for the original policy. This actually brings me to one of the confusions I have. In VFP I would have to store the return value somewhere, but this code does not store the returned PolicyEntity anywhere, so how does the this.oPolicy.Entity get populated with the data and why isn't it showing the new/blank policy data?
>>
>>Frank, when you use the business object methods to retrieve an entity or entity list they are stored on the business object collections. If you retrieve an entity into a local reference the way you did, that may not be the case. Try doing this instead.
>>
>> public PolicyEntity GetPolicyByPolicyPK(Guid policyPK)
>>       {
>>           
>>            
>>            // get the requested entity - leave on the business object for return in the event we need it.
>>            this.GetEntity("PoliciesSelectByPK",
>>                            this.CreateParameter("@PolicyPK", policyPK));
>>
>>            // check its status
>>            if (oPolicyEntity.StatusFK != (int)StatusCode.Pending)
>>            {
>>                // if it is not Pending then create a new entity, copy the data from the original entity 
>>                PolicyEntity oNewPolicyEntity = new PolicyEntity();
>>                //CopyPolicyEntity(oPolicyEntity, oNewPolicyEntity);
>>
>>                // Clear the current entity list and add this one instead
>>                 this.EntityList.Clear();
>>                this.EntityList.Add(oNewPolicyEntity);
>>            }
>>            // This will return either the original or the newly created one that is added.
>>           return this.Entity;
>>}
>>
>
>Tim,
>
>that hasn't made a difference, I am still seeing the old data on the form, not the new blank record (it should be blank because I haven't copied the data from the original entity yet).
>
>While debugging after doing the EntityList.Clear(), this.Entity still shows the original values and does so even after adding the newpolicyentity.
>
>This is beginning to make my head hurt :(

Well, usually Tim is the one helping me out but I'm going to take a stab at this. I hope this helps.
 public PolicyEntity GetPolicyByPolicyPK(Guid policyPK)
       {
           
            // get the requested entity - leave on the business object for return in the event we need it.
            this.GetEntity("PoliciesSelectByPK",
                            this.CreateParameter("@PolicyPK", policyPK));

            // check its status
            if (oPolicyEntity.StatusFK != (int)StatusCode.Pending)
            {
                // if it is not Pending then get this entity into a local reference. 
                PolicyEntity oOldPolicyEntity = this.GetEntity("PoliciesSelectByPK",
                            this.CreateParameter("@PolicyPK", policyPK));
                //Get an empty dataset and add a new row
                this.GetEmptyDataSet();
                this.NewRow(this.GetCurrentDataSet());
                //CopyPolicyEntity(oOldPolicyEntity, this.Entity);
            }
            // This will return either the original or the newly created one that is added.
           return this.Entity;
}
Linda Harmes
HiBit Technologies, Inc.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform