/// <summary> /// Get one family by name OR id /// </summary> /// <param name="Name"> The name of the family to get </param> /// <param name="Id"> The id of the family to get </param> /// <returns> The family searched </returns> public Familles GetFamille(string Name = "", int Id = -1) { Familles Famille = new Familles(); SQLiteCommand Sql; if (Name.CompareTo("") != 0) { Sql = new SQLiteCommand("SELECT * FROM Familles WHERE Nom = @name", Conn); Sql.Parameters.AddWithValue("@name", Name); } else { Sql = new SQLiteCommand("SELECT * FROM Familles WHERE RefFamille = @idFamille", Conn); Sql.Parameters.AddWithValue("@idFamille", Id); } SQLiteDataReader Reader = Sql.ExecuteReader(); if (Reader.Read()) { Famille.ConvertDataReaderToFamilles(Reader); return(Famille); } else { return(null); } }
/// <summary> /// Get all family /// </summary> /// <returns> A dictionnary of the family </returns> public Dictionary <int, Familles> GetAllFamilles() { Dictionary <int, Familles> ListFamille = new Dictionary <int, Familles>(); SQLiteCommand Sql = new SQLiteCommand("SELECT * FROM Familles", Conn); SQLiteDataReader Reader = Sql.ExecuteReader(); while (Reader.Read()) { Familles Famille = new Familles(); Famille.ConvertDataReaderToFamilles(Reader); ListFamille.Add(Famille.Id, Famille); } return(ListFamille); }