[chronojump] SqliteEncoderExercise update better method



commit 77f05a2708760ca1d2cfdcade52a0e9ef7d933d7
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Oct 4 15:53:04 2019 +0200

    SqliteEncoderExercise update better method

 src/sqlite/encoder.cs | 21 ++++++++++++++++++++-
 src/sqlite/main.cs    |  6 +++---
 2 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index daf209d2..90c158b8 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -781,7 +781,26 @@ class SqliteEncoder : Sqlite
                }
        }
 
-       public static void UpdateExercise(bool dbconOpened, string nameOld, string name, int 
percentBodyWeight, 
+       public static void UpdateExercise (bool dbconOpened, EncoderExercise ex)
+       {
+               if(! dbconOpened)
+                       Sqlite.Open();
+
+               dbcmd.CommandText = "UPDATE " + Constants.EncoderExerciseTable + " SET" +
+                               " name = \"" + ex.Name +
+                               "\", percentBodyWeight = " + ex.PercentBodyWeight +
+                               ", ressistance = \"" + ex.Ressistance +
+                               "\", description = \"" + ex.Description +
+                               "\", future1 = \"" + Util.ConvertToPoint(ex.Speed1RM) +
+                               "\" WHERE uniqueID = " + ex.UniqueID;
+
+               LogB.SQL(dbcmd.CommandText.ToString());
+               dbcmd.ExecuteNonQuery();
+
+               if(! dbconOpened)
+                       Sqlite.Close();
+       }
+       public static void UpdateExerciseByName_old_do_not_use(bool dbconOpened, string nameOld, string name, 
int percentBodyWeight,
                        string ressistance, string description, string speed1RM)
        {
                if(! dbconOpened)
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 43ffc20f..ac07e9e3 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -1373,7 +1373,7 @@ class Sqlite
                        if(currentVersion == "0.90") {
                                Sqlite.Open();
                                
-                               SqliteEncoder.UpdateExercise(true, "Squat", "Squat", 100, "weight bar", "", 
"");        
+                               SqliteEncoder.UpdateExerciseByName_old_do_not_use(true, "Squat", "Squat", 
100, "weight bar", "", "");
                                LogB.SQL("Encoder Squat 75% -> 100%");
                                
                                SqlitePreferences.Update ("databaseVersion", "0.91", true); 
@@ -1395,8 +1395,8 @@ class Sqlite
                        if(currentVersion == "0.92") {
                                Sqlite.Open();
                                
-                               SqliteEncoder.UpdateExercise(true, "Bench press", "Bench press", 0, "weight 
bar", "","0.185");
-                               SqliteEncoder.UpdateExercise(true, "Squat", "Squat", 100, "weight bar", 
"","0.31");
+                               SqliteEncoder.UpdateExerciseByName_old_do_not_use(true, "Bench press", "Bench 
press", 0, "weight bar", "","0.185");
+                               SqliteEncoder.UpdateExerciseByName_old_do_not_use(true, "Squat", "Squat", 
100, "weight bar", "","0.31");
                                LogB.SQL("Added speed1RM on encoder exercise");
                                
                                SqlitePreferences.Update ("databaseVersion", "0.93", true); 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]