[chronojump] Encoder 1RM shows personName and exerciseName
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder 1RM shows personName and exerciseName
- Date: Mon, 17 Jun 2013 15:41:56 +0000 (UTC)
commit 1d96fd2fec1592d935bef761e7810a7b114c9baa
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Jun 17 17:41:27 2013 +0200
Encoder 1RM shows personName and exerciseName
src/encoder.cs | 22 +++++++++++++++++++-
src/gui/encoder.cs | 13 +++++++----
src/sqlite/encoder.cs | 52 ++++++++++++++++++++++++++++++++++++------------
3 files changed, 68 insertions(+), 19 deletions(-)
---
diff --git a/src/encoder.cs b/src/encoder.cs
index 90e689e..cab86c8 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -477,6 +477,9 @@ public class Encoder1RM
public int exerciseID;
public double load1RM;
+ public string personName;
+ public string exerciseName;
+
public Encoder1RM() {
}
@@ -489,10 +492,27 @@ public class Encoder1RM
this.load1RM = load1RM;
}
+ public Encoder1RM(int uniqueID, int personID, int sessionID, int exerciseID, double load1RM, string
personName, string exerciseName)
+ {
+ this.uniqueID = uniqueID;
+ this.personID = personID;
+ this.sessionID = sessionID;
+ this.exerciseID = exerciseID;
+ this.load1RM = load1RM;
+ this.personName = personName;
+ this.exerciseName = exerciseName;
+ }
+
public string [] ToStringArray() {
- string [] s = { uniqueID.ToString(), load1RM.ToString() };
+ string [] s = { uniqueID.ToString(), load1RM.ToString() };
return s;
}
+
+ public string [] ToStringArray2() {
+ string [] s = { uniqueID.ToString(), personName, exerciseName, load1RM.ToString() };
+ return s;
+ }
+
~Encoder1RM() {}
}
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 13a12da..5f2c49d 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -311,7 +311,7 @@ public partial class ChronoJumpWindow
//1RM
ArrayList array1RM = SqliteEncoder.Select1RM(
- false, currentPerson.UniqueID, currentSession.UniqueID,
getExerciseIDFromCombo());
+ false, currentPerson.UniqueID, currentSession.UniqueID,
getExerciseIDFromCombo(), false);
double load1RM = 0;
if(array1RM.Count > 0)
load1RM = ((Encoder1RM) array1RM[0]).load1RM; //take only the first in array (will be
the last uniqueID)
@@ -324,15 +324,17 @@ public partial class ChronoJumpWindow
void on_button_encoder_1RM_win_clicked (object o, EventArgs args) {
ArrayList array1RM = SqliteEncoder.Select1RM(
- false, currentPerson.UniqueID, currentSession.UniqueID,
getExerciseIDFromCombo());
+ false, currentPerson.UniqueID, currentSession.UniqueID,
getExerciseIDFromCombo(), true);
ArrayList dataPrint = new ArrayList();
foreach(Encoder1RM e1RM in array1RM) {
- dataPrint.Add(e1RM.ToStringArray());
+ dataPrint.Add(e1RM.ToStringArray2());
}
string [] columnsString = {
- Catalog.GetString("ID"),
+ "ID",
+ Catalog.GetString("Person"),
+ Catalog.GetString("Exercise"),
Catalog.GetString("Load 1RM")
};
@@ -346,7 +348,8 @@ public partial class ChronoJumpWindow
genericWin = GenericWindow.Show(false, //don't show now
string.Format(Catalog.GetString("Saved 1RM values of athlete {0} on this
session."),
currentPerson.Name) + "\n" +
- Catalog.GetString("If you want to delete a row, right click on it.") + "\n",
+ Catalog.GetString("If you want to delete a row, right click on it.") + "\n" +
+ Catalog.GetString("If there is more than one value for an exercise,\nthe used
value is the top one."),
bigArray);
genericWin.SetTreeview(columnsString, false, dataPrint, new ArrayList(),
Constants.ContextMenu.DELETE);
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index aff5203..24bb97c 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -439,7 +439,7 @@ class SqliteEncoder : Sqlite
dbcon.Close();
}
- public static ArrayList Select1RM (bool dbconOpened, int personID, int sessionID, int exerciseID)
+ public static ArrayList Select1RM (bool dbconOpened, int personID, int sessionID, int exerciseID,
bool returnPersonNameAndExerciseName)
{
if(! dbconOpened)
dbcon.Open();
@@ -450,21 +450,36 @@ class SqliteEncoder : Sqlite
string andStr = "";
if(personID != -1) {
- whereStr += " personID = " + personID;
+ whereStr += " " + Constants.Encoder1RMTable + ".personID = " + personID;
andStr = " AND ";
}
if(sessionID != -1) {
- whereStr += andStr + " sessionID = " + sessionID;
+ whereStr += andStr + " " + Constants.Encoder1RMTable + ".sessionID = " +
sessionID;
andStr = " AND ";
}
if(exerciseID != -1)
- whereStr += andStr + " exerciseID = " + exerciseID;
+ whereStr += andStr + " " + Constants.Encoder1RMTable + ".exerciseID = " +
exerciseID;
}
- dbcmd.CommandText = "SELECT * FROM " + Constants.Encoder1RMTable + whereStr +
- " ORDER BY uniqueID DESC"; //this allows to select the last uniqueID because will be
the first in the returned array
+ if(returnPersonNameAndExerciseName) {
+ if(whereStr == "")
+ whereStr = " WHERE ";
+ else
+ whereStr += " AND ";
+ whereStr += Constants.Encoder1RMTable + ".personID = person77.uniqueID AND " +
+ Constants.Encoder1RMTable + ".exerciseID = encoderExercise.uniqueID";
+ }
+
+ if(returnPersonNameAndExerciseName)
+ dbcmd.CommandText = "SELECT " + Constants.Encoder1RMTable + ".*, person77.name,
encoderExercise.name" +
+ " FROM " + Constants.Encoder1RMTable + ", person77, encoderExercise " +
+ whereStr +
+ " ORDER BY uniqueID DESC"; //this allows to select the last uniqueID because
will be the first in the returned array
+ else
+ dbcmd.CommandText = "SELECT * FROM " + Constants.Encoder1RMTable + whereStr +
+ " ORDER BY uniqueID DESC"; //this allows to select the last uniqueID because
will be the first in the returned array
Log.WriteLine(dbcmd.CommandText.ToString());
@@ -475,13 +490,24 @@ class SqliteEncoder : Sqlite
Encoder1RM e1RM = new Encoder1RM();
while(reader.Read()) {
- e1RM = new Encoder1RM (
- Convert.ToInt32(reader[0].ToString()), //uniqueID
- Convert.ToInt32(reader[1].ToString()), //personID
- Convert.ToInt32(reader[2].ToString()), //sessionID
- Convert.ToInt32(reader[3].ToString()), //exerciseID
- Convert.ToDouble(Util.ChangeDecimalSeparator(reader[4].ToString()))
//load1RM
- );
+ if(returnPersonNameAndExerciseName)
+ e1RM = new Encoder1RM (
+ Convert.ToInt32(reader[0].ToString()), //uniqueID
+ Convert.ToInt32(reader[1].ToString()), //personID
+ Convert.ToInt32(reader[2].ToString()), //sessionID
+ Convert.ToInt32(reader[3].ToString()), //exerciseID
+
Convert.ToDouble(Util.ChangeDecimalSeparator(reader[4].ToString())), //load1RM
+ reader[8].ToString(), //personName
+ reader[9].ToString() //exerciseName
+ );
+ else
+ e1RM = new Encoder1RM (
+ Convert.ToInt32(reader[0].ToString()), //uniqueID
+ Convert.ToInt32(reader[1].ToString()), //personID
+ Convert.ToInt32(reader[2].ToString()), //sessionID
+ Convert.ToInt32(reader[3].ToString()), //exerciseID
+
Convert.ToDouble(Util.ChangeDecimalSeparator(reader[4].ToString())) //load1RM
+ );
array.Add (e1RM);
}
reader.Close();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]