public static RunType SelectAndReturnRunIntervalType(string typeName, bool dbconOpened) { if (!dbconOpened) { Sqlite.Open(); } dbcmd.CommandText = "SELECT * " + " FROM " + Constants.RunIntervalTypeTable + " WHERE name = \"" + typeName + "\" ORDER BY uniqueID"; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); RunType myRunType = new RunType(); while (reader.Read()) { myRunType.Name = reader[1].ToString(); myRunType.Distance = Convert.ToDouble(reader[2].ToString()); myRunType.HasIntervals = true; myRunType.TracksLimited = Util.IntToBool(Convert.ToInt32(reader[3].ToString())); myRunType.FixedValue = Convert.ToInt32(reader[4].ToString()); myRunType.Unlimited = Util.IntToBool(Convert.ToInt32(reader[5].ToString())); myRunType.Description = reader[6].ToString(); myRunType.DistancesString = Util.ChangeDecimalSeparator(reader[7].ToString()); //if it has no value sqlite reads it as 0, but should be "" if (myRunType.DistancesString == "0") { myRunType.DistancesString = ""; } } myRunType.IsPredefined = myRunType.FindIfIsPredefined(); reader.Close(); if (!dbconOpened) { Sqlite.Close(); } return(myRunType); }
public static RunType SelectAndReturnRunType(string typeName, bool dbconOpened) { if (!dbconOpened) { Sqlite.Open(); } dbcmd.CommandText = "SELECT * " + " FROM " + Constants.RunTypeTable + " WHERE name = \"" + typeName + "\" ORDER BY uniqueID"; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); RunType myRunType = new RunType(); while (reader.Read()) { myRunType.Name = reader[1].ToString(); myRunType.Distance = Convert.ToDouble(reader[2].ToString()); myRunType.Description = reader[3].ToString(); } myRunType.IsPredefined = myRunType.FindIfIsPredefined(); reader.Close(); if (!dbconOpened) { Sqlite.Close(); } return(myRunType); }
public static RunType SelectAndReturnRunType(string typeName, bool dbconOpened) { if(!dbconOpened) dbcon.Open(); dbcmd.CommandText = "SELECT * " + " FROM " + Constants.RunTypeTable + " WHERE name = '" + typeName + "' ORDER BY uniqueID"; Log.WriteLine(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); RunType myRunType = new RunType(); while(reader.Read()) { myRunType.Name = reader[1].ToString(); myRunType.Distance = Convert.ToDouble( reader[2].ToString() ); myRunType.Description = reader[3].ToString(); } myRunType.IsPredefined = myRunType.FindIfIsPredefined(); reader.Close(); if(!dbconOpened) dbcon.Close(); return myRunType; }
public static RunType SelectAndReturnRunIntervalType(string typeName, bool dbconOpened) { if(!dbconOpened) dbcon.Open(); dbcmd.CommandText = "SELECT * " + " FROM " + Constants.RunIntervalTypeTable + " WHERE name = '" + typeName + "' ORDER BY uniqueID"; Log.WriteLine(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); RunType myRunType = new RunType(); while(reader.Read()) { myRunType.Name = reader[1].ToString(); myRunType.Distance = Convert.ToDouble( reader[2].ToString() ); myRunType.HasIntervals = true; myRunType.TracksLimited = Util.IntToBool(Convert.ToInt32(reader[3].ToString())); myRunType.FixedValue = Convert.ToInt32( reader[4].ToString() ); myRunType.Unlimited = Util.IntToBool(Convert.ToInt32(reader[5].ToString())); myRunType.Description = reader[6].ToString(); myRunType.DistancesString = Util.ChangeDecimalSeparator(reader[7].ToString()); } myRunType.IsPredefined = myRunType.FindIfIsPredefined(); reader.Close(); if(!dbconOpened) dbcon.Close(); return myRunType; }