/// <summary> /// /// </summary> /// <param name="sid"></param> /// <param name="date"></param> /// <returns></returns> public static HappyIndex GetHappyIndex( string sid, DateTime date ) { using( DBCommand cmd = new DBCommand( Con, CommandType.Text ) ) { cmd.CommandText = "SELECT * FROM HappyIndexes WHERE [User_ID] = @User_ID AND [Date] = @date"; cmd.AddWithValue( "@User_ID", GetUser().ID ); cmd.AddWithValue( "@date", date.Format() ); if( cmd.Read() ) { return new HappyIndex { ID = cmd.GetInt( "HappyIndex_ID" ), Date = date, EmotionalComment = cmd.GetString( "EmotionalComment" ), EmotionalIndex = cmd.GetDouble( "EmotionalIndex" ), ProductivityIndex = cmd.GetDouble( "ProductivityIndex" ), MotivationIndex = cmd.GetDouble( "MotivationIndex" ), IndexComment = cmd.GetString( "IndexComment" ) }; } } return null; }
public void LocaleFormatWorks() { var dt = new DateTime(2011, 7, 12, 13); Assert.AreEqual(dt.Format("yyyy-MM-dd"), "2011-07-12"); }
public static List<HappyIndex> GetTeamStatistics( int teamID, DateTime fromDate, DateTime toDate ) { List<HappyIndex> list = new List<HappyIndex>(); using( DBCommand cmd = new DBCommand( Con, CommandType.Text ) ) { cmd.CommandText = string.Format( @"select HappyIndexes.Date, AVG( HappyIndexes.EmotionalIndex ) AS EmotionalIndex, AVG( HappyIndexes.ProductivityIndex ) AS ProductivityIndex, AVG( HappyIndexes.MotivationIndex ) AS MotivationIndex FROM HappyIndexes INNER JOIN UserTeams ON UserTeams.User_ID = HappyIndexes.User_ID INNER JOIN Teams ON Teams.Team_ID = UserTeams.Team_ID WHERE Teams.Team_ID = {0} AND HappyIndexes.Date >= '{1}' AND HappyIndexes.Date <= '{2}' GROUP BY HappyIndexes.Date", teamID, fromDate.Format(), toDate.Format() ); while( cmd.Read() ) { list.Add( new HappyIndex { Date = cmd.GetDateTime( "Date" ), EmotionalIndex = cmd.GetDouble( "EmotionalIndex" ), ProductivityIndex = cmd.GetDouble( "ProductivityIndex" ), MotivationIndex = cmd.GetDouble( "MotivationIndex" ) } ); } list.Sort(delegate(HappyIndex x, HappyIndex y) { return x.Date.CompareTo( y.Date ); }); } return list; }
public static List<HappyIndex> GetUserIndexes( int userID, DateTime fromDate, DateTime toDate ) { List<HappyIndex> list = new List<HappyIndex>(); using( DBCommand cmd = new DBCommand( Con, CommandType.Text ) ) { cmd.CommandText = string.Format( "SELECT * FROM HappyIndexes WHERE [User_ID] = {0} AND HappyIndexes.Date >= '{1}' AND HappyIndexes.Date <= '{2}'", userID, fromDate.Format(), toDate.Format() ); while( cmd.Read() ) { list.Add( new HappyIndex { Date = cmd.GetDateTime( "Date" ), EmotionalIndex = cmd.GetDouble( "EmotionalIndex" ), ProductivityIndex = cmd.GetDouble( "ProductivityIndex" ), MotivationIndex = cmd.GetDouble( "MotivationIndex" ) } ); } } return list; }
private void LoadControl( DateTime d ) { splitContainer1.Panel2.Controls.Clear(); splitContainer1.Panel2.Controls.Add( new Label { Text = "Working... please wait", AutoSize = false, TextAlign = ContentAlignment.MiddleCenter, Dock = DockStyle.Fill } ); Cursor = Cursors.AppStarting; NameValueCollection parameters = new NameValueCollection(); parameters.Add( "date", d.Format() ); BackgroundCall( "index", delegate( object sndr, RunWorkerCompletedEventArgs e ) { HappyIndex hi = e.Result as HappyIndex ?? new HappyIndex { Date = d }; ReportControlBase c; if( d.Date != DateTime.Now.Date ) { c = new DayControl( hi ); } else { if( hi.ID <= 0 ) { c = new EmotionControl( hi ); } else { c = new ProductionControl( hi ); } } c.Dock = DockStyle.Fill; splitContainer1.Panel2.Controls.Clear(); splitContainer1.Panel2.Controls.Add( c ); Cursor = Cursors.Default; }, APICaller.GetData<HappyIndex>, parameters ); }
public void SetDate(DateTime dateTime) { this.view.TextBox.Value = dateTime.Format("dd/MM/yyyy"); }