Add age to member admin window
This commit is contained in:
@ -173,5 +173,12 @@ namespace Elwig.Helpers {
|
|||||||
public static long DecToDb(decimal value, byte precision) {
|
public static long DecToDb(decimal value, byte precision) {
|
||||||
return (long)decimal.Round(value * (decimal)Math.Pow(10, precision), 0);
|
return (long)decimal.Round(value * (decimal)Math.Pow(10, precision), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int GetAge(DateOnly birthday) {
|
||||||
|
var today = DateTime.Today;
|
||||||
|
var a = (today.Year * 100 + today.Month) * 100 + today.Day;
|
||||||
|
var b = (birthday.Year * 100 + birthday.Month) * 100 + birthday.Day;
|
||||||
|
return (a - b) / 10000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,6 +142,9 @@
|
|||||||
<TextBox x:Name="BirthdayInput" Margin="0,100,0,0" Grid.Column="1" Width="78" TextAlignment="Right" HorizontalAlignment="Left"
|
<TextBox x:Name="BirthdayInput" Margin="0,100,0,0" Grid.Column="1" Width="78" TextAlignment="Right" HorizontalAlignment="Left"
|
||||||
TextChanged="PartialDateInput_TextChanged" LostFocus="PartialDateInput_LostFocus"/>
|
TextChanged="PartialDateInput_TextChanged" LostFocus="PartialDateInput_LostFocus"/>
|
||||||
|
|
||||||
|
<Label Content="Alter:" Margin="85,100,0,0" Grid.Column="1"/>
|
||||||
|
<TextBlock x:Name="Age" Text="-" Margin="119,104,0,0" Grid.Column="1" TextWrapping="NoWrap" VerticalAlignment="Top"/>
|
||||||
|
|
||||||
<Label Content="Adresse:" Margin="10,130,0,0"/>
|
<Label Content="Adresse:" Margin="10,130,0,0"/>
|
||||||
<TextBox x:Name="AddressInput" Margin="0,130,10,0" Grid.Column="1" Grid.ColumnSpan="3"
|
<TextBox x:Name="AddressInput" Margin="0,130,10,0" Grid.Column="1" Grid.ColumnSpan="3"
|
||||||
TextChanged="TextBox_TextChanged"/>
|
TextChanged="TextBox_TextChanged"/>
|
||||||
|
@ -347,6 +347,13 @@ namespace Elwig.Windows {
|
|||||||
FamilyNameInput.Text = m.FamilyName;
|
FamilyNameInput.Text = m.FamilyName;
|
||||||
SuffixInput.Text = m.Suffix;
|
SuffixInput.Text = m.Suffix;
|
||||||
BirthdayInput.Text = (m.Birthday != null) ? string.Join(".", m.Birthday.Split("-").Reverse()) : null;
|
BirthdayInput.Text = (m.Birthday != null) ? string.Join(".", m.Birthday.Split("-").Reverse()) : null;
|
||||||
|
if (m.Birthday?.Length == 10) {
|
||||||
|
Age.Text = Utils.GetAge(DateOnly.ParseExact(m.Birthday, "yyyy-MM-dd")).ToString();
|
||||||
|
} else if (m.Birthday != null) {
|
||||||
|
Age.Text = "ca. " + (DateTime.Now.Year - int.Parse(m.Birthday[^4..])).ToString();
|
||||||
|
} else {
|
||||||
|
Age.Text = "-";
|
||||||
|
}
|
||||||
AddressInput.Text = m.Address;
|
AddressInput.Text = m.Address;
|
||||||
AT_PlzDest? p = m.PostalDest.AtPlz;
|
AT_PlzDest? p = m.PostalDest.AtPlz;
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
@ -412,6 +419,7 @@ namespace Elwig.Windows {
|
|||||||
new protected void ClearInputs() {
|
new protected void ClearInputs() {
|
||||||
Menu_Member_SendEmail.IsEnabled = false;
|
Menu_Member_SendEmail.IsEnabled = false;
|
||||||
AreaCommitment.Text = "- m²";
|
AreaCommitment.Text = "- m²";
|
||||||
|
Age.Text = "-";
|
||||||
base.ClearInputs();
|
base.ClearInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user