Start of databinding, add OnPropertyChanged

pull/41/head
Titouan LOUVET 2 years ago
parent 9f9397ee77
commit 6875c6e718

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -7,14 +8,64 @@ using System.Threading.Tasks;
namespace Banquale.Model
{
public class Compte
public class Compte : INotifyPropertyChanged
{
public int Solde { get; set; }
public string Nom { get; set;}
public event PropertyChangedEventHandler PropertyChanged;
public string IBAN { get; set; }
void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public double Solde
{
get => solde;
set
{
if (solde == value)
return;
solde = value;
OnPropertyChanged(nameof(Solde));
}
}
private double solde;
public string Nom
{
get => nom;
set
{
if (nom == value)
return;
nom = value;
OnPropertyChanged(nameof(Nom));
}
}
private string nom;
public string IBAN
{
get => iBAN;
set
{
if (iBAN == value)
return;
iBAN = value;
OnPropertyChanged(nameof(IBAN));
}
}
private string iBAN;
public List<Transactions> CompteList { get; set; }
public Compte(int solde, string nom, string iBAN)
{
Solde = solde;
Nom = nom;
IBAN = iBAN;
}
}
}

@ -10,6 +10,6 @@ namespace Banquale.Model
{
public (List<Client>, List<Transactions>) ChargeDonnee();
void SauvegardeDonnee(List<Client> c, List<Transactions> t);
void SauvegardeDonnee(List<Client> c, List<Transactions> t /*, List<Compte> c2*/);
}
}

@ -1,26 +1,93 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Banquale.Model
{
public class Transactions
public class Transactions : INotifyPropertyChanged
{
public int Type { get; private set; }
public int Somme { get; private set; }
void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public int Type
{
get => type;
set
{
if(type == value)
return;
type = value;
OnPropertyChanged(nameof(Type));
}
}
private int type;
public Double Somme
{
get => somme;
set
{
if (somme == value)
return;
somme = value;
OnPropertyChanged(nameof(Somme));
}
}
private Double somme;
public Compte CompteImplique
{
get => compteImplique;
set
{
if (compteImplique == value)
return;
compteImplique = value;
OnPropertyChanged(nameof(CompteImplique));
}
}
private Compte compteImplique;
public Compte CompteImplique { get; private set; }
public string Categorie
{
get => categorie;
set
{
if (categorie == value)
return;
categorie = value;
OnPropertyChanged(nameof(Categorie));
}
}
private string categorie;
public string Categorie { get; private set; }
public DateTime Date
{
get => date;
set
{
if (date == value)
return;
date = value;
OnPropertyChanged(nameof(Date));
}
}
private DateTime date;
public Transactions(int type, int somme, Compte compteImplique, string categorie) {
public Transactions(int type, Double somme, Compte compteImplique, string categorie, DateTime date) {
Type = type;
Somme = somme;
CompteImplique = compteImplique;
Categorie = categorie;
Date = date;
}
public event PropertyChangedEventHandler PropertyChanged;
}
}

@ -6,18 +6,33 @@ namespace Banquale.Stub
public class Stub : IPersistanceManager
{
public (List<Client>, List<Transactions>) ChargeDonnee()
public (List<Client>, List<Transactions> /*, List<Compte>*/) ChargeDonnee()
{
Client Client1 = new Client("Jacques", "Morice", "J'aimeLesFrites");
Client Client2 = new Client("Francis", "Begore", "J'aimeLes");
Client Client3 = new Client("Michel", "Boudout", "MonMdP");
Compte Compte1 = new Compte(999, "Tatouille", "FR76 9161 9581 6296 8415 2361 004");
Compte Compte2 = new Compte(9510, "Despoints", "FR76 4785 8569 6914 4152 5263 003");
Compte Compte3 = new Compte(3519, "Perotte", "FR76 6352 2541 4169 6958 5847 002");
Transactions Transactions1 = new Transactions(0, 55, Compte1, "Test", new DateTime(2023, 6, 21));
Transactions Transactions2 = new Transactions(1, 54.99, Compte2, "Test", new DateTime(2022, 8, 15));
Transactions Transactions3 = new Transactions(0, 1000, Compte3, "Test", new DateTime(2020, 9, 1));
Console.WriteLine(Client1);
List<Client> ListeClients = new List<Client>();
List<Transactions> ListeTransactions = new List<Transactions>();
//List<Compte> ListeCompte = new List<Compte>();
//ListeCompte.Add( Compte1 );
//ListeCompte.Add(Compte2);
//ListeCompte.Add(Compte3);
ListeClients.Add(Client1);
ListeClients.Add(Client2);
ListeClients.Add(Client3);
return (ListeClients, ListeTransactions);
return (ListeClients, ListeTransactions /*, ListeCompte*/);
}
public void SauvegardeDonnee(List<Client> c, List<Transactions> t)

@ -2,10 +2,11 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Banquale.Views"
xmlns:model="clr-namespace:Model"
xmlns:model="clr-namespace:Banquale.Model"
x:Class="Banquale.Views.BalancePage"
Title="BalancePage"
Shell.NavBarIsVisible="False">
Shell.NavBarIsVisible="False"
>
<Grid RowDefinitions="auto, *">
<Grid BackgroundColor="Beige"
@ -27,21 +28,24 @@
BackgroundColor="AliceBlue"
Margin="0, 15, 0, 0"/>
<Label
Text="Mme Perotte"
Text="{Binding Nom}"
Grid.Row="1"
Grid.ColumnSpan="2"
HorizontalOptions="Center"
TextColor="Black"
BackgroundColor="SaddleBrown"/> <!-- colspan permet de redefinir la taille de la colonne -->
<Grid ColumnDefinitions="*, *" Grid.Row="2" >
<Label
Text="Solde"
WidthRequest="75"
TextColor="Black"
HorizontalOptions="Center"/>
<Label
Text="1999,00 €"
Text="{Binding Solde}"
Grid.Column="1"
MinimumWidthRequest="70"
TextColor="Black"
HorizontalOptions="Center"/>
</Grid>

@ -4,10 +4,12 @@ namespace Banquale.Views;
public partial class BalancePage : ContentPage
{
//public Manager Mgr { get; private set; } = new Manager();
public BalancePage()
{
InitializeComponent();
BindingContext = new Compte(999, "Tatouille", "FR76 9161 9581 6296 8415 2361 004"); ;
}

Loading…
Cancel
Save