Beispiel #1
0
        /// <summary>Archives a TransactionType 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="transactionTypeCode">The value for the TransactionTypeCode 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 transactionTypeCode)
        {
            // Accessor for the TransactionType Table.
            ServerDataModel.TransactionTypeDataTable transactionTypeTable = ServerDataModel.TransactionType;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.TransactionTypeRow transactionTypeRow = transactionTypeTable.FindByTransactionTypeCode(transactionTypeCode);
            if ((transactionTypeRow == null))
            {
                throw new Exception(string.Format("The TransactionType table does not have an element identified by {0}", transactionTypeCode));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((transactionTypeRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < transactionTypeRow.GetAllocationRows().Length); index = (index + 1))
            {
                ServerDataModel.AllocationRow childAllocationRow = transactionTypeRow.GetAllocationRows()[index];
                Allocation.Archive(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId);
            }
            for (int index = 0; (index < transactionTypeRow.GetBlockOrderRows().Length); index = (index + 1))
            {
                ServerDataModel.BlockOrderRow childBlockOrderRow = transactionTypeRow.GetBlockOrderRows()[index];
                BlockOrder.Archive(adoTransaction, sqlTransaction, childBlockOrderRow.RowVersion, childBlockOrderRow.BlockOrderId);
            }
            for (int index = 0; (index < transactionTypeRow.GetOrderRows().Length); index = (index + 1))
            {
                ServerDataModel.OrderRow childOrderRow = transactionTypeRow.GetOrderRows()[index];
                Order.Archive(adoTransaction, sqlTransaction, childOrderRow.RowVersion, childOrderRow.OrderId);
            }
            for (int index = 0; (index < transactionTypeRow.GetProposedOrderRows().Length); index = (index + 1))
            {
                ServerDataModel.ProposedOrderRow childProposedOrderRow = transactionTypeRow.GetProposedOrderRows()[index];
                ProposedOrder.Archive(adoTransaction, sqlTransaction, childProposedOrderRow.RowVersion, childProposedOrderRow.ProposedOrderId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            transactionTypeRow[transactionTypeTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(transactionTypeRow);
            transactionTypeRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"TransactionType\" set \"IsArchived\" = 1 where \"TransactionTypeCode\"=@transa" +
                                                   "ctionTypeCode");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@transactionTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, transactionTypeCode));
            sqlCommand.ExecuteNonQuery();
        }
Beispiel #2
0
        /// <summary>Archives a ProposedOrder 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="proposedOrderId">The value for the ProposedOrderId 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 proposedOrderId)
        {
            // Accessor for the ProposedOrder Table.
            ServerDataModel.ProposedOrderDataTable proposedOrderTable = ServerDataModel.ProposedOrder;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.ProposedOrderRow proposedOrderRow = proposedOrderTable.FindByProposedOrderId(proposedOrderId);
            if ((proposedOrderRow == null))
            {
                throw new Exception(string.Format("The ProposedOrder table does not have an element identified by {0}", proposedOrderId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((proposedOrderRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < proposedOrderRow.GetProposedOrderTreeRowsByFKProposedOrderProposedOrderTreeChildId().Length); index = (index + 1))
            {
                ServerDataModel.ProposedOrderTreeRow childProposedOrderTreeRow = proposedOrderRow.GetProposedOrderTreeRowsByFKProposedOrderProposedOrderTreeChildId()[index];
                ProposedOrderTree.Archive(adoTransaction, sqlTransaction, childProposedOrderTreeRow.RowVersion, childProposedOrderTreeRow.ParentId, childProposedOrderTreeRow.ChildId);
            }
            for (int index = 0; (index < proposedOrderRow.GetProposedOrderTreeRowsByFKProposedOrderProposedOrderTreeParentId().Length); index = (index + 1))
            {
                ServerDataModel.ProposedOrderTreeRow childProposedOrderTreeRow = proposedOrderRow.GetProposedOrderTreeRowsByFKProposedOrderProposedOrderTreeParentId()[index];
                ProposedOrderTree.Archive(adoTransaction, sqlTransaction, childProposedOrderTreeRow.RowVersion, childProposedOrderTreeRow.ParentId, childProposedOrderTreeRow.ChildId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            proposedOrderRow[proposedOrderTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(proposedOrderRow);
            proposedOrderRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"ProposedOrder\" set \"IsArchived\" = 1 where \"ProposedOrderId\"=@proposedOrde" +
                                                   "rId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@proposedOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, proposedOrderId));
            sqlCommand.ExecuteNonQuery();
        }
Beispiel #3
0
        /// <summary>Inserts a ProposedOrder record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="blotterId">The value for the BlotterId 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="brokerId">The value for the BrokerId column.</param>
        /// <param name="positionTypeCode">The value for the PositionTypeCode column.</param>
        /// <param name="transactionTypeCode">The value for the TransactionTypeCode column.</param>
        /// <param name="timeInForceCode">The value for the TimeInForceCode column.</param>
        /// <param name="orderTypeCode">The value for the OrderTypeCode column.</param>
        /// <param name="conditionCode">The value for the ConditionCode column.</param>
        /// <param name="isAgency">The value for the IsAgency 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="note">The value for the Note column.</param>
        public static int Insert(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            object blotterId,
            int accountId,
            int securityId,
            int settlementId,
            object brokerId,
            int positionTypeCode,
            int transactionTypeCode,
            int timeInForceCode,
            int orderTypeCode,
            object conditionCode,
            object isAgency,
            decimal quantity,
            object price1,
            object price2,
            object note)
        {
            // Accessor for the ProposedOrder Table.
            ServerDataModel.ProposedOrderDataTable proposedOrderTable = ServerDataModel.ProposedOrder;
            // Apply Defaults
            if ((blotterId == null))
            {
                blotterId = System.DBNull.Value;
            }
            if ((brokerId == null))
            {
                brokerId = System.DBNull.Value;
            }
            if ((conditionCode == null))
            {
                conditionCode = System.DBNull.Value;
            }
            if ((isAgency == null))
            {
                isAgency = false;
            }
            if ((price1 == null))
            {
                price1 = System.DBNull.Value;
            }
            if ((price2 == null))
            {
                price2 = System.DBNull.Value;
            }
            if ((note == null))
            {
                note = System.DBNull.Value;
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerDataModel.ProposedOrderRow proposedOrderRow = proposedOrderTable.NewProposedOrderRow();
            proposedOrderRow[proposedOrderTable.RowVersionColumn]          = rowVersion;
            proposedOrderRow[proposedOrderTable.BlotterIdColumn]           = blotterId;
            proposedOrderRow[proposedOrderTable.AccountIdColumn]           = accountId;
            proposedOrderRow[proposedOrderTable.SecurityIdColumn]          = securityId;
            proposedOrderRow[proposedOrderTable.SettlementIdColumn]        = settlementId;
            proposedOrderRow[proposedOrderTable.BrokerIdColumn]            = brokerId;
            proposedOrderRow[proposedOrderTable.PositionTypeCodeColumn]    = positionTypeCode;
            proposedOrderRow[proposedOrderTable.TransactionTypeCodeColumn] = transactionTypeCode;
            proposedOrderRow[proposedOrderTable.TimeInForceCodeColumn]     = timeInForceCode;
            proposedOrderRow[proposedOrderTable.OrderTypeCodeColumn]       = orderTypeCode;
            proposedOrderRow[proposedOrderTable.ConditionCodeColumn]       = conditionCode;
            proposedOrderRow[proposedOrderTable.IsAgencyColumn]            = isAgency;
            proposedOrderRow[proposedOrderTable.QuantityColumn]            = quantity;
            proposedOrderRow[proposedOrderTable.Price1Column] = price1;
            proposedOrderRow[proposedOrderTable.Price2Column] = price2;
            proposedOrderRow[proposedOrderTable.NoteColumn]   = note;
            proposedOrderTable.AddProposedOrderRow(proposedOrderRow);
            adoTransaction.DataRows.Add(proposedOrderRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"insert ""ProposedOrder"" (""rowVersion"",""ProposedOrderId"",""BlotterId"",""AccountId"",""SecurityId"",""SettlementId"",""BrokerId"",""PositionTypeCode"",""TransactionTypeCode"",""TimeInForceCode"",""OrderTypeCode"",""ConditionCode"",""IsAgency"",""Quantity"",""Price1"",""Price2"",""Note"") values (@rowVersion,@proposedOrderId,@blotterId,@accountId,@securityId,@settlementId,@brokerId,@positionTypeCode,@transactionTypeCode,@timeInForceCode,@orderTypeCode,@conditionCode,@isAgency,@quantity,@price1,@price2,@note)");

            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("@proposedOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, proposedOrderRow[proposedOrderTable.ProposedOrderIdColumn]));
            sqlCommand.Parameters.Add(new SqlParameter("@blotterId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, blotterId));
            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("@brokerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerId));
            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("@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("@conditionCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, conditionCode));
            sqlCommand.Parameters.Add(new SqlParameter("@isAgency", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isAgency));
            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("@note", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, note));
            sqlCommand.ExecuteNonQuery();
            // Return Statements
            return(proposedOrderRow.ProposedOrderId);
        }
Beispiel #4
0
        /// <summary>Updates a ProposedOrder 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="proposedOrderId">The value for the ProposedOrderId column.</param>
        /// <param name="blotterId">The value for the BlotterId 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="brokerId">The value for the BrokerId column.</param>
        /// <param name="positionTypeCode">The value for the PositionTypeCode column.</param>
        /// <param name="transactionTypeCode">The value for the TransactionTypeCode column.</param>
        /// <param name="timeInForceCode">The value for the TimeInForceCode column.</param>
        /// <param name="orderTypeCode">The value for the OrderTypeCode column.</param>
        /// <param name="conditionCode">The value for the ConditionCode column.</param>
        /// <param name="isAgency">The value for the IsAgency 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="note">The value for the Note column.</param>
        public static void Update(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            int proposedOrderId,
            object blotterId,
            object accountId,
            object securityId,
            object settlementId,
            object brokerId,
            object positionTypeCode,
            object transactionTypeCode,
            object timeInForceCode,
            object orderTypeCode,
            object conditionCode,
            object isAgency,
            object quantity,
            object price1,
            object price2,
            object note)
        {
            // Accessor for the ProposedOrder Table.
            ServerDataModel.ProposedOrderDataTable proposedOrderTable = ServerDataModel.ProposedOrder;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.ProposedOrderRow proposedOrderRow = proposedOrderTable.FindByProposedOrderId(proposedOrderId);
            if ((proposedOrderRow == null))
            {
                throw new Exception(string.Format("The ProposedOrder table does not have an element identified by {0}", proposedOrderId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((proposedOrderRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((blotterId == null))
            {
                blotterId = proposedOrderRow[proposedOrderTable.BlotterIdColumn];
            }
            if ((accountId == null))
            {
                accountId = proposedOrderRow[proposedOrderTable.AccountIdColumn];
            }
            if ((securityId == null))
            {
                securityId = proposedOrderRow[proposedOrderTable.SecurityIdColumn];
            }
            if ((settlementId == null))
            {
                settlementId = proposedOrderRow[proposedOrderTable.SettlementIdColumn];
            }
            if ((brokerId == null))
            {
                brokerId = proposedOrderRow[proposedOrderTable.BrokerIdColumn];
            }
            if ((positionTypeCode == null))
            {
                positionTypeCode = proposedOrderRow[proposedOrderTable.PositionTypeCodeColumn];
            }
            if ((transactionTypeCode == null))
            {
                transactionTypeCode = proposedOrderRow[proposedOrderTable.TransactionTypeCodeColumn];
            }
            if ((timeInForceCode == null))
            {
                timeInForceCode = proposedOrderRow[proposedOrderTable.TimeInForceCodeColumn];
            }
            if ((orderTypeCode == null))
            {
                orderTypeCode = proposedOrderRow[proposedOrderTable.OrderTypeCodeColumn];
            }
            if ((conditionCode == null))
            {
                conditionCode = proposedOrderRow[proposedOrderTable.ConditionCodeColumn];
            }
            if ((isAgency == null))
            {
                isAgency = proposedOrderRow[proposedOrderTable.IsAgencyColumn];
            }
            if ((quantity == null))
            {
                quantity = proposedOrderRow[proposedOrderTable.QuantityColumn];
            }
            if ((price1 == null))
            {
                price1 = proposedOrderRow[proposedOrderTable.Price1Column];
            }
            if ((price2 == null))
            {
                price2 = proposedOrderRow[proposedOrderTable.Price2Column];
            }
            if ((note == null))
            {
                note = proposedOrderRow[proposedOrderTable.NoteColumn];
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Update the record in the ADO database.
            proposedOrderRow[proposedOrderTable.RowVersionColumn]          = rowVersion;
            proposedOrderRow[proposedOrderTable.BlotterIdColumn]           = blotterId;
            proposedOrderRow[proposedOrderTable.AccountIdColumn]           = accountId;
            proposedOrderRow[proposedOrderTable.SecurityIdColumn]          = securityId;
            proposedOrderRow[proposedOrderTable.SettlementIdColumn]        = settlementId;
            proposedOrderRow[proposedOrderTable.BrokerIdColumn]            = brokerId;
            proposedOrderRow[proposedOrderTable.PositionTypeCodeColumn]    = positionTypeCode;
            proposedOrderRow[proposedOrderTable.TransactionTypeCodeColumn] = transactionTypeCode;
            proposedOrderRow[proposedOrderTable.TimeInForceCodeColumn]     = timeInForceCode;
            proposedOrderRow[proposedOrderTable.OrderTypeCodeColumn]       = orderTypeCode;
            proposedOrderRow[proposedOrderTable.ConditionCodeColumn]       = conditionCode;
            proposedOrderRow[proposedOrderTable.IsAgencyColumn]            = isAgency;
            proposedOrderRow[proposedOrderTable.QuantityColumn]            = quantity;
            proposedOrderRow[proposedOrderTable.Price1Column] = price1;
            proposedOrderRow[proposedOrderTable.Price2Column] = price2;
            proposedOrderRow[proposedOrderTable.NoteColumn]   = note;
            adoTransaction.DataRows.Add(proposedOrderRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"update ""ProposedOrder"" set ""RowVersion""=@rowVersion,""BlotterId""=@blotterId,""AccountId""=@accountId,""SecurityId""=@securityId,""SettlementId""=@settlementId,""BrokerId""=@brokerId,""PositionTypeCode""=@positionTypeCode,""TransactionTypeCode""=@transactionTypeCode,""TimeInForceCode""=@timeInForceCode,""OrderTypeCode""=@orderTypeCode,""ConditionCode""=@conditionCode,""IsAgency""=@isAgency,""Quantity""=@quantity,""Price1""=@price1,""Price2""=@price2,""Note""=@note where ""ProposedOrderId""=@proposedOrderId");

            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("@proposedOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, proposedOrderId));
            sqlCommand.Parameters.Add(new SqlParameter("@blotterId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, blotterId));
            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("@brokerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerId));
            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("@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("@conditionCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, conditionCode));
            sqlCommand.Parameters.Add(new SqlParameter("@isAgency", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isAgency));
            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("@note", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, note));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }
Beispiel #5
0
        /// <summary>ArchiveChildrens a Security 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="securityId">The value for the SecurityId 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 securityId)
        {
            // Accessor for the Security Table.
            ServerDataModel.SecurityDataTable securityTable = ServerDataModel.Security;
            // This record can be used to iterate through all the children.
            ServerDataModel.SecurityRow securityRow = securityTable.FindBySecurityId(securityId);
            // Archive the child records.
            for (int index = 0; (index < securityRow.GetAccountRows().Length); index = (index + 1))
            {
                ServerDataModel.AccountRow childAccountRow = securityRow.GetAccountRows()[index];
                Account.ArchiveChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId);
            }
            for (int index = 0; (index < securityRow.GetAllocationRowsByFKSecurityAllocationSecurityId().Length); index = (index + 1))
            {
                ServerDataModel.AllocationRow childAllocationRow = securityRow.GetAllocationRowsByFKSecurityAllocationSecurityId()[index];
                Allocation.Archive(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId);
            }
            for (int index = 0; (index < securityRow.GetAllocationRowsByFKSecurityAllocationSettlementId().Length); index = (index + 1))
            {
                ServerDataModel.AllocationRow childAllocationRow = securityRow.GetAllocationRowsByFKSecurityAllocationSettlementId()[index];
                Allocation.Archive(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId);
            }
            for (int index = 0; (index < securityRow.GetBlockOrderRowsByFKSecurityBlockOrderSecurityId().Length); index = (index + 1))
            {
                ServerDataModel.BlockOrderRow childBlockOrderRow = securityRow.GetBlockOrderRowsByFKSecurityBlockOrderSecurityId()[index];
                BlockOrder.Archive(adoTransaction, sqlTransaction, childBlockOrderRow.RowVersion, childBlockOrderRow.BlockOrderId);
            }
            for (int index = 0; (index < securityRow.GetBlockOrderRowsByFKSecurityBlockOrderSettlementId().Length); index = (index + 1))
            {
                ServerDataModel.BlockOrderRow childBlockOrderRow = securityRow.GetBlockOrderRowsByFKSecurityBlockOrderSettlementId()[index];
                BlockOrder.Archive(adoTransaction, sqlTransaction, childBlockOrderRow.RowVersion, childBlockOrderRow.BlockOrderId);
            }
            for (int index = 0; (index < securityRow.GetBlotterMapRows().Length); index = (index + 1))
            {
                ServerDataModel.BlotterMapRow childBlotterMapRow = securityRow.GetBlotterMapRows()[index];
                BlotterMap.Archive(adoTransaction, sqlTransaction, childBlotterMapRow.RowVersion, childBlotterMapRow.BlotterMapId);
            }
            for (int index = 0; (index < securityRow.GetDebtRowsByFKSecurityDebtDebtId().Length); index = (index + 1))
            {
                ServerDataModel.DebtRow childDebtRow = securityRow.GetDebtRowsByFKSecurityDebtDebtId()[index];
                Debt.ArchiveChildren(adoTransaction, sqlTransaction, childDebtRow.RowVersion, childDebtRow.DebtId);
            }
            for (int index = 0; (index < securityRow.GetDebtRowsByFKSecurityDebtSettlementId().Length); index = (index + 1))
            {
                ServerDataModel.DebtRow childDebtRow = securityRow.GetDebtRowsByFKSecurityDebtSettlementId()[index];
                Debt.ArchiveChildren(adoTransaction, sqlTransaction, childDebtRow.RowVersion, childDebtRow.DebtId);
            }
            for (int index = 0; (index < securityRow.GetCurrencyRows().Length); index = (index + 1))
            {
                ServerDataModel.CurrencyRow childCurrencyRow = securityRow.GetCurrencyRows()[index];
                Currency.ArchiveChildren(adoTransaction, sqlTransaction, childCurrencyRow.RowVersion, childCurrencyRow.CurrencyId);
            }
            for (int index = 0; (index < securityRow.GetEquityRowsByFKSecurityEquityEquityId().Length); index = (index + 1))
            {
                ServerDataModel.EquityRow childEquityRow = securityRow.GetEquityRowsByFKSecurityEquityEquityId()[index];
                Equity.ArchiveChildren(adoTransaction, sqlTransaction, childEquityRow.RowVersion, childEquityRow.EquityId);
            }
            for (int index = 0; (index < securityRow.GetEquityRowsByFKSecurityEquitySettlementId().Length); index = (index + 1))
            {
                ServerDataModel.EquityRow childEquityRow = securityRow.GetEquityRowsByFKSecurityEquitySettlementId()[index];
                Equity.ArchiveChildren(adoTransaction, sqlTransaction, childEquityRow.RowVersion, childEquityRow.EquityId);
            }
            for (int index = 0; (index < securityRow.GetOrderRowsByFKSecurityOrderSecurityId().Length); index = (index + 1))
            {
                ServerDataModel.OrderRow childOrderRow = securityRow.GetOrderRowsByFKSecurityOrderSecurityId()[index];
                Order.Archive(adoTransaction, sqlTransaction, childOrderRow.RowVersion, childOrderRow.OrderId);
            }
            for (int index = 0; (index < securityRow.GetOrderRowsByFKSecurityOrderSettlementId().Length); index = (index + 1))
            {
                ServerDataModel.OrderRow childOrderRow = securityRow.GetOrderRowsByFKSecurityOrderSettlementId()[index];
                Order.Archive(adoTransaction, sqlTransaction, childOrderRow.RowVersion, childOrderRow.OrderId);
            }
            for (int index = 0; (index < securityRow.GetPositionRows().Length); index = (index + 1))
            {
                ServerDataModel.PositionRow childPositionRow = securityRow.GetPositionRows()[index];
                Position.Archive(adoTransaction, sqlTransaction, childPositionRow.RowVersion, childPositionRow.AccountId, childPositionRow.SecurityId, childPositionRow.PositionTypeCode);
            }
            for (int index = 0; (index < securityRow.GetPositionTargetRows().Length); index = (index + 1))
            {
                ServerDataModel.PositionTargetRow childPositionTargetRow = securityRow.GetPositionTargetRows()[index];
                PositionTarget.Archive(adoTransaction, sqlTransaction, childPositionTargetRow.RowVersion, childPositionTargetRow.ModelId, childPositionTargetRow.SecurityId, childPositionTargetRow.PositionTypeCode);
            }
            for (int index = 0; (index < securityRow.GetPriceRows().Length); index = (index + 1))
            {
                ServerDataModel.PriceRow childPriceRow = securityRow.GetPriceRows()[index];
                Price.Archive(adoTransaction, sqlTransaction, childPriceRow.RowVersion, childPriceRow.SecurityId, childPriceRow.CurrencyId);
            }
            for (int index = 0; (index < securityRow.GetProposedOrderRowsByFKSecurityProposedOrderSecurityId().Length); index = (index + 1))
            {
                ServerDataModel.ProposedOrderRow childProposedOrderRow = securityRow.GetProposedOrderRowsByFKSecurityProposedOrderSecurityId()[index];
                ProposedOrder.Archive(adoTransaction, sqlTransaction, childProposedOrderRow.RowVersion, childProposedOrderRow.ProposedOrderId);
            }
            for (int index = 0; (index < securityRow.GetProposedOrderRowsByFKSecurityProposedOrderSettlementId().Length); index = (index + 1))
            {
                ServerDataModel.ProposedOrderRow childProposedOrderRow = securityRow.GetProposedOrderRowsByFKSecurityProposedOrderSettlementId()[index];
                ProposedOrder.Archive(adoTransaction, sqlTransaction, childProposedOrderRow.RowVersion, childProposedOrderRow.ProposedOrderId);
            }
            for (int index = 0; (index < securityRow.GetTaxLotRows().Length); index = (index + 1))
            {
                ServerDataModel.TaxLotRow childTaxLotRow = securityRow.GetTaxLotRows()[index];
                TaxLot.Archive(adoTransaction, sqlTransaction, childTaxLotRow.RowVersion, childTaxLotRow.TaxLotId);
            }
            for (int index = 0; (index < securityRow.GetViolationRows().Length); index = (index + 1))
            {
                ServerDataModel.ViolationRow childViolationRow = securityRow.GetViolationRows()[index];
                Violation.Archive(adoTransaction, sqlTransaction, childViolationRow.RowVersion, childViolationRow.ViolationId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            securityRow[securityTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(securityRow);
            securityRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Security\" set \"IsArchived\" = 1 where \"SecurityId\"=@securityId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId));
            sqlCommand.ExecuteNonQuery();
        }