[Quantproject-developers] QuantProject/b2_DataAccess SQLBuilder.cs, 1.1.1.1, 1.2
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-11-08 20:31:22
|
Update of /cvsroot/quantproject/QuantProject/b2_DataAccess In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv19322/b2_DataAccess Modified Files: SQLBuilder.cs Log Message: the following method has been added internal static string GetDateTimeConstant( DateTime dateTime ) the following method has been added public static string GetTimeConstant( DateTime dateTime ) the following method has been added internal static string GetFilterForTime( string fieldName , SqlComparisonOperator sqlComparisonOperator , DateTime time ) Index: SQLBuilder.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b2_DataAccess/SQLBuilder.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** SQLBuilder.cs 13 Oct 2003 21:58:01 -0000 1.1.1.1 --- SQLBuilder.cs 8 Nov 2008 20:31:17 -0000 1.2 *************** *** 3,7 **** SQLBuilder.cs ! Copyright (C) 2003 Glauco Siliprandi --- 3,7 ---- SQLBuilder.cs ! Copyright (C) 2003 Glauco Siliprandi *************** *** 19,26 **** along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ using System; namespace QuantProject.DataAccess { --- 19,28 ---- along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ using System; + using QuantProject.ADT; + namespace QuantProject.DataAccess { *************** *** 37,47 **** } ! internal static string GetDateConstant( DateTime dateTime ) ! { ! string getDateConstant; ! getDateConstant = "#" + dateTime.Month + "/" + dateTime.Day + "/" + ! dateTime.Year + "#"; ! return getDateConstant; ! } } } --- 39,153 ---- } ! internal static string GetDateConstant( DateTime dateTime ) ! { ! string getDateConstant; ! getDateConstant = "#" + dateTime.Month + "/" + dateTime.Day + "/" + ! dateTime.Year + "#"; ! return getDateConstant; ! } ! ! /// <summary> ! /// returns a string to be used as a DateTime constant for a query ! /// for an Access database ! /// </summary> ! /// <param name="dateTime"></param> ! /// <returns></returns> ! internal static string GetDateTimeConstant( DateTime dateTime ) ! { ! string dateTimeConstant = ! "#" + ! dateTime.Month + "/" + ! dateTime.Day + "/" + ! dateTime.Year + " " + ! dateTime.Hour + ":" + ! dateTime.Minute + ":" + ! dateTime.Second + ! "#"; ! return dateTimeConstant; ! } ! ! #region GetTimeConstant ! public static string GetTimeConstant( DateTime dateTime ) ! { ! string timeConstant = ! "'" + ! dateTime.Hour.ToString( "00" ) + "." + ! dateTime.Minute.ToString( "00" ) + "." + ! dateTime.Second.ToString( "00" ) + "'"; ! return timeConstant; ! } ! #endregion GetTimeConstant ! ! #region GetFilterForTime ! private static void getFilterForTime_checkParameters( DateTime time ) ! { ! // if ( ( comparisonOperator != "=" ) && ! // ( comparisonOperator != "<" ) && ! // ( comparisonOperator != "<=" ) && ! // ( comparisonOperator != ">" ) && ! // ( comparisonOperator != ">=" ) ) ! // throw new Exception( ! // "comparisonOperator can either be '=' or '<' or '<=' or '>' or '>='" ); ! if ( !ExtendedDateTime.IsTime( time ) ) ! throw new Exception( ! "time is actually not a time. Use the method " + ! "QuantProject.ADT.ExtendedDateTime.GetTime() to build your time" ); ! } ! ! #region getFilterForTime_actually ! private static string getSqlStringForComparisonOperator( ! SqlComparisonOperator sqlComparisonOperator ) ! { ! string sqlStringForComparisonOperator = ""; ! switch( sqlComparisonOperator ) ! { ! case SqlComparisonOperator.Equal: ! sqlStringForComparisonOperator = "="; ! break; ! case SqlComparisonOperator.LessThan: ! sqlStringForComparisonOperator = "<"; ! break; ! case SqlComparisonOperator.LessThanOrEqual: ! sqlStringForComparisonOperator = "<="; ! break; ! case SqlComparisonOperator.GreaterThan: ! sqlStringForComparisonOperator = ">"; ! break; ! case SqlComparisonOperator.GreaterThanOrEqual: ! sqlStringForComparisonOperator = ">="; ! break; ! } ! return sqlStringForComparisonOperator; ! } ! private static string getFilterForTime_actually( ! string fieldName , SqlComparisonOperator sqlComparisonOperator , DateTime time ) ! { ! string filterForDailyTime = ! "(Format([baDateTimeForOpen],'hh:mm:ss')" + ! SQLBuilder.getSqlStringForComparisonOperator( sqlComparisonOperator ) + ! SQLBuilder.GetTimeConstant( time ); ! return filterForDailyTime; ! } ! #endregion getFilterForTime_actually ! ! /// <summary> ! /// returns a sql where expression, to compare a field value with ! /// the given time ! /// </summary> ! /// <param name="fieldName"></param> ! /// <param name="comparisonOperator">it can either be "=" or "<" or ! /// "<=" or ">" or ">="</param> ! /// <param name="dateTime"></param> ! /// <returns></returns> ! internal static string GetFilterForTime( ! string fieldName , SqlComparisonOperator sqlComparisonOperator , DateTime time ) ! { ! SQLBuilder.getFilterForTime_checkParameters( time ); ! string filterForTime = ! SQLBuilder.getFilterForTime_actually( ! fieldName , sqlComparisonOperator , time ); ! return filterForTime; ! } ! #endregion GetFilterForTime } } |