Implementing IEditableObject when using as a datasource

If have used a class as datasource , you would know that to provide proper validation and you would nees to implement a IEditableObject, but if you sont its really simple all you have to do is provide 3 functions , The code Mentioned below is a simple example and I think you can take it from there

 public class ReceiptPay : IEditableObject
        {
            public int FeeComponentId { get; set; }
            public string FeeComponent { get; set; }
            public decimal Amount { get; set; }
 
            private decimal amtbkp;
            private bool inTXN = false;
 
            public ReceiptPay(int FCId, string FC)
            {
                FeeComponentId = FCId;
                FeeComponent = FC;
            }
 
            #region IEditableObject Members
 
            public void BeginEdit()
            {
                if (!inTXN)
                {
                    amtbkp = Amount;
                    inTXN = true;
                }
            }
 
            public void CancelEdit()
            {
                if (inTXN)
                {
                    Amount = amtbkp;
                    inTXN = false;
                }
            }
 
            public void EndEdit()
            {
                inTXN = false;
            }
 
            #endregion
        }
16
Dec 2008
Author naresh
Category

.net Programming

Comments 2 Comments