Implemented restrictions for the entry and departure dates.
Implemented restrictions for decimal values.
This commit is contained in:
@@ -52,6 +52,7 @@ namespace UCalc
|
||||
private void OnTenantsFrameLoadCompleted(object sender, NavigationEventArgs e)
|
||||
{
|
||||
var page = (TenantsPage) ((Frame) sender).Content;
|
||||
page.Model = Model;
|
||||
page.Tenants = Model.Root.Tenants;
|
||||
page.House = Model.Root.House;
|
||||
page.ParentWindow = this;
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ namespace UCalc
|
||||
public static readonly SolidColorBrush MainColor = Brushes.White;
|
||||
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 static readonly ImmutableList<string> SalutationStrs =
|
||||
|
||||
@@ -127,11 +127,15 @@ namespace UCalc.Models
|
||||
}
|
||||
|
||||
private readonly Validator _validator;
|
||||
public DateTime StartDate { get; }
|
||||
public DateTime EndDate { get; }
|
||||
public BillingProperty Root { get; }
|
||||
|
||||
public Model(Billing billing)
|
||||
{
|
||||
_validator = new Validator(this);
|
||||
StartDate = billing.StartDate;
|
||||
EndDate = billing.EndDate;
|
||||
|
||||
using var validator = BeginValidation();
|
||||
Root = new BillingProperty(this, null, billing);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
@@ -171,9 +172,17 @@ namespace UCalc.Models
|
||||
|
||||
protected override string ValidateValue()
|
||||
{
|
||||
return !decimal.TryParse(Value, out var n) || n < 0
|
||||
? $"{Name}: Der eingegebene Wert ist kein gültiger Betrag."
|
||||
: "";
|
||||
if (!decimal.TryParse(Value, out var n) || n < 0)
|
||||
{
|
||||
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 "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace UCalc.Pages
|
||||
public partial class TenantsPage
|
||||
{
|
||||
public Window ParentWindow { get; set; }
|
||||
public Model Model { get; set; }
|
||||
public TenantsProperty Tenants { get; set; }
|
||||
public HouseProperty House { get; set; }
|
||||
|
||||
@@ -35,7 +36,7 @@ namespace UCalc.Pages
|
||||
{
|
||||
var tenant = (TenantProperty) ((HighlightButton) sender).DataContext;
|
||||
|
||||
new TenantWindow(tenant, House) {Owner = ParentWindow}.ShowDialog();
|
||||
new TenantWindow(Model, tenant, House) {Owner = ParentWindow}.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,9 +151,11 @@
|
||||
DockPanel.Dock="Right"
|
||||
VerticalAlignment="Center"
|
||||
Property="{Binding Path=Tenant.EntryDate, RelativeSource={RelativeSource AncestorType=local:TenantWindow}}" />
|
||||
<!-- TODO DisplayDateStart="{}" -->
|
||||
|
||||
<DatePicker VerticalAlignment="Center"
|
||||
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}}" />
|
||||
</DockPanel>
|
||||
|
||||
@@ -170,6 +172,8 @@
|
||||
|
||||
<DatePicker VerticalAlignment="Center"
|
||||
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}}" />
|
||||
</DockPanel>
|
||||
|
||||
|
||||
@@ -7,11 +7,13 @@ namespace UCalc
|
||||
{
|
||||
public partial class TenantWindow
|
||||
{
|
||||
public Model Model { get; }
|
||||
public TenantProperty Tenant { get; }
|
||||
public HouseProperty House { get; }
|
||||
|
||||
public TenantWindow(TenantProperty tenant, HouseProperty house)
|
||||
public TenantWindow(Model model, TenantProperty tenant, HouseProperty house)
|
||||
{
|
||||
Model = model;
|
||||
Tenant = tenant;
|
||||
House = house;
|
||||
InitializeComponent();
|
||||
|
||||
Reference in New Issue
Block a user