public Planet GetPlanetByName(string name) { Planet ret = null; using (SQLiteCommand comm = connection.CreateCommand()) { comm.CommandText = DBConstants.PLANET_GET_BY_NAME_PREPARED_STATEMENT_STRING; comm.Parameters.AddWithValue("@name", name); SQLiteDataReader reader = comm.ExecuteReader(); while (reader.Read()) { int idColumn = reader.GetOrdinal(DBConstants.ID_FIELD); int nameColumn = reader.GetOrdinal(DBConstants.NAME_FIELD); int idValue = (reader.IsDBNull(idColumn)) ? -1 : reader.GetInt32(idColumn); string nameValue = (reader.IsDBNull(nameColumn)) ? string.Empty : reader.GetString(nameColumn); ret = new Planet(idValue, nameValue, PIObject.ObjectType.Planet); break; } reader.Close(); reader = null; } return (ret); }
private TreeNode planetNodes(Planet planet) { string planetName = string.Format("{0}: {1}", planet.Type.Value, planet.Name); TreeNode ret = new TreeNode(planetName); return (ret); }
public List<Planet> GetAllPlanetObjects() { List<Planet> ret = new List<Planet>(); using (SQLiteCommand comm = connection.CreateCommand()) { comm.CommandText = DBConstants.PLANET_GET_ALL_PREPARED_STATEMENT_STRING; SQLiteDataReader reader = comm.ExecuteReader(); while (reader.Read()) { int idColumn = reader.GetOrdinal(DBConstants.ID_FIELD); int nameColumn = reader.GetOrdinal(DBConstants.NAME_FIELD); int idValue = (reader.IsDBNull(idColumn)) ? -1 : reader.GetInt32(idColumn); string nameValue = (reader.IsDBNull(nameColumn)) ? string.Empty : reader.GetString(nameColumn); Planet obj = new Planet(idValue, nameValue, PIObject.ObjectType.Planet); ret.Add(obj); } reader.Close(); reader = null; } return (ret); }