Merge branch 'xaml-C#/data-binding' of codefirst.iut.uca.fr:antoine.perederii/Banquale into xaml-C#/data-binding

pull/52/head
Antoine PEREDERII 2 years ago
commit c4cd2894fc

@ -22,6 +22,10 @@ public partial class App : Application
MainPage = new AppShell(); MainPage = new AppShell();
//MyManager.SelectedTransaction = MyManager.CustomersList[0].AccountsList[0].TransactionsList[0];
//MainPage = new Views.TransactionsPage();
} }
} }

@ -1,6 +1,7 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using Model; using Model;
using Org.Apache.Http.Cookies;
namespace Banquale.Stub namespace Banquale.Stub
{ {
@ -25,26 +26,32 @@ namespace Banquale.Stub
Account Account3 = new Account(3519, "Perotte", "FR7663522541416969585847002"); Account Account3 = new Account(3519, "Perotte", "FR7663522541416969585847002");
Transaction Transaction1 = new Transaction(true, 55, Account1, 1, new DateTime(2023, 6, 21, 15, 29, 20)); Transaction Transaction1 = new Transaction(true, 55, Account2, 1, new DateTime(2023, 6, 21, 15, 29, 20));
Transaction Transaction12 = new Transaction(true, 105, Account1, 2, new DateTime(2023, 8, 17, 18, 54, 35)); Transaction Transaction12 = new Transaction(true, 105, Account2, 2, new DateTime(2023, 8, 17, 18, 54, 35));
Transaction Transaction13 = new Transaction(true, 187, Account1, 3, new DateTime(2023, 5, 3, 8, 39, 49)); Transaction Transaction13 = new Transaction(true, 187, Account3, 3, new DateTime(2023, 5, 3, 8, 39, 49));
Transaction Transaction2 = new Transaction(false, 54.99, Account2, 4, new DateTime(2022, 8, 15)); Transaction Transaction2 = new Transaction(false, 54.99, Account2, 4, new DateTime(2022, 8, 15));
Transaction Transaction3 = new Transaction(true, 1000, Account3, 5, new DateTime(2020, 9, 1, 20, 00, 00)); Transaction Transaction3 = new Transaction(true, 1000, Account3, 5, new DateTime(2020, 9, 1, 20, 00, 00));
Debug.WriteLine(Customer1.Name, Customer1.Password); Debug.WriteLine(Customer1.Name, Customer1.Password);
List<Customer> CustomersList = new List<Customer>(); List<Customer> CustomersList = new List<Customer>();
List<Transaction> TransactionList= new List<Transaction>();
List<Account> AccountsList = new List<Account>();
List<Transaction> TransactionsList= new List<Transaction>();
List<Account> AccountsList = new List<Account>();
//Account1.TransactionsList.Add(Transaction1);
//Account1.TransactionsList.Add(Transaction12);
//Account1.TransactionsList.Add(Transaction13);
//Account1.TransactionsList.Add(Transaction2);
//Account1.TransactionsList.Add(Transaction3);
//Account2.TransactionsList.Add(Transaction2);
Account1.TransactionsList.Add(Transaction1); Account1.DoTransactions(Account2, 55, true, 1);
Account1.TransactionsList.Add(Transaction12); Account1.DoTransactions(Account2, 105, true, 2);
Account1.TransactionsList.Add(Transaction13); Account1.DoTransactions(Account3, 187, true, 3);
Account1.TransactionsList.Add(Transaction2); Account1.DoTransactions(Account2, 54.99, false, 4);
Account1.TransactionsList.Add(Transaction3); Account1.DoTransactions(Account3, 1000, false, 5);
Account2.TransactionsList.Add(Transaction2);
Customer1.AccountsList.Add(Account1); Customer1.AccountsList.Add(Account1);
Customer1.AccountsList.Add(Account2); Customer1.AccountsList.Add(Account2);

@ -20,9 +20,9 @@
HorizontalOptions="Fill"> HorizontalOptions="Fill">
<Grid.GestureRecognizers> <Grid.GestureRecognizers>
<!--<TapGestureRecognizer <TapGestureRecognizer
Tapped="Transaction_Clicked" Tapped="Transaction_Clicked"
NumberOfTapsRequired="1" />--> NumberOfTapsRequired="1" />
</Grid.GestureRecognizers> </Grid.GestureRecognizers>

@ -35,6 +35,8 @@ public partial class BalanceView : ContentView
//Mgr.SelectedTransaction = transaction; //Mgr.SelectedTransaction = transaction;
Mgr.SelectedTransaction = Mgr.CustomersList[0].AccountsList[0].TransactionsList[0];
await Navigation.PushModalAsync(new TransactionsPage()); await Navigation.PushModalAsync(new TransactionsPage());
} }

@ -6,16 +6,7 @@
Title="CategoryPage"> Title="CategoryPage">
<VerticalStackLayout <VerticalStackLayout
VerticalOptions="Center" > VerticalOptions="Center">
<local:CategoryView />
<local:CategoryView />
<local:CategoryView />
<local:CategoryView />
<local:CategoryView />
<local:CategoryView />
<local:CategoryView />
<local:CategoryView />
<local:CategoryView />
<local:CategoryView /> <local:CategoryView />
</VerticalStackLayout> </VerticalStackLayout>

@ -1,7 +1,11 @@
using Model;
namespace Banquale.Views.Category; namespace Banquale.Views.Category;
public partial class CategoryPage : ContentPage public partial class CategoryPage : ContentPage
{ {
public Manager Mgr => (App.Current as App).MyManager;
public CategoryPage() public CategoryPage()
{ {
InitializeComponent(); InitializeComponent();

@ -5,7 +5,7 @@
<VerticalStackLayout> <VerticalStackLayout>
<ListView ItemsSource="{Binding TransactionsList}" <ListView ItemsSource="{Binding CategoryList}"
Grid.Row="2" Grid.Row="2"
SelectionMode="None"> SelectionMode="None">
@ -16,7 +16,7 @@
<ViewCell> <ViewCell>
<Grid <Grid
ColumnDefinitions="40, 3*, *" ColumnDefinitions="*, *, *"
Margin="20, 5, 20, 5" Margin="20, 5, 20, 5"
HorizontalOptions="Fill"> HorizontalOptions="Fill">
@ -28,22 +28,11 @@
</Grid.GestureRecognizers> </Grid.GestureRecognizers>
<Label <Label
Text="{Binding Id}" Text="{Binding .}"
Grid.Column="0" Grid.Column="1"
x:Name="transactionId"/> x:Name="transactionId"/>
<Label
Text="{Binding Date, StringFormat='{0:ddd dd MMM yyyy}'}"
Grid.Column="1"
VerticalOptions="Center"
Margin="10, 0, 0, 0"/>
<Label
Text="{Binding Sum, StringFormat='{0} €'}"
Grid.Column="2"
VerticalOptions="Center"
HorizontalOptions="End"
Margin="0, 0, 20, 0"/>
</Grid> </Grid>

@ -1,9 +1,14 @@
using Model;
namespace Banquale.Views.Category; namespace Banquale.Views.Category;
public partial class CategoryView : ContentView public partial class CategoryView : ContentView
{ {
public Manager Mgr => (App.Current as App).MyManager;
public CategoryView() public CategoryView()
{ {
InitializeComponent(); InitializeComponent();
BindingContext = Mgr;
} }
} }

@ -22,7 +22,7 @@ public partial class ConnectionPage : ContentPage
return; return;
} }
if(currentId == 0) if(currentId == 0 && password == "consultant")
{ {
Mgr.IsConsultant = true; Mgr.IsConsultant = true;
await Navigation.PushModalAsync(new ConsultantHomePage()); await Navigation.PushModalAsync(new ConsultantHomePage());

@ -3,20 +3,19 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Banquale.Views.MessageListPage" x:Class="Banquale.Views.MessageListPage"
Title="MessageListPage" Title="MessageListPage"
Shell.NavBarIsVisible="False"> Shell.NavBarIsVisible="True">
<VerticalStackLayout> <VerticalStackLayout>
<Label <!--<Label
Text="{Binding MessagesList[0].Subject}" Text="rzklpkrz,e"
Grid.Column="1" Grid.Column="1"
VerticalOptions="Center" VerticalOptions="Center"
Margin="10, 0, 0, 0" Margin="10, 0, 0, 0"
BackgroundColor="Red"/> BackgroundColor="Red"/>-->
<!--<Label Text="{Binding }" />-->
<!--<ListView ItemsSource="{Binding Consultant}" <ListView ItemsSource="{Binding Consultant.MessagesList}"
SelectionMode="None"> SelectionMode="None">
<ListView.ItemTemplate> <ListView.ItemTemplate>
@ -25,17 +24,17 @@
<ViewCell> <ViewCell>
<Grid ColumnDefinitions="*, *, *">
<Label <Label
Text="Hello" Text="{Binding Subject}"
VerticalOptions="Center" Grid.Column="0"/>
Margin="10, 0, 0, 0"/>
<Label
Text="{Binding Description}"
Grid.Column="2"/>
</Grid>
</ViewCell> </ViewCell>
@ -43,7 +42,7 @@
</ListView.ItemTemplate> </ListView.ItemTemplate>
</ListView>--> </ListView>
</VerticalStackLayout> </VerticalStackLayout>
</ContentPage> </ContentPage>

@ -12,6 +12,6 @@ public partial class MessageListPage : ContentPage
{ {
Debug.WriteLine(Mgr.Consultant.MessagesList[0].Subject); Debug.WriteLine(Mgr.Consultant.MessagesList[0].Subject);
InitializeComponent(); InitializeComponent();
BindingContext = Mgr.Consultant; BindingContext = Mgr;
} }
} }

@ -118,7 +118,7 @@ namespace Model
/// <param name="sum">Somme de la transaction.</param> /// <param name="sum">Somme de la transaction.</param>
/// <param name="type">Type de transaction (débit ou crédit).</param> /// <param name="type">Type de transaction (débit ou crédit).</param>
/// <param name="nb">Numéro de la transaction.</param> /// <param name="nb">Numéro de la transaction.</param>
public void DoTransactions(Account involvedAccount, Double sum, bool type, int nb) public void DoTransactions(Account involvedAccount, double sum, bool type, int nb)
{ {
if (type) // si le type est True => c'est un débit, on doit donc ajouter la transaction pour l'autre compte if (type) // si le type est True => c'est un débit, on doit donc ajouter la transaction pour l'autre compte
{ {

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.Serialization; using System.Runtime.Serialization;
@ -27,7 +28,7 @@ namespace Model
[DataMember] [DataMember]
public List<Customer> CustomersList { get; private set; } // devient un set public List<Customer> CustomersList { get; private set; } // devient un set
public List<string> CategoryList { get; private set; } = new List<string> {"Automobile", "Santé", "Abonnement", "Logement", "Impôts et taxes", "Courses", "Loisirs et sorties", "Enfant(s)"}; public ObservableCollection<string> CategoryList { get; private set; } = new ObservableCollection<string> {"Automobile", "Santé", "Abonnement", "Logement", "Impôts et taxes", "Courses", "Loisirs et sorties", "Enfant(s)"};
/// <summary> /// <summary>
/// Consultant assigné au gestionnaire. /// Consultant assigné au gestionnaire.

@ -3,6 +3,8 @@
/// \author Votre nom /// \author Votre nom
using System; using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization; using System.Runtime.Serialization;
namespace Model namespace Model
@ -11,20 +13,49 @@ namespace Model
/// Classe représentant un message. /// Classe représentant un message.
/// </summary> /// </summary>
[DataContract] [DataContract]
public class Message public class Message : INotifyPropertyChanged
{ {
public event PropertyChangedEventHandler? PropertyChanged;
void OnPropertyChanged([CallerMemberName] string? propertyName = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
/// <summary> /// <summary>
/// Sujet du message. /// Sujet du message.
/// </summary> /// </summary>
[DataMember] [DataMember]
public string Subject { get; private set; } public string Subject
{
get => subject;
set
{
if (subject == value) return;
subject = value;
OnPropertyChanged();
}
}
private string subject;
/// <summary> /// <summary>
/// Description du message. /// Description du message.
/// </summary> /// </summary>
[DataMember] [DataMember]
public string Description { get; private set; } public string Description
{
get => description;
set
{
if (description == value) return;
description = value;
OnPropertyChanged();
}
}
private string description;
/// <summary> /// <summary>
/// Constructeur de la classe Message. /// Constructeur de la classe Message.
/// </summary> /// </summary>

@ -12,7 +12,7 @@ namespace Model
/// <summary> /// <summary>
/// Occurs when a property value changes. /// Occurs when a property value changes.
/// </summary> /// </summary>
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler? PropertyChanged;
void OnPropertyChanged(string propertyName) void OnPropertyChanged(string propertyName)
{ {
@ -65,7 +65,7 @@ namespace Model
/// Gets or sets the account(s) involved in the transaction. /// Gets or sets the account(s) involved in the transaction.
/// </summary> /// </summary>
[DataMember(Order = 4)] [DataMember(Order = 4)]
public Account InvolvedAccounts public Account? InvolvedAccounts
{ {
get => involvedAccounts; get => involvedAccounts;
set set
@ -77,13 +77,13 @@ namespace Model
} }
} }
[DataMember] [DataMember]
private Account involvedAccounts; private Account? involvedAccounts;
/// <summary> /// <summary>
/// Gets or sets the category of the transaction. /// Gets or sets the category of the transaction.
/// </summary> /// </summary>
[DataMember(Order = 5)] [DataMember(Order = 5)]
public string Category public string? Category
{ {
get => category; get => category;
set set
@ -125,6 +125,7 @@ namespace Model
/// <param name="date">The date of the transaction.</param> /// <param name="date">The date of the transaction.</param>
public Transaction(bool type, double sum, Account involvedAccounts, int id, DateTime date) public Transaction(bool type, double sum, Account involvedAccounts, int id, DateTime date)
{ {
Category = null;
Type = type; Type = type;
Sum = sum; Sum = sum;
Id = id; Id = id;

Loading…
Cancel
Save