Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Update Fields
Message
From
08/02/2010 11:41:58
Antonio Llano
Inmollano S.L.
Getxo, Spain
 
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Environment versions
Environment:
C# 3.0
OS:
Vista
Network:
Windows 2008 Server
Database:
VistaDB
Application:
Desktop
Miscellaneous
Thread ID:
01443663
Message ID:
01448075
Views:
54
Thaks for your suggestion.

I have changed the code. I use the existing propertychanged event in this way:

First, I have created a partial class for the entity in an entity.partial file and register a method for the propertychanged event in the constructor:
public partial class MuestrasEntity : ABusinessEntity
	{
        public MuestrasEntity()
        {
            this.PropertyChanged += new PropertyChangedEventHandler(MuestrasEntity_ChangeValues);
        }
Second, I added the method to handle the event, that cheks for the correct sender and executes a method with the required code in the business object;
        private void MuestrasEntity_ChangeValues(Object sender, PropertyChangedEventArgs e)
        {
            MuestrasEntity entity = sender as MuestrasEntity;
            if (entity != null && entity.BusinessObject != null)
            {
                ((MuestrasObj)entity.BusinessObject).MuestrasEntityChangeValues(entity, e.PropertyName);
            }
        }
At last, I wrote the operations needed in the business objects partial file:
        public void MuestrasEntityChangeValues(MuestrasEntity entity, string property)
        {
            if (this.State != mmBusinessState.Adding)
            {
                if (property == "ValorTotal" || property == "Superficie")
                {
                    this.SetValorUnitario(entity);
                }
                else if (property == "ValorUnitario" || property == "CoefHmgKAvg")
                {
                    this.SetValorHomogeneo(entity);
                }
                else if (property.Contains("CoefHmgK"))
                {
                    this.SetKAvg(entity);
                }
                else if (property == "ValorHomogeneo")
                {
                    this.SetValoresMedios();
                }
            }
        }
I think of this a a good solution.

Best Regards,
Antonio Llano
Previous
Reply
Map
View

Click here to load this message in the networking platform