diff --git a/Code/IHM/App.xaml.cs b/Code/IHM/App.xaml.cs index d606932..c799256 100644 --- a/Code/IHM/App.xaml.cs +++ b/Code/IHM/App.xaml.cs @@ -16,5 +16,7 @@ namespace IHM public partial class App : Application { public Manager AllInscrits { get; private set; } = new Manager(new LinqToPgSQL.PersLinqToPgSQL()); + //public Manager AllInscrits { get; private set; } = new Manager(new Stub()); + } } diff --git a/Code/IHM/Converters/Func2WindowPartConverter.cs b/Code/IHM/Converters/Func2WindowPartConverter.cs new file mode 100644 index 0000000..d825da7 --- /dev/null +++ b/Code/IHM/Converters/Func2WindowPartConverter.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; +using System.Windows.Data; + +namespace IHM.Converters +{ + public class Func2WindowPartConverter : IValueConverter + { + public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Func? windowPartCreator = value as Func; + if (windowPartCreator == null) + { + return null; + } + return windowPartCreator(); + } + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Code/IHM/MainWindow.xaml.cs b/Code/IHM/MainWindow.xaml.cs index 4fe0295..a346163 100644 --- a/Code/IHM/MainWindow.xaml.cs +++ b/Code/IHM/MainWindow.xaml.cs @@ -39,7 +39,7 @@ namespace IHM { - MessageBox.Show($"{i.Id} + {i.Nom} + {i.Mdp} + {i.Mail} + {i.Dev}"); + MessageBox.Show($"{i.Id} + {i.Nom} + {i.Prenom} + {i.Mail} + {i.Mdp}"); } @@ -69,5 +69,6 @@ namespace IHM testSelect(); /* testSuppression();*/ } + } } diff --git a/Code/LinqToPgSQL/PersLinqToPgSQL.cs b/Code/LinqToPgSQL/PersLinqToPgSQL.cs index dc41c6d..f7f274e 100644 --- a/Code/LinqToPgSQL/PersLinqToPgSQL.cs +++ b/Code/LinqToPgSQL/PersLinqToPgSQL.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Npgsql; using Model; using System.IO; +using System.Diagnostics; namespace LinqToPgSQL { @@ -32,33 +33,29 @@ namespace LinqToPgSQL List ListeInscrits = new List(); var conn = new NpgsqlConnection(connString); - Console.Out.WriteLine("Ouverture de la connection"); - conn.Open(); - - var AllInscrit = new NpgsqlCommand("SELECT * FROM Inscrit", conn); + Console.Out.WriteLine("Ouverture de la connection"); try + { + conn.Open(); + } + catch + { + conn.Close(); + Environment.Exit(0); + + } + + + NpgsqlDataReader dbReader = new NpgsqlCommand("SELECT * FROM Inscrit", conn).ExecuteReader(); - var reader = AllInscrit.ExecuteReader(); - while (reader.Read()) + while (dbReader.Read()) { - Console.WriteLine( - string.Format( - "({0}, {1}, {2}, {3}, {4}", - reader.GetString(0), - reader.GetString(1), - reader.GetString(2), - reader.GetString(3), - reader.GetString(4) - /*reader.GetInt32(2).ToString()*/ - ) - ); - foreach (var EltInscrit in reader) - { - ListeInscrits.Add(new(reader.GetString(0), reader.GetString(1), reader.GetString(3), reader.GetString(2), reader.GetString(4))); - } - + ListeInscrits.Add(new Inscrit(dbReader.GetString(0), dbReader.GetString(1), dbReader.GetString(2), dbReader.GetString(3), dbReader.GetString(4))); + } - reader.Close(); + + + dbReader.Close(); return ListeInscrits; } diff --git a/Code/Model/Inscrit.cs b/Code/Model/Inscrit.cs index 4a495fa..c952c38 100644 --- a/Code/Model/Inscrit.cs +++ b/Code/Model/Inscrit.cs @@ -10,7 +10,7 @@ namespace Model public class Inscrit { - public Inscrit(string id, string nom, string mail, string prenom, string mdp) + public Inscrit(string id, string nom, string prenom, string mail, string mdp) { Id = id; Nom = nom; diff --git a/Code/Model/Stub.cs b/Code/Model/Stub.cs index 1a671fb..42b3df6 100644 --- a/Code/Model/Stub.cs +++ b/Code/Model/Stub.cs @@ -12,6 +12,8 @@ namespace Model public List Inscrits = new(); public List Comptes = new(); + + // ajouter load all pour tout les inscrits public List LoadInscrit()