Example #1
0
        /// <summary>Archives a Placement record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="RowVersion">The version number of this row.</param>
        /// <param name="placementId">The value for the PlacementId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        public static void Archive(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int placementId)
        {
            // Accessor for the Placement Table.
            ServerDataModel.PlacementDataTable placementTable = ServerDataModel.Placement;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.PlacementRow placementRow = placementTable.FindByPlacementId(placementId);
            if ((placementRow == null))
            {
                throw new Exception(string.Format("The Placement table does not have an element identified by {0}", placementId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((placementRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            placementRow[placementTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(placementRow);
            placementRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Placement\" set \"IsArchived\" = 1 where \"PlacementId\"=@placementId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@placementId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, placementId));
            sqlCommand.ExecuteNonQuery();
        }
Example #2
0
        /// <summary>ArchiveChildrens a Broker record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="rowVersion">the version number of this row.</param>
        /// <param name="brokerId">The value for the BrokerId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        internal static void ArchiveChildren(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int brokerId)
        {
            // Accessor for the Broker Table.
            ServerDataModel.BrokerDataTable brokerTable = ServerDataModel.Broker;
            // This record can be used to iterate through all the children.
            ServerDataModel.BrokerRow brokerRow = brokerTable.FindByBrokerId(brokerId);
            // Archive the child records.
            for (int index = 0; (index < brokerRow.GetExecutionRows().Length); index = (index + 1))
            {
                ServerDataModel.ExecutionRow childExecutionRow = brokerRow.GetExecutionRows()[index];
                Execution.Archive(adoTransaction, sqlTransaction, childExecutionRow.RowVersion, childExecutionRow.ExecutionId);
            }
            for (int index = 0; (index < brokerRow.GetPlacementRows().Length); index = (index + 1))
            {
                ServerDataModel.PlacementRow childPlacementRow = brokerRow.GetPlacementRows()[index];
                Placement.Archive(adoTransaction, sqlTransaction, childPlacementRow.RowVersion, childPlacementRow.PlacementId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            brokerRow[brokerTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(brokerRow);
            brokerRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Broker\" set \"IsArchived\" = 1 where \"BrokerId\"=@brokerId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@brokerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerId));
            sqlCommand.ExecuteNonQuery();
        }
Example #3
0
 /// <summary>Archives a BlockOrder record.</summary>
 /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
 /// <param name="RowVersion">The version number of this row.</param>
 /// <param name="blockOrderId">The value for the BlockOrderId column.</param>
 /// <param name="archive">true to archive the object, false to unarchive it.</param>
 public static void Archive(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int blockOrderId)
 {
     // Accessor for the BlockOrder Table.
     ServerDataModel.BlockOrderDataTable blockOrderTable = ServerDataModel.BlockOrder;
     // Rule #1: Make sure the record exists before updating it.
     ServerDataModel.BlockOrderRow blockOrderRow = blockOrderTable.FindByBlockOrderId(blockOrderId);
     if ((blockOrderRow == null))
     {
         throw new Exception(string.Format("The BlockOrder table does not have an element identified by {0}", blockOrderId));
     }
     // Rule #2: Optimistic Concurrency Check
     if ((blockOrderRow.RowVersion != rowVersion))
     {
         throw new System.Exception("This record is busy.  Please try again later.");
     }
     // Archive the child records.
     for (int index = 0; (index < blockOrderRow.GetAllocationRows().Length); index = (index + 1))
     {
         ServerDataModel.AllocationRow childAllocationRow = blockOrderRow.GetAllocationRows()[index];
         Allocation.Archive(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId);
     }
     for (int index = 0; (index < blockOrderRow.GetBlockOrderTreeRowsByFKBlockOrderBlockOrderTreeChildId().Length); index = (index + 1))
     {
         ServerDataModel.BlockOrderTreeRow childBlockOrderTreeRow = blockOrderRow.GetBlockOrderTreeRowsByFKBlockOrderBlockOrderTreeChildId()[index];
         BlockOrderTree.Archive(adoTransaction, sqlTransaction, childBlockOrderTreeRow.RowVersion, childBlockOrderTreeRow.ParentId, childBlockOrderTreeRow.ChildId);
     }
     for (int index = 0; (index < blockOrderRow.GetBlockOrderTreeRowsByFKBlockOrderBlockOrderTreeParentId().Length); index = (index + 1))
     {
         ServerDataModel.BlockOrderTreeRow childBlockOrderTreeRow = blockOrderRow.GetBlockOrderTreeRowsByFKBlockOrderBlockOrderTreeParentId()[index];
         BlockOrderTree.Archive(adoTransaction, sqlTransaction, childBlockOrderTreeRow.RowVersion, childBlockOrderTreeRow.ParentId, childBlockOrderTreeRow.ChildId);
     }
     for (int index = 0; (index < blockOrderRow.GetExecutionRows().Length); index = (index + 1))
     {
         ServerDataModel.ExecutionRow childExecutionRow = blockOrderRow.GetExecutionRows()[index];
         Execution.Archive(adoTransaction, sqlTransaction, childExecutionRow.RowVersion, childExecutionRow.ExecutionId);
     }
     for (int index = 0; (index < blockOrderRow.GetOrderRows().Length); index = (index + 1))
     {
         ServerDataModel.OrderRow childOrderRow = blockOrderRow.GetOrderRows()[index];
         Order.Archive(adoTransaction, sqlTransaction, childOrderRow.RowVersion, childOrderRow.OrderId);
     }
     for (int index = 0; (index < blockOrderRow.GetPlacementRows().Length); index = (index + 1))
     {
         ServerDataModel.PlacementRow childPlacementRow = blockOrderRow.GetPlacementRows()[index];
         Placement.Archive(adoTransaction, sqlTransaction, childPlacementRow.RowVersion, childPlacementRow.PlacementId);
     }
     // Increment the row version
     rowVersion = ServerDataModel.RowVersion.Increment();
     // Delete the record in the ADO database.
     blockOrderRow[blockOrderTable.RowVersionColumn] = rowVersion;
     adoTransaction.DataRows.Add(blockOrderRow);
     blockOrderRow.Delete();
     // Archive the record in the SQL database.
     SqlCommand sqlCommand = new SqlCommand("update \"BlockOrder\" set \"IsArchived\" = 1 where \"BlockOrderId\"=@blockOrderId");
     sqlCommand.Connection = sqlTransaction.Connection;
     sqlCommand.Transaction = sqlTransaction;
     sqlCommand.Parameters.Add(new SqlParameter("@blockOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, blockOrderId));
     sqlCommand.ExecuteNonQuery();
 }
Example #4
0
        /// <summary>DeleteChildrens a User record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="rowVersion">the version number of this row.</param>
        /// <param name="userId">The value for the UserId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        internal static void DeleteChildren(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int userId)
        {
            // Accessor for the User Table.
            ServerDataModel.UserDataTable userTable = ServerDataModel.User;
            // This record can be used to iterate through all the children.
            ServerDataModel.UserRow userRow = userTable.FindByUserId(userId);
            // Delete the child records.
            for (int index = 0; (index < userRow.GetAllocationRowsByFKUserAllocationCreatedUserId().Length); index = (index + 1))
            {
                ServerDataModel.AllocationRow childAllocationRow = userRow.GetAllocationRowsByFKUserAllocationCreatedUserId()[index];
                Allocation.Delete(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId);
            }
            for (int index = 0; (index < userRow.GetAllocationRowsByFKUserAllocationModifiedUserId().Length); index = (index + 1))
            {
                ServerDataModel.AllocationRow childAllocationRow = userRow.GetAllocationRowsByFKUserAllocationModifiedUserId()[index];
                Allocation.Delete(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId);
            }
            for (int index = 0; (index < userRow.GetExecutionRowsByFKUserExecutionCreatedUserId().Length); index = (index + 1))
            {
                ServerDataModel.ExecutionRow childExecutionRow = userRow.GetExecutionRowsByFKUserExecutionCreatedUserId()[index];
                Execution.Delete(adoTransaction, sqlTransaction, childExecutionRow.RowVersion, childExecutionRow.ExecutionId);
            }
            for (int index = 0; (index < userRow.GetExecutionRowsByFKUserExecutionModifiedUserId().Length); index = (index + 1))
            {
                ServerDataModel.ExecutionRow childExecutionRow = userRow.GetExecutionRowsByFKUserExecutionModifiedUserId()[index];
                Execution.Delete(adoTransaction, sqlTransaction, childExecutionRow.RowVersion, childExecutionRow.ExecutionId);
            }
            for (int index = 0; (index < userRow.GetPlacementRowsByFKUserPlacementCreatedUserId().Length); index = (index + 1))
            {
                ServerDataModel.PlacementRow childPlacementRow = userRow.GetPlacementRowsByFKUserPlacementCreatedUserId()[index];
                Placement.Delete(adoTransaction, sqlTransaction, childPlacementRow.RowVersion, childPlacementRow.PlacementId);
            }
            for (int index = 0; (index < userRow.GetPlacementRowsByFKUserPlacementModifiedUserId().Length); index = (index + 1))
            {
                ServerDataModel.PlacementRow childPlacementRow = userRow.GetPlacementRowsByFKUserPlacementModifiedUserId()[index];
                Placement.Delete(adoTransaction, sqlTransaction, childPlacementRow.RowVersion, childPlacementRow.PlacementId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            userRow[userTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(userRow);
            userRow.Delete();
            // Delete the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"User\" set \"IsDeleted\" = 1 where \"UserId\"=@userId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@userId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userId));
            sqlCommand.ExecuteNonQuery();
        }
Example #5
0
        /// <summary>Archives a TimeInForce record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="RowVersion">The version number of this row.</param>
        /// <param name="timeInForceCode">The value for the TimeInForceCode column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        public static void Archive(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int timeInForceCode)
        {
            // Accessor for the TimeInForce Table.
            ServerDataModel.TimeInForceDataTable timeInForceTable = ServerDataModel.TimeInForce;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.TimeInForceRow timeInForceRow = timeInForceTable.FindByTimeInForceCode(timeInForceCode);
            if ((timeInForceRow == null))
            {
                throw new Exception(string.Format("The TimeInForce table does not have an element identified by {0}", timeInForceCode));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((timeInForceRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < timeInForceRow.GetAccountRows().Length); index = (index + 1))
            {
                ServerDataModel.AccountRow childAccountRow = timeInForceRow.GetAccountRows()[index];
                Account.ArchiveChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId);
            }
            for (int index = 0; (index < timeInForceRow.GetOrderRows().Length); index = (index + 1))
            {
                ServerDataModel.OrderRow childOrderRow = timeInForceRow.GetOrderRows()[index];
                Order.Archive(adoTransaction, sqlTransaction, childOrderRow.RowVersion, childOrderRow.OrderId);
            }
            for (int index = 0; (index < timeInForceRow.GetPlacementRows().Length); index = (index + 1))
            {
                ServerDataModel.PlacementRow childPlacementRow = timeInForceRow.GetPlacementRows()[index];
                Placement.Archive(adoTransaction, sqlTransaction, childPlacementRow.RowVersion, childPlacementRow.PlacementId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            timeInForceRow[timeInForceTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(timeInForceRow);
            timeInForceRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"TimeInForce\" set \"IsArchived\" = 1 where \"TimeInForceCode\"=@timeInForceCod" +
                                                   "e");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@timeInForceCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, timeInForceCode));
            sqlCommand.ExecuteNonQuery();
        }
Example #6
0
        /// <summary>Inserts a Placement record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="blockOrderId">The value for the BlockOrderId column.</param>
        /// <param name="brokerId">The value for the BrokerId column.</param>
        /// <param name="timeInForceCode">The value for the TimeInForceCode column.</param>
        /// <param name="orderTypeCode">The value for the OrderTypeCode column.</param>
        /// <param name="isDeleted">The value for the IsDeleted column.</param>
        /// <param name="isRouted">The value for the IsRouted column.</param>
        /// <param name="quantity">The value for the Quantity column.</param>
        /// <param name="price1">The value for the Price1 column.</param>
        /// <param name="price2">The value for the Price2 column.</param>
        /// <param name="createdTime">The value for the CreatedTime column.</param>
        /// <param name="createdUserId">The value for the CreatedUserId column.</param>
        /// <param name="modifiedTime">The value for the ModifiedTime column.</param>
        /// <param name="modifiedUserId">The value for the ModifiedUserId column.</param>
        public static int Insert(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            int blockOrderId,
            int brokerId,
            int timeInForceCode,
            int orderTypeCode,
            object isDeleted,
            object isRouted,
            decimal quantity,
            object price1,
            object price2,
            System.DateTime createdTime,
            int createdUserId,
            System.DateTime modifiedTime,
            int modifiedUserId)
        {
            // Accessor for the Placement Table.
            ServerDataModel.PlacementDataTable placementTable = ServerDataModel.Placement;
            // Apply Defaults
            if ((isDeleted == null))
            {
                isDeleted = false;
            }
            if ((isRouted == null))
            {
                isRouted = false;
            }
            if ((price1 == null))
            {
                price1 = System.DBNull.Value;
            }
            if ((price2 == null))
            {
                price2 = System.DBNull.Value;
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerDataModel.PlacementRow placementRow = placementTable.NewPlacementRow();
            placementRow[placementTable.RowVersionColumn]      = rowVersion;
            placementRow[placementTable.BlockOrderIdColumn]    = blockOrderId;
            placementRow[placementTable.BrokerIdColumn]        = brokerId;
            placementRow[placementTable.TimeInForceCodeColumn] = timeInForceCode;
            placementRow[placementTable.OrderTypeCodeColumn]   = orderTypeCode;
            placementRow[placementTable.IsDeletedColumn]       = isDeleted;
            placementRow[placementTable.IsRoutedColumn]        = isRouted;
            placementRow[placementTable.QuantityColumn]        = quantity;
            placementRow[placementTable.Price1Column]          = price1;
            placementRow[placementTable.Price2Column]          = price2;
            placementRow[placementTable.CreatedTimeColumn]     = createdTime;
            placementRow[placementTable.CreatedUserIdColumn]   = createdUserId;
            placementRow[placementTable.ModifiedTimeColumn]    = modifiedTime;
            placementRow[placementTable.ModifiedUserIdColumn]  = modifiedUserId;
            placementTable.AddPlacementRow(placementRow);
            adoTransaction.DataRows.Add(placementRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"insert ""Placement"" (""rowVersion"",""PlacementId"",""BlockOrderId"",""BrokerId"",""TimeInForceCode"",""OrderTypeCode"",""IsDeleted"",""IsRouted"",""Quantity"",""Price1"",""Price2"",""CreatedTime"",""CreatedUserId"",""ModifiedTime"",""ModifiedUserId"") values (@rowVersion,@placementId,@blockOrderId,@brokerId,@timeInForceCode,@orderTypeCode,@isDeleted,@isRouted,@quantity,@price1,@price2,@createdTime,@createdUserId,@modifiedTime,@modifiedUserId)");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@rowVersion", SqlDbType.BigInt, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rowVersion));
            sqlCommand.Parameters.Add(new SqlParameter("@placementId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, placementRow[placementTable.PlacementIdColumn]));
            sqlCommand.Parameters.Add(new SqlParameter("@blockOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, blockOrderId));
            sqlCommand.Parameters.Add(new SqlParameter("@brokerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerId));
            sqlCommand.Parameters.Add(new SqlParameter("@timeInForceCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, timeInForceCode));
            sqlCommand.Parameters.Add(new SqlParameter("@orderTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, orderTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@isDeleted", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isDeleted));
            sqlCommand.Parameters.Add(new SqlParameter("@isRouted", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isRouted));
            sqlCommand.Parameters.Add(new SqlParameter("@quantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, quantity));
            sqlCommand.Parameters.Add(new SqlParameter("@price1", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, price1));
            sqlCommand.Parameters.Add(new SqlParameter("@price2", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, price2));
            sqlCommand.Parameters.Add(new SqlParameter("@createdTime", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, createdTime));
            sqlCommand.Parameters.Add(new SqlParameter("@createdUserId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, createdUserId));
            sqlCommand.Parameters.Add(new SqlParameter("@modifiedTime", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, modifiedTime));
            sqlCommand.Parameters.Add(new SqlParameter("@modifiedUserId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, modifiedUserId));
            sqlCommand.ExecuteNonQuery();
            // Return Statements
            return(placementRow.PlacementId);
        }
Example #7
0
        /// <summary>Updates a Placement record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="rowVersion">The version number of the row</param>
        /// <param name="placementId">The value for the PlacementId column.</param>
        /// <param name="blockOrderId">The value for the BlockOrderId column.</param>
        /// <param name="brokerId">The value for the BrokerId column.</param>
        /// <param name="timeInForceCode">The value for the TimeInForceCode column.</param>
        /// <param name="orderTypeCode">The value for the OrderTypeCode column.</param>
        /// <param name="isDeleted">The value for the IsDeleted column.</param>
        /// <param name="isRouted">The value for the IsRouted column.</param>
        /// <param name="quantity">The value for the Quantity column.</param>
        /// <param name="price1">The value for the Price1 column.</param>
        /// <param name="price2">The value for the Price2 column.</param>
        /// <param name="createdTime">The value for the CreatedTime column.</param>
        /// <param name="createdUserId">The value for the CreatedUserId column.</param>
        /// <param name="modifiedTime">The value for the ModifiedTime column.</param>
        /// <param name="modifiedUserId">The value for the ModifiedUserId column.</param>
        public static void Update(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            int placementId,
            object blockOrderId,
            object brokerId,
            object timeInForceCode,
            object orderTypeCode,
            object isDeleted,
            object isRouted,
            object quantity,
            object price1,
            object price2,
            object createdTime,
            object createdUserId,
            object modifiedTime,
            object modifiedUserId)
        {
            // Accessor for the Placement Table.
            ServerDataModel.PlacementDataTable placementTable = ServerDataModel.Placement;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.PlacementRow placementRow = placementTable.FindByPlacementId(placementId);
            if ((placementRow == null))
            {
                throw new Exception(string.Format("The Placement table does not have an element identified by {0}", placementId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((placementRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((blockOrderId == null))
            {
                blockOrderId = placementRow[placementTable.BlockOrderIdColumn];
            }
            if ((brokerId == null))
            {
                brokerId = placementRow[placementTable.BrokerIdColumn];
            }
            if ((timeInForceCode == null))
            {
                timeInForceCode = placementRow[placementTable.TimeInForceCodeColumn];
            }
            if ((orderTypeCode == null))
            {
                orderTypeCode = placementRow[placementTable.OrderTypeCodeColumn];
            }
            if ((isDeleted == null))
            {
                isDeleted = placementRow[placementTable.IsDeletedColumn];
            }
            if ((isRouted == null))
            {
                isRouted = placementRow[placementTable.IsRoutedColumn];
            }
            if ((quantity == null))
            {
                quantity = placementRow[placementTable.QuantityColumn];
            }
            if ((price1 == null))
            {
                price1 = placementRow[placementTable.Price1Column];
            }
            if ((price2 == null))
            {
                price2 = placementRow[placementTable.Price2Column];
            }
            if ((createdTime == null))
            {
                createdTime = placementRow[placementTable.CreatedTimeColumn];
            }
            if ((createdUserId == null))
            {
                createdUserId = placementRow[placementTable.CreatedUserIdColumn];
            }
            if ((modifiedTime == null))
            {
                modifiedTime = placementRow[placementTable.ModifiedTimeColumn];
            }
            if ((modifiedUserId == null))
            {
                modifiedUserId = placementRow[placementTable.ModifiedUserIdColumn];
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Update the record in the ADO database.
            placementRow[placementTable.RowVersionColumn]      = rowVersion;
            placementRow[placementTable.BlockOrderIdColumn]    = blockOrderId;
            placementRow[placementTable.BrokerIdColumn]        = brokerId;
            placementRow[placementTable.TimeInForceCodeColumn] = timeInForceCode;
            placementRow[placementTable.OrderTypeCodeColumn]   = orderTypeCode;
            placementRow[placementTable.IsDeletedColumn]       = isDeleted;
            placementRow[placementTable.IsRoutedColumn]        = isRouted;
            placementRow[placementTable.QuantityColumn]        = quantity;
            placementRow[placementTable.Price1Column]          = price1;
            placementRow[placementTable.Price2Column]          = price2;
            placementRow[placementTable.CreatedTimeColumn]     = createdTime;
            placementRow[placementTable.CreatedUserIdColumn]   = createdUserId;
            placementRow[placementTable.ModifiedTimeColumn]    = modifiedTime;
            placementRow[placementTable.ModifiedUserIdColumn]  = modifiedUserId;
            adoTransaction.DataRows.Add(placementRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"update ""Placement"" set ""RowVersion""=@rowVersion,""BlockOrderId""=@blockOrderId,""BrokerId""=@brokerId,""TimeInForceCode""=@timeInForceCode,""OrderTypeCode""=@orderTypeCode,""IsDeleted""=@isDeleted,""IsRouted""=@isRouted,""Quantity""=@quantity,""Price1""=@price1,""Price2""=@price2,""CreatedTime""=@createdTime,""CreatedUserId""=@createdUserId,""ModifiedTime""=@modifiedTime,""ModifiedUserId""=@modifiedUserId where ""PlacementId""=@placementId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@rowVersion", SqlDbType.BigInt, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rowVersion));
            sqlCommand.Parameters.Add(new SqlParameter("@placementId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, placementId));
            sqlCommand.Parameters.Add(new SqlParameter("@blockOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, blockOrderId));
            sqlCommand.Parameters.Add(new SqlParameter("@brokerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerId));
            sqlCommand.Parameters.Add(new SqlParameter("@timeInForceCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, timeInForceCode));
            sqlCommand.Parameters.Add(new SqlParameter("@orderTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, orderTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@isDeleted", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isDeleted));
            sqlCommand.Parameters.Add(new SqlParameter("@isRouted", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isRouted));
            sqlCommand.Parameters.Add(new SqlParameter("@quantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, quantity));
            sqlCommand.Parameters.Add(new SqlParameter("@price1", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, price1));
            sqlCommand.Parameters.Add(new SqlParameter("@price2", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, price2));
            sqlCommand.Parameters.Add(new SqlParameter("@createdTime", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, createdTime));
            sqlCommand.Parameters.Add(new SqlParameter("@createdUserId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, createdUserId));
            sqlCommand.Parameters.Add(new SqlParameter("@modifiedTime", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, modifiedTime));
            sqlCommand.Parameters.Add(new SqlParameter("@modifiedUserId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, modifiedUserId));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }