/// <summary>
 /// Handles a change to a Entity row.
 /// </summary>
 /// <param name="sender">The Object that originated the event.</param>
 /// <param name="entityRowChangeEventArgs">The event arguments.</param>
 void OnEntityRowChanged(Object sender, DataModel.EntityRowChangeEventArgs entityRowChangeEventArgs)
 {
     // We're only interested in changes that affect this Entity.  When the created or modified dates change, update the related properties in the MVVM.
     if (entityRowChangeEventArgs.Action == DataRowAction.Change)
     {
         DataModel.EntityRow entityRow = entityRowChangeEventArgs.Row;
         if (entityRow.EntityId == this.BlotterId)
         {
             this.CreatedTime  = entityRow.CreatedTime;
             this.ModifiedTime = entityRow.ModifiedTime;
         }
     }
 }
 /// <summary>
 /// Handles a change to a Entity row.
 /// </summary>
 /// <param name="sender">The Object that originated the event.</param>
 /// <param name="entityRowChangeEventArgs">The event arguments.</param>
 void OnEntityRowChanged(Object sender, DataModel.EntityRowChangeEventArgs entityRowChangeEventArgs)
 {
     // We're only interested in changes that affect this Entity.
     if (entityRowChangeEventArgs.Action == DataRowAction.Change)
     {
         DataModel.EntityRow entityRow = entityRowChangeEventArgs.Row;
         if (entityRow.EntityId == this.EntityId)
         {
             this.CreatedTime  = entityRow.CreatedTime;
             this.ModifiedTime = entityRow.ModifiedTime;
         }
     }
 }
Example #3
0
 /// <summary>
 /// Handles a change to a Entity record in the data model.
 /// </summary>
 /// <param name="sender">The object that originated the event.</param>
 /// <param name="entityRowChangeEventArgs">The event arguments.</param>
 private void OnEntityRowChanged(Object sender, DataModel.EntityRowChangeEventArgs entityRowChangeEventArgs)
 {
     // Any changes in the Entity table will be copied to only the blotters in this list.
     if (entityRowChangeEventArgs.Action == DataRowAction.Change)
     {
         foreach (DataModel.BlotterRow blotterRow in entityRowChangeEventArgs.Row.GetBlotterRows())
         {
             Int32 index = this.BinarySearch(blotterItem => blotterItem.BlotterId, blotterRow.BlotterId);
             if (index >= 0)
             {
                 this[index].Copy(blotterRow);
             }
         }
     }
 }
Example #4
0
        /// <summary>
        /// Handles a change to the Entity table.
        /// </summary>
        /// <param name="sender">The object that originated the event.</param>
        /// <param name="entityRowChangeEventArgs">The event arguments.</param>
        protected virtual void OnEntityRowChanged(Object sender, DataModel.EntityRowChangeEventArgs entityRowChangeEventArgs)
        {
            // Validate the parameters.
            if (sender == null)
            {
                throw new ArgumentNullException("sender");
            }
            if (entityRowChangeEventArgs == null)
            {
                throw new ArgumentNullException("entityRowChangeEventArgs");
            }

            // We're only interested in changes.
            if (entityRowChangeEventArgs.Action == DataRowAction.Change)
            {
                // Select all the WorkingOrderRows that are related to the Securities that are related to the EntityRow that has changed.  We are looking for
                // changes to the names of the securities which are kept in the Entity table.
                var workingOrderRows = from securityRow in entityRowChangeEventArgs.Row.GetSecurityRows()
                                       from workingOrderRow in securityRow.GetWorkingOrderRowsByFK_Security_WorkingOrder_SecurityId()
                                       select workingOrderRow;

                // Iterate through all the rows affected by the change to the entity row and update the properties related to the entity table.  For example, the
                // full name of the security is found in the entity row.  Note that we immediately filter out events not related to this blotter or its children.
                foreach (DataModel.WorkingOrderRow workingOrderRow in workingOrderRows)
                {
                    if (this.blotterIdSet.Contains(workingOrderRow.BlotterId))
                    {
                        // This will copy and commit the changes made to the Entity row to the WorkingOrder record.
                        Int32 index = this.BinarySearch(order => order.WorkingOrderId, workingOrderRow.WorkingOrderId);
                        if (index >= 0)
                        {
                            TType workingOrder = this[index];
                            this.workingOrderCollectionView.EditItem(workingOrder);
                            workingOrder.SecurityName = entityRowChangeEventArgs.Row.Name;
                            this.workingOrderCollectionView.CommitEdit();
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Handles a change to the DataModel.Entity table.
 /// </summary>
 /// <param name="sender">Object that generated the event.</param>
 /// <param name="entityRowChangeEvent">The event arguments.</param>
 void OnChangeEntityRow(Object sender, DataModel.EntityRowChangeEventArgs entityRowChangeEvent)
 {
     // Update the entire collection when the relationship between entities has changed.
     this.UpdateCollection();
 }