/// <summary>
        /// Handlers for the Toggle button class of controls.
        /// </summary>
        /// <param name="sender">The object that originated the event.</param>
        /// <param name="routedEventArgs">The routed event arguments.</param>
        private void OnToggleButtonChange(object sender, RoutedEventArgs routedEventArgs)
        {
            // The main idea of this handler is to sort out the user generated actions from the machine generated actions.  Once
            // its determined that it was a user action, a background thread is called to change the associated field to the value
            // selected by the ToggleButton.
            ToggleButton toggleButton = routedEventArgs.OriginalSource as ToggleButton;
            IContent     iContent     = toggleButton.DataContext as IContent;

            // This filters all the ToggleButton events looking for user initiated actions that are bound to the data model.
            if (InputHelper.IsUserInitiated(toggleButton, ToggleButton.IsCheckedProperty) &&
                iContent != null && iContent.Key is DataTableCoordinate)
            {
                bool toggleButtonState = toggleButton.IsChecked.GetValueOrDefault();

                // At this point, a ToggleButton was modified by the user and it is connected to a data model field.  This will
                // extract the coordinates of the field in the table.  That, in turn, drives the decision about how to update the
                // shared data model.
                DataTableCoordinate     dataTableCoordiante = iContent.Key as DataTableCoordinate;
                ConsumerTrustPaymentRow paymentRow          = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;
                // Update the IsActive column.
                if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.IsActiveColumn)
                {
                    FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                       TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(paymentRow)
                    {
                        IsActive = toggleButtonState
                    })));
                }
                // Update the IsCleared column.
                if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.IsClearedColumn)
                {
                    FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                       TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(paymentRow)
                    {
                        IsCleared = toggleButtonState
                    })));
                }
            }
        }
        /// <summary>
        /// Handle sending data down to the server for a combo box changed event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="routedEventArgs"></param>
        private void OnComboBoxChange(object sender, RoutedEventArgs routedEventArgs)
        {
            FluidTrade.Guardian.Windows.Controls.StatusComboBox originalSourceStatusComboBox = routedEventArgs.OriginalSource as FluidTrade.Guardian.Windows.Controls.StatusComboBox;
            if (originalSourceStatusComboBox != null)
            {
                IContent iContent = originalSourceStatusComboBox.DataContext as IContent;
                FluidTrade.Guardian.Windows.Controls.StatusComboBox sourceStatusComboBox = routedEventArgs.Source as FluidTrade.Guardian.Windows.Controls.StatusComboBox;

                if (InputHelper.IsUserInitiated(originalSourceStatusComboBox, FluidTrade.Guardian.Windows.Controls.StatusComboBox.PersistentSelectedValueProperty) &&
                    (sourceStatusComboBox != null) &&
                    (iContent != null) &&
                    (iContent.Key is DataTableCoordinate))
                {
                    // At this point, a ComboBox was modified by the user and it is connected to a data model field.  This will
                    // extract the coordinates of the field in the table.  That, in turn, drives the decision about how to update the
                    // shared data model.
                    DataTableCoordinate     dataTableCoordiante = iContent.Key as DataTableCoordinate;
                    ConsumerTrustPaymentRow paymentRow          = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;

                    // Update the Payment Status (StatusId) column.
                    if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.StatusIdColumn)
                    {
                        Guid selectedItem          = (Guid)sourceStatusComboBox.SelectedValue;
                        Guid persistedSelectedItem = (Guid)sourceStatusComboBox.PersistentSelectedValue;

                        FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                           TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(paymentRow)
                        {
                            StatusId = persistedSelectedItem
                        })));
                    }
                }
            }
        }
        /// <summary>
        /// Handle sending data down to the server for a date time picker changed event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="routedEventArgs"></param>
        private void OnDateTimePicker(object sender, RoutedEventArgs routedEventArgs)
        {
            FluidTrade.Actipro.DateTimePicker originalSourceDateTimePicker = routedEventArgs.OriginalSource as FluidTrade.Actipro.DateTimePicker;
            if (originalSourceDateTimePicker != null)
            {
                IContent iContent = originalSourceDateTimePicker.DataContext as IContent;
                FluidTrade.Actipro.DateTimePicker sourceDateTimePicker = routedEventArgs.Source as FluidTrade.Actipro.DateTimePicker;

                if (InputHelper.IsUserInitiated(originalSourceDateTimePicker, FluidTrade.Actipro.DateTimePicker.DateTimeProperty) &&
                    (sourceDateTimePicker != null) &&
                    (iContent != null) &&
                    (iContent.Key is DataTableCoordinate))
                {
                    // At this point, a ComboBox was modified by the user and it is connected to a data model field.  This will
                    // extract the coordinates of the field in the table.  That, in turn, drives the decision about how to update the
                    // shared data model.
                    DataTableCoordinate     dataTableCoordiante = iContent.Key as DataTableCoordinate;
                    ConsumerTrustPaymentRow paymentRow          = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;

                    // Update the Cleared Date column.
                    if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.ClearedDateColumn)
                    {
                        if (sourceDateTimePicker.DateTime != null)
                        {
                            DateTime selectedItem = (DateTime)sourceDateTimePicker.DateTime;
                            FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                               TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(paymentRow)
                            {
                                ClearedDate = selectedItem
                            })));
                        }
                    }

                    // Update the Actual Payment Date column.
                    if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.ActualPaymentDateColumn)
                    {
                        if (sourceDateTimePicker.DateTime != null)
                        {
                            DateTime selectedItem = (DateTime)sourceDateTimePicker.DateTime;
                            FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                               TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(paymentRow)
                            {
                                ActualPaymentDate = selectedItem
                            })));
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Handle sending data down to the server for a text box changed event.
        /// </summary>
        /// <param name="textBoxTxt"></param>
        /// <param name="iContent"></param>
        private void TextBoxValueChanged(string textBoxTxt, IContent iContent)
        {
            DataTableCoordinate dataTableCoordiante = iContent.Key as DataTableCoordinate;
            ConsumerRow         workingOrderRow     = dataTableCoordiante.DataRow as ConsumerRow;
            string textBoxString  = textBoxTxt;
            Guid   workingOrderId = dataTableCoordiante.Association;

            if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.CheckIdColumn)
            {
                ConsumerTrustPaymentRow consumerTrustPaymentRow = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(consumerTrustPaymentRow)
                {
                    CheckId = textBoxTxt
                })));
            }

            if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.Fee0Column)
            {
                Decimal result;
                bool    parsed = Decimal.TryParse(textBoxTxt, out result);
                if (!parsed)
                {
                    result = 0.0m;
                }

                ConsumerTrustPaymentRow consumerTrustPaymentRow = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(consumerTrustPaymentRow)
                {
                    Fee0 = result
                })));
            }

            if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.ActualPaymentValueColumn)
            {
                Decimal result;
                bool    parsed = Decimal.TryParse(textBoxTxt, out result);
                if (!parsed)
                {
                    result = 0.0m;
                }

                ConsumerTrustPaymentRow consumerTrustPaymentRow = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(consumerTrustPaymentRow)
                {
                    ActualPaymentValue = result
                })));
            }

            if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.Memo0Column)
            {
                ConsumerTrustPaymentRow consumerTrustPaymentRow = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(consumerTrustPaymentRow)
                {
                    Memo0 = textBoxTxt
                })));
            }

            if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.Memo1Column)
            {
                ConsumerTrustPaymentRow consumerTrustPaymentRow = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(consumerTrustPaymentRow)
                {
                    Memo1 = textBoxTxt
                })));
            }

            if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.Memo2Column)
            {
                ConsumerTrustPaymentRow consumerTrustPaymentRow = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(consumerTrustPaymentRow)
                {
                    Memo2 = textBoxTxt
                })));
            }

            if (dataTableCoordiante.DataColumn == DataModel.ConsumerTrustPayment.TrackingNumberColumn)
            {
                ConsumerTrustPaymentRow consumerTrustPaymentRow = dataTableCoordiante.DataRow as ConsumerTrustPaymentRow;
                FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(UpdateField, new Func <MethodResponseErrorCode>(() =>
                                                                                                                   TradingSupportWebService.UpdateConsumerTrustPayment(new ConsumerTrustPayment(consumerTrustPaymentRow)
                {
                    TrackingNumber = textBoxTxt
                })));
            }
        }