DIB
This commit is contained in:
parent
15fec4ddf1
commit
ca3ac85ecd
7 changed files with 100 additions and 49 deletions
|
|
@ -26,9 +26,8 @@
|
||||||
<Label Text="{Binding Previsional}" />
|
<Label Text="{Binding Previsional}" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" >
|
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" >
|
||||||
<maps:Map x:Name="map" VerticalOptions="FillAndExpand"></maps:Map>
|
<maps:Map x:Name="map" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"></maps:Map>
|
||||||
|
<Button Text="{Binding EditEstimateButtonText}" Clicked="OnEditEstimate" VerticalOptions="End"/>
|
||||||
<Button Text="{Binding EditEstimateButtonText}" Clicked="OnEditEstimate" />
|
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
|
|
@ -7,6 +7,7 @@ namespace BookAStar.Pages
|
||||||
using Data;
|
using Data;
|
||||||
using Model;
|
using Model;
|
||||||
using Model.Workflow;
|
using Model.Workflow;
|
||||||
|
using System.Linq;
|
||||||
using ViewModels;
|
using ViewModels;
|
||||||
|
|
||||||
public partial class BookQueryPage : ContentPage
|
public partial class BookQueryPage : ContentPage
|
||||||
|
|
@ -57,23 +58,35 @@ namespace BookAStar.Pages
|
||||||
|
|
||||||
private void OnEditEstimate(object sender, EventArgs ev)
|
private void OnEditEstimate(object sender, EventArgs ev)
|
||||||
{
|
{
|
||||||
var viewModel = ((BookQueryViewModel)BindingContext).DraftEstimate;
|
var bookQueryViewModel = (BookQueryViewModel)BindingContext;
|
||||||
if (viewModel == null)
|
|
||||||
|
var editEstimateViewModel = bookQueryViewModel.DraftEstimate;
|
||||||
|
if (editEstimateViewModel == null)
|
||||||
{
|
{
|
||||||
DataManager.Current.Contacts.Merge(BookQuery.Client);
|
// First search for an existing estimate
|
||||||
var e = new Estimate()
|
var estimateToEdit = DataManager.Current.Estimates.FirstOrDefault(
|
||||||
|
estimate=> estimate.CommandId == bookQueryViewModel.Id
|
||||||
|
);
|
||||||
|
if (estimateToEdit == null)
|
||||||
{
|
{
|
||||||
ClientId = BookQuery.Client.UserId,
|
DataManager.Current.Contacts.Merge(BookQuery.Client);
|
||||||
CommandId = BookQuery.Id,
|
estimateToEdit = new Estimate()
|
||||||
OwnerId = MainSettings.CurrentUser.Id,
|
{
|
||||||
Id = 0,
|
ClientId = BookQuery.Client.UserId,
|
||||||
Description = "# **Hello Estimate!**"
|
CommandId = BookQuery.Id,
|
||||||
};
|
OwnerId = MainSettings.CurrentUser.Id,
|
||||||
viewModel = new EditEstimateViewModel(e, LocalState.New);
|
Id = 0,
|
||||||
DataManager.Current.EstimationCache.Add(viewModel);
|
Description = "# **Hello Estimate!**"
|
||||||
|
};
|
||||||
|
editEstimateViewModel = new EditEstimateViewModel(estimateToEdit, LocalState.New);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
editEstimateViewModel = new EditEstimateViewModel(estimateToEdit, LocalState.UpToDate);
|
||||||
|
|
||||||
|
DataManager.Current.EstimationCache.Add(editEstimateViewModel);
|
||||||
}
|
}
|
||||||
App.NavigationService.NavigateTo<EditEstimatePage>(true,
|
App.NavigationService.NavigateTo<EditEstimatePage>(true,
|
||||||
viewModel);
|
editEstimateViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnSizeAllocated(double width, double height)
|
protected override void OnSizeAllocated(double width, double height)
|
||||||
|
|
|
||||||
|
|
@ -93,8 +93,10 @@
|
||||||
Path=IsValid,
|
Path=IsValid,
|
||||||
Converter={StaticResource boolToStyleImage}}" />
|
Converter={StaticResource boolToStyleImage}}" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
|
<Button Text="Términé"
|
||||||
<Button Text="Valider cette ligne de devis"
|
Command="{Binding DeleteCommand}"
|
||||||
|
Clicked="OnValidateClicked"></Button>
|
||||||
|
<Button Text="Términé"
|
||||||
Command="{Binding ValidateCommand}"
|
Command="{Binding ValidateCommand}"
|
||||||
Clicked="OnValidateClicked"></Button>
|
Clicked="OnValidateClicked"></Button>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
|
|
|
||||||
|
|
@ -21,5 +21,11 @@ namespace BookAStar.Pages
|
||||||
{
|
{
|
||||||
this.Navigation.PopAsync();
|
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">
|
<StackLayout x:Name="biAnVaLayout">
|
||||||
<ListView x:Name="BillListView" ItemsSource="{Binding Bill}"
|
<ListView x:Name="BillListView" ItemsSource="{Binding Bill}"
|
||||||
MinimumHeightRequest="40" HasUnevenRows="true" VerticalOptions="FillAndExpand"
|
MinimumHeightRequest="40" HasUnevenRows="true" VerticalOptions="FillAndExpand"
|
||||||
HeightRequest="40">
|
HeightRequest="40" ItemTapped="OnEditLine">
|
||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate >
|
<DataTemplate >
|
||||||
<ViewCell>
|
<ViewCell>
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ namespace BookAStar.Pages
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
BindingContext = model;
|
BindingContext = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnBindingContextChanged()
|
protected override void OnBindingContextChanged()
|
||||||
{
|
{
|
||||||
base.OnBindingContextChanged();
|
base.OnBindingContextChanged();
|
||||||
|
|
@ -41,17 +42,36 @@ namespace BookAStar.Pages
|
||||||
protected void OnNewCommanLine(object sender, EventArgs e)
|
protected void OnNewCommanLine(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var com = new BillingLine() { Count = 1, UnitaryCost = 0.01m };
|
var com = new BillingLine() { Count = 1, UnitaryCost = 0.01m };
|
||||||
var lineView = new BillingLineViewModel(com);
|
var bill = ((EditEstimateViewModel)BindingContext).Bill;
|
||||||
var bill =
|
var lineView = new BillingLineViewModel(com)
|
||||||
((EditEstimateViewModel)BindingContext).Bill;
|
{ ValidateCommand = new Command(() => {
|
||||||
bill.Add(com);
|
bill.Add(com);
|
||||||
bill.SaveCollection();
|
bill.SaveCollection();
|
||||||
lineView.PropertyChanged += (s,f) => bill.SaveCollection();
|
})};
|
||||||
App.NavigationService.NavigateTo<EditBillingLinePage>(
|
App.NavigationService.NavigateTo<EditBillingLinePage>(
|
||||||
true,
|
true,
|
||||||
new object[] { lineView } );
|
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)
|
protected void OnEstimateValidated(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
@ -68,7 +88,9 @@ namespace BookAStar.Pages
|
||||||
DataManager.Current.Estimates.Update(evm.Data);
|
DataManager.Current.Estimates.Update(evm.Data);
|
||||||
}
|
}
|
||||||
DataManager.Current.Estimates.SaveCollection();
|
DataManager.Current.Estimates.SaveCollection();
|
||||||
evm.State = LocalState.UpToDate;
|
DataManager.Current.EstimationCache.Remove(evm);
|
||||||
|
DataManager.Current.EstimationCache.SaveCollection();
|
||||||
|
Navigation.PopAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,48 +13,57 @@ namespace BookAStar.ViewModels
|
||||||
{
|
{
|
||||||
BillingLine data;
|
BillingLine data;
|
||||||
|
|
||||||
public BillingLineViewModel( BillingLine data)
|
public BillingLineViewModel(BillingLine data)
|
||||||
{
|
{
|
||||||
this.data = data ?? new BillingLine();
|
this.data = data ?? new BillingLine();
|
||||||
// sets durationValue & durationUnit
|
// sets durationValue & durationUnit
|
||||||
|
count = data.Count;
|
||||||
|
description = data.Description;
|
||||||
|
|
||||||
Duration = data.Duration;
|
Duration = data.Duration;
|
||||||
unitaryCostText = data.UnitaryCost.ToString("G",CultureInfo.InvariantCulture);
|
unitaryCostText = data.UnitaryCost.ToString("G", CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int count;
|
||||||
public int Count
|
public int Count
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return data.Count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
data.Count = value;
|
SetProperty<int>(ref count, value);
|
||||||
|
data.Count = count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private string description;
|
||||||
public string Description
|
public string Description
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return data.Description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
data.Description = value;
|
SetProperty<string>(ref description, value);
|
||||||
|
data.Description = description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
decimal unitaryCost;
|
||||||
public decimal UnitaryCost
|
public decimal UnitaryCost
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return data.UnitaryCost;
|
return unitaryCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
data.UnitaryCost = value;
|
SetProperty<decimal>(ref unitaryCost, value);
|
||||||
|
data.UnitaryCost = unitaryCost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,12 +81,12 @@ namespace BookAStar.ViewModels
|
||||||
data.Duration = this.Duration;
|
data.Duration = this.Duration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum DurationUnits:int
|
public enum DurationUnits : int
|
||||||
{
|
{
|
||||||
Jours=0,
|
Jours = 0,
|
||||||
Heures=1,
|
Heures = 1,
|
||||||
Minutes=2
|
Minutes = 2
|
||||||
}
|
}
|
||||||
private DurationUnits durationUnit;
|
private DurationUnits durationUnit;
|
||||||
|
|
||||||
|
|
@ -85,17 +94,17 @@ namespace BookAStar.ViewModels
|
||||||
pour décrire la quantité de travail associée à ce type de service")]
|
pour décrire la quantité de travail associée à ce type de service")]
|
||||||
public DurationUnits DurationUnit
|
public DurationUnits DurationUnit
|
||||||
{
|
{
|
||||||
get {
|
get
|
||||||
|
{
|
||||||
return durationUnit;
|
return durationUnit;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
SetProperty<DurationUnits>(ref durationUnit, value, "DurationUnit");
|
SetProperty<DurationUnits>(ref durationUnit, value, "DurationUnit");
|
||||||
data.Duration = this.Duration;
|
data.Duration = this.Duration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected decimal unitaryCost;
|
|
||||||
public static readonly string unitCostFormat = "0,.00";
|
public static readonly string unitCostFormat = "0,.00";
|
||||||
string unitaryCostText;
|
string unitaryCostText;
|
||||||
public string UnitaryCostText
|
public string UnitaryCostText
|
||||||
|
|
@ -129,7 +138,7 @@ pour décrire la quantité de travail associée à ce type de service")]
|
||||||
case DurationUnits.Heures:
|
case DurationUnits.Heures:
|
||||||
return new TimeSpan(DurationValue, 0, 0);
|
return new TimeSpan(DurationValue, 0, 0);
|
||||||
case DurationUnits.Jours:
|
case DurationUnits.Jours:
|
||||||
return new TimeSpan(DurationValue*24, 0, 0);
|
return new TimeSpan(DurationValue * 24, 0, 0);
|
||||||
case DurationUnits.Minutes:
|
case DurationUnits.Minutes:
|
||||||
return new TimeSpan(0, DurationValue, 0);
|
return new TimeSpan(0, DurationValue, 0);
|
||||||
// Assert(false); since all units are treated bellow
|
// Assert(false); since all units are treated bellow
|
||||||
|
|
@ -143,21 +152,21 @@ pour décrire la quantité de travail associée à ce type de service")]
|
||||||
double days = value.TotalDays;
|
double days = value.TotalDays;
|
||||||
if (days >= 1.0)
|
if (days >= 1.0)
|
||||||
{
|
{
|
||||||
DurationValue = (int) days;
|
DurationValue = (int)days;
|
||||||
DurationUnit = DurationUnits.Jours;
|
DurationUnit = DurationUnits.Jours;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double hours = value.TotalHours;
|
double hours = value.TotalHours;
|
||||||
if (hours >= 1.0)
|
if (hours >= 1.0)
|
||||||
{
|
{
|
||||||
DurationValue = (int) hours;
|
DurationValue = (int)hours;
|
||||||
DurationUnit = DurationUnits.Jours;
|
DurationUnit = DurationUnits.Jours;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DurationValue = (int) value.TotalMinutes;
|
DurationValue = (int)value.TotalMinutes;
|
||||||
DurationUnit = DurationUnits.Minutes;
|
DurationUnit = DurationUnits.Minutes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue