DIB
This commit is contained in:
@ -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,23 +58,35 @@ 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)
|
||||
{
|
||||
DataManager.Current.Contacts.Merge(BookQuery.Client);
|
||||
var e = new Estimate()
|
||||
// First search for an existing estimate
|
||||
var estimateToEdit = DataManager.Current.Estimates.FirstOrDefault(
|
||||
estimate=> estimate.CommandId == bookQueryViewModel.Id
|
||||
);
|
||||
if (estimateToEdit == null)
|
||||
{
|
||||
ClientId = BookQuery.Client.UserId,
|
||||
CommandId = BookQuery.Id,
|
||||
OwnerId = MainSettings.CurrentUser.Id,
|
||||
Id = 0,
|
||||
Description = "# **Hello Estimate!**"
|
||||
};
|
||||
viewModel = new EditEstimateViewModel(e, LocalState.New);
|
||||
DataManager.Current.EstimationCache.Add(viewModel);
|
||||
DataManager.Current.Contacts.Merge(BookQuery.Client);
|
||||
estimateToEdit = new Estimate()
|
||||
{
|
||||
ClientId = BookQuery.Client.UserId,
|
||||
CommandId = BookQuery.Id,
|
||||
OwnerId = MainSettings.CurrentUser.Id,
|
||||
Id = 0,
|
||||
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,
|
||||
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;
|
||||
bill.Add(com);
|
||||
bill.SaveCollection();
|
||||
lineView.PropertyChanged += (s,f) => bill.SaveCollection();
|
||||
var bill = ((EditEstimateViewModel)BindingContext).Bill;
|
||||
var lineView = new BillingLineViewModel(com)
|
||||
{ ValidateCommand = new Command(() => {
|
||||
bill.Add(com);
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,48 +13,57 @@ namespace BookAStar.ViewModels
|
||||
{
|
||||
BillingLine data;
|
||||
|
||||
public BillingLineViewModel( BillingLine data)
|
||||
public BillingLineViewModel(BillingLine data)
|
||||
{
|
||||
this.data = data ?? new BillingLine();
|
||||
// sets durationValue & durationUnit
|
||||
count = data.Count;
|
||||
description = data.Description;
|
||||
|
||||
Duration = data.Duration;
|
||||
unitaryCostText = data.UnitaryCost.ToString("G",CultureInfo.InvariantCulture);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,11 +82,11 @@ namespace BookAStar.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public enum DurationUnits:int
|
||||
public enum DurationUnits : int
|
||||
{
|
||||
Jours=0,
|
||||
Heures=1,
|
||||
Minutes=2
|
||||
Jours = 0,
|
||||
Heures = 1,
|
||||
Minutes = 2
|
||||
}
|
||||
private DurationUnits durationUnit;
|
||||
|
||||
@ -85,17 +94,17 @@ namespace BookAStar.ViewModels
|
||||
pour décrire la quantité de travail associée à ce type de service")]
|
||||
public DurationUnits DurationUnit
|
||||
{
|
||||
get {
|
||||
get
|
||||
{
|
||||
return durationUnit;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty<DurationUnits>(ref durationUnit, value, "DurationUnit");
|
||||
data.Duration = this.Duration;
|
||||
SetProperty<DurationUnits>(ref durationUnit, value, "DurationUnit");
|
||||
data.Duration = this.Duration;
|
||||
}
|
||||
}
|
||||
|
||||
protected decimal unitaryCost;
|
||||
public static readonly string unitCostFormat = "0,.00";
|
||||
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:
|
||||
return new TimeSpan(DurationValue, 0, 0);
|
||||
case DurationUnits.Jours:
|
||||
return new TimeSpan(DurationValue*24, 0, 0);
|
||||
return new TimeSpan(DurationValue * 24, 0, 0);
|
||||
case DurationUnits.Minutes:
|
||||
return new TimeSpan(0, DurationValue, 0);
|
||||
// Assert(false); since all units are treated bellow
|
||||
@ -143,18 +152,18 @@ pour décrire la quantité de travail associée à ce type de service")]
|
||||
double days = value.TotalDays;
|
||||
if (days >= 1.0)
|
||||
{
|
||||
DurationValue = (int) days;
|
||||
DurationValue = (int)days;
|
||||
DurationUnit = DurationUnits.Jours;
|
||||
return;
|
||||
}
|
||||
double hours = value.TotalHours;
|
||||
if (hours >= 1.0)
|
||||
{
|
||||
DurationValue = (int) hours;
|
||||
DurationValue = (int)hours;
|
||||
DurationUnit = DurationUnits.Jours;
|
||||
return;
|
||||
}
|
||||
DurationValue = (int) value.TotalMinutes;
|
||||
DurationValue = (int)value.TotalMinutes;
|
||||
DurationUnit = DurationUnits.Minutes;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user