Check MgNr and PredecessorMgNr
This commit is contained in:
@ -112,7 +112,7 @@ namespace WGneu.Windows {
|
||||
MgNrInput.Text = NextMgNr().ToString();
|
||||
}
|
||||
|
||||
private void MemberList_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
|
||||
private void MemberList_SelectionChanged(object sender, RoutedEventArgs evt) {
|
||||
RefreshInputs();
|
||||
}
|
||||
|
||||
@ -165,6 +165,8 @@ namespace WGneu.Windows {
|
||||
m = new();
|
||||
|
||||
int newMgNr = int.Parse(MgNrInput.Text);
|
||||
m.PredecessorMgNr = (PredecessorMgNrInput.Text == "") ? null : int.Parse(PredecessorMgNrInput.Text);
|
||||
m.Predecessor = Context.Members.Find(m.PredecessorMgNr);
|
||||
m.Prefix = (PrefixInput.Text == "") ? null : PrefixInput.Text;
|
||||
m.GivenName = GivenNameInput.Text;
|
||||
m.FamilyName = FamilyNameInput.Text;
|
||||
@ -257,7 +259,7 @@ namespace WGneu.Windows {
|
||||
RefreshMemberList();
|
||||
}
|
||||
|
||||
private void Menu_Member_SendEmail_Click(object sender, EventArgs evt) {
|
||||
private void Menu_Member_SendEmail_Click(object sender, RoutedEventArgs evt) {
|
||||
Utils.MailTo(((Member)MemberList.SelectedItem).Email);
|
||||
}
|
||||
|
||||
@ -467,7 +469,15 @@ namespace WGneu.Windows {
|
||||
}
|
||||
|
||||
private void InputTextChanged(TextBox input, bool optional, Func<TextBox, bool, ValidationResult> checker) {
|
||||
var res = checker(input, optional);
|
||||
InputTextChanged(input, optional, (tb, opt, ctx) => checker(tb, opt));
|
||||
}
|
||||
|
||||
private void InputTextChanged(TextBox input, bool optional, Func<TextBox, bool, AppDbContext, ValidationResult> checker) {
|
||||
InputTextChanged(input, optional, (tb, opt, ctx, m) => checker(tb, opt, ctx));
|
||||
}
|
||||
|
||||
private void InputTextChanged(TextBox input, bool optional, Func<TextBox, bool, AppDbContext, Member, ValidationResult> checker) {
|
||||
var res = checker(input, optional, Context, (Member)MemberList.SelectedItem);
|
||||
Valid[input] = res.IsValid;
|
||||
if (res.IsValid) {
|
||||
if (InputHasChanged(input)) {
|
||||
@ -481,8 +491,16 @@ namespace WGneu.Windows {
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private void InputLostFocus(TextBox input, bool optional, Func<TextBox, bool, ValidationResult> checker, string? msg) {
|
||||
var res = checker(input, optional);
|
||||
private void InputLostFocus(TextBox input, bool optional, Func<TextBox, bool, ValidationResult> checker, string? msg = null) {
|
||||
InputLostFocus(input, optional, (tb, optional, ctx) => checker(tb, optional), msg);
|
||||
}
|
||||
|
||||
private void InputLostFocus(TextBox input, bool optional, Func<TextBox, bool, AppDbContext, ValidationResult> checker, string? msg = null) {
|
||||
InputLostFocus(input, optional, (tb, optional, ctx, m) => checker(tb, optional, ctx), msg);
|
||||
}
|
||||
|
||||
private void InputLostFocus(TextBox input, bool optional, Func<TextBox, bool, AppDbContext, Member, ValidationResult> checker, string? msg = null) {
|
||||
var res = checker(input, optional, Context, (Member)MemberList.SelectedItem);
|
||||
if (!res.IsValid)
|
||||
MessageBox.Show(res.ErrorContent.ToString(), msg ?? res.ErrorContent.ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
@ -528,13 +546,29 @@ namespace WGneu.Windows {
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
private void MgNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, false, Validator.CheckMgNr);
|
||||
}
|
||||
|
||||
private void MgNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, false, Validator.CheckMgNr);
|
||||
}
|
||||
|
||||
private void PredecessorMgNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckPredecessorMgNr);
|
||||
}
|
||||
|
||||
private void PredecessorMgNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckPredecessorMgNr);
|
||||
}
|
||||
|
||||
private void PlzInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, false, Validator.CheckPlz);
|
||||
UpdatePlz((TextBox)sender, OrtInput);
|
||||
}
|
||||
|
||||
private void PlzInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckPlz, null);
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckPlz);
|
||||
UpdatePlz((TextBox)sender, OrtInput);
|
||||
}
|
||||
|
||||
@ -543,7 +577,7 @@ namespace WGneu.Windows {
|
||||
}
|
||||
|
||||
private void PhoneNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckPhoneNumber, null);
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckPhoneNumber);
|
||||
}
|
||||
|
||||
private void EmailInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
@ -551,7 +585,7 @@ namespace WGneu.Windows {
|
||||
}
|
||||
|
||||
private void EmailInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckEmailAddress, null);
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckEmailAddress);
|
||||
}
|
||||
|
||||
private void IbanInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
@ -559,7 +593,7 @@ namespace WGneu.Windows {
|
||||
}
|
||||
|
||||
private void IbanInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckIban, null);
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckIban);
|
||||
}
|
||||
|
||||
private void BicInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
@ -567,7 +601,15 @@ namespace WGneu.Windows {
|
||||
}
|
||||
|
||||
private void BicInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckBic, null);
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckBic);
|
||||
}
|
||||
|
||||
private void UstIdInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, true, Validator.CheckUstId);
|
||||
}
|
||||
|
||||
private void UstIdInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckUstId);
|
||||
}
|
||||
|
||||
private void LfbisNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
@ -575,7 +617,7 @@ namespace WGneu.Windows {
|
||||
}
|
||||
|
||||
private void LfbisNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckLfbisNr, "Betriebsnummer ungültig");
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckLfbisNr);
|
||||
}
|
||||
|
||||
private void BillingPlzInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
@ -584,7 +626,7 @@ namespace WGneu.Windows {
|
||||
}
|
||||
|
||||
private void BillingPlzInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckPlz, null);
|
||||
InputLostFocus((TextBox)sender, true, Validator.CheckPlz);
|
||||
UpdatePlz((TextBox)sender, BillingOrtInput);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user