Add Bic and Plz validation
This commit is contained in:
@ -101,15 +101,6 @@ namespace WGneu.Windows {
|
||||
RefreshInputs();
|
||||
}
|
||||
|
||||
private void PlzInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||
if (PlzInput.Text.Length == 4 && PlzInput.Text.All(char.IsDigit)) {
|
||||
int plz = int.Parse(PlzInput.Text);
|
||||
var o = Context.Postleitzahlen.Where(p => p.Plz == plz).ToHashSet();
|
||||
OrtInput.ItemsSource = o;
|
||||
OrtInput.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void NewMemberButton_Click(object sender, RoutedEventArgs e) {
|
||||
IsCreating = true;
|
||||
MemberList.IsEnabled = false;
|
||||
@ -385,6 +376,18 @@ namespace WGneu.Windows {
|
||||
return true; // TODO
|
||||
}
|
||||
|
||||
private void UpdatePlz(TextBox plzInput, ComboBox ortInput) {
|
||||
if (plzInput.Text.Length == 4) {
|
||||
int plz = int.Parse(plzInput.Text);
|
||||
ortInput.ItemsSource = Context.Postleitzahlen.Where(p => p.Plz == plz).ToHashSet();
|
||||
} else {
|
||||
ortInput.ItemsSource = null;
|
||||
}
|
||||
ortInput.SelectedItem = null;
|
||||
Valid[plzInput] = (ortInput.ItemsSource != null);
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private void InputTextChanged(TextBox input, bool optional, Func<TextBox, bool, ValidationResult> checker) {
|
||||
var res = checker(input, optional);
|
||||
Valid[input] = res.IsValid;
|
||||
@ -405,6 +408,16 @@ namespace WGneu.Windows {
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private void PlzInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||
InputTextChanged((TextBox)sender, false, Validator.CheckPlz);
|
||||
UpdatePlz((TextBox)sender, OrtInput);
|
||||
}
|
||||
|
||||
private void PlzInput_LostFocus(object sender, RoutedEventArgs e) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckPlz, null);
|
||||
UpdatePlz((TextBox)sender, OrtInput);
|
||||
}
|
||||
|
||||
private void PhoneNrInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckPhoneNumber);
|
||||
}
|
||||
@ -429,6 +442,14 @@ namespace WGneu.Windows {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckIban, null);
|
||||
}
|
||||
|
||||
private void BicInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckBic);
|
||||
}
|
||||
|
||||
private void BicInput_LostFocus(object sender, RoutedEventArgs e) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckBic, null);
|
||||
}
|
||||
|
||||
private void LfbisNrInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckLfbisNr);
|
||||
}
|
||||
@ -436,5 +457,15 @@ namespace WGneu.Windows {
|
||||
private void LfbisNrInput_LostFocus(object sender, RoutedEventArgs e) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckLfbisNr, "Betriebsnummer ungültig");
|
||||
}
|
||||
|
||||
private void BillingPlzInput_TextChanged(object sender, RoutedEventArgs e) {
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckPlz);
|
||||
UpdatePlz((TextBox)sender, BillingOrtInput);
|
||||
}
|
||||
|
||||
private void BillingPlzInput_LostFocus(object sender, RoutedEventArgs e) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckPlz, null);
|
||||
UpdatePlz((TextBox)sender, BillingOrtInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user