Example #1
0
 public void updateStockPriceVolume(double quantity, QuoteDataModel quote)
 {
     //See note above: want to use existing connection
     MarketSummary marketSummaryDal = new MarketSummary(_internalConnection, _internalADOTransaction);
     marketSummaryDal.updateStockPriceVolume(quantity, quote);
     return;
 }
Example #2
0
 /// <summary>
 /// Converts from service data contract model class to a UI Model class for quick HTML display in ASPX pages.
 /// </summary>
 private QuoteDataUI convertQuoteToUI(QuoteDataModel quote)
 {
     if (quote != null)
         return new QuoteDataUI(quote.symbol, quote.companyName, quote.volume, quote.price, quote.open, quote.low, quote.high, quote.change);
     else return null;
 }
 public QuoteDataModel getQuoteForUpdate(string symbol)
 {
     try
     {
         SqlParameter parm1 = new SqlParameter(PARM_SYMBOL, SqlDbType.VarChar, 10);
         parm1.Value = symbol;
         SqlDataReader rdr = SQLHelper.ExecuteReaderSingleRowSingleParm(_internalConnection, _internalADOTransaction, CommandType.Text, SQL_SELECT_QUOTE, parm1);
         QuoteDataModel quote = null;
         if (rdr.HasRows)
         {
             rdr.Read();
             quote = new QuoteDataModel(rdr.GetString(0), rdr.GetString(1), rdr.GetDouble(2), rdr.GetDecimal(3), rdr.GetDecimal(4), rdr.GetDecimal(5), rdr.GetDecimal(6), rdr.GetDouble(7));
         }
         rdr.Close();
         return quote;
     }
     catch
     {
         throw;
     }
 }
 public MarketSummaryDataModelWS getMarketSummaryData()
 {
     try
     {
         decimal TSIA = (decimal)SQLHelper.ExecuteScalarNoParm(_internalConnection,_internalADOTransaction, CommandType.Text,SQL_SELECT_MARKETSUMMARY_TSIA);
         decimal openTSIA = (decimal)SQLHelper.ExecuteScalarNoParm(_internalConnection,_internalADOTransaction,CommandType.Text,SQL_SELECT_MARKETSUMMARY_OPENTSIA);
         double totalVolume = (double)SQLHelper.ExecuteScalarNoParm(_internalConnection,_internalADOTransaction,CommandType.Text,SQL_SELECT_MARKETSUMMARY_VOLUME);
         SqlDataReader rdr = SQLHelper.ExecuteReaderNoParm(_internalConnection,_internalADOTransaction,CommandType.Text,SQL_SELECT_MARKETSUMMARY_GAINERS);
         List<QuoteDataModel> topgainers = new List<QuoteDataModel>();
         List<QuoteDataModel> toplosers = new List<QuoteDataModel>();
         int i = 0;
         while (rdr.Read() && i++<5)
         {
             QuoteDataModel quote = new QuoteDataModel(rdr.GetString(0), rdr.GetString(1), rdr.GetDouble(2), rdr.GetDecimal(3), rdr.GetDecimal(4), rdr.GetDecimal(5), rdr.GetDecimal(6), rdr.GetDouble(7));
             topgainers.Add(quote);
         }
         rdr.Close();
         rdr = SQLHelper.ExecuteReaderNoParm(_internalConnection,_internalADOTransaction,CommandType.Text,SQL_SELECT_MARKETSUMMARY_LOSERS);
         i = 0;
         while (rdr.Read() && i++ < 5)
         {
             QuoteDataModel quote = new QuoteDataModel(rdr.GetString(0), rdr.GetString(1), rdr.GetDouble(2), rdr.GetDecimal(3), rdr.GetDecimal(4), rdr.GetDecimal(5), rdr.GetDecimal(6), rdr.GetDouble(7));
             toplosers.Add(quote);
         }
         rdr.Close();
         MarketSummaryDataModelWS marketSummaryData = new MarketSummaryDataModelWS(TSIA, openTSIA, totalVolume, topgainers, toplosers);
         return marketSummaryData;
     }
     catch
     {
         throw;
     }
 }
 public void updateStockPriceVolume(double Quantity, QuoteDataModel quote)
 {
     try
     {
         SqlParameter[] updatestockpriceparm = GetUpdateStockPriceVolumeParameters();
         decimal priceChangeFactor = StockTraderUtility.getRandomPriceChangeFactor(quote.price);
         decimal newprice = quote.price * priceChangeFactor;
         if (newprice < quote.low)
             quote.low = newprice;
         if (newprice > quote.high)
             quote.high = newprice;
         updatestockpriceparm[0].Value = (decimal)newprice;
         updatestockpriceparm[1].Value = (float)Quantity;
         updatestockpriceparm[2].Value = quote.symbol;
         updatestockpriceparm[3].Value = quote.low;
         updatestockpriceparm[4].Value = quote.high;
         SQLHelper.ExecuteNonQuery(_internalConnection, _internalADOTransaction, CommandType.Text, SQL_UPDATE_STOCKPRICEVOLUME, updatestockpriceparm);
         return;
     }
     catch 
     {
         throw;
     }
 }