[Quantproject-developers] QuantProject/b2_DataAccess DataBase.cs,1.7,1.8
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2006-01-15 23:35:19
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23356 Modified Files: DataBase.cs Log Message: - GetQuote has been added - WasExchanged has been added Index: DataBase.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/DataBase.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** DataBase.cs 11 Jan 2006 18:36:02 -0000 1.7 --- DataBase.cs 15 Jan 2006 23:35:09 -0000 1.8 *************** *** 140,143 **** --- 140,185 ---- } #endregion + public static double GetQuote( string ticker , + QuoteField quoteField , DateTime dateTime ) + { + double quote = Double.MinValue; + string sqlQuery = + "select " + getFieldName( quoteField ) + " " + + "from quotes where (quTicker='" + ticker + "') " + + "and (quDate=" + SQLBuilder.GetDateConstant( dateTime ) + ")"; + DataTable quotes = new DataTable(); + try + { + quotes = SqlExecutor.GetDataTable( sqlQuery ); + } + catch (Exception ex) + { + MessageBox.Show( ex.ToString() ); + } + if ( quotes.Rows.Count == 0 ) + throw new MissingQuoteException( ticker , dateTime ); + else + quote = (double)( quotes.Rows[ 0 ][ 0 ] ); + return quote; + } + public static bool WasExchanged( string ticker , + ExtendedDateTime extendedDateTime ) + { + string sqlQuery = + "select * " + + "from quotes where (quTicker='" + ticker + "') " + + "and (quDate=" + + SQLBuilder.GetDateConstant( extendedDateTime.DateTime ) + ")"; + DataTable quotes = new DataTable(); + try + { + quotes = SqlExecutor.GetDataTable( sqlQuery ); + } + catch (Exception ex) + { + MessageBox.Show( ex.ToString() ); + } + return ( quotes.Rows.Count > 0 ); + } } } |