/// <summary>Inserts a TraderVolumeSetting record using Metadata Parameters.</summary> /// <param name="parameters">Contains the metadata parameters.</param> public static void Delete(ParameterList parameters) { // Extract the parameters from the command batch. AdoTransaction adoTransaction = parameters["adoTransaction"]; SqlTransaction sqlTransaction = parameters["sqlTransaction"]; long rowVersion = parameters["rowVersion"]; int traderVolumeSettingId = parameters["traderVolumeSettingId"]; // Call the internal method to complete the operation. TraderVolumeSetting.Delete(adoTransaction, sqlTransaction, rowVersion, traderVolumeSettingId); }
/// <summary>Deletes a VolumeCategory 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="volumeCategoryId">The value for the VolumeCategoryId column.</param> /// <param name="archive">true to archive the object, false to unarchive it.</param> public static void Delete(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int volumeCategoryId) { // Accessor for the VolumeCategory Table. ServerMarketData.VolumeCategoryDataTable volumeCategoryTable = ServerMarketData.VolumeCategory; // Rule #1: Make sure the record exists before updating it. ServerMarketData.VolumeCategoryRow volumeCategoryRow = volumeCategoryTable.FindByVolumeCategoryId(volumeCategoryId); if ((volumeCategoryRow == null)) { throw new Exception(string.Format("The VolumeCategory table does not have an element identified by {0}", volumeCategoryId)); } // Rule #2: Optimistic Concurrency Check if ((volumeCategoryRow.RowVersion != rowVersion)) { throw new System.Exception("This record is busy. Please try again later."); } // Delete the child records. for (int index = 0; (index < volumeCategoryRow.GetSecurityRows().Length); index = (index + 1)) { ServerMarketData.SecurityRow childSecurityRow = volumeCategoryRow.GetSecurityRows()[index]; Security.DeleteChildren(adoTransaction, sqlTransaction, childSecurityRow.RowVersion, childSecurityRow.SecurityId); } for (int index = 0; (index < volumeCategoryRow.GetTraderVolumeSettingRows().Length); index = (index + 1)) { ServerMarketData.TraderVolumeSettingRow childTraderVolumeSettingRow = volumeCategoryRow.GetTraderVolumeSettingRows()[index]; TraderVolumeSetting.Delete(adoTransaction, sqlTransaction, childTraderVolumeSettingRow.RowVersion, childTraderVolumeSettingRow.TraderVolumeSettingId); } // Increment the row version rowVersion = ServerMarketData.RowVersion.Increment(); // Delete the record in the ADO database. volumeCategoryRow[volumeCategoryTable.RowVersionColumn] = rowVersion; adoTransaction.DataRows.Add(volumeCategoryRow); volumeCategoryRow.Delete(); // Delete the record in the SQL database. SqlCommand sqlCommand = new SqlCommand("update \"VolumeCategory\" set \"IsDeleted\" = 1 where \"VolumeCategoryId\"=@volumeCateg" + "oryId"); sqlCommand.Connection = sqlTransaction.Connection; sqlCommand.Transaction = sqlTransaction; sqlCommand.Parameters.Add(new SqlParameter("@volumeCategoryId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, volumeCategoryId)); sqlCommand.ExecuteNonQuery(); }