[chronojump] All SQL methods for LastJumpTypeSimpleParams
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] All SQL methods for LastJumpTypeSimpleParams
- Date: Fri, 9 Apr 2021 15:24:08 +0000 (UTC)
commit 9e14660803d2313723892f0d960ea58e12d6cb44
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Apr 9 17:22:16 2021 +0200
All SQL methods for LastJumpTypeSimpleParams
src/sqlite/jumpType.cs | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)
---
diff --git a/src/sqlite/jumpType.cs b/src/sqlite/jumpType.cs
index c13ca5cb..33893351 100644
--- a/src/sqlite/jumpType.cs
+++ b/src/sqlite/jumpType.cs
@@ -667,4 +667,74 @@ class SqliteJumpType : Sqlite
dbcmd.ExecuteNonQuery();
}
+ public static LastJumpSimpleTypeParams LastJumpSimpleTypeParamsSelect (string name)
+ {
+ Sqlite.Open();
+ dbcmd.CommandText = "SELECT * " +
+ " FROM " + Constants.LastJumpSimpleTypeParamsTable + " " +
+ " 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();
+
+ LastJumpSimpleTypeParams ljstp = new LastJumpSimpleTypeParams(name);
+
+ if (reader.Read())
+ ljstp = new LastJumpSimpleTypeParams(
+ Convert.ToInt32(reader[0].ToString()), //uniqueID
+ reader[1].ToString(), //name
+ Util.IntToBool(Convert.ToInt32(reader[2].ToString())),
//weightIsPercent
+ Convert.ToDouble(Util.ChangeDecimalSeparator(reader[3].ToString())),
//weightValue
+ Convert.ToInt32(reader[4].ToString())); //fallmm
+
+ reader.Close();
+ Sqlite.Close();
+
+ return ljstp;
+ }
+
+ public static void LastJumpSimpleTypeParamsInsertOrUpdate (LastJumpSimpleTypeParams ljstp)
+ {
+ LastJumpSimpleTypeParams ljstpFound = LastJumpSimpleTypeParamsSelect(ljstp.name);
+// LogB.Information("LastJumpSimpleTypeParamsInsertOrUpdate search: " + ljstp.ToSqlString());
+ if(ljstpFound.uniqueID == -1)
+ lastJumpSimpleTypeParamsInsert (ljstp.ToSqlString());
+ else
+ lastJumpSimpleTypeParamsUpdate (ljstp, ljstpFound.uniqueID); //ljstp comes from the
gui choices, but we need the uniqueID
+ }
+
+ private static void lastJumpSimpleTypeParamsInsert (string ljstp_string)
+ {
+ Sqlite.Open();
+ dbcmd.CommandText = "INSERT INTO " + Constants.LastJumpSimpleTypeParamsTable +
+ " (uniqueID, name, weightIsPercent, weightValue, fallmm) VALUES (" +
+ ljstp_string + ")";
+
+ LogB.SQL(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+ Sqlite.Close();
+ }
+
+ private static void lastJumpSimpleTypeParamsUpdate (LastJumpSimpleTypeParams ljstp, int uniqueID)
+ {
+ Sqlite.Open();
+ LogB.Information("LastJumpSimpleTypeParamsUpdate ljstp: " + ljstp.ToSqlString());
+ dbcmd.CommandText = "UPDATE " + Constants.LastJumpSimpleTypeParamsTable +
+ " SET weightIsPercent = " + Util.BoolToInt(ljstp.weightIsPercent) +
+ ", weightValue = " + Util.ConvertToPoint(ljstp.weightValue) +
+ ", fallmm = " + ljstp.fallmm +
+ " WHERE uniqueID = " + uniqueID;
+
+ LogB.SQL(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+ Sqlite.Close();
+ }
+
+ // ****************************
+ // **** lastJumpRjTypeParams **
+ // ****************************
+ //for store default params of each jump (multiple)
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]