[chronojump] All SQL methods for LastJumpTypeRjParams



commit f517beb213d126869a1e04d14472d570c3be11ca
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Apr 12 15:38:39 2021 +0200

    All SQL methods for LastJumpTypeRjParams

 src/sqlite/jumpType.cs | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
---
diff --git a/src/sqlite/jumpType.cs b/src/sqlite/jumpType.cs
index 902666b1..5a60506c 100644
--- a/src/sqlite/jumpType.cs
+++ b/src/sqlite/jumpType.cs
@@ -750,4 +750,71 @@ class SqliteJumpType : Sqlite
                dbcmd.ExecuteNonQuery();
        }
 
+       public static LastJumpRjTypeParams LastJumpRjTypeParamsSelect (string name)
+       {
+               Sqlite.Open();
+               dbcmd.CommandText = "SELECT * " +
+                       " FROM " + Constants.LastJumpRjTypeParamsTable + " " +
+                       " WHERE name  = \"" + name +
+                       "\" ORDER BY uniqueID DESC"; //to shown last if there are more than one by import 
problems
+
+               LogB.SQL(dbcmd.CommandText.ToString());
+               dbcmd.ExecuteNonQuery();
+               SqliteDataReader reader;
+               reader = dbcmd.ExecuteReader();
+
+               LastJumpRjTypeParams ljrtp = new LastJumpRjTypeParams(name);
+
+               if (reader.Read())
+                       ljrtp = new LastJumpRjTypeParams(
+                                       Convert.ToInt32(reader[0].ToString()),   //uniqueID
+                                       reader[1].ToString(),                   //name
+                                       Convert.ToInt32(reader[2].ToString()),  //limitedValue
+                                       Util.IntToBool(Convert.ToInt32(reader[3].ToString())), 
//weightIsPercent
+                                       Convert.ToDouble(Util.ChangeDecimalSeparator(reader[4].ToString())), 
//weightValue
+                                       Convert.ToInt32(reader[5].ToString())); //fallmm
+
+               reader.Close();
+               Sqlite.Close();
+
+               return ljrtp;
+       }
+
+       public static void LastJumpRjTypeParamsInsertOrUpdate (LastJumpRjTypeParams ljrtp)
+       {
+               LastJumpRjTypeParams ljrtpFound = LastJumpRjTypeParamsSelect(ljrtp.name);
+//             LogB.Information("LastJumpRjTypeParamsInsertOrUpdate search: " + ljrtp.ToSqlString());
+               if(ljrtpFound.uniqueID == -1)
+                       lastJumpRjTypeParamsInsert (ljrtp.ToSqlString());
+               else
+                       lastJumpRjTypeParamsUpdate (ljrtp, ljrtpFound.uniqueID); //ljrtp comes from the gui 
choices, but we need the uniqueID
+       }
+
+       private static void lastJumpRjTypeParamsInsert (string ljrtp_string)
+       {
+               Sqlite.Open();
+               dbcmd.CommandText = "INSERT INTO " + Constants.LastJumpRjTypeParamsTable +
+                       " (uniqueID, name, limitedValue, weightIsPercent, weightValue, fallmm) VALUES (" +
+                       ljrtp_string + ")";
+
+               LogB.SQL(dbcmd.CommandText.ToString());
+               dbcmd.ExecuteNonQuery();
+               Sqlite.Close();
+       }
+
+       private static void lastJumpRjTypeParamsUpdate (LastJumpRjTypeParams ljrtp, int uniqueID)
+       {
+               Sqlite.Open();
+               LogB.Information("LastJumpRjTypeParamsUpdate ljrtp: " + ljrtp.ToSqlString());
+               dbcmd.CommandText = "UPDATE " + Constants.LastJumpRjTypeParamsTable +
+                       " SET limitedValue = " + ljrtp.limitedValue +
+                       ", weightIsPercent = " + Util.BoolToInt(ljrtp.weightIsPercent) +
+                       ", weightValue = " + Util.ConvertToPoint(ljrtp.weightValue) +
+                       ", fallmm = " + ljrtp.fallmm +
+                       " WHERE uniqueID = " + uniqueID;
+
+               LogB.SQL(dbcmd.CommandText.ToString());
+               dbcmd.ExecuteNonQuery();
+               Sqlite.Close();
+       }
 }      


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