diff --git a/Code/ConsEco.sln b/Code/ConsEco.sln
index 8ff780e..4d578dd 100644
--- a/Code/ConsEco.sln
+++ b/Code/ConsEco.sln
@@ -14,7 +14,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestsUnitaires", "TestsUnit
{ACFA83F8-98C8-43AE-9328-B3F751098FFA} = {ACFA83F8-98C8-43AE-9328-B3F751098FFA}
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LinqToSql", "LinqToSql\LinqToSql.csproj", "{1F51162A-1232-42E1-A2C3-B19D96905696}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LinqToPgSQL", "LinqToPgSQL\LinqToPgSQL.csproj", "{4A9DB718-B874-4565-87B0-57C73B9BE240}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -38,10 +38,10 @@ Global
{B1AE713C-B5DE-4E81-A33F-818AAD0548A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1AE713C-B5DE-4E81-A33F-818AAD0548A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1AE713C-B5DE-4E81-A33F-818AAD0548A7}.Release|Any CPU.Build.0 = Release|Any CPU
- {1F51162A-1232-42E1-A2C3-B19D96905696}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {1F51162A-1232-42E1-A2C3-B19D96905696}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {1F51162A-1232-42E1-A2C3-B19D96905696}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {1F51162A-1232-42E1-A2C3-B19D96905696}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4A9DB718-B874-4565-87B0-57C73B9BE240}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4A9DB718-B874-4565-87B0-57C73B9BE240}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4A9DB718-B874-4565-87B0-57C73B9BE240}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4A9DB718-B874-4565-87B0-57C73B9BE240}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Code/IHM/App.xaml.cs b/Code/IHM/App.xaml.cs
index aff7815..d606932 100644
--- a/Code/IHM/App.xaml.cs
+++ b/Code/IHM/App.xaml.cs
@@ -5,6 +5,8 @@ using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
+using Model;
+using LinqToPgSQL;
namespace IHM
{
@@ -13,5 +15,6 @@ namespace IHM
///
public partial class App : Application
{
+ public Manager AllInscrits { get; private set; } = new Manager(new LinqToPgSQL.PersLinqToPgSQL());
}
}
diff --git a/Code/IHM/IHM.csproj b/Code/IHM/IHM.csproj
index 7dc11f9..b8191b8 100644
--- a/Code/IHM/IHM.csproj
+++ b/Code/IHM/IHM.csproj
@@ -7,4 +7,9 @@
true
+
+
+
+
+
diff --git a/Code/IHM/MainWindow.xaml b/Code/IHM/MainWindow.xaml
index d796ffe..4a745ad 100644
--- a/Code/IHM/MainWindow.xaml
+++ b/Code/IHM/MainWindow.xaml
@@ -7,6 +7,8 @@
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
+
+
diff --git a/Code/IHM/MainWindow.xaml.cs b/Code/IHM/MainWindow.xaml.cs
index 9ea40a2..9239b99 100644
--- a/Code/IHM/MainWindow.xaml.cs
+++ b/Code/IHM/MainWindow.xaml.cs
@@ -12,6 +12,8 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
+using LinqToPgSQL;
+using Model;
namespace IHM
{
@@ -20,9 +22,37 @@ namespace IHM
///
public partial class MainWindow : Window
{
+ public Manager ListedesInscrits => ((App)Application.Current).AllInscrits;
public MainWindow()
{
InitializeComponent();
+
+ ListedesInscrits.LoadInscrit();
+ DataContext = ListedesInscrits;
+
+ }
+
+ public void test()
+ {
+ foreach (Inscrit i in ListedesInscrits.ListedesInscrits)
+ {
+ if(i.Nom == "YOUVOI")
+ {
+ MessageBox.Show($"{i.Id} + {i.Nom} + {i.Mdp} + {i.Mail} + {i.Dev}");
+ }
+
+ }
+
+ }
+
+ private void test_Click(object sender, RoutedEventArgs e)
+ {
+
+ test();
+
+
+
+
}
}
}
diff --git a/Code/LinqToPgSQL/LinqToPgSQL.csproj b/Code/LinqToPgSQL/LinqToPgSQL.csproj
new file mode 100644
index 0000000..dd6aef7
--- /dev/null
+++ b/Code/LinqToPgSQL/LinqToPgSQL.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net6.0-windows
+ enable
+ true
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Code/LinqToPgSQL/PersLinqToPgSQL.cs b/Code/LinqToPgSQL/PersLinqToPgSQL.cs
new file mode 100644
index 0000000..2255c03
--- /dev/null
+++ b/Code/LinqToPgSQL/PersLinqToPgSQL.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Npgsql;
+using Model;
+using System.IO;
+
+namespace LinqToPgSQL
+{
+ public class PersLinqToPgSQL : IPersistanceManager
+ {
+ private static string Host = "90.114.135.116";
+ private static string User = "postgres";
+ private static string DBname = "conseco";
+ private static string Password = "lulu";
+ private static string Port = "5432";
+
+ string connString =
+ String.Format(
+ "Server={0};Username={1};Database={2};Port={3};Password={4};SSLMode=Prefer",
+ Host,
+ User,
+ DBname,
+ Port,
+ Password);
+
+ public PersLinqToPgSQL() { }
+ public IEnumerable LoadInscrit()
+ {
+ 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);
+
+ var reader = AllInscrit.ExecuteReader();
+ while (reader.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.GetString(5)*/
+ /*reader.GetInt32(2).ToString()*/
+ )
+ );
+ foreach (var EltInscrit in reader)
+ {
+ ListeInscrits.Add(new(reader.GetString(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4)));
+ }
+
+
+ }
+ reader.Close();
+
+
+
+ return ListeInscrits;
+ }
+ }
+}
diff --git a/Code/LinqToSql/LinqToSql.csproj b/Code/LinqToSql/LinqToSql.csproj
deleted file mode 100644
index 59b04a5..0000000
--- a/Code/LinqToSql/LinqToSql.csproj
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
- Exe
- net6.0
- enable
- enable
-
-
-
-
-
-
-
diff --git a/Code/LinqToSql/Program.cs b/Code/LinqToSql/Program.cs
deleted file mode 100644
index ca53f45..0000000
--- a/Code/LinqToSql/Program.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System;
-using Microsoft.Data.SqlClient;
-using System.Text;
-
-namespace sqltest
-{
- class Program
- {
- static void Main(string[] args)
- {
- try
- {
- SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
- builder.DataSource = ".database.windows.net";
- builder.UserID = "";
- builder.Password = "";
- builder.InitialCatalog = "";
-
- using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
- {
- Console.WriteLine("\nQuery data example:");
- Console.WriteLine("=========================================\n");
-
- String sql = "SELECT name, collation_name FROM sys.databases";
-
- using (SqlCommand command = new SqlCommand(sql, connection))
- {
- connection.Open();
- using (SqlDataReader reader = command.ExecuteReader())
- {
- while (reader.Read())
- {
- Console.WriteLine("{0} {1}", reader.GetString(0), reader.GetString(1));
- }
- }
- }
- }
- }
- catch (SqlException e)
- {
- Console.WriteLine(e.ToString());
- }
- Console.ReadLine();
- }
- }
-}
\ No newline at end of file
diff --git a/Code/Model/IPersistanceManager.cs b/Code/Model/IPersistanceManager.cs
new file mode 100644
index 0000000..f5a8a75
--- /dev/null
+++ b/Code/Model/IPersistanceManager.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Model
+{
+ public interface IPersistanceManager
+ {
+ IEnumerable LoadInscrit();
+ }
+}
diff --git a/Code/Model/Inscrit.cs b/Code/Model/Inscrit.cs
index cba18c5..fcac7ae 100644
--- a/Code/Model/Inscrit.cs
+++ b/Code/Model/Inscrit.cs
@@ -9,6 +9,19 @@ namespace Model
{
public class Inscrit
{
+
+ public Inscrit(string id, string nom, string mail, string prenom, string mdp)
+ {
+ Id = id;
+ Nom = nom;
+ Mail = mail;
+ Prenom = prenom;
+ Mdp = mdp;
+
+ }
+
+
+
public Inscrit(string id, string nom, string mail, string prenom, string mdp, double soldeTotal)
{
Id = id;
diff --git a/Code/Model/Manager.cs b/Code/Model/Manager.cs
index 99d03be..b1d16e7 100644
--- a/Code/Model/Manager.cs
+++ b/Code/Model/Manager.cs
@@ -10,11 +10,14 @@ namespace Model
{
public class Manager : INotifyPropertyChanged
{
+ public Manager() { }
+
+ public event PropertyChangedEventHandler? PropertyChanged;
+
public IReadOnlyCollection ListedesInscrits { get; private set; }
private List TousLesInscrits { get; set; } = new List();
- public event PropertyChangedEventHandler? PropertyChanged;
- void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ public IPersistanceManager Pers { get; private set; }
public Inscrit SelectedInscrits
@@ -22,7 +25,7 @@ namespace Model
get => selectedInscrits;
set
{
- if(selectedInscrits != value)
+ if (selectedInscrits != value)
{
selectedInscrits = value;
OnPropertyChanged(nameof(SelectedInscrits));
@@ -31,22 +34,23 @@ namespace Model
}
private Inscrit selectedInscrits;
- public Manager(IReadOnlyCollection listedesInscrits, List tousLesInscrits, Inscrit selectedInscrits)
- {
- ListedesInscrits = listedesInscrits;
- TousLesInscrits = tousLesInscrits;
- this.selectedInscrits = selectedInscrits;
-
- }
+ void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+
- /*En attente de la persistance*/
+ public void LoadInscrit()
+ {
+ TousLesInscrits.Clear();
+ TousLesInscrits.AddRange(Pers.LoadInscrit());
+ if (TousLesInscrits.Count > 0)
+ SelectedInscrits = TousLesInscrits.First();
- /* public Manager(IPersistanceManager persistance)
- {
- ListedesInscrits = new ReadOnlyCollection(TousLesInscrits);
- persistance = persistance;
- }*/
+ }
+ public Manager(IPersistanceManager persistance)
+ {
+ ListedesInscrits = new ReadOnlyCollection(TousLesInscrits);
+ Pers = persistance;
+ }
}
diff --git a/desktop.ini b/desktop.ini
new file mode 100644
index 0000000..aaacced
--- /dev/null
+++ b/desktop.ini
@@ -0,0 +1,6 @@
+[.ShellClassInfo]
+IconResource=C:\WINDOWS\System32\SHELL32.dll,294
+[ViewState]
+Mode=
+Vid=
+FolderType=Generic