Esempio n. 1
0
        /// <summary>Inserts a Allocation 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="accountId">The value for the AccountId column.</param>
        /// <param name="securityId">The value for the SecurityId column.</param>
        /// <param name="settlementId">The value for the SettlementId column.</param>
        /// <param name="positionTypeCode">The value for the PositionTypeCode column.</param>
        /// <param name="transactionTypeCode">The value for the TransactionTypeCode column.</param>
        /// <param name="quantity">The value for the Quantity column.</param>
        /// <param name="price">The value for the Price column.</param>
        /// <param name="commission">The value for the Commission column.</param>
        /// <param name="accruedInterest">The value for the AccruedInterest column.</param>
        /// <param name="userFee0">The value for the UserFee0 column.</param>
        /// <param name="userFee1">The value for the UserFee1 column.</param>
        /// <param name="userFee2">The value for the UserFee2 column.</param>
        /// <param name="userFee3">The value for the UserFee3 column.</param>
        /// <param name="tradeDate">The value for the TradeDate column.</param>
        /// <param name="settlementDate">The value for the SettlementDate 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 accountId,
            int securityId,
            int settlementId,
            int positionTypeCode,
            int transactionTypeCode,
            decimal quantity,
            decimal price,
            decimal commission,
            decimal accruedInterest,
            decimal userFee0,
            decimal userFee1,
            decimal userFee2,
            decimal userFee3,
            System.DateTime tradeDate,
            System.DateTime settlementDate,
            System.DateTime createdTime,
            int createdUserId,
            System.DateTime modifiedTime,
            int modifiedUserId)
        {
            // Accessor for the Allocation Table.
            ServerDataModel.AllocationDataTable allocationTable = ServerDataModel.Allocation;
            // Apply Defaults
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerDataModel.AllocationRow allocationRow = allocationTable.NewAllocationRow();
            allocationRow[allocationTable.RowVersionColumn]          = rowVersion;
            allocationRow[allocationTable.BlockOrderIdColumn]        = blockOrderId;
            allocationRow[allocationTable.AccountIdColumn]           = accountId;
            allocationRow[allocationTable.SecurityIdColumn]          = securityId;
            allocationRow[allocationTable.SettlementIdColumn]        = settlementId;
            allocationRow[allocationTable.PositionTypeCodeColumn]    = positionTypeCode;
            allocationRow[allocationTable.TransactionTypeCodeColumn] = transactionTypeCode;
            allocationRow[allocationTable.QuantityColumn]            = quantity;
            allocationRow[allocationTable.PriceColumn]           = price;
            allocationRow[allocationTable.CommissionColumn]      = commission;
            allocationRow[allocationTable.AccruedInterestColumn] = accruedInterest;
            allocationRow[allocationTable.UserFee0Column]        = userFee0;
            allocationRow[allocationTable.UserFee1Column]        = userFee1;
            allocationRow[allocationTable.UserFee2Column]        = userFee2;
            allocationRow[allocationTable.UserFee3Column]        = userFee3;
            allocationRow[allocationTable.TradeDateColumn]       = tradeDate;
            allocationRow[allocationTable.SettlementDateColumn]  = settlementDate;
            allocationRow[allocationTable.CreatedTimeColumn]     = createdTime;
            allocationRow[allocationTable.CreatedUserIdColumn]   = createdUserId;
            allocationRow[allocationTable.ModifiedTimeColumn]    = modifiedTime;
            allocationRow[allocationTable.ModifiedUserIdColumn]  = modifiedUserId;
            allocationTable.AddAllocationRow(allocationRow);
            adoTransaction.DataRows.Add(allocationRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"insert ""Allocation"" (""rowVersion"",""AllocationId"",""BlockOrderId"",""AccountId"",""SecurityId"",""SettlementId"",""PositionTypeCode"",""TransactionTypeCode"",""Quantity"",""Price"",""Commission"",""AccruedInterest"",""UserFee0"",""UserFee1"",""UserFee2"",""UserFee3"",""TradeDate"",""SettlementDate"",""CreatedTime"",""CreatedUserId"",""ModifiedTime"",""ModifiedUserId"") values (@rowVersion,@allocationId,@blockOrderId,@accountId,@securityId,@settlementId,@positionTypeCode,@transactionTypeCode,@quantity,@price,@commission,@accruedInterest,@userFee0,@userFee1,@userFee2,@userFee3,@tradeDate,@settlementDate,@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("@allocationId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, allocationRow[allocationTable.AllocationIdColumn]));
            sqlCommand.Parameters.Add(new SqlParameter("@blockOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, blockOrderId));
            sqlCommand.Parameters.Add(new SqlParameter("@accountId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, accountId));
            sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId));
            sqlCommand.Parameters.Add(new SqlParameter("@settlementId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, settlementId));
            sqlCommand.Parameters.Add(new SqlParameter("@positionTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, positionTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@transactionTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, transactionTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@quantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, quantity));
            sqlCommand.Parameters.Add(new SqlParameter("@price", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, price));
            sqlCommand.Parameters.Add(new SqlParameter("@commission", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, commission));
            sqlCommand.Parameters.Add(new SqlParameter("@accruedInterest", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, accruedInterest));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee0", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee0));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee1", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee1));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee2", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee2));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee3", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee3));
            sqlCommand.Parameters.Add(new SqlParameter("@tradeDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, tradeDate));
            sqlCommand.Parameters.Add(new SqlParameter("@settlementDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, settlementDate));
            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(allocationRow.AllocationId);
        }