From d4de3b9a2084dc285c0ea095efeadd3e2a759c5a Mon Sep 17 00:00:00 2001 From: Vincent ASTOLFI Date: Tue, 15 Nov 2022 19:40:06 +0100 Subject: [PATCH] =?UTF-8?q?premier=20ajout=20de=20la=20page=20op=C3=A9rati?= =?UTF-8?q?ons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Data/PersLinqToPgSQL.cs | 29 +++++++++++++ Sources/IHM/IHM.csproj | 7 +++ Sources/IHM/MainPage.xaml.cs | 1 + Sources/IHM/Operations.xaml | 52 ++++++++++++++++++++++- Sources/IHM/Operations.xaml.cs | 32 +++++++++++++- Sources/IHM/Resources/Images/refresh.png | Bin 0 -> 748 bytes Sources/Modele/IPersistanceManager.cs | 1 + Sources/Modele/Inscrit.cs | 5 +++ Sources/Modele/Manager.cs | 31 +++++++++++++- Sources/Modele/Stub.cs | 12 +++--- 10 files changed, 162 insertions(+), 8 deletions(-) create mode 100644 Sources/IHM/Resources/Images/refresh.png diff --git a/Sources/Data/PersLinqToPgSQL.cs b/Sources/Data/PersLinqToPgSQL.cs index e701759..c5b0959 100644 --- a/Sources/Data/PersLinqToPgSQL.cs +++ b/Sources/Data/PersLinqToPgSQL.cs @@ -149,6 +149,35 @@ namespace LinqToPgSQL await cmd.ExecuteNonQueryAsync(); } + public int CalculTotalSoldeComtpe(Inscrit user) + { + var conn = new NpgsqlConnection(connexionBDD); + Console.Out.WriteLine("Ouverture de la connection"); + try + { + conn.Open(); + } + catch + { + conn.Close(); + Debug.WriteLine("Problème de connection à la base de données. Aprés fermeture, l'application se fermera automatiquement."); + Environment.Exit(-1); + } + NpgsqlCommand cmd = new NpgsqlCommand($"SELECT sum(c.solde) FROM Compte c, Inscrit i, InscrBanque ib WHERE i.mail = (@mailUser) AND i.id = ib.idinscrit AND c.idinscritbanque = ib.id", conn) + { + Parameters = + { + new NpgsqlParameter("mailuser", user.Mail), + } + }; + NpgsqlDataReader dataReader = cmd.ExecuteReader(); + if (dataReader.Read()) + { + return dataReader.GetInt32(0); + } + return -1; + } + public string RecupMdpBdd(string mail) { var conn = new NpgsqlConnection(connexionBDD); diff --git a/Sources/IHM/IHM.csproj b/Sources/IHM/IHM.csproj index cbce615..e12cd6e 100644 --- a/Sources/IHM/IHM.csproj +++ b/Sources/IHM/IHM.csproj @@ -46,6 +46,9 @@ PreserveNewest + + PreserveNewest + @@ -54,6 +57,10 @@ + + + + diff --git a/Sources/IHM/MainPage.xaml.cs b/Sources/IHM/MainPage.xaml.cs index 7056a7a..803ff69 100644 --- a/Sources/IHM/MainPage.xaml.cs +++ b/Sources/IHM/MainPage.xaml.cs @@ -27,6 +27,7 @@ namespace IHM if (Mgr.isEqualHash(Mgr.recupMdpBdd(EntryMail.Text), EntryPassworld.Text)) { Mgr.LoadInscrit(EntryMail.Text, EntryPassworld.Text); + Mgr.createUser(EntryMail.Text); ConnexionValide(); } else diff --git a/Sources/IHM/Operations.xaml b/Sources/IHM/Operations.xaml index 36ee16a..4dbb154 100644 --- a/Sources/IHM/Operations.xaml +++ b/Sources/IHM/Operations.xaml @@ -3,9 +3,59 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="IHM.Operations"> + + + + + + + \ No newline at end of file diff --git a/Sources/IHM/Operations.xaml.cs b/Sources/IHM/Operations.xaml.cs index dd1c8e6..d9a981b 100644 --- a/Sources/IHM/Operations.xaml.cs +++ b/Sources/IHM/Operations.xaml.cs @@ -1,9 +1,39 @@ +using Model; + namespace IHM; public partial class Operations : ContentPage { + public Manager Mgr => (App.Current as App).Manager; public Operations() { InitializeComponent(); - } + BindingContext = Mgr; + double test = Mgr.recupTotalSolde(); + double i = test / 2000; + PrgressAnimationBar(i); + } + + private void Button_Clicked(object sender, EventArgs e) + { + double test = Mgr.recupTotalSolde(); + double i = test/2000; + PrgressAnimationBar(i); + UpdateArc(); + } + private async void UpdateArc() + { + ActualisationButton.IsEnabled = false; + int timeRemaining = 60; + while (timeRemaining != 0) + { + timeRemaining--; + await Task.Delay(1000); + } + ActualisationButton.IsEnabled = true; + } + private async void PrgressAnimationBar(double progress) + { + await ProgressBarSolde.ProgressTo(0.75, 500, Easing.Linear); + } } \ No newline at end of file diff --git a/Sources/IHM/Resources/Images/refresh.png b/Sources/IHM/Resources/Images/refresh.png new file mode 100644 index 0000000000000000000000000000000000000000..c43cfe8c574d78eab8aec5608414eebd6d60d7f8 GIT binary patch literal 748 zcmVPx%rb$FWRA@u(n1M|kF%U&R6+j0-1%V2H3P=Ye6@*j(sQ~BzDgY_~Du7gwqyj<( zpci?hk#&1JzO`9aSxcwW%3kmP^Z$5kuW90KZQ}Sf6Bt{;S%F!Bff1N3L>%D91;7^# zJ(u(&Q=~Zoz~4#Q$q@Zak;Nw1g&%F-{iD=o_8u1dnyf}wQv!enJS40=Bqab6X%IrW zLpK;(9V8OX2mtz*1OJkMTt-kY7=s#EXg&2AiN_X6oZANQL^2xnE{-TlLYu81;nl6S z3K6Mq2}LdNMv9e;K$sGqY!w200P9#I;a0UxmlCK+Zsn~C0l*%mnMqh%RZ6XoT^2>z z<{>BYdNP;*etdRFcL(^M<&|n((gqV?YjB;u$U2{|{Uu;VA>i#p#XK!RoQ-86C=I|; zyGHgxK57&io^U+v$+f zQ36E4A87pfwJ%7K{`{QHbxY`)ri1{wfW($ywMgXPIqji1^Y^wA0!#)83Y$NKe;;r< z<7VQ_p)5YCmJ;AwL<}YT$%<#T+R>dV_TW;CNLvFuNgJKx-+QYNFeSX53a8&|Eg2Rp7RP_3_V*tg9c|xAg=NLl3<|3K^utR^82rCUM z+n{@;8Uze5R-uyG^}1QdECNvbVY8JY-a>(B#G8z(sX!BeeUr`v`Xbc2e^#J%g!|^7 e73hml>;5+xB!w|dw~W*P0000 solde; + set + { + if(solde != value) + { + solde = value; + OnPropertyChanged(nameof(Solde)); + } + } + } + + private int solde; + + public Inscrit User { get; set; } + public Banque SelectedBanque { get => selectedBanque; @@ -19,7 +36,7 @@ namespace Model if(selectedBanque != value) { selectedBanque = value; - OnPropertyChanged(nameof(selectedBanque)); + OnPropertyChanged(nameof(SelectedBanque)); } } } @@ -29,6 +46,7 @@ namespace Model public Manager(IPersistanceManager persistance) { + Solde = 20; Pers = persistance; } @@ -76,6 +94,17 @@ namespace Model { return hash.IsEqualHash(mdpBdd, mdpSent); } + + public void createUser(string mail) + { + User = new Inscrit(mail); + } + + public int recupTotalSolde() + { + Solde = Pers.CalculTotalSoldeComtpe(User); + return Solde; + } } } diff --git a/Sources/Modele/Stub.cs b/Sources/Modele/Stub.cs index 1b5ba0c..f34e091 100644 --- a/Sources/Modele/Stub.cs +++ b/Sources/Modele/Stub.cs @@ -16,7 +16,7 @@ namespace Model // ajouter load all pour tout les inscrits - /* public List LoadInscrit() + public List LoadInscrit() { Inscrits.Add(new("00001", "Evard", "lucasevard@gmail.com","Lucas","test",10,LoadBanques())); Inscrits.Add(new("00002", "Livet", "hugolivet@gmail.com", "Hugo", "test", 280,LoadBanques())); @@ -26,19 +26,21 @@ namespace Model Inscrits.Add(new("00006", "March", "march@gmail.com", "bastien", "test", 1120,LoadBanques())); return Inscrits; } + public List LoadBanques() { Banques.Add(new("BNP Paribas", "https://mabanque.bnpparibas/", "https://logos-marques.com/wp-content/uploads/2020/12/BNP-Paribas-logo.png",LoadCompte())); Banques.Add(new("Crédit Agricole", "https://www.credit-agricole.fr", "https://yt3.ggpht.com/a/AGF-l7_mEfX2eQaGm8GefLOg5ZMRciNw-pESE3gUWg=s900-c-k-c0xffffffff-no-rj-mo",LoadCompte())); return Banques; } + public List LoadCompte() { - Comptes.Add(new("Livret A", 1500)); - Comptes.Add(new("Compte Courant", 2000)); - Comptes.Add(new("PEL", 22000)); + Comptes.Add(new("1","Livret A", 1500)); + Comptes.Add(new("2","Compte Courant", 2000)); + Comptes.Add(new("3","PEL", 22000)); return Comptes; - }*/ + } }