Example #1
0
 public string UpdateAveragesAndScores( SqlDatabase db, DateTime when )
 {
     string result = "Successfully updated scores and averages";
     DbConnection conn = db.CreateConnection();
     conn.Open();
     DbTransaction trans = conn.BeginTransaction();
     try
     {
         db.ExecuteNonQuery( "spSetCurrentScore", when );
         db.ExecuteNonQuery( "spRecalcPlayerAverages" );
         trans.Commit();
     }
     catch( Exception e )
     {
         result = "Failed to update scores and averages: " + e.Message;
         trans.Rollback();
     }
     conn.Close();
     return result;
 }
Example #2
0
 public ArrayList SavePerformances( SqlDatabase db, ArrayList perfs, DateTime when )
 {
     ArrayList problems = new ArrayList();
     DbConnection conn = db.CreateConnection();
     conn.Open();
     DbTransaction trans = conn.BeginTransaction();
     try
     {
         foreach( PlayerPerformance p in perfs )
         {
             DbCommand cmd = db.GetStoredProcCommand( "spAddPlayerPerformance",
                 when, p.FirstName, p.LastName, p.TeamName, p.Minutes, p.Assists, p.Blocks,
                 p.DefensiveRebounds, p.Fouls, p.FTAttempts, p.FTsMade, p.OffensiveRebounds,
                 p.PlusMinus, p.ShotAttempts, p.ShotsMade, p.Steals, p.ThreeAttempts,
                 p.ThreesMade, p.Turnovers, p.NBAId );
             int x = (int)db.ExecuteScalar( cmd, trans );
             if( x != 0 )
             {
                 problems.Add( p );
             }
         }
         trans.Commit();
     }
     catch( Exception e )
     {
         trans.Rollback();
         PlayerPerformance p = new PlayerPerformance();
         p.FirstName = "Exception thrown while saving results to db: " + e.Message;
         problems.Add( p );
     }
     conn.Close();
     return problems;
 }