Paul Schneider 9 years ago
parent e930a0d188
commit 16dac3f1fd
7 changed files with 100 additions and 49 deletions

@ -26,9 +26,8 @@
<Label Text="{Binding Previsional}" />
</StackLayout>
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" >
<maps:Map x:Name="map" VerticalOptions="FillAndExpand"></maps:Map>
<Button Text="{Binding EditEstimateButtonText}" Clicked="OnEditEstimate" />
<maps:Map x:Name="map" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"></maps:Map>
<Button Text="{Binding EditEstimateButtonText}" Clicked="OnEditEstimate" VerticalOptions="End"/>
</StackLayout>
</StackLayout>
</ContentPage>

@ -7,6 +7,7 @@ namespace BookAStar.Pages
using Data;
using Model;
using Model.Workflow;
using System.Linq;
using ViewModels;
public partial class BookQueryPage : ContentPage
@ -57,11 +58,19 @@ namespace BookAStar.Pages
private void OnEditEstimate(object sender, EventArgs ev)
{
var viewModel = ((BookQueryViewModel)BindingContext).DraftEstimate;
if (viewModel == null)
var bookQueryViewModel = (BookQueryViewModel)BindingContext;
var editEstimateViewModel = bookQueryViewModel.DraftEstimate;
if (editEstimateViewModel == null)
{
// First search for an existing estimate
var estimateToEdit = DataManager.Current.Estimates.FirstOrDefault(
estimate=> estimate.CommandId == bookQueryViewModel.Id
);
if (estimateToEdit == null)
{
DataManager.Current.Contacts.Merge(BookQuery.Client);
var e = new Estimate()
estimateToEdit = new Estimate()
{
ClientId = BookQuery.Client.UserId,
CommandId = BookQuery.Id,
@ -69,11 +78,15 @@ namespace BookAStar.Pages
Id = 0,
Description = "# **Hello Estimate!**"
};
viewModel = new EditEstimateViewModel(e, LocalState.New);
DataManager.Current.EstimationCache.Add(viewModel);
editEstimateViewModel = new EditEstimateViewModel(estimateToEdit, LocalState.New);
}
else
editEstimateViewModel = new EditEstimateViewModel(estimateToEdit, LocalState.UpToDate);
DataManager.Current.EstimationCache.Add(editEstimateViewModel);
}
App.NavigationService.NavigateTo<EditEstimatePage>(true,
viewModel);
editEstimateViewModel);
}
protected override void OnSizeAllocated(double width, double height)

@ -93,8 +93,10 @@
Path=IsValid,
Converter={StaticResource boolToStyleImage}}" />
</StackLayout>
<Button Text="Valider cette ligne de devis"
<Button Text="Términé"
Command="{Binding DeleteCommand}"
Clicked="OnValidateClicked"></Button>
<Button Text="Términé"
Command="{Binding ValidateCommand}"
Clicked="OnValidateClicked"></Button>
</StackLayout>

@ -21,5 +21,11 @@ namespace BookAStar.Pages
{
this.Navigation.PopAsync();
}
protected override bool OnBackButtonPressed()
{
var bvm = (BillingLineViewModel)BindingContext;
bvm.ValidateCommand?.Execute(null);
return base.OnBackButtonPressed();
}
}
}

@ -40,7 +40,7 @@
<StackLayout x:Name="biAnVaLayout">
<ListView x:Name="BillListView" ItemsSource="{Binding Bill}"
MinimumHeightRequest="40" HasUnevenRows="true" VerticalOptions="FillAndExpand"
HeightRequest="40">
HeightRequest="40" ItemTapped="OnEditLine">
<ListView.ItemTemplate>
<DataTemplate >
<ViewCell>

@ -14,6 +14,7 @@ namespace BookAStar.Pages
InitializeComponent();
BindingContext = model;
}
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
@ -41,17 +42,36 @@ namespace BookAStar.Pages
protected void OnNewCommanLine(object sender, EventArgs e)
{
var com = new BillingLine() { Count = 1, UnitaryCost = 0.01m };
var lineView = new BillingLineViewModel(com);
var bill =
((EditEstimateViewModel)BindingContext).Bill;
var bill = ((EditEstimateViewModel)BindingContext).Bill;
var lineView = new BillingLineViewModel(com)
{ ValidateCommand = new Command(() => {
bill.Add(com);
bill.SaveCollection();
lineView.PropertyChanged += (s,f) => bill.SaveCollection();
})};
App.NavigationService.NavigateTo<EditBillingLinePage>(
true,
new object[] { lineView } );
}
protected void OnEditLine(object sender, ItemTappedEventArgs e)
{
var line = (BillingLine)e.Item;
var bill = ((EditEstimateViewModel)BindingContext).Bill;
var lineView = new BillingLineViewModel(line)
{
ValidateCommand = new Command(() => {
bill.SaveCollection();
})
};
lineView.PropertyChanged += LineView_PropertyChanged;
App.NavigationService.NavigateTo<EditBillingLinePage>(
true,
new object[] { lineView });
}
private void LineView_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
DataManager.Current.EstimationCache.SaveCollection();
}
protected void OnEstimateValidated(object sender, EventArgs e)
{
@ -68,7 +88,9 @@ namespace BookAStar.Pages
DataManager.Current.Estimates.Update(evm.Data);
}
DataManager.Current.Estimates.SaveCollection();
evm.State = LocalState.UpToDate;
DataManager.Current.EstimationCache.Remove(evm);
DataManager.Current.EstimationCache.SaveCollection();
Navigation.PopAsync();
}
}
}

@ -17,44 +17,53 @@ namespace BookAStar.ViewModels
{
this.data = data ?? new BillingLine();
// sets durationValue & durationUnit
count = data.Count;
description = data.Description;
Duration = data.Duration;
unitaryCostText = data.UnitaryCost.ToString("G", CultureInfo.InvariantCulture);
}
private int count;
public int Count
{
get
{
return data.Count;
return count;
}
set
{
data.Count = value;
SetProperty<int>(ref count, value);
data.Count = count;
}
}
private string description;
public string Description
{
get
{
return data.Description;
return description;
}
set
{
data.Description = value;
SetProperty<string>(ref description, value);
data.Description = description;
}
}
decimal unitaryCost;
public decimal UnitaryCost
{
get
{
return data.UnitaryCost;
return unitaryCost;
}
set
{
data.UnitaryCost = value;
SetProperty<decimal>(ref unitaryCost, value);
data.UnitaryCost = unitaryCost;
}
}
@ -85,7 +94,8 @@ namespace BookAStar.ViewModels
pour décrire la quantité de travail associée à ce type de service")]
public DurationUnits DurationUnit
{
get {
get
{
return durationUnit;
}
set
@ -95,7 +105,6 @@ pour décrire la quantité de travail associée à ce type de service")]
}
}
protected decimal unitaryCost;
public static readonly string unitCostFormat = "0,.00";
string unitaryCostText;
public string UnitaryCostText

Loading…