public static void Update(bool dbconOpened, ForceSensorExercise ex) { if (!dbconOpened) { Sqlite.Open(); } /* * string uniqueIDStr = "NULL"; * if(ex.UniqueID != -1) * uniqueIDStr = ex.UniqueID.ToString(); */ dbcmd.CommandText = "UPDATE " + table + " SET " + " name = \"" + ex.Name + "\", percentBodyWeight = " + ex.PercentBodyWeight + ", resistance = \"" + ex.Resistance + "\", angleDefault = " + ex.AngleDefault + ", description = \"" + ex.Description + "\" WHERE uniqueID = " + ex.UniqueID; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); if (!dbconOpened) { Sqlite.Close(); } }
public static ArrayList Select(bool dbconOpened, int uniqueID, bool onlyNames) { if (!dbconOpened) { Sqlite.Open(); } string uniqueIDStr = ""; if (uniqueID != -1) { uniqueIDStr = " WHERE " + table + ".uniqueID = " + uniqueID; } if (onlyNames) { dbcmd.CommandText = "SELECT name FROM " + table + uniqueIDStr; } else { dbcmd.CommandText = "SELECT * FROM " + table + uniqueIDStr; } LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); ArrayList array = new ArrayList(1); ForceSensorExercise ex = new ForceSensorExercise(); if (onlyNames) { while (reader.Read()) { ex = new ForceSensorExercise(reader[0].ToString()); array.Add(ex); } } else { while (reader.Read()) { int angleDefault = 0; ex = new ForceSensorExercise( Convert.ToInt32(reader[0].ToString()), //uniqueID reader[1].ToString(), //name Convert.ToInt32(reader[2].ToString()), //percentBodyWeight reader[3].ToString(), //resistance angleDefault, reader[5].ToString() //description ); array.Add(ex); } } reader.Close(); if (!dbconOpened) { Sqlite.Close(); } return(array); }