示例#1
0
        public static Matiere GetMatiere(string id)
        {
            NpgsqlConnection conn;

            conn = new NpgsqlConnection(chaineConnection);
            conn.Open();

            string query = @"SELECT id, nom, ""Fournisseur"" FROM ""Matiere"" where id = '" + id + "'";

            Debug.WriteLine(query);

            NpgsqlCommand    command = new NpgsqlCommand(query, conn);
            NpgsqlDataReader dr      = command.ExecuteReader();

            while (dr.Read())
            {
                Matiere OneMatiere = new Matiere(new Guid(dr[0].ToString()), dr[1].ToString(), BDDExterne.GetFournisseur(dr[2].ToString()));
                conn.Close();
                return(OneMatiere);
            }
            conn.Close();
            return(null);
        }
示例#2
0
        public static List <Matiere> GetAllMatiere()
        {
            NpgsqlConnection conn;

            conn = new NpgsqlConnection(chaineConnection);
            conn.Open();
            List <Matiere> ListeMatiere = new List <Matiere>();
            string         query        = @"SELECT id, nom, ""Fournisseur""FROM ""Matiere""";

            Debug.WriteLine(query);

            NpgsqlCommand command = new NpgsqlCommand(query, conn);

            NpgsqlDataReader dr = command.ExecuteReader();

            while (dr.Read())
            {
                ListeMatiere.Add(new Matiere(new Guid(dr[0].ToString()), dr[1].ToString(), BDDExterne.GetFournisseur(dr[2].ToString())));
            }
            conn.Close();
            return(ListeMatiere);
        }