wip billing
This commit is contained in:
parent
f9bd1c2511
commit
737f881189
2 changed files with 51 additions and 26 deletions
|
|
@ -3,6 +3,8 @@
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
|
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
|
||||||
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar"
|
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar"
|
||||||
|
xmlns:behaviors="clr-namespace:BookAStar.Behaviors;assembly=BookAStar"
|
||||||
|
xmlns:extensions="clr-namespace:BookAStar.Extensions;assembly=BookAStar"
|
||||||
x:Class="BookAStar.Pages.EditBillingLinePage"
|
x:Class="BookAStar.Pages.EditBillingLinePage"
|
||||||
Style="{StaticResource PageStyle}">
|
Style="{StaticResource PageStyle}">
|
||||||
<ContentPage.Resources>
|
<ContentPage.Resources>
|
||||||
|
|
@ -13,6 +15,23 @@
|
||||||
<Style TargetType="Button">
|
<Style TargetType="Button">
|
||||||
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
|
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
<local:BooleanToObjectConverter x:Key="boolToStyleImage" x:TypeArguments="Style">
|
||||||
|
|
||||||
|
<local:BooleanToObjectConverter.FalseObject>
|
||||||
|
<Style TargetType="Image">
|
||||||
|
<Setter Property="HeightRequest" Value="20" />
|
||||||
|
<Setter Property="Source" Value="{extensions:ImageResource Samples.Images.error.png}" />
|
||||||
|
</Style>
|
||||||
|
</local:BooleanToObjectConverter.FalseObject>
|
||||||
|
|
||||||
|
<local:BooleanToObjectConverter.TrueObject>
|
||||||
|
<Style TargetType="Image">
|
||||||
|
<Setter Property="HeightRequest" Value="20" />
|
||||||
|
<Setter Property="Source" Value="{extensions:ImageResource Samples.Images.success.png}" />
|
||||||
|
</Style>
|
||||||
|
</local:BooleanToObjectConverter.TrueObject>
|
||||||
|
</local:BooleanToObjectConverter>
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</ContentPage.Resources>
|
</ContentPage.Resources>
|
||||||
<StackLayout x:Name="mainStackLayout">
|
<StackLayout x:Name="mainStackLayout">
|
||||||
|
|
@ -22,7 +41,8 @@
|
||||||
Style="{StaticResource InputLabelStyle}"></Label>
|
Style="{StaticResource InputLabelStyle}"></Label>
|
||||||
<StackLayout Orientation="Horizontal">
|
<StackLayout Orientation="Horizontal">
|
||||||
<Entry Placeholder="Durée" Keyboard="Numeric" Style="{StaticResource BigEntry}" />
|
<Entry Placeholder="Durée" Keyboard="Numeric" Style="{StaticResource BigEntry}" />
|
||||||
<Picker x:Name="picker" SelectedIndex="{Binding UnitaryCost, Mode=TwoWay}" Style="{StaticResource PickerStyle}" Title="Unité de temps">
|
<Picker x:Name="picker" SelectedIndex="{Binding UnitaryCost, Mode=TwoWay}"
|
||||||
|
Style="{StaticResource PickerStyle}" Title="Unité de temps">
|
||||||
<Picker.Items>
|
<Picker.Items>
|
||||||
<x:String>Jours</x:String>
|
<x:String>Jours</x:String>
|
||||||
<x:String>Heures</x:String>
|
<x:String>Heures</x:String>
|
||||||
|
|
@ -31,12 +51,24 @@
|
||||||
</Picker>
|
</Picker>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<Label Text="Quantité facturée" Style="{StaticResource InputLabelStyle}"></Label>
|
<Label Text="Quantité facturée" Style="{StaticResource InputLabelStyle}"></Label>
|
||||||
<Entry Text="{Binding Count, Mode=TwoWay}" Placeholder="Quantité" Keyboard="Numeric" Style="{StaticResource BigEntry}"/>
|
<Entry Text="{Binding Count, Mode=TwoWay}" Placeholder="Quantité" Keyboard="Numeric"
|
||||||
|
Style="{StaticResource BigEntry}"/>
|
||||||
<Label Text="Prix unitaire" Style="{StaticResource InputLabelStyle}"></Label>
|
<Label Text="Prix unitaire" Style="{StaticResource InputLabelStyle}"></Label>
|
||||||
<StackLayout Orientation="Horizontal">
|
<StackLayout Orientation="Horizontal">
|
||||||
<Entry Text="{Binding UnitaryCostText, Mode=TwoWay}" Placeholder="Prix" Keyboard="Numeric" Style="{StaticResource BigEntry}"></Entry>
|
|
||||||
|
<Entry Text="{Binding UnitaryCostText, Mode=TwoWay}" Placeholder="Prix"
|
||||||
|
Keyboard="Numeric" Style="{StaticResource BigEntry}" >
|
||||||
|
<Entry.Behaviors>
|
||||||
|
<behaviors:DecimalValidatorBehavior x:Name="unitCostValidator" />
|
||||||
|
</Entry.Behaviors>
|
||||||
|
<Image x:Name="unitaryCostSuccessErrorImage"
|
||||||
|
Style="{Binding Source={x:Reference unitCostValidator},
|
||||||
|
Path=IsValid,
|
||||||
|
Converter={StaticResource boolToStyleImage}}" />
|
||||||
|
</Entry>
|
||||||
<Label Text="€" Style="{StaticResource BigLabel}" HorizontalTextAlignment="Start"/>
|
<Label Text="€" Style="{StaticResource BigLabel}" HorizontalTextAlignment="Start"/>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<Button Text="Valider cette ligne de facture" Command="{Binding ValidateCommand}" Clicked="OnValidateClicked"></Button>
|
<Button Text="Valider cette ligne de facture" Command="{Binding ValidateCommand}"
|
||||||
|
Clicked="OnValidateClicked"></Button>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
|
|
@ -83,25 +83,30 @@ namespace BookAStar.ViewModels
|
||||||
|
|
||||||
protected decimal unitaryCost;
|
protected decimal unitaryCost;
|
||||||
public static readonly string unitCostFormat = "0,.00";
|
public static readonly string unitCostFormat = "0,.00";
|
||||||
|
string unitaryCostText;
|
||||||
public string UnitaryCostText
|
public string UnitaryCostText
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return unitaryCost.ToString(unitCostFormat, CultureInfo.InvariantCulture);
|
return unitaryCostText;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
decimal newValue;
|
if (unitaryCostText != value)
|
||||||
if (decimal.TryParse(value, NumberStyles.Currency,
|
|
||||||
CultureInfo.InvariantCulture,
|
|
||||||
out newValue))
|
|
||||||
{
|
{
|
||||||
SetProperty<decimal>(ref unitaryCost, newValue, "UnitaryCostText");
|
try
|
||||||
SetProperty<bool>(ref invalidCost, false, "InvalidCost");
|
{
|
||||||
|
data.UnitaryCost = decimal.Parse(value, CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// TODO Error model
|
||||||
|
// UI should shoud entry as wearing a wrong value
|
||||||
|
// thanks to its `Behaviors`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
SetProperty<string>(ref unitaryCostText, value, "UnitaryCostText");
|
||||||
SetProperty<bool>(ref invalidCost, true, "InvalidCost");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool invalidCost;
|
bool invalidCost;
|
||||||
|
|
@ -150,17 +155,5 @@ namespace BookAStar.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public decimal UnitaryCost
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return decimal.Parse(this.UnitaryCostText,CultureInfo.InvariantCulture);
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
UnitaryCostText = value.ToString(unitCostFormat, CultureInfo.InvariantCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue