public List <ArchiveTemplateStock> Get(int archiveId) { List <ArchiveTemplateStock> templateStocks = new List <ArchiveTemplateStock>(); if (archiveId < 1) { return(templateStocks); } var dbCommand = _dbHelper.GetStoredProcCommand(SP_Get); _dbHelper.AddInParameter(dbCommand, "@ArchiveId", System.Data.DbType.Int32, archiveId); var reader = _dbHelper.ExecuteReader(dbCommand); if (reader.HasRows) { while (reader.Read()) { ArchiveTemplateStock item = new ArchiveTemplateStock(); item.ArchiveId = (int)reader["ArchiveId"]; item.TemplateNo = (int)reader["TemplateId"]; item.SecuCode = (string)reader["SecuCode"]; //item.SecuName = (string)reader["SecuName"]; //item.Exchange = (string)reader["ExchangeCode"]; item.Amount = (int)reader["Amount"]; item.MarketCap = (double)(decimal)reader["MarketCap"]; item.MarketCapWeight = (double)(decimal)reader["MarketCapOpt"]; item.SettingWeight = (double)(decimal)reader["SettingWeight"]; templateStocks.Add(item); } } reader.Close(); _dbHelper.Close(dbCommand); return(templateStocks); }
public string Create(ArchiveTemplateStock stock) { var dbCommand = _dbHelper.GetStoredProcCommand(SP_Create); _dbHelper.AddInParameter(dbCommand, "@ArchiveId", System.Data.DbType.Int32, stock.ArchiveId); _dbHelper.AddInParameter(dbCommand, "@TemplateId", System.Data.DbType.Int32, stock.TemplateNo); _dbHelper.AddInParameter(dbCommand, "@SecuCode", System.Data.DbType.String, stock.SecuCode); _dbHelper.AddInParameter(dbCommand, "@Amount", System.Data.DbType.Int32, stock.Amount); _dbHelper.AddInParameter(dbCommand, "@MarketCap", System.Data.DbType.Decimal, stock.MarketCap); _dbHelper.AddInParameter(dbCommand, "@MarketCapOpt", System.Data.DbType.Decimal, stock.MarketCapWeight); _dbHelper.AddInParameter(dbCommand, "@SettingWeight", System.Data.DbType.Decimal, stock.SettingWeight); _dbHelper.AddOutParameter(dbCommand, "@ReturnValue", System.Data.DbType.String, 50); int ret = _dbHelper.ExecuteNonQuery(dbCommand); string newid = string.Empty; if (ret > 0) { newid = (string)dbCommand.Parameters["@ReturnValue"].Value; } return(newid); }