From 5c5ac6637d214679b7f4cf44ae0e13df7287f129 Mon Sep 17 00:00:00 2001 From: hulivet1 Date: Thu, 1 Dec 2022 15:42:39 +0100 Subject: [PATCH] Gestion de l'erreur de connexion a la BDD, ajout de composants + ajouts de vues --- README.md | 2 +- Sources/Data/PersLinqToPgSQL.cs | 49 ++++++++++++++++-- Sources/IHM/AppShell.xaml | 17 ++++-- Sources/IHM/AppShell.xaml.cs | 12 +++-- Sources/IHM/Composant/BanqueDispo.xaml | 12 +++++ Sources/IHM/Composant/BanqueDispo.xaml.cs | 23 ++++++++ Sources/IHM/Composant/BanqueVC.xaml | 18 +++++++ Sources/IHM/Composant/BanqueVC.xaml.cs | 32 ++++++++++++ Sources/IHM/IHM.csproj | 25 +++++++++ Sources/IHM/Mobile/AjoutBanques.xaml | 18 +++++++ Sources/IHM/Mobile/AjoutBanques.xaml.cs | 9 ++++ Sources/IHM/Mobile/Dashboard.xaml | 5 +- Sources/IHM/Mobile/Dashboard.xaml.cs | 18 +++++-- Sources/IHM/Mobile/ErrorPage.xaml | 16 ++++++ Sources/IHM/Mobile/ErrorPage.xaml.cs | 46 ++++++++++++++++ Sources/IHM/Mobile/GestionBanques.xaml | 49 ++++++++++++++++++ Sources/IHM/Mobile/GestionBanques.xaml.cs | 16 ++++++ Sources/IHM/Mobile/MainPage.xaml.cs | 4 +- .../Images/GestionBanques/reload_banks.png | Bin 0 -> 551 bytes Sources/Modele/IPersistanceManager.cs | 2 + Sources/Modele/Manager.cs | 15 +++++- Sources/Modele/Stub.cs | 2 +- 22 files changed, 367 insertions(+), 23 deletions(-) create mode 100644 Sources/IHM/Composant/BanqueDispo.xaml create mode 100644 Sources/IHM/Composant/BanqueDispo.xaml.cs create mode 100644 Sources/IHM/Composant/BanqueVC.xaml create mode 100644 Sources/IHM/Composant/BanqueVC.xaml.cs create mode 100644 Sources/IHM/Mobile/AjoutBanques.xaml create mode 100644 Sources/IHM/Mobile/AjoutBanques.xaml.cs create mode 100644 Sources/IHM/Mobile/ErrorPage.xaml create mode 100644 Sources/IHM/Mobile/ErrorPage.xaml.cs create mode 100644 Sources/IHM/Mobile/GestionBanques.xaml create mode 100644 Sources/IHM/Mobile/GestionBanques.xaml.cs create mode 100644 Sources/IHM/Resources/Images/GestionBanques/reload_banks.png diff --git a/README.md b/README.md index 4d1c84d..0face04 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Cons'Eco [![Build Status](https://codefirst.iut.uca.fr/api/badges/hugo.livet/ConsEco/status.svg)](https://codefirst.iut.uca.fr/hugo.livet/ConsEco) -[![Csharp](https://img.shields.io/badge/-CSharp-50C878?style=for-the-badge&logo=csharp)](https://learn.microsoft.com/fr-fr/dotnet/csharp/) [![Xaml](https://img.shields.io/badge/-XAML-6495ED?style=for-the-badge&logo=xaml)](https://learn.microsoft.com/fr-fr/dotnet/desktop/wpf/xaml/?view=netdesktop-6.0) [![.NET/MAUI](https://img.shields.io/badge/-.NET/WPF-B87333?style=for-the-badge&logo=dotnet)](https://learn.microsoft.com/fr-fr/dotnet/maui/what-is-maui?view=net-maui-7.0) +[![Csharp](https://img.shields.io/badge/-CSharp-50C878?style=for-the-badge&logo=csharp)](https://learn.microsoft.com/fr-fr/dotnet/csharp/) [![Xaml](https://img.shields.io/badge/-XAML-6495ED?style=for-the-badge&logo=xaml)](https://learn.microsoft.com/fr-fr/dotnet/desktop/wpf/xaml/?view=netdesktop-6.0) [![.NET/WPF](https://img.shields.io/badge/-.NET/WPF-B87333?style=for-the-badge&logo=dotnet)](https://learn.microsoft.com/fr-fr/dotnet/desktop/wpf/?view=netdesktop-6.0)
diff --git a/Sources/Data/PersLinqToPgSQL.cs b/Sources/Data/PersLinqToPgSQL.cs index 2927b13..d6fa114 100644 --- a/Sources/Data/PersLinqToPgSQL.cs +++ b/Sources/Data/PersLinqToPgSQL.cs @@ -13,14 +13,34 @@ using System.Threading; using Model; using System.Runtime.CompilerServices; using System.Data.Common; +using System.Reflection.PortableExecutable; namespace LinqToPgSQL { public class PersLinqToPgSQL : IPersistanceManager { private Hash hash = new Hash(); - string connexionBDD = String.Format("Server=90.114.135.116; Username=postgres; Database=conseco; Port=5432; Password=lulu; SSLMode=Prefer"); - + private static string connexionBDD = String.Format("Server=2.3.8.130; Username=postgres; Database=conseco; Port=5432; Password=lulu; SSLMode=Prefer"); + private static NpgsqlConnection dbAccess = new NpgsqlConnection(connexionBDD); + public bool TestConnexionAsDatabase() + { + bool isOk = true; + try + { + dbAccess.Open(); + } + catch(NpgsqlException ex) + { + isOk = false; + Debug.WriteLine("Problème de connection à la base de données. - " + ex.Message); + } + finally + { + dbAccess.Close(); + } + return isOk; + } + public string LoadInscrit(string id, string mdp) { int resultat=0; @@ -53,7 +73,11 @@ namespace LinqToPgSQL { var conn = new NpgsqlConnection(connexionBDD); Console.Out.WriteLine("Ouverture de la connection"); - try + + conn.Open(); + + + /*try { conn.Open(); } @@ -62,7 +86,7 @@ namespace LinqToPgSQL conn.Close(); Debug.WriteLine("Problème de connection à la base de données. Aprés fermeture, l'application se fermera automatiquement."); Environment.Exit(-1); - } + }*/ NpgsqlDataReader dbReader = new NpgsqlCommand("SELECT mail FROM Inscrit", conn).ExecuteReader(); @@ -335,5 +359,22 @@ namespace LinqToPgSQL // attente des autres supression } + + public IList ImportBanques() + { + IList bquesDispo = new List(); + dbAccess.Open(); + + NpgsqlCommand cmd = new NpgsqlCommand($"SELECT * FROM Banque", dbAccess); + NpgsqlDataReader dbReader = cmd.ExecuteReader(); + while (dbReader.Read()) + { + bquesDispo.Add(new Banque(dbReader.GetString(0), dbReader.GetString(1), dbReader.GetString(2))); + } + dbAccess.Close(); + return bquesDispo; + } + + } } \ No newline at end of file diff --git a/Sources/IHM/AppShell.xaml b/Sources/IHM/AppShell.xaml index f5e6baf..87ab094 100644 --- a/Sources/IHM/AppShell.xaml +++ b/Sources/IHM/AppShell.xaml @@ -7,11 +7,6 @@ Shell.FlyoutBehavior="Disabled" Shell.NavBarIsVisible="False"> - - + + + + + + diff --git a/Sources/IHM/AppShell.xaml.cs b/Sources/IHM/AppShell.xaml.cs index e82d776..1001ddd 100644 --- a/Sources/IHM/AppShell.xaml.cs +++ b/Sources/IHM/AppShell.xaml.cs @@ -14,12 +14,16 @@ namespace IHM Routing.RegisterRoute("Inscription", typeof(Inscription)); Routing.RegisterRoute("ForgetPassword", typeof(ForgetPassword)); Routing.RegisterRoute("ChangePassword", typeof(ChangePassword)); + Routing.RegisterRoute("GestionBanques", typeof(GestionBanques)); + Routing.RegisterRoute("AjoutBanques", typeof(AjoutBanques)); + + Routing.RegisterRoute("ErrorPage", typeof(ErrorPage)); + - } - - - + + + } } \ No newline at end of file diff --git a/Sources/IHM/Composant/BanqueDispo.xaml b/Sources/IHM/Composant/BanqueDispo.xaml new file mode 100644 index 0000000..cce516c --- /dev/null +++ b/Sources/IHM/Composant/BanqueDispo.xaml @@ -0,0 +1,12 @@ + + + + + + +