示例#1
0
        /// <summary>
        /// Handles the deletion of a SourceOrder row.
        /// </summary>
        /// <param name="sender">The object that originated the event.</param>
        /// <param name="sourceOrderRowChangeEventArgs">The event arguments.</param>
        protected virtual void OnSourceOrderRowDeleted(Object sender, DataModel.SourceOrderRowChangeEventArgs sourceOrderRowChangeEventArgs)
        {
            // Validate the parameters.
            if (sender == null)
            {
                throw new ArgumentNullException("sender");
            }
            if (sourceOrderRowChangeEventArgs == null)
            {
                throw new ArgumentNullException("sourceOrderRowChangeEventArgs");
            }

            // We're only interested in deletes that affect the WorkingOrder records in this blotter.
            if (sourceOrderRowChangeEventArgs.Action == DataRowAction.Delete)
            {
                Guid workingOrderId = (Guid)sourceOrderRowChangeEventArgs.Row[DataModel.SourceOrder.WorkingOrderIdColumn, DataRowVersion.Original];
                DataModel.WorkingOrderRow workingOrderRow = DataModel.WorkingOrder.WorkingOrderKey.Find(workingOrderId);
                if (workingOrderRow != null && this.blotterIdSet.Contains(workingOrderRow.BlotterId))
                {
                    Int32 index = this.BinarySearch(order => order.WorkingOrderId, workingOrderRow.WorkingOrderId);
                    if (index >= 0)
                    {
                        this.UpdateSourceOrderQuantity(this[index], workingOrderRow);
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Handles a change to a SourceOrder row.
        /// </summary>
        /// <param name="sender">The Object that originated the event.</param>
        /// <param name="sourceOrderRowChangeEventArgs">The event arguments.</param>
        protected virtual void OnSourceOrderRowChanged(Object sender, DataModel.SourceOrderRowChangeEventArgs sourceOrderRowChangeEventArgs)
        {
            // Validate the parameters.
            if (sender == null)
            {
                throw new ArgumentNullException("sender");
            }
            if (sourceOrderRowChangeEventArgs == null)
            {
                throw new ArgumentNullException("sourceOrderRowChangeEventArgs");
            }

            // We're only interested in additions and changes that affect the WorkingOrder records in this blotter.
            if (sourceOrderRowChangeEventArgs.Action == DataRowAction.Add || sourceOrderRowChangeEventArgs.Action == DataRowAction.Change)
            {
                DataModel.WorkingOrderRow workingOrderRow = sourceOrderRowChangeEventArgs.Row.WorkingOrderRow;
                if (this.blotterIdSet.Contains(workingOrderRow.BlotterId))
                {
                    Int32 index = this.BinarySearch(order => order.WorkingOrderId, workingOrderRow.WorkingOrderId);
                    if (index >= 0)
                    {
                        this.UpdateSourceOrderQuantity(this[index], workingOrderRow);
                    }
                }
            }
        }
 /// <summary>
 /// Handles a change to a SourceOrder row.
 /// </summary>
 /// <param name="sender">The Object that originated the event.</param>
 /// <param name="sourceOrderRowChangeEventArgs">The event arguments.</param>
 void OnSourceOrderRowChanged(Object sender, DataModel.SourceOrderRowChangeEventArgs sourceOrderRowChangeEventArgs)
 {
     // We're only interested in additions and changes that affect the WorkingOrder records in this blotter.
     if (sourceOrderRowChangeEventArgs.Action == DataRowAction.Add || sourceOrderRowChangeEventArgs.Action == DataRowAction.Change)
     {
         // This is designed to filter out all events that don't pertain to this blotter.
         DataModel.SourceOrderRow sourceOrderRow = sourceOrderRowChangeEventArgs.Row;
         if (this.blotterIdSet.Contains(sourceOrderRow.WorkingOrderRow.BlotterId))
         {
             // Once the previous order is subtracted and the current order added to the totals we can calculate the percentages of orders completed.
             if (sourceOrderRow.HasVersion(DataRowVersion.Original))
             {
                 this.sourceOrderQuantityField -= (Decimal)sourceOrderRow[DataModel.SourceOrder.OrderedQuantityColumn, DataRowVersion.Original];
             }
             this.SourceOrderQuantity += sourceOrderRow.OrderedQuantity;
             this.OrderedPercent       = this.SourceOrderQuantity == 0.0m ? 0.0 : Convert.ToDouble(this.DestinationOrderQuantity / this.SourceOrderQuantity);
         }
     }
 }
 /// <summary>
 /// Handles the deletion of a SourceOrder row.
 /// </summary>
 /// <param name="sender">The object that originated the event.</param>
 /// <param name="sourceOrderRowChangeEventArgs">The event arguments.</param>
 void OnSourceOrderRowDeleted(Object sender, DataModel.SourceOrderRowChangeEventArgs sourceOrderRowChangeEventArgs)
 {
     // We're only interested in deletes that affect the WorkingOrder records in this blotter.
     if (sourceOrderRowChangeEventArgs.Action == DataRowAction.Delete)
     {
         // Filtering requires a little more work with a deleted record.  We need to first find the original record and then look up the working order to
         // which it belonged.  We don't need to check for the existence of the working order as we know that this order was just deleted and, for it to have
         // existed in the first place, there must have been a working order.
         DataModel.SourceOrderRow sourceOrderRow = sourceOrderRowChangeEventArgs.Row;
         Guid workingOrderId = (Guid)sourceOrderRow[DataModel.SourceOrder.WorkingOrderIdColumn, DataRowVersion.Original];
         DataModel.WorkingOrderRow workingOrderRow = DataModel.WorkingOrder.WorkingOrderKey.Find(workingOrderId);
         if (this.blotterIdSet.Contains(workingOrderRow.BlotterId))
         {
             // Once the quantity has been removed from the totals, the percent ordered and executed can be updated.
             this.SourceOrderQuantity -= (Decimal)sourceOrderRow[DataModel.SourceOrder.OrderedQuantityColumn, DataRowVersion.Original];
             this.OrderedPercent       = this.SourceOrderQuantity == 0.0m ? 0.0 : Convert.ToDouble(this.DestinationOrderQuantity / this.SourceOrderQuantity);
         }
     }
 }
 /// <summary>
 /// Validates a change to a Source Order.
 /// </summary>
 /// <param name="sender">The object that originated the event.</param>
 /// <param name="e">The event data.</param>
 internal static void OnSourceOrderRowValidate(object sender, DataModel.SourceOrderRowChangeEventArgs e)
 {
     // Use the map to call the handler for the action.  Note that I would rather do nothing than incur conditional logic.
     SourceOrderService.sourceOrderHandlerMap[e.Action](e.Row);
 }