[Quantproject-developers] QuantProject/b2_DataAccess/Tables Quotes.cs,1.24,1.25
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2005-05-04 18:26:00
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6416/b2_DataAccess/Tables Modified Files: Quotes.cs Log Message: Added to some methods the "if" clause with "is" operator before casting, in order to avoid noisy exception. Index: Quotes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/Tables/Quotes.cs,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Quotes.cs 19 Apr 2005 18:30:40 -0000 1.24 --- Quotes.cs 4 May 2005 18:25:51 -0000 1.25 *************** *** 721,724 **** --- 721,726 ---- { + double returnValue = Double.MaxValue; + DataTable dt; string sql = "SELECT quotes.quTicker, " + *************** *** 730,737 **** " GROUP BY quotes.quTicker"; dt = SqlExecutor.GetDataTable( sql ); ! if(dt.Rows.Count==0) ! return 0; ! else ! return (double)dt.Rows[0]["CloseToOpenStandDev"]; } --- 732,742 ---- " GROUP BY quotes.quTicker"; dt = SqlExecutor.GetDataTable( sql ); ! if(dt.Rows.Count > 0) ! { ! if( dt.Rows[0]["CloseToOpenStandDev"] is double ) ! //cast is possible ! returnValue = (double)dt.Rows[0]["CloseToOpenStandDev"]; ! } ! return returnValue; } *************** *** 745,749 **** { ! DataTable dt; string sql = "SELECT quotes.quTicker, tickers.tiCompanyName, " + "Avg(quotes.quOpen) AS AverageRawOpenPrice " + --- 750,755 ---- { ! double returnValue = 0; ! DataTable dt; string sql = "SELECT quotes.quTicker, tickers.tiCompanyName, " + "Avg(quotes.quOpen) AS AverageRawOpenPrice " + *************** *** 755,762 **** "GROUP BY quotes.quTicker, tickers.tiCompanyName"; dt = SqlExecutor.GetDataTable( sql ); ! if(dt.Rows.Count==0) ! return 0; ! else ! return (double)dt.Rows[0]["AverageRawOpenPrice"]; } --- 761,772 ---- "GROUP BY quotes.quTicker, tickers.tiCompanyName"; dt = SqlExecutor.GetDataTable( sql ); ! if(dt.Rows.Count > 0) ! { ! if( dt.Rows[0]["AverageRawOpenPrice"] is double ) ! //cast is possible ! returnValue = (double)dt.Rows[0]["AverageRawOpenPrice"]; ! } ! return returnValue; ! } *************** *** 770,774 **** { ! DataTable dt; string sql = "SELECT quotes.quTicker, tickers.tiCompanyName, " + "StDev(quotes.quOpen) AS RawOpenPriceStdDev " + --- 780,785 ---- { ! double returnValue = Double.MaxValue; ! DataTable dt; string sql = "SELECT quotes.quTicker, tickers.tiCompanyName, " + "StDev(quotes.quOpen) AS RawOpenPriceStdDev " + *************** *** 780,787 **** "GROUP BY quotes.quTicker, tickers.tiCompanyName"; dt = SqlExecutor.GetDataTable( sql ); ! if(dt.Rows.Count==0) ! return 0; ! else ! return (double)dt.Rows[0]["RawOpenPriceStdDev"]; } --- 791,801 ---- "GROUP BY quotes.quTicker, tickers.tiCompanyName"; dt = SqlExecutor.GetDataTable( sql ); ! if(dt.Rows.Count > 0) ! { ! if( dt.Rows[0]["RawOpenPriceStdDev"] is double ) ! //cast is possible ! returnValue = (double)dt.Rows[0]["RawOpenPriceStdDev"]; ! } ! return returnValue; } *************** *** 805,810 **** dt = SqlExecutor.GetDataTable( sql ); if(dt.Rows.Count > 0) ! returnValue = (int)dt.Rows[0][0]; ! return returnValue; } --- 819,826 ---- dt = SqlExecutor.GetDataTable( sql ); if(dt.Rows.Count > 0) ! { ! if(dt.Rows[0][0] is int) ! returnValue = (int)dt.Rows[0][0]; ! } return returnValue; } |