add Create customer page feature

pull/52/head
Antoine PEREDERII 2 years ago
parent 01960e963d
commit 0ddd1c1c56

@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Banquale.Views.Balance.BalancePage"
xmlns:local="clr-namespace:Banquale.Views.Balance"
Title="BalancePage"
Shell.NavBarIsVisible="False">
<Grid RowDefinitions="auto, auto, *" x:Name="Grid">

@ -4,49 +4,100 @@
x:Class="Banquale.Views.CreateCustomerPage"
Title="CreateCustomerPage">
<StackLayout Margin="20"
x:Name="StackLayout">
<VerticalStackLayout>
<Label
Text="Informations du client"
FontSize="Title"
HorizontalOptions="Center"
Margin="0,0,0,20" />
<Label
Text="Nom"
FontSize="Subtitle" />
<Entry
x:Name="NameEntry"
Placeholder="Entrez le nom" />
<Label
Text="Prénom"
FontSize="Subtitle" />
<Entry
x:Name="FirstNameEntry"
Placeholder="Entrez le prénom" />
Margin="0,20,0,15"
TextColor="Red"/>
<Label
Text="Mot de Passe"
FontSize="Subtitle" />
<Entry
x:Name="PasswordEntry"
Placeholder="Entrez le mot de passe" />
<StackLayout Margin="20"
x:Name="StackLayout">
<Label
Text="Compte 1"
FontSize="Title" />
<Entry
x:Name="BalanceEntry"
Placeholder="Entrez le solde du compte" />
<Grid
ColumnDefinitions="*, *"
RowDefinitions="auto, auto">
<Label
Text="Nom du compte"
FontSize="Subtitle" />
<Entry
x:Name="Name1Entry"
Placeholder="Entrez le nom" />
<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>
<Button
Text="Ajouter un compte"
@ -60,6 +111,8 @@
Margin="0,20,0,0"
Clicked="Create_Customer_Clicked"/>
</StackLayout>
</VerticalStackLayout>
</ContentPage>

@ -1,4 +1,5 @@
using Model;
using System.Diagnostics;
using Model;
namespace Banquale.Views;
public partial class CreateCustomerPage : ContentPage
@ -17,27 +18,76 @@ public partial class CreateCustomerPage : ContentPage
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))
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", "OK");
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)};
Label balance = new Label { Text = "Solde" };
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" };
StackLayout.Add(account);
StackLayout.Add(balance);
StackLayout.Add(balanceEntry);
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);
}
}

@ -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