add collection

pull/52/head
Antoine PEREDERII 2 years ago
parent 7a00520e16
commit 1f994eb49d

@ -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,11 +1,12 @@
<?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"
x:Class="Banquale.Views.Balance.BalancePage"
xmlns:local="clr-namespace:Banquale.Views.Balance"
Title="BalancePage"
Shell.NavBarIsVisible="False">
<Grid RowDefinitions="auto, auto, *">
<Grid RowDefinitions="auto, auto, *" x:Name="Grid">
<Frame BackgroundColor="{StaticResource Key=Banquale}"
CornerRadius="15"
@ -72,61 +73,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,29 @@
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 { HeightRequest = 100 };
backArrow.SetBinding(Image.SourceProperty, "backArrowIcon");
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,41 @@
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)
{
//uint TransactionId = Convert.ToUInt32(transactionId.Text);
//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;
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());
}
}

@ -5,17 +5,55 @@
<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 TransactionsList}"
Grid.Row="2"
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>

@ -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());
}
}

@ -1,3 +1,4 @@
using System.Diagnostics;
using Model;
namespace Banquale.Views;
@ -15,12 +16,27 @@ public partial class SwitchAccountPage : ContentPage
public async void Transfer_Clicked(object sender, EventArgs e)
{
Mgr.SelectedAccount = Mgr.SelectedCustomer.AccountsList[0]; // 0 <20> changer
await Shell.Current.GoToAsync("//balance");
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");
}
}
}

@ -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,7 @@ 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; set; } = new ObservableCollection<Transaction>();
/// <summary>
/// Effectue une transaction entre le compte courant et un compte tiers.

@ -27,6 +27,8 @@ namespace Model
[DataMember]
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)"};
/// <summary>
/// Consultant assigné au gestionnaire.
/// </summary>

Loading…
Cancel
Save