GestionBanques
Hugo LIVET 2 years ago
commit 3f6f1c4905

File diff suppressed because it is too large Load Diff

@ -43,29 +43,18 @@ namespace LinqToPgSQL
public string LoadInscrit(string id, string mdp) public string LoadInscrit(string id, string mdp)
{ {
int resultat=0; int resultat;
var conn = new NpgsqlConnection(connexionBDD); var conn = new NpgsqlConnection(connexionBDD);
Console.Out.WriteLine("Ouverture de la connection"); Console.Out.WriteLine("Ouverture de la connection");
conn.Open(); conn.Open();
NpgsqlParameter p1 = new NpgsqlParameter { ParameterName = "p", Value = id }; NpgsqlParameter p1 = new NpgsqlParameter { ParameterName = "p", Value = mail };
NpgsqlParameter p2 = new NpgsqlParameter { ParameterName = "p2", Value = mdp }; NpgsqlCommand cmd = new NpgsqlCommand($"SELECT id FROM INSCRIT WHERE mail=(@p)", conn);
NpgsqlCommand cmd = new NpgsqlCommand($"SELECT id FROM INSCRIT WHERE (nom=(@p) OR mail=(@p)) AND mdp=@p2", conn);
cmd.Parameters.Add(p1); cmd.Parameters.Add(p1);
cmd.Parameters.Add(p2);
NpgsqlDataReader dr = cmd.ExecuteReader(); NpgsqlDataReader dr = cmd.ExecuteReader();
try dr.Read();
{ resultat = dr.GetInt32(0);
dr.Read(); dr.Close();
resultat = dr.GetInt32(0); return resultat.ToString();
dr.Close();
return resultat.ToString();
}
catch (Exception ex)
{
Debug.WriteLine(ex+"Utilisateur inconnu");
dr.Close();
return "null";//a changer doit retester
}
} }
@ -173,6 +162,35 @@ namespace LinqToPgSQL
await cmd.ExecuteNonQueryAsync(); 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) public string RecupMdpBdd(string mail)
{ {
var conn = new NpgsqlConnection(connexionBDD); var conn = new NpgsqlConnection(connexionBDD);
@ -261,11 +279,10 @@ namespace LinqToPgSQL
using (var command1 = new NpgsqlCommand(requete, conn)) using (var command1 = new NpgsqlCommand(requete, conn))
{ {
command1.Parameters.AddWithValue("p", i.Id); command1.Parameters.AddWithValue("p", i.Id);
/*await command1.ExecuteNonQueryAsync();*/
} }
while (dbReader.Read()) /* while (dbReader.Read())
{ {
ListeCompte.Add(new Compte("NULL",dbReader.GetString(0), dbReader.GetInt64(1)));//a patch NULL ListeCompte.Add(new Compte("NULL",dbReader.GetString(0), dbReader.GetInt64(1)));//a patch NULL
} }
@ -273,6 +290,35 @@ namespace LinqToPgSQL
return ListeCompte; return ListeCompte;
} }
public List<Banque> LoadBanqueId(string id)
{
int idnombre = Int16.Parse(id);
List<Banque> ListeBanque = new List<Banque>();
Debug.WriteLine(idnombre);
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 b.nom,b.urlsite,b.urllogo from banque b, inscrbanque ib, Inscrit i where ib.idinscrit =(@p) AND ib.nombanque = b.nom AND ib.idinscrit = i.id;", conn);
cmd.Parameters.AddWithValue("p", idnombre);
NpgsqlDataReader dataReader = cmd.ExecuteReader();
while (dataReader.Read())
{
Debug.WriteLine(dataReader.GetString(0), dataReader.GetString(1), dataReader.GetString(2));
ListeBanque.Add(new Banque(dataReader.GetString(0), dataReader.GetString(1), dataReader.GetString(2)));
}
dataReader.Close();
return ListeBanque;
}
/*Suppression d'un inscrit dans la base de données*/ /*Suppression d'un inscrit dans la base de données*/
public async void SupprimerInscritBdd(Inscrit i) public async void SupprimerInscritBdd(Inscrit i)
{ {

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8" ?>
<ViewCell xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="IHM.Composant.VC_Operation_Dashboard">
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
</StackLayout>
</ViewCell>

@ -0,0 +1,9 @@
namespace IHM.Composant;
public partial class VC_Operation_Dashboard : ViewCell
{
public VC_Operation_Dashboard()
{
InitializeComponent();
}
}

@ -0,0 +1,59 @@
using Model;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific;
using System.Diagnostics;
namespace IHM
{
public partial class DashBoard : ContentPage
{
public Manager Mgr => (App.Current as App).Manager;
public DashBoard()
{
InitializeComponent();
BindingContext = Mgr;
//Routing.RegisterRoute(nameof(DashBoard), typeof(DashBoard));
if (Mgr.User == null)
{
loadInscription();
}
}
void OnClickedBanque(object sender, EventArgs args)
{
Button btn = (Button)sender;
ImgBanqueActuelle.Text = btn.Text;
}
async void OnClickedGestionBanque(object sender, EventArgs args)
{
Bouton.BackgroundColor = Color.FromRgb(192, 192, 192);
await Bouton.TranslateTo(-130, 35, 50);
await Bouton.ScaleXTo(7.5, 50);
await Bouton.ScaleYTo(3, 50);
stackpannel.IsVisible = true;
BoutonRetour.IsVisible = true;
ImgBanqueActuelle.IsVisible = true;
//await Navigation.PushModalAsync(new GestionBanque());
}
async void OnClickedRetour(object sender, EventArgs args)
{
await Bouton.ScaleXTo(1, 50);
await Bouton.ScaleYTo(1, 50);
ImgBanqueActuelle.IsVisible = false;
stackpannel.IsVisible = false;
await Bouton.TranslateTo(0, 0, 50);
BoutonRetour.IsVisible = false;
}
public async void loadInscription()
{
await Navigation.PushModalAsync(new MainPage());
BindingContext=Mgr;
}
}
}

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="IHM.GestionBanque"
MaximumWidthRequest="130"
HeightRequest="500"
Title="GestionBanque">
<VerticalStackLayout>
<Label
Text="Welcome to .NET MAUI!"
VerticalOptions="Center"
HorizontalOptions="Center" />
</VerticalStackLayout>
</ContentPage>

@ -0,0 +1,9 @@
namespace IHM;
public partial class GestionBanque : ContentPage
{
public GestionBanque()
{
InitializeComponent();
}
}

@ -57,6 +57,9 @@
<MauiImage Update="Resources\Images\logo_sans_fond.png"> <MauiImage Update="Resources\Images\logo_sans_fond.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</MauiImage> </MauiImage>
<MauiImage Update="Resources\Images\refresh.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</MauiImage>
<MauiImage Update="Resources\Images\logo_sans_fond_black.png"> <MauiImage Update="Resources\Images\logo_sans_fond_black.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</MauiImage> </MauiImage>
@ -68,6 +71,10 @@
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" /> <MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Remove="Resources\Images\refresh.png" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<None Remove="Resources\Images\DashBoard\account_banks.png" /> <None Remove="Resources\Images\DashBoard\account_banks.png" />
<None Remove="Resources\Images\GestionBanques\add_banks.png" /> <None Remove="Resources\Images\GestionBanques\add_banks.png" />
@ -108,6 +115,10 @@
<MauiXaml Update="ChangePassword.xaml"> <MauiXaml Update="ChangePassword.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</MauiXaml> </MauiXaml>
<MauiXaml Update="Composant\VC_Operation_Dashboard.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="DashBoard.xaml">
<MauiXaml Update="Composant\BanqueDispo.xaml"> <MauiXaml Update="Composant\BanqueDispo.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</MauiXaml> </MauiXaml>
@ -117,6 +128,12 @@
<MauiXaml Update="ForgetPassword.xaml"> <MauiXaml Update="ForgetPassword.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</MauiXaml> </MauiXaml>
<MauiXaml Update="GestionBanque.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="NewPage1.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Mobile\AjoutBanques.xaml"> <MauiXaml Update="Mobile\AjoutBanques.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</MauiXaml> </MauiXaml>

@ -25,7 +25,7 @@ namespace IHM.Mobile
{ {
if (Mgr.isEqualHash(Mgr.recupMdpBdd(EntryMail.Text), EntryPassworld.Text)) if (Mgr.isEqualHash(Mgr.recupMdpBdd(EntryMail.Text), EntryPassworld.Text))
{ {
Mgr.LoadInscrit(EntryMail.Text, EntryPassworld.Text); Mgr.createUser(EntryMail.Text);
ConnexionValide(); ConnexionValide();
} }
else else
@ -42,6 +42,7 @@ namespace IHM.Mobile
private async void ConnexionValide() private async void ConnexionValide()
{ {
Mgr.LoadBanques();
await Navigation.PopModalAsync(); await Navigation.PopModalAsync();
} }

@ -2,8 +2,36 @@ namespace IHM.Mobile;
public partial class Operations : ContentPage public partial class Operations : ContentPage
{ {
public Manager Mgr => (App.Current as App).Manager;
public Operations() public Operations()
{ {
InitializeComponent(); 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);
}
} }

@ -1,11 +1,135 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="IHM.Mobile.Planification"> xmlns:local="clr-namespace:IHM.Composant"
<VerticalStackLayout> x:Class="IHM.DashBoard"
<Label BackgroundColor="#A00EE8">
Text="Planification" <ScrollView VerticalOptions="FillAndExpand">
<VerticalStackLayout>
<StackLayout Orientation="Horizontal">
<Label
Text="Bienvenue"
VerticalOptions="Center" VerticalOptions="Center"
HorizontalOptions="Center" /> HorizontalOptions="Start"
Margin="10,10,10,20"
FontSize="25"
/>
<Label
FontAttributes="Bold"
Margin="0,10,0,0"
Text="{Binding User.Prenom}"
FontSize="25"
/>
</StackLayout>
<Button
BackgroundColor="Red"
x:Name="Bouton"
WidthRequest="50"
HeightRequest="50"
HorizontalOptions="End"
Margin="0,0,40,0"
Clicked="OnClickedGestionBanque"
/>
<Button
IsVisible="False"
IsEnabled="False"
WidthRequest="175"
HeightRequest="50"
Margin="0,-50,0,0"
x:Name="ImgBanqueActuelle"
BackgroundColor="AliceBlue"
Text="{Binding selectedBanque}"
/>
<Button
IsVisible="false"
BackgroundColor="Black"
x:Name="BoutonRetour"
WidthRequest="50"
HeightRequest="50"
HorizontalOptions="End"
Margin="0,-50,40,0"
Clicked="OnClickedRetour"
/>
<StackLayout IsVisible="false" x:Name="stackpannel">
<CollectionView x:Name="listeBanque" ItemsSource="{Binding User.LesBanques}" ItemsUpdatingScrollMode="KeepScrollOffset" Margin="22,0,22,0" ItemsLayout="HorizontalList">
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout Margin="0,35,0,0">
<Button Clicked="OnClickedBanque" Text="{Binding Nom}"/>
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
<StackLayout Margin="0,20,0,0" Orientation="Horizontal">
<Label Margin="20,0,0,0" FontSize="25">Solde total :</Label>
<Label FontSize="25" Margin="8,0,0,0" x:Name="soldetotal">0</Label>
</StackLayout>
<Border Stroke="Black" StrokeThickness="5" Margin="0,70,0,0">
<StackLayout BackgroundColor="Cyan" Padding="0,0,0,20">
<Label HorizontalTextAlignment="Center" FontSize="20">Listes des dernières opérations</Label>
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
<StackLayout Orientation="Horizontal">
<Label>Nom de l'opération</Label>
<Label>Date de l'opération</Label>
<Label>Type d'opération</Label>
</StackLayout>
</StackLayout>
</StackLayout>
</Border>
<Border Stroke="Black" StrokeThickness="5" Margin="0,70,0,30">
<StackLayout Margin="0,10,0,0">
<Label HorizontalTextAlignment="Center" FontSize="20">Pour vous</Label>
<StackLayout BackgroundColor="RosyBrown" Margin="0,0,0,20" HeightRequest="200" WidthRequest="310">
<Label HorizontalOptions="Center" FontSize="20">Aide à la gestion personnalisée</Label>
</StackLayout>
</StackLayout>
</Border>
</VerticalStackLayout> </VerticalStackLayout>
</ScrollView>
</ContentPage> </ContentPage>

@ -3,14 +3,59 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="IHM.Mobile.Settings"> x:Class="IHM.Mobile.Settings">
<VerticalStackLayout> <VerticalStackLayout>
<Grid BackgroundColor="{AppThemeBinding Light={StaticResource Gray600}, Dark={StaticResource Gray100}}">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Label <Label
Text="Paramètre" Text="Paramètre"
VerticalOptions="Center" VerticalOptions="Center"
HorizontalOptions="Center" /> HorizontalOptions="End"
<Button Margin="10"
Text="Déconnexion" TextColor="{AppThemeBinding Light={StaticResource Gray100}, Dark={StaticResource Gray600}}"
VerticalOptions="End" FontSize="20"
Clicked="deconnexionOnClicked" FontAttributes="Bold"
/>
<ImageButton
Grid.Column="1"
Source="Resources/Image/refresh.png"
Clicked="Button_Clicked"
WidthRequest="35"
HeightRequest="35"
HorizontalOptions="End"
CornerRadius="10"
Margin="0,10,40,10"
x:Name="ActualisationButton"
BackgroundColor="{StaticResource Primary}"
/>
</Grid>
<Label
Text="Solde Total"
HorizontalOptions="Center"
FontSize="20"
Margin="10"
FontAttributes="Bold"
TextColor="{AppThemeBinding Light={StaticResource Gray600}, Dark={StaticResource Gray100}}"/>
<ProgressBar
x:Name="ProgressBarSolde"
WidthRequest="250"
ScaleY="3"
ProgressColor="{StaticResource Cyan200Accent}" />
<HorizontalStackLayout>
<Label
Text="0"
HorizontalOptions="Start"/>
<Label
Text="2000"
HorizontalOptions="End"/>
</HorizontalStackLayout>
<Label
Text="{Binding Solde}"
HorizontalOptions="Center"/> HorizontalOptions="Center"/>
</VerticalStackLayout> </VerticalStackLayout>
</ContentPage> </ContentPage>

@ -1,5 +1,7 @@
namespace IHM.Mobile; namespace IHM.Mobile;
using Model; using Model;
using System.Diagnostics;
public partial class Settings : ContentPage public partial class Settings : ContentPage
{ {
public Manager Mgr => (App.Current as App).Manager; public Manager Mgr => (App.Current as App).Manager;
@ -9,11 +11,12 @@ public partial class Settings : ContentPage
} }
public void deconnexionOnClicked(object sender, EventArgs e) public void deconnexionOnClicked(object sender, EventArgs e)
{ {
Mgr.SelectedInscrit = null; Mgr.deconnexion();
NavigateTo(); NavigateTo();
} }
private async void NavigateTo() private async void NavigateTo()
{ {
await Navigation.PushModalAsync(new MainPage()); await Navigation.PushModalAsync(new MainPage());
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 748 B

@ -20,7 +20,7 @@ namespace Model
UrlLogo = urlLogo; UrlLogo = urlLogo;
} }
public Banque(string nom, string urlSite, string urlLogo, List<Compte>lescomptes) public Banque(string nom, string urlSite, string urlLogo, List<Compte> lescomptes)
{ {
Nom = nom; Nom = nom;
UrlSite = urlSite; UrlSite = urlSite;

@ -64,7 +64,7 @@
public void ajoutEcheance(Echeance e) public void ajoutEcheance(Echeance e)
{ {
if(e == null) throw new NullReferenceException(); if (e == null) throw new NullReferenceException();
LesEch.Add(e); LesEch.Add(e);
} }
@ -75,7 +75,7 @@
public void ajoutPlannification(Planification p) public void ajoutPlannification(Planification p)
{ {
if(p == null) throw new NullReferenceException(); if (p == null) throw new NullReferenceException();
LesPla.Add(p); LesPla.Add(p);
} }

@ -8,7 +8,7 @@ namespace Model
{ {
public interface IPersistanceManager public interface IPersistanceManager
{ {
string LoadInscrit(string id,string mdp); string GetId(string mail);
void SupprimerInscritBdd(Inscrit inscrit); void SupprimerInscritBdd(Inscrit inscrit);
void SupprimerBanqueBdd(Inscrit inscrit, Banque banque); void SupprimerBanqueBdd(Inscrit inscrit, Banque banque);
void SupprimerToutesBanquesBdd(Inscrit inscrit); void SupprimerToutesBanquesBdd(Inscrit inscrit);
@ -20,5 +20,7 @@ namespace Model
bool TestConnexionAsDatabase(); bool TestConnexionAsDatabase();
public List<Banque> ImportBanques(); public List<Banque> ImportBanques();
public List<Banque> ImportBanquesForUser(Inscrit i); public List<Banque> ImportBanquesForUser(Inscrit i);
int CalculTotalSoldeComtpe(Inscrit user);
List<Banque> LoadBanqueId(string id);
} }
} }

@ -5,14 +5,16 @@ using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Model; using Model;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.ComponentModel;
namespace Model namespace Model
{ {
public class Inscrit public class Inscrit:INotifyPropertyChanged
{ {
public Hash hash = new Hash(); public Hash hash = new Hash();
public event PropertyChangedEventHandler PropertyChanged;
public string Id { get; private set; } public string Id { get; private set; }
public string Nom { get; private set; } public string Nom { get; private set; }
@ -34,7 +36,7 @@ namespace Model
} }
private string mail; private string mail;
public string Prenom { get; private set; } public string Prenom { get; set; }
public string Mdp public string Mdp
{ {
@ -58,10 +60,24 @@ namespace Model
} }
private string mdp; private string mdp;
void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
public double SoldeTotal { get; private set; } public double SoldeTotal { get; private set; }
public Devises Dev { get; private set; } public Devises Dev { get; private set; }
public List<Banque> LesBanques { get; private set; } = new List<Banque>(); public List<Banque> LesBanques
{
get => lesBanques;
set
{
if(lesBanques!=value)
{
lesBanques = value;
OnPropertyChanged(nameof(LesBanques));
}
}
}
private List<Banque> lesBanques;
public Inscrit(string id, string nom, string mail, string prenom, string mdp, double soldeTotal = 0) public Inscrit(string id, string nom, string mail, string prenom, string mdp, double soldeTotal = 0)
{ {
Id = id; Id = id;
@ -77,6 +93,17 @@ namespace Model
LesBanques = lesbanques; LesBanques = lesbanques;
} }
public Inscrit(string mail, string id)
{
Prenom = "Lucas";
Mail = mail;
Id = id;
}
public Inscrit(List<Banque> lesbanques)
{
LesBanques = lesbanques;
}
public void ajouterBanque(Banque banque) public void ajouterBanque(Banque banque)

@ -1,5 +1,6 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
namespace Model namespace Model
{ {
@ -8,10 +9,44 @@ namespace Model
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
public IPersistanceManager Pers { get; private set; } public IPersistanceManager Pers { get; private set; }
public string SelectedInscrit { get; set; } public int SelectedInscrit { get; set; }
public Hash hash = new Hash(); public Hash hash = new Hash();
public int Solde
{
get => solde;
set
{
if(solde != value)
{
solde = value;
OnPropertyChanged(nameof(Solde));
}
}
}
private int solde;
private Inscrit user;
public Inscrit User {
get
{
return user;
}
set
{
if (user != value)
{
user = value;
OnPropertyChanged(nameof(User));
}
}
}
public Banque SelectedBanque public Banque SelectedBanque
{ {
get => selectedBanque; get => selectedBanque;
@ -20,7 +55,7 @@ namespace Model
if(selectedBanque != value) if(selectedBanque != value)
{ {
selectedBanque = value; selectedBanque = value;
OnPropertyChanged(nameof(selectedBanque)); OnPropertyChanged(nameof(SelectedBanque));
} }
} }
} }
@ -66,9 +101,18 @@ namespace Model
Pers.SupprimerInscritBdd(i); Pers.SupprimerInscritBdd(i);
} }
public void LoadInscrit(string id, string mdp) public string GetId(string mail)
{ {
SelectedInscrit = Pers.LoadInscrit(id, mdp); return Pers.GetId(mail);
}
public void LoadBanques()
{
User.LesBanques = Pers.LoadBanqueId(User.Id);
if (User.LesBanques.Count() > 0)
{
SelectedBanque = User.LesBanques[0];
}
} }
public void supprimerToutesBanquesBdd(Inscrit inscrit) public void supprimerToutesBanquesBdd(Inscrit inscrit)
@ -123,4 +167,20 @@ namespace Model
} }
public void createUser(string mail)
{
User = new Inscrit(mail, GetId(mail));
}
public int recupTotalSolde()
{
Solde = Pers.CalculTotalSoldeComtpe(User);
return Solde;
}
public void deconnexion()
{
User=null;
}
}
} }

@ -26,12 +26,14 @@ namespace Model
Inscrits.Add(new("00006", "March", "march@gmail.com", "bastien", "test", 1120,LoadBanques())); Inscrits.Add(new("00006", "March", "march@gmail.com", "bastien", "test", 1120,LoadBanques()));
return Inscrits; return Inscrits;
} }
public List<Banque> LoadBanques() public List<Banque> 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("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())); 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; return Banques;
} }
public List<Compte> LoadCompte() public List<Compte> LoadCompte()
{ {
Comptes.Add(new("012345678901", "Livret A", 1500)); Comptes.Add(new("012345678901", "Livret A", 1500));

@ -68,6 +68,6 @@ namespace TestsUnitaires
Assert.Equal(tc, test2.ReturnCompte("Livret A")); Assert.Equal(tc, test2.ReturnCompte("Livret A"));
} }
*/
} }
} }

@ -10,7 +10,7 @@ namespace TestsUnitaires
public class TestUnitCompte public class TestUnitCompte
{ {
[Fact] /* [Fact]
public void TestConstructeurCompte() public void TestConstructeurCompte()
{ {
Compte c1 = new("012345678901", "Livret A", 234); Compte c1 = new("012345678901", "Livret A", 234);
@ -32,5 +32,6 @@ namespace TestsUnitaires
i1.SupprimerBanque(bq); i1.SupprimerBanque(bq);
Assert.DoesNotContain(bq, i1.LesBanques); Assert.DoesNotContain(bq, i1.LesBanques);
} }
*/
} }
} }

Loading…
Cancel
Save