Merge pull request 'xaml-C#/data-binding' (#52) from xaml-C#/data-binding into master
continuous-integration/drone/push Build is passing Details

Reviewed-on: #52
pull/54/head
Antoine PEREDERII 2 years ago
commit b0de911d77

@ -9,19 +9,23 @@ public partial class App : Application
public Manager MyManager { get; private set; } = new Manager(new Stub.Stub() /*DataContractPersistance.DataContractPersXML()*/);
public App()
{
MyManager.DataLoad();
MyManager.Persistence = new DataContractPersistance.DataContractPersXML();
MyManager.DataSave();
MyManager.DataSave();
InitializeComponent();
MainPage = new AppShell();
}
//MyManager.SelectedTransaction = MyManager.CustomersList[0].AccountsList[0].TransactionsList[0];
//MainPage = new Views.TransactionsPage();
}
}

@ -4,6 +4,7 @@
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Banquale.Views"
xmlns:balance="clr-namespace:Banquale.Views.Balance"
xmlns:transfer="clr-namespace:Banquale.Views.Transfer"
Shell.FlyoutBehavior="Disabled">
@ -15,7 +16,7 @@
<ShellContent
Title="Solde"
ContentTemplate="{DataTemplate views:BalancePage}"
ContentTemplate="{DataTemplate balance:BalancePage}"
Route="balance"
Icon="{StaticResource HomeIcon}"/>

@ -60,6 +60,7 @@
<None Remove="Resources\Images\Sources\home.svg" />
<None Remove="Resources\Images\Sources\transactions.svg" />
<None Remove="Resources\Images\sources\banquale.png" />
<None Remove="Views\Balance\" />
</ItemGroup>
<ItemGroup>
<MauiXaml Remove="Resources\Images\Images.xaml" />
@ -71,6 +72,7 @@
<ItemGroup>
<Folder Include="Stub\" />
<Folder Include="Views\Category\" />
<Folder Include="Views\Balance\" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Images\ImagesDictionary.xaml" />

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

@ -1,11 +1,11 @@
<?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="Banquale.Views.BalancePage"
Title="BalancePage"
x:Class="Banquale.Views.Balance.BalancePage"
xmlns:local="clr-namespace:Banquale.Views.Balance"
Shell.NavBarIsVisible="False">
<Grid RowDefinitions="auto, auto, *">
<Grid RowDefinitions="auto, auto, *" x:Name="Grid">
<Frame BackgroundColor="{StaticResource Key=Banquale}"
CornerRadius="15"
@ -72,61 +72,8 @@
<Label Text="{Binding TransactionsList[0].Id}"
x:Name="idLabel" />
<ListView ItemsSource="{Binding TransactionsList}"
Grid.Row="2"
SelectionMode="None">
<!--ItemSelected="Transactions_Clicked"-->
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid
ColumnDefinitions="40, 3*, *"
Margin="20, 5, 20, 5"
HorizontalOptions="Fill">
<Grid.GestureRecognizers>
<TapGestureRecognizer
Tapped="Transaction_Clicked"
NumberOfTapsRequired="1" />
</Grid.GestureRecognizers>
<!--<Image
Source="dotnet_bot.png"
Grid.Column="0"
MaximumHeightRequest="30"/>-->
<Label
Text="{Binding Id}"
Grid.Column="0"
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>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<local:BalanceView
Grid.Row="2"/>
</Grid>
</ContentPage>

@ -0,0 +1,28 @@
using Model;
namespace Banquale.Views.Balance;
public partial class BalancePage : ContentPage
{
public Manager Mgr => (App.Current as App).MyManager;
public BalancePage()
{
InitializeComponent();
BindingContext = Mgr.SelectedAccount;
if(Mgr.IsConsultant == true)
{
//Label lext = new Label { Text = "Hello" };
//Grid.Add(lext);
Image backArrow = new Image { Source = "{StaticResource AccountIcon}", HeightRequest = 100 };
Grid.Add(backArrow);
}
}
public async void Balance_Clicked(object sender, EventArgs e)
{
await Shell.Current.Navigation.PushAsync(new NewPage1());
}
}

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Banquale.Views.Balance.BalanceView">
<VerticalStackLayout>
<ListView ItemsSource="{Binding TransactionsList}"
SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid
ColumnDefinitions="40, 3*, *"
Margin="20, 5, 20, 5"
HorizontalOptions="Fill">
<Grid.GestureRecognizers>
<TapGestureRecognizer
Tapped="Transaction_Clicked"
NumberOfTapsRequired="1" />
</Grid.GestureRecognizers>
<Label
Text="{Binding Id}"
Grid.Column="0"
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>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</VerticalStackLayout>
</ContentView>

@ -0,0 +1,49 @@
using System.Diagnostics;
using Model;
namespace Banquale.Views.Balance;
public partial class BalanceView : ContentView
{
public Manager Mgr => (App.Current as App).MyManager;
public BalanceView()
{
InitializeComponent();
BindingContext = Mgr.SelectedAccount;
}
public async void Transaction_Clicked(Object sender, EventArgs e)
{
var selectedItem = (sender as Grid)?.BindingContext as Transaction;
if (selectedItem != null)
{
Mgr.SelectedTransaction = selectedItem;
await Navigation.PushModalAsync(new TransactionsPage());
}
//if (string.IsNullOrWhiteSpace(idLabel.Text))
//{
// //await DisplayAlert("Erreur", "Aucune transaction présente", "OK");
// Debug.WriteLine("Erreur1");
// return;
//}
//Transaction transaction = Mgr.SelectedAccount.TransactionsList.FirstOrDefault(u => u.Id == TransactionId);
//if (transaction == null)
//{
// Debug.WriteLine("Erreur2");
// //await DisplayAlert("Erreur", "La transaction n'éxiste pas !", "OK");
// return;
//}
//Mgr.SelectedTransaction = transaction;
//Mgr.SelectedTransaction = Mgr.CustomersList[0].AccountsList[0].TransactionsList[0];
//await Navigation.PushModalAsync(new TransactionsPage());
}
}

@ -1,53 +0,0 @@
using Model;
namespace Banquale.Views;
public partial class BalancePage : ContentPage
{
public Manager Mgr => (App.Current as App).MyManager;
public BalancePage()
{
InitializeComponent();
BindingContext = Mgr.SelectedAccount;
//BindingContext = new Account(999, "Tatouille", "FR76 9161 9581 6296 8415 2361 004");
}
public async void Transactions_Clicked(System.Object sender, Microsoft.Maui.Controls.TappedEventArgs e)
{
Mgr.SelectedTransaction = Mgr.SelectedAccount.TransactionsList[0];
//Mgr.SelectedTransaction = Mgr.PropertyChanged;
await Shell.Current.Navigation.PushAsync(new TransactionsPage());
}
public async void Balance_Clicked(object sender, EventArgs e)
{
await Shell.Current.Navigation.PushAsync(new NewPage1());
}
public async void Transaction_Clicked(Object sender, EventArgs e)
{
uint TransactionId = Convert.ToUInt32(idLabel.Text);
if (string.IsNullOrWhiteSpace(idLabel.Text))
{
await DisplayAlert("Erreur", "Aucune transaction présente", "OK");
return;
}
Transaction transaction = Mgr.SelectedAccount.TransactionsList.FirstOrDefault(u => u.Id == TransactionId);
if (transaction == null)
{
await DisplayAlert("Erreur", "La transaction n'éxiste pas !", "OK");
return;
}
Mgr.SelectedTransaction = transaction;
await Navigation.PushModalAsync(new TransactionsPage());
}
}

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

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

@ -5,17 +5,44 @@
<VerticalStackLayout>
<BoxView HorizontalOptions="FillAndExpand"
HeightRequest="1.3"
Margin="20, 0, 20, 0"/>
<Grid Margin="20, 5, 20, 5"
HorizontalOptions="Fill">
<Label
Text="Catégorie"
HorizontalOptions="Center"
VerticalOptions="Center"/>
</Grid>
<ListView ItemsSource="{Binding CategoryList}"
Grid.Row="2"
SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid
ColumnDefinitions="*, *, *"
Margin="20, 5, 20, 5"
HorizontalOptions="Fill">
<Grid.GestureRecognizers>
<TapGestureRecognizer
Tapped="Category_Clicked"
NumberOfTapsRequired="1" />
</Grid.GestureRecognizers>
<Label
Text="{Binding .}"
Grid.Column="1"
x:Name="categoryName"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</VerticalStackLayout>
</ContentView>

@ -1,9 +1,25 @@
using Model;
namespace Banquale.Views.Category;
public partial class CategoryView : ContentView
{
public CategoryView()
public Manager Mgr => (App.Current as App).MyManager;
public CategoryView()
{
InitializeComponent();
BindingContext = Mgr;
}
public async void Category_Clicked(object sender, EventArgs e)
{
var selectedItem = (sender as Grid)?.BindingContext as string;
if (selectedItem != null)
{
Mgr.SelectedTransaction.ChangeCategory(selectedItem);
await Shell.Current.Navigation.PopAsync();
}
}
}

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

@ -1,24 +1,60 @@
using System.Diagnostics;
using Banquale.Views;
using Model;
namespace Banquale.Views;
public partial class ConsultantIdPage : ContentPage
{
public ConsultantIdPage()
public Manager Mgr => (App.Current as App).MyManager;
public ConsultantIdPage()
{
InitializeComponent();
}
//public async void Connection_Clicked(Object sender, EventArgs e)
//{
// string id = ident.Text;
// if (string.IsNullOrWhiteSpace(id))
// {
// await DisplayAlert("Erreur", "l'id ne doit pas être nulle", "OK");
// return;
// }
// await Navigation.PushModalAsync(new Balance.BalancePage());
//}
public async void Connection_Clicked(Object sender, EventArgs e)
{
string id = ident.Text;
uint currentId = Convert.ToUInt32(ident.Text);
if (string.IsNullOrWhiteSpace(ident.Text))
{
await DisplayAlert("Erreur", "Il faut rentrer un ID", "OK");
return;
}
if (currentId == 0)
{
await DisplayAlert("Erreur", "Ce compte est innaccessible", "OK");
return;
}
if (string.IsNullOrWhiteSpace(id))
Customer customer = Mgr.CustomersList.FirstOrDefault(u => u.Id == currentId);
if (customer == null)
{
await DisplayAlert("Erreur", "l'id ne doit pas être nulle", "OK");
await DisplayAlert("Erreur", "L'id entré est incorrect ou n'existe pas.", "OK");
return;
}
await Navigation.PushModalAsync(new BalancePage());
Mgr.SelectedCustomer = customer;
Debug.WriteLine(Mgr.IsConsultant);
await Navigation.PushModalAsync(new SwitchAccountPage());
}
}

@ -4,21 +4,115 @@
x:Class="Banquale.Views.CreateCustomerPage"
Title="CreateCustomerPage">
<StackLayout Margin="20">
<VerticalStackLayout>
<Label
Text="Informations du client"
FontSize="Title"
HorizontalOptions="Center"
Margin="0,20,0,15"
TextColor="Red"/>
<StackLayout Margin="20"
x:Name="StackLayout">
<Grid
ColumnDefinitions="*, *"
RowDefinitions="auto, auto">
<Label
Text="Nom"
FontSize="Subtitle"
Grid.Column="0"
Grid.Row="0"/>
<Entry
x:Name="NameEntry"
Placeholder="Entrez le nom"
Grid.Column="0"
Grid.Row="1" />
<Label
Text="Prénom"
FontSize="Subtitle"
Grid.Column="1"
Grid.Row="0"/>
<Entry
x:Name="FirstNameEntry"
Placeholder="Entrez le prénom"
Grid.Column="1"
Grid.Row="1"/>
</Grid>
<Label
Text="Mot de Passe"
FontSize="Subtitle" />
<Entry
x:Name="PasswordEntry"
Placeholder="Entrez le mot de passe" />
<Label
Text="Compte 1"
FontSize="Title"
Margin="0, 10, 0, 10"
TextColor="DarkRed"/>
<Grid
ColumnDefinitions="*, *"
RowDefinitions="auto, auto">
<Label
Text="Solde"
FontSize="Subtitle"
Grid.Column="0"
Grid.Row="0"/>
<Entry
x:Name="AccountBalanceEntry"
Placeholder="Entrez le solde du compte"
Keyboard="Numeric"
Grid.Column="0"
Grid.Row="1"/>
<Label
Text="Nom du compte"
FontSize="Subtitle"
Grid.Column="1"
Grid.Row="0"/>
<Entry
x:Name="AccountNameEntry"
Placeholder="Entrez le nom du compte"
Grid.Column="1"
Grid.Row="1" />
</Grid>
<Label
Text="IBAN"
FontSize="Subtitle" />
<Entry
Text="FR "
x:Name="AccountIbanEntry"
Placeholder="Entrez l'IBAN du compte"
Keyboard="Telephone"/>
</StackLayout>
<Label Text="Informations du client" FontSize="Title" HorizontalOptions="Center" Margin="0,0,0,20" />
<Label Text="ID client" FontSize="Subtitle" />
<Entry x:Name="clientIdEntry" Placeholder="Entrez l'ID client" />
<Label Text="Nom" FontSize="Subtitle" />
<Entry x:Name="clientLastNameEntry" Placeholder="Entrez le nom" />
<Label Text="Prénom" FontSize="Subtitle" />
<Entry x:Name="clientFirstNameEntry" Placeholder="Entrez le prénom" />
<Button
Text="Ajouter un compte"
HorizontalOptions="Center"
Margin="0,20,0,0"
Clicked="Account_Clicked"/>
<Button Text="Enregistrer" HorizontalOptions="Center" Margin="0,20,0,0" />
<Button
Text="Enregistrer"
HorizontalOptions="Center"
Margin="0,20,0,0"
Clicked="Create_Customer_Clicked"/>
</VerticalStackLayout>
</StackLayout>
</ContentPage>

@ -1,9 +1,93 @@
namespace Banquale.Views;
using System.Diagnostics;
using Model;
namespace Banquale.Views;
public partial class CreateCustomerPage : ContentPage
{
public CreateCustomerPage()
public Manager Mgr => (App.Current as App).MyManager;
int nbAccount = 1;
public CreateCustomerPage()
{
InitializeComponent();
}
public void Create_Customer_Clicked(System.Object sender, System.EventArgs e)
{
string name = NameEntry.Text;
string firstName = FirstNameEntry.Text;
string password = PasswordEntry.Text;
string accountName = AccountNameEntry.Text;
double accountBalance = Convert.ToDouble(AccountBalanceEntry.Text);
string accountIban = AccountIbanEntry.Text;
if(string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(firstName) || string.IsNullOrWhiteSpace(password)
|| double.IsNegative(accountBalance) || string.IsNullOrWhiteSpace(accountName)
|| string.IsNullOrWhiteSpace(accountIban) || string.IsNullOrWhiteSpace(AccountBalanceEntry.Text))
{
DisplayAlert("Erreur", "Tous les champs doivent être renseignés et corect (pas de solde négatif)", "OK");
}
else
{
Customer customer = new Customer(name, firstName, password);
Account account = new Account(accountBalance, accountName, accountIban);
customer.AccountsList.Add(account);
Mgr.CustomersList.Add(customer);
Debug.WriteLine(customer.Id);
Debug.WriteLine(customer.Password);
Debug.WriteLine(account.IBAN);
DisplayAlert("Création", "Client " + customer.Name +" crée avec succès.", "OK");
Shell.Current.Navigation.PopAsync();
}
}
public void Account_Clicked(object sender, EventArgs e)
{
nbAccount++;
if(nbAccount >= 4)
{
DisplayAlert("Erreur", "Impossible d'ajouter plus de compte. Un client ne peut avoir plus de 3 comptes.", "OK");
return;
}
Label account = new Label { Text = "Compte " + Convert.ToString(nbAccount)};
account.FontSize = 20;
Grid gridAccount = new Grid();
ColumnDefinition col1 = new ColumnDefinition(GridLength.Star);
ColumnDefinition col2 = new ColumnDefinition(GridLength.Star);
RowDefinition row1 = new RowDefinition(GridLength.Auto);
RowDefinition row2 = new RowDefinition(GridLength.Auto);
gridAccount.RowDefinitions.Add(row1);
gridAccount.RowDefinitions.Add(row2);
gridAccount.ColumnDefinitions.Add(col1);
gridAccount.ColumnDefinitions.Add(col2);
Label balance = new Label { Text = "Solde" };
balance.FontSize = 12;
Entry balanceEntry = new Entry { Placeholder = "Entrez le solde du compte" };
Label nameLabel = new Label { Text = "Nom du compte" };
Entry nameEntry = new Entry { Placeholder = "Entrez le nom du compte" };
Label iban = new Label { Text = "IBAN" };
Entry ibanEntry = new Entry { Placeholder = "Entrez l'IBAN du compte" };
StackLayout.Add(account);
gridAccount.SetColumn(balance, 0);
gridAccount.SetRow(balance, 0);
gridAccount.SetColumn(balanceEntry, 0);
gridAccount.SetRow(balanceEntry, 1);
gridAccount.SetColumn(nameLabel, 1);
gridAccount.SetRow(nameLabel, 0);
gridAccount.SetColumn(nameEntry, 1);
gridAccount.SetColumn(nameEntry, 1);
gridAccount.Children.Add(balance);
gridAccount.Children.Add(balanceEntry);
gridAccount.Children.Add(nameLabel);
gridAccount.Children.Add(nameEntry);
StackLayout.Add(gridAccount);
//StackLayout.Add(balance);
// StackLayout.Add(balanceEntry);
//StackLayout.Add(nameLabel);
//StackLayout.Add(nameEntry);
StackLayout.Add(iban);
StackLayout.Add(ibanEntry);
}
}

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

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

@ -1,3 +1,4 @@
using System.Diagnostics;
using Model;
namespace Banquale.Views;
@ -14,13 +15,34 @@ public partial class SwitchAccountPage : ContentPage
public async void Transfer_Clicked(object sender, EventArgs e)
{
Mgr.SelectedAccount = Mgr.SelectedCustomer.AccountsList[0]; // 0 <20> changer
var selectedItem = (sender as Button)?.BindingContext as Account;
await Shell.Current.GoToAsync("//balance");
if (selectedItem != null)
{
Mgr.SelectedAccount = selectedItem;
if (Mgr.IsConsultant == true)
{
await Shell.Current.Navigation.PushAsync(new Balance.BalancePage());
}
else
{
await Shell.Current.GoToAsync("//balance");
}
}
}
async void DisconnectionClicked(System.Object sender, System.EventArgs e)
async void DisconnectionClicked(object sender, EventArgs e)
{
await Shell.Current.GoToAsync("///connection");
if(Mgr.IsConsultant == true)
{
//await Shell.Current.GoToAsync(;
Debug.WriteLine("Hello");
}
else
{
await Shell.Current.GoToAsync("///connection");
}
}
}

@ -25,7 +25,12 @@ public partial class TransferPage : ContentPage
{
if(acc.Name == Name.Text && acc.IBAN == IBAN.Text)
{
acc.DoTransactions(acc, Convert.ToDouble(Sum.Text), true, count+1); // Type true car c'est un virement
if(Mgr.SelectedAccount.Balance - Convert.ToDouble(Sum.Text) < 0)
{
await DisplayAlert("Erreur", "Vous ne possèdez pas assez d'argent sur ce compte pour aboutir à la transaction", "OK");
return;
}
Mgr.SelectedAccount.DoTransactions(acc, Convert.ToDouble(Sum.Text), true, count+1); // Type true car c'est un virement
await Shell.Current.Navigation.PopAsync();
return;
}

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
@ -108,7 +109,17 @@ namespace Model
/// Obtient ou définit la liste des transactions effectuées sur le compte.
/// </summary>
[DataMember(Order = 5)]
public List<Transaction> TransactionsList { get; set; } = new List<Transaction>();
public ObservableCollection<Transaction> TransactionsList
{
get => transactionsList;
set
{
transactionsList = value;
OnPropertyChanged(nameof(TransactionsList));
}
}
private ObservableCollection<Transaction> transactionsList;
/// <summary>
/// Effectue une transaction entre le compte courant et un compte tiers.
@ -117,7 +128,7 @@ namespace Model
/// <param name="sum">Somme de la transaction.</param>
/// <param name="type">Type de transaction (débit ou crédit).</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
{
@ -145,6 +156,7 @@ namespace Model
Name = name;
IBAN = iban;
IBANHide = IBANToString();
TransactionsList = new ObservableCollection<Transaction>();
}
/// <summary>

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
@ -27,6 +28,8 @@ namespace Model
[DataMember]
public List<Customer> CustomersList { get; private set; } // devient un set
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>
/// Consultant assigné au gestionnaire.
/// </summary>

@ -3,6 +3,8 @@
/// \author Votre nom
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
namespace Model
@ -11,20 +13,49 @@ namespace Model
/// Classe représentant un message.
/// </summary>
[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>
/// Sujet du message.
/// </summary>
[DataMember]
public string Subject { get; private set; }
public string Subject
{
get => subject;
set
{
if (subject == value) return;
subject = value;
OnPropertyChanged();
}
}
private string subject;
/// <summary>
/// Description du message.
/// </summary>
[DataMember]
public string Description { get; private set; }
public string Description
{
get => description;
set
{
if (description == value) return;
description = value;
OnPropertyChanged();
}
}
private string description;
/// <summary>
/// Constructeur de la classe Message.
/// </summary>

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

@ -1,14 +0,0 @@
using System.Diagnostics;
using Model;
namespace UnitTest;
public class UnitTest1
{
[Fact]
public void Test1()
{
Account Remi = new Account(900, "Remi", "FR00299209");
Debug.WriteLine(Remi.Balance);
}
}
Loading…
Cancel
Save