Implemented restrictions for the entry and departure dates.

Implemented restrictions for decimal values.
This commit is contained in:
Tobias Erbshäußer
2020-06-15 18:25:35 +02:00
parent 9fb148cf48
commit 3f97fbfae4
7 changed files with 29 additions and 8 deletions
+1
View File
@@ -52,6 +52,7 @@ namespace UCalc
private void OnTenantsFrameLoadCompleted(object sender, NavigationEventArgs e) private void OnTenantsFrameLoadCompleted(object sender, NavigationEventArgs e)
{ {
var page = (TenantsPage) ((Frame) sender).Content; var page = (TenantsPage) ((Frame) sender).Content;
page.Model = Model;
page.Tenants = Model.Root.Tenants; page.Tenants = Model.Root.Tenants;
page.House = Model.Root.House; page.House = Model.Root.House;
page.ParentWindow = this; page.ParentWindow = this;
+1 -1
View File
@@ -11,7 +11,7 @@ namespace UCalc
public static readonly SolidColorBrush MainColor = Brushes.White; public static readonly SolidColorBrush MainColor = Brushes.White;
public static readonly SolidColorBrush SubMainColor = new SolidColorBrush(Color.FromRgb(0x00, 0x7A, 0xCC)); public static readonly SolidColorBrush SubMainColor = new SolidColorBrush(Color.FromRgb(0x00, 0x7A, 0xCC));
public const string DecimalFormat = ".00"; public const string DecimalFormat = "0.00";
public const string DateFormat = "dd.MM.yyyy"; public const string DateFormat = "dd.MM.yyyy";
public static readonly ImmutableList<string> SalutationStrs = public static readonly ImmutableList<string> SalutationStrs =
+4
View File
@@ -127,11 +127,15 @@ namespace UCalc.Models
} }
private readonly Validator _validator; private readonly Validator _validator;
public DateTime StartDate { get; }
public DateTime EndDate { get; }
public BillingProperty Root { get; } public BillingProperty Root { get; }
public Model(Billing billing) public Model(Billing billing)
{ {
_validator = new Validator(this); _validator = new Validator(this);
StartDate = billing.StartDate;
EndDate = billing.EndDate;
using var validator = BeginValidation(); using var validator = BeginValidation();
Root = new BillingProperty(this, null, billing); Root = new BillingProperty(this, null, billing);
+13 -4
View File
@@ -1,4 +1,5 @@
using System.Collections; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.ComponentModel; using System.ComponentModel;
@@ -171,9 +172,17 @@ namespace UCalc.Models
protected override string ValidateValue() protected override string ValidateValue()
{ {
return !decimal.TryParse(Value, out var n) || n < 0 if (!decimal.TryParse(Value, out var n) || n < 0)
? $"{Name}: Der eingegebene Wert ist kein gültiger Betrag." {
: ""; return $"{Name}: Der eingegebene Wert ist kein gültiger Betrag.";
}
if (Math.Round(n, 2) != n)
{
return $"{Name}: Der eingegebene Wert besitzt mehr als 2 Nachkommastellen.";
}
return "";
} }
} }
+2 -1
View File
@@ -7,6 +7,7 @@ namespace UCalc.Pages
public partial class TenantsPage public partial class TenantsPage
{ {
public Window ParentWindow { get; set; } public Window ParentWindow { get; set; }
public Model Model { get; set; }
public TenantsProperty Tenants { get; set; } public TenantsProperty Tenants { get; set; }
public HouseProperty House { get; set; } public HouseProperty House { get; set; }
@@ -35,7 +36,7 @@ namespace UCalc.Pages
{ {
var tenant = (TenantProperty) ((HighlightButton) sender).DataContext; var tenant = (TenantProperty) ((HighlightButton) sender).DataContext;
new TenantWindow(tenant, House) {Owner = ParentWindow}.ShowDialog(); new TenantWindow(Model, tenant, House) {Owner = ParentWindow}.ShowDialog();
} }
} }
} }
+5 -1
View File
@@ -151,9 +151,11 @@
DockPanel.Dock="Right" DockPanel.Dock="Right"
VerticalAlignment="Center" VerticalAlignment="Center"
Property="{Binding Path=Tenant.EntryDate, RelativeSource={RelativeSource AncestorType=local:TenantWindow}}" /> Property="{Binding Path=Tenant.EntryDate, RelativeSource={RelativeSource AncestorType=local:TenantWindow}}" />
<!-- TODO DisplayDateStart="{}" -->
<DatePicker VerticalAlignment="Center" <DatePicker VerticalAlignment="Center"
MinHeight="22" MinHeight="22"
DisplayDateStart="{Binding Path=Model.StartDate, RelativeSource={RelativeSource AncestorType=local:TenantWindow}, Mode=OneWay}"
DisplayDateEnd="{Binding Path=Model.EndDate, RelativeSource={RelativeSource AncestorType=local:TenantWindow}, Mode=OneWay}"
Text="{Binding Path=Tenant.EntryDate.Value, RelativeSource={RelativeSource AncestorType=local:TenantWindow}, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, Converter={StaticResource DatePickerTextToDateTimeConverter}}" /> Text="{Binding Path=Tenant.EntryDate.Value, RelativeSource={RelativeSource AncestorType=local:TenantWindow}, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, Converter={StaticResource DatePickerTextToDateTimeConverter}}" />
</DockPanel> </DockPanel>
@@ -170,6 +172,8 @@
<DatePicker VerticalAlignment="Center" <DatePicker VerticalAlignment="Center"
MinHeight="22" MinHeight="22"
DisplayDateStart="{Binding Path=Model.StartDate, RelativeSource={RelativeSource AncestorType=local:TenantWindow}, Mode=OneWay}"
DisplayDateEnd="{Binding Path=Model.EndDate, RelativeSource={RelativeSource AncestorType=local:TenantWindow}, Mode=OneWay}"
Text="{Binding Path=Tenant.DepartureDate.Value, RelativeSource={RelativeSource AncestorType=local:TenantWindow}, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, Converter={StaticResource DatePickerTextToDateTimeConverter}}" /> Text="{Binding Path=Tenant.DepartureDate.Value, RelativeSource={RelativeSource AncestorType=local:TenantWindow}, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, Converter={StaticResource DatePickerTextToDateTimeConverter}}" />
</DockPanel> </DockPanel>
+3 -1
View File
@@ -7,11 +7,13 @@ namespace UCalc
{ {
public partial class TenantWindow public partial class TenantWindow
{ {
public Model Model { get; }
public TenantProperty Tenant { get; } public TenantProperty Tenant { get; }
public HouseProperty House { get; } public HouseProperty House { get; }
public TenantWindow(TenantProperty tenant, HouseProperty house) public TenantWindow(Model model, TenantProperty tenant, HouseProperty house)
{ {
Model = model;
Tenant = tenant; Tenant = tenant;
House = house; House = house;
InitializeComponent(); InitializeComponent();