Binding Mobile

pull/143/head
Hugo LIVET 2 years ago
parent c031ce2137
commit 12f7ebad49

@ -11,7 +11,7 @@ public partial class AjoutBanques : ContentPage
{ {
InitializeComponent(); InitializeComponent();
BindingContext = Mgr; BindingContext = Mgr;
//Mgr.LoadBanques(); Mgr.LoadBanqueDispo();
if (OperatingSystem.IsIOS()) if (OperatingSystem.IsIOS())
{ {
boutonRetour.IsVisible = true; boutonRetour.IsVisible = true;

@ -7,7 +7,8 @@
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="0.25*"/> <RowDefinition Height="0.25*"/>
<RowDefinition Height="0.15*"/> <RowDefinition Height="0.15*"/>
<RowDefinition Height="1.40*"/> <RowDefinition Height="0.15*"/>
<RowDefinition Height="1.30*"/>
<RowDefinition Height="0.15*"/> <RowDefinition Height="0.15*"/>
<RowDefinition/> <RowDefinition/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
@ -38,16 +39,20 @@
Clicked="Banques_Clicked"/> Clicked="Banques_Clicked"/>
<HorizontalStackLayout Grid.Row="1" Grid.ColumnSpan="2" HorizontalOptions="Center" >
<Picker Title="Choisir une Banque"
ItemsSource="{Binding ListeDesBanques}"
ItemDisplayBinding="{Binding Name}"
Margin="0,0,30,0"/>
<Picker Title="Choisir un Compte"
ItemsSource="{Binding ListeDesComptes}"
ItemDisplayBinding="{Binding Nom}"
Margin="30,0,0,0"/>
</HorizontalStackLayout>
<Label Grid.Row="2" Grid.ColumnSpan="2" Text="Liste des Dernières Opérations : " FontAttributes="Bold" FontSize="Body" Padding="20,5,0,0"/>
<Label Grid.Row="1" Grid.ColumnSpan="2" Text="Liste des Dernières Opérations : " FontAttributes="Bold" FontSize="Body" Padding="20,5,0,0"/> <CollectionView ItemsSource="{Binding SelectedCompte.LesOpe}" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2">
<CollectionView x:Name="DerniereOpe" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2">
<!--User.LesBanques[0].ListeDesComptes[0].LesOpe}-->
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Grid Margin="0,7,0,7" > <Grid Margin="0,7,0,7" >
@ -66,12 +71,13 @@
Source="{Binding ImageSrc}" Source="{Binding ImageSrc}"
CornerRadius="10"/>--> CornerRadius="10"/>-->
<Label Grid.Row="0" Grid.Column="0" <Label Grid.Row="0" Grid.Column="0"
Text="{Binding IntituleOperation}" Text="{Binding Nom}"
FontAttributes="Bold" FontAttributes="Bold"
FontSize="Body" FontSize="Body"
Margin="50,0,0,0"/> Margin="50,0,0,0"/>
<Label Grid.Row="1" Grid.Column="0" <Label Grid.Row="1" Grid.Column="0"
Text="{Binding DetailTypeOpe}" Text="{Binding Tag}"
Margin="50,0,0,0"
FontAttributes="Italic"/> FontAttributes="Italic"/>
<Label Grid.Row="0" Grid.Column="2" <Label Grid.Row="0" Grid.Column="2"
Text="{Binding DateOperation}"/> Text="{Binding DateOperation}"/>
@ -90,10 +96,10 @@
<Label Grid.Row="3" Grid.ColumnSpan="2" Text="Liste des Comptes favoris :" FontAttributes="Bold" FontSize="Body" Padding="20,0,0,0"/> <Label Grid.Row="4" Grid.ColumnSpan="2" Text="Liste des Banques favoris :" FontAttributes="Bold" FontSize="Body" Padding="20,0,0,0"/>
<CollectionView Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" ItemsSource="{Binding User.LesBanques}"> <CollectionView Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" ItemsSource="{Binding ListeDesBanques}">
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Grid> <Grid>
@ -102,7 +108,7 @@
<ColumnDefinition/> <ColumnDefinition/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Label Grid.Column="0" Text="{Binding Nom}" <Label Grid.Column="0" Text="{Binding Name}"
FontAttributes="Bold" FontSize="Body" FontAttributes="Bold" FontSize="Body"
HorizontalOptions="Center" HorizontalOptions="Center"
VerticalOptions="Center"/> VerticalOptions="Center"/>

@ -7,12 +7,15 @@ public partial class DashBoard : ContentPage
{ {
public Manager Mgr => (App.Current as App).Manager; public Manager Mgr => (App.Current as App).Manager;
List<Operation> operations;
public DashBoard() public DashBoard()
{ {
InitializeComponent(); InitializeComponent();
//Routing.RegisterRoute(nameof(DashBoard), typeof(DashBoard)); Mgr.LoadBanque();
// if (Mgr.SelectedBanque != null)
{
Mgr.LoadCompte();
}
BindingContext = Mgr; BindingContext = Mgr;
if (Mgr.User == null) if (Mgr.User == null)
@ -21,20 +24,14 @@ public partial class DashBoard : ContentPage
} }
operations = new List<Operation>();
operations.Add(new("Internet", 33.44, DateTime.Now, MethodePayement.CB, TagOperation.Divers, false));
operations.Add(new("Course", 45.20, DateTime.Now, MethodePayement.CB, TagOperation.Divers, true));
operations.Add(new("Orange", 50, DateTime.Now, MethodePayement.CB, TagOperation.Divers, true));
operations.Add(new("EDF", 55.80, DateTime.Now, MethodePayement.Virement, TagOperation.Energie, true));
operations.Add(new("Spotify", 33.44, DateTime.Now, MethodePayement.CB, TagOperation.Divers, false));
operations.Add(new("Garage", 45.20, DateTime.Now, MethodePayement.CB, TagOperation.Divers, true));
/*if (!Mgr.Pers.TestConnexion()) /*if (!Mgr.Pers.TestConnexion())
{ {
loadPage(new ErrorPage()); loadPage(new ErrorPage());
Debug.WriteLine("cc"); Debug.WriteLine("cc");
}*/ }*/
DerniereOpe.ItemsSource = operations;
} }

@ -32,8 +32,7 @@
<Label Grid.Row="1" Grid.ColumnSpan="3" Text="Liste de vos banques : " FontAttributes="Bold" FontSize="Body" Padding="20,10,0,0"/> <Label Grid.Row="1" Grid.ColumnSpan="3" Text="Liste de vos banques : " FontAttributes="Bold" FontSize="Body" Padding="20,10,0,0"/>
<ScrollView> <CollectionView Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" ItemsSource="{Binding ListeDesBanques}">
<CollectionView Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" ItemsSource="{Binding User.LesBanques}">
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Grid> <Grid>
@ -42,7 +41,7 @@
<ColumnDefinition/> <ColumnDefinition/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Label Grid.Column="0" Text="{Binding Nom}" <Label Grid.Column="0" Text="{Binding Name}"
FontAttributes="Bold" FontSize="Body" FontAttributes="Bold" FontSize="Body"
HorizontalOptions="Center" HorizontalOptions="Center"
VerticalOptions="Center"/> VerticalOptions="Center"/>
@ -58,7 +57,6 @@
</DataTemplate> </DataTemplate>
</CollectionView.ItemTemplate> </CollectionView.ItemTemplate>
</CollectionView> </CollectionView>
</ScrollView>
</Grid> </Grid>

@ -11,7 +11,7 @@ public partial class GestionBanques : ContentPage
{ {
InitializeComponent(); InitializeComponent();
BindingContext= Mgr; BindingContext= Mgr;
//Mgr.LoadBanques(); Mgr.LoadBanque();
if (OperatingSystem.IsIOS()) if (OperatingSystem.IsIOS())
{ {
boutonRetour.IsVisible = true; boutonRetour.IsVisible = true;

@ -28,7 +28,7 @@ namespace IHM.Mobile
Mgr.createUser(EntryMail.Text); Mgr.createUser(EntryMail.Text);
await Navigation.PopModalAsync(); await Navigation.PopModalAsync();
//Mgr.LoadBanques(); Mgr.LoadBanque();
} }
else else
{ {

@ -5,7 +5,7 @@
<ScrollView> <ScrollView>
<VerticalStackLayout> <VerticalStackLayout>
<Label Text="Mes Opérations :" FontAttributes="Bold" Margin="10,10,0,20" FontSize="20"/> <Label Text="Mes Opérations :" FontAttributes="Bold" Margin="10,10,0,20" FontSize="20"/>
<CollectionView Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" ItemsSource="{Binding }"> <CollectionView Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" ItemsSource="{Binding SelectedCompte.LesOpe}">
<!--User.LesBanques[0].ListeDesComptes[0].LesOpe}--> <!--User.LesBanques[0].ListeDesComptes[0].LesOpe}-->
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
@ -25,13 +25,14 @@
Source="{Binding ImageSrc}" Source="{Binding ImageSrc}"
CornerRadius="10"/>--> CornerRadius="10"/>-->
<Label Grid.Row="0" Grid.Column="0" <Label Grid.Row="0" Grid.Column="0"
Text="{Binding IntituleOperation}" Text="{Binding Nom}"
FontAttributes="Bold" FontAttributes="Bold"
FontSize="Body" FontSize="Body"
Margin="50,0,0,0"/> Margin="50,0,0,0"/>
<Label Grid.Row="1" Grid.Column="0" <Label Grid.Row="1" Grid.Column="0"
Text="{Binding DetailTypeOpe}" Text="{Binding Tag}"
FontAttributes="Italic"/> FontAttributes="Italic"
Margin="50,0,0,0"/>
<Label Grid.Row="0" Grid.Column="2" <Label Grid.Row="0" Grid.Column="2"
Text="{Binding DateOperation}"/> Text="{Binding DateOperation}"/>
<Label Grid.Row="1" Grid.Column="2" <Label Grid.Row="1" Grid.Column="2"

@ -7,36 +7,11 @@ public partial class Operations : ContentPage
{ {
public Manager Mgr => (App.Current as App).Manager; public Manager Mgr => (App.Current as App).Manager;
List<Operation> operations;
public Operations() public Operations()
{ {
InitializeComponent(); InitializeComponent();
//BindingContext = Mgr; BindingContext = Mgr;
Mgr.LoadCompte();
operations = new List<Operation>();
operations.Add(new("op", 33.44, DateTime.Now, MethodePayement.CB, TagOperation.Divers, false));
operations.Add(new("course", 45.20, DateTime.Now, MethodePayement.CB, TagOperation.Divers, true));
operations.Add(new("Orange", 50, DateTime.Now, MethodePayement.CB, TagOperation.Divers, true));
operations.Add(new("EDF", 55.80, DateTime.Now, MethodePayement.Virement, TagOperation.Energie, true));
operations.Add(new("op", 33.44, DateTime.Now, MethodePayement.CB, TagOperation.Divers, false));
operations.Add(new("course", 45.20, DateTime.Now, MethodePayement.CB, TagOperation.Divers, true));
operations.Add(new("Orange", 50, DateTime.Now, MethodePayement.CB, TagOperation.Divers, true));
operations.Add(new("EDF", 55.80, DateTime.Now, MethodePayement.Virement, TagOperation.Energie, true));
operations.Add(new("op", 33.44, DateTime.Now, MethodePayement.CB, TagOperation.Divers, false));
operations.Add(new("course", 45.20, DateTime.Now, MethodePayement.CB, TagOperation.Divers, true));
operations.Add(new("Orange", 50, DateTime.Now, MethodePayement.CB, TagOperation.Divers, true));
operations.Add(new("EDF", 55.80, DateTime.Now, MethodePayement.Virement, TagOperation.Energie, true));
operations.Add(new("op", 33.44, DateTime.Now, MethodePayement.CB, TagOperation.Divers, false));
operations.Add(new("course", 45.20, DateTime.Now, MethodePayement.CB, TagOperation.Divers, true));
operations.Add(new("Orange", 50, DateTime.Now, MethodePayement.CB, TagOperation.Divers, true));
operations.Add(new("EDF", 55.80, DateTime.Now, MethodePayement.Virement, TagOperation.Energie, true));
operations.Add(new("op", 33.44, DateTime.Now, MethodePayement.CB, TagOperation.Divers, false));
operations.Add(new("course", 45.20, DateTime.Now, MethodePayement.CB, TagOperation.Divers, true));
operations.Add(new("Orange", 50, DateTime.Now, MethodePayement.CB, TagOperation.Divers, true));
operations.Add(new("EDF", 55.80, DateTime.Now, MethodePayement.Virement, TagOperation.Energie, true));
BindingContext = operations;
} }
} }

@ -6,7 +6,7 @@
<ScrollView> <ScrollView>
<VerticalStackLayout> <VerticalStackLayout>
<Label Text="Mes Echeances du mois :" FontAttributes="Bold" Margin="10,10,0,20" FontSize="20"/> <Label Text="Mes Echeances du mois :" FontAttributes="Bold" Margin="10,10,0,20" FontSize="20"/>
<CollectionView x:Name="Ech"> <CollectionView ItemsSource="{Binding SelectedCompte.LesEch}">
<!--User.LesBanques[0].ListeDesComptes[0].LesOpe}--> <!--User.LesBanques[0].ListeDesComptes[0].LesOpe}-->
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
@ -26,13 +26,14 @@
Source="{Binding ImageSrc}" Source="{Binding ImageSrc}"
CornerRadius="10"/>--> CornerRadius="10"/>-->
<Label Grid.Row="0" Grid.Column="0" <Label Grid.Row="0" Grid.Column="0"
Text="{Binding IntituleOperation}" Text="{Binding Nom}"
FontAttributes="Bold" FontAttributes="Bold"
FontSize="Body" FontSize="Body"
Margin="50,0,0,0"/> Margin="50,0,0,0"/>
<Label Grid.Row="1" Grid.Column="0" <Label Grid.Row="1" Grid.Column="0"
Text="{Binding DetailTypeOpe}" Text="{Binding Tag}"
FontAttributes="Italic"/> FontAttributes="Italic"
Margin="50,0,0,0"/>
<Label Grid.Row="0" Grid.Column="2" <Label Grid.Row="0" Grid.Column="2"
Text="{Binding DateOperation}"/> Text="{Binding DateOperation}"/>
<Label Grid.Row="1" Grid.Column="2" <Label Grid.Row="1" Grid.Column="2"

@ -5,23 +5,11 @@ namespace IHM.Mobile;
public partial class Planification : ContentPage public partial class Planification : ContentPage
{ {
public Manager Mgr => (App.Current as App).Manager; public Manager Mgr => (App.Current as App).Manager;
List<Operation> operations;
public Planification() public Planification()
{ {
InitializeComponent(); InitializeComponent();
//BindingContext = Mgr; BindingContext = Mgr;
//Routing.RegisterRoute(nameof(DashBoard), typeof(DashBoard)); Mgr.LoadCompte();
operations = new List<Operation>();
operations.Add(new("Vulcan Mag", 3.44, DateTime.Now, MethodePayement.CB, TagOperation.Divers, false));
operations.Add(new("Apple Music", 45.20, DateTime.Now, MethodePayement.CB, TagOperation.Divers, true));
operations.Add(new("Orange", 50, DateTime.Now, MethodePayement.CB, TagOperation.Divers, true));
operations.Add(new("EDF", 55.80, DateTime.Now, MethodePayement.Virement, TagOperation.Energie, true));
Ech.ItemsSource = operations;
} }

@ -1,27 +1,32 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Model namespace Model
{ {
public class BanqueInscrit public class BanqueInscrit : INotifyPropertyChanged
{ {
public int Id { get; private set; } public event PropertyChangedEventHandler PropertyChanged;
public string Name { get; private set; }
public string Name { get; set; }
public int Id { get; set; }
[JsonConstructor] [JsonConstructor]
public BanqueInscrit(int id, string name) public BanqueInscrit(int id, string nomBanque)
{ {
Id = id; Id = id;
Name = name; Name = nomBanque;
} }
void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
public override string ToString() public override string ToString()
{ {
return Id + " " + Name; return Name + " " + Id;
} }
} }
} }

@ -24,7 +24,21 @@ namespace Model
} }
private IList<Operation> lesOpe = new List<Operation>(); private IList<Operation> lesOpe = new List<Operation>();
public IList<Planification> LesPla { get; set; } = new List<Planification>(); public IList<Planification> LesPla { get; set; } = new List<Planification>();
public IList<Echeance> LesEch { get; set; } = new List<Echeance>();
public IList<Echeance> LesEch
{
get => lesEch;
set
{
if (lesEch != value)
{
lesEch = value;
OnPropertyChanged(nameof(LesEch));
}
}
}
private IList<Echeance> lesEch = new List<Echeance>();
//public IList<Echeance> LesEch { get; set; } = new List<Echeance>();
[JsonConstructor] [JsonConstructor]
public Compte(string id, string nom) public Compte(string id, string nom)

@ -41,6 +41,7 @@ namespace Model
{ {
selectedBanque = value; selectedBanque = value;
OnPropertyChanged(nameof(SelectedBanque)); OnPropertyChanged(nameof(SelectedBanque));
LoadCompte();
} }
} }
} }
@ -76,19 +77,57 @@ namespace Model
private Compte selectedCompte; private Compte selectedCompte;
public IList<BanqueInscrit> ListeDesBanques
{
get => listeDesBanques;
set
{
if (listeDesBanques != value)
{
listeDesBanques = value;
OnPropertyChanged(nameof(ListeDesBanques));
}
}
}
private IList<BanqueInscrit> listeDesBanques = new List<BanqueInscrit>(); private IList<BanqueInscrit> listeDesBanques = new List<BanqueInscrit>();
public ReadOnlyCollection<BanqueInscrit> AllBanque { get; private set; }
//private IList<BanqueInscrit> listeDesBanques = new List<BanqueInscrit>();
/*public ReadOnlyCollection<BanqueInscrit> AllBanque
{
get => allBanque;
set
{
if (allBanque != value)
{
allBanque = value;
OnPropertyChanged(nameof(AllBanque));
}
}
}
private ReadOnlyCollection<BanqueInscrit> allBanque;*/
public List<Compte> ListeDesComptes
{
get => listeDesComptes;
set
{
if (listeDesComptes != value)
{
listeDesComptes = value;
OnPropertyChanged(nameof(ListeDesComptes));
}
}
}
private List<Compte> listeDesComptes = new List<Compte>(); private List<Compte> listeDesComptes = new List<Compte>();
public ReadOnlyCollection<Compte> AllCompte { get; private set; } //public ReadOnlyCollection<Compte> AllCompte { get; private set; }
public Manager(IPersistanceManager persistance) public Manager(IPersistanceManager persistance)
{ {
AllBanque = new ReadOnlyCollection<BanqueInscrit>(listeDesBanques); //AllBanque = new ReadOnlyCollection<BanqueInscrit>(listeDesBanques);
AllCompte = new ReadOnlyCollection<Compte>(listeDesComptes); //AllCompte = new ReadOnlyCollection<Compte>(listeDesComptes);
Pers = persistance; Pers = persistance;
} }
@ -99,7 +138,7 @@ namespace Model
public async void LoadCompte() public async void LoadCompte()
{ {
listeDesComptes.Clear(); ListeDesComptes.Clear();
if(SelectedBanque == null) if(SelectedBanque == null)
{ {
@ -109,8 +148,8 @@ namespace Model
try try
{ {
IList<Compte> comptes = await Pers.RecupererCompte(SelectedBanque); IList<Compte> comptes = await Pers.RecupererCompte(SelectedBanque);
listeDesComptes.AddRange(comptes); ListeDesComptes.AddRange(comptes);
foreach (Compte compte in listeDesComptes) foreach (Compte compte in ListeDesComptes)
{ {
compte.LesPla = await Pers.RecupererPlanification(compte); compte.LesPla = await Pers.RecupererPlanification(compte);
@ -119,12 +158,9 @@ namespace Model
} }
if (listeDesComptes.Count > 0)
{
selectedCompte = listeDesComptes.First();
}
SelectedCompte = listeDesComptes.FirstOrDefault();
SelectedCompte = ListeDesComptes.FirstOrDefault();
} }
catch(Exception exception) catch(Exception exception)
{ {
@ -137,8 +173,8 @@ namespace Model
{ {
try try
{ {
listeDesBanques = await Pers.RecupererBanques(User); ListeDesBanques = await Pers.RecupererBanques(User);
SelectedBanque = listeDesBanques.FirstOrDefault(); SelectedBanque = ListeDesBanques.FirstOrDefault();
} }
catch (Exception exception) catch (Exception exception)

Loading…
Cancel
Save