Fix required fields
This commit is contained in:
@ -30,11 +30,11 @@ namespace Elwig.Helpers {
|
|||||||
{ "423", Array.Empty<string[]>() },
|
{ "423", Array.Empty<string[]>() },
|
||||||
};
|
};
|
||||||
|
|
||||||
public static ValidationResult CheckNumeric(TextBox input, bool optional) {
|
public static ValidationResult CheckNumeric(TextBox input, bool required) {
|
||||||
return CheckNumeric(input, optional, -1);
|
return CheckNumeric(input, required, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ValidationResult CheckNumeric(TextBox input, bool optional, int maxLen) {
|
private static ValidationResult CheckNumeric(TextBox input, bool required, int maxLen) {
|
||||||
string text = "";
|
string text = "";
|
||||||
int pos = input.CaretIndex;
|
int pos = input.CaretIndex;
|
||||||
for (int i = 0; i < input.Text.Length; i++) {
|
for (int i = 0; i < input.Text.Length; i++) {
|
||||||
@ -48,8 +48,7 @@ namespace Elwig.Helpers {
|
|||||||
input.CaretIndex = pos;
|
input.CaretIndex = pos;
|
||||||
|
|
||||||
if (text.Length == 0) {
|
if (text.Length == 0) {
|
||||||
if (optional) return new(true, null);
|
return required ? new(false, "Wert ist nicht optional") : new(true, null);
|
||||||
return new(false, "Wert ist nicht optional");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxLen >= 0 && input.Text.Length > maxLen) {
|
if (maxLen >= 0 && input.Text.Length > maxLen) {
|
||||||
@ -60,9 +59,9 @@ namespace Elwig.Helpers {
|
|||||||
return new(true, null);
|
return new(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult CheckPlz(TextBox input, bool optional, AppDbContext ctx) {
|
public static ValidationResult CheckPlz(TextBox input, bool required, AppDbContext ctx) {
|
||||||
CheckNumeric(input, true, 4);
|
CheckNumeric(input, false, 4);
|
||||||
if (optional && input.Text.Length == 0) {
|
if (!required && input.Text.Length == 0) {
|
||||||
return new(true, null);
|
return new(true, null);
|
||||||
} else if (input.Text.Length != 4) {
|
} else if (input.Text.Length != 4) {
|
||||||
return new(false, "PLZ zu kurz");
|
return new(false, "PLZ zu kurz");
|
||||||
@ -74,7 +73,7 @@ namespace Elwig.Helpers {
|
|||||||
return new(true, null);
|
return new(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult CheckPhoneNumber(TextBox input, bool optional) {
|
public static ValidationResult CheckPhoneNumber(TextBox input, bool required) {
|
||||||
string text = "";
|
string text = "";
|
||||||
int pos = input.CaretIndex;
|
int pos = input.CaretIndex;
|
||||||
for (int i = 0, v = 0; i < input.Text.Length && v < 30; i++) {
|
for (int i = 0, v = 0; i < input.Text.Length && v < 30; i++) {
|
||||||
@ -112,15 +111,16 @@ namespace Elwig.Helpers {
|
|||||||
input.Text = text;
|
input.Text = text;
|
||||||
input.CaretIndex = pos;
|
input.CaretIndex = pos;
|
||||||
|
|
||||||
if (optional && text.Length == 0)
|
if (!required && text.Length == 0) {
|
||||||
return new(true, null);
|
return new(true, null);
|
||||||
if (text.Length < 10)
|
} else if (text.Length < 10) {
|
||||||
return new(false, "Telefonnummer zu kurz");
|
return new(false, "Telefonnummer zu kurz");
|
||||||
|
}
|
||||||
|
|
||||||
return new(true, null);
|
return new(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult CheckEmailAddress(TextBox input, bool optional) {
|
public static ValidationResult CheckEmailAddress(TextBox input, bool required) {
|
||||||
string text = "";
|
string text = "";
|
||||||
int pos = input.CaretIndex;
|
int pos = input.CaretIndex;
|
||||||
bool domain = false;
|
bool domain = false;
|
||||||
@ -145,8 +145,7 @@ namespace Elwig.Helpers {
|
|||||||
input.CaretIndex = pos;
|
input.CaretIndex = pos;
|
||||||
|
|
||||||
if (text.Length == 0) {
|
if (text.Length == 0) {
|
||||||
if (optional) return new(true, null);
|
return required ? new(false, "E-Mail_Adresse ist nicht optional") : new(true, null);
|
||||||
return new(false, "E-Mail-Adresse ist nicht optional");
|
|
||||||
} else if (text[0] == '@' || !domain) {
|
} else if (text[0] == '@' || !domain) {
|
||||||
return new(false, "E-Mail-Adresse ungültig");
|
return new(false, "E-Mail-Adresse ungültig");
|
||||||
}
|
}
|
||||||
@ -158,7 +157,7 @@ namespace Elwig.Helpers {
|
|||||||
return new(true, null);
|
return new(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult CheckIban(TextBox input, bool optional) {
|
public static ValidationResult CheckIban(TextBox input, bool required) {
|
||||||
string text = "";
|
string text = "";
|
||||||
int pos = input.CaretIndex;
|
int pos = input.CaretIndex;
|
||||||
int v = 0;
|
int v = 0;
|
||||||
@ -184,7 +183,7 @@ namespace Elwig.Helpers {
|
|||||||
input.Text = text;
|
input.Text = text;
|
||||||
input.CaretIndex = pos;
|
input.CaretIndex = pos;
|
||||||
|
|
||||||
if (optional && text.Length == 0) {
|
if (!required && text.Length == 0) {
|
||||||
return new(true, null);
|
return new(true, null);
|
||||||
} else if (v < 5 || (text.StartsWith("AT") && v != 20) || (text.StartsWith("DE") && v != 22)) {
|
} else if (v < 5 || (text.StartsWith("AT") && v != 20) || (text.StartsWith("DE") && v != 22)) {
|
||||||
return new(false, "IBAN hat falsche Länge");
|
return new(false, "IBAN hat falsche Länge");
|
||||||
@ -199,7 +198,7 @@ namespace Elwig.Helpers {
|
|||||||
return new(true, null);
|
return new(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult CheckBic(TextBox input, bool optional) {
|
public static ValidationResult CheckBic(TextBox input, bool required) {
|
||||||
string text = "";
|
string text = "";
|
||||||
int pos = input.CaretIndex;
|
int pos = input.CaretIndex;
|
||||||
for (int i = 0, v = 0; i < input.Text.Length; i++) {
|
for (int i = 0, v = 0; i < input.Text.Length; i++) {
|
||||||
@ -217,8 +216,7 @@ namespace Elwig.Helpers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (text.Length == 0) {
|
if (text.Length == 0) {
|
||||||
if (optional) return new(true, null);
|
return required ? new(false, "BIC ist nicht optional") : new(true, null);
|
||||||
return new(false, "BIC ist nicht optional");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text.Length > 11) {
|
if (text.Length > 11) {
|
||||||
@ -238,11 +236,11 @@ namespace Elwig.Helpers {
|
|||||||
return new(true, null);
|
return new(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult CheckLfbisNr(TextBox input, bool optional) {
|
public static ValidationResult CheckLfbisNr(TextBox input, bool required) {
|
||||||
var res = CheckNumeric(input, true, 7);
|
var res = CheckNumeric(input, false, 7);
|
||||||
if (!res.IsValid) {
|
if (!res.IsValid) {
|
||||||
return res;
|
return res;
|
||||||
} else if (optional && input.Text.Length == 0) {
|
} else if (!required && input.Text.Length == 0) {
|
||||||
return new(true, null);
|
return new(true, null);
|
||||||
} else if (input.Text.Length != 7) {
|
} else if (input.Text.Length != 7) {
|
||||||
return new(false, "Betriebsnummer zu kurz");
|
return new(false, "Betriebsnummer zu kurz");
|
||||||
@ -253,16 +251,16 @@ namespace Elwig.Helpers {
|
|||||||
return new(true, "Not implemented yet");
|
return new(true, "Not implemented yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult CheckUstId(TextBox input, bool optional) {
|
public static ValidationResult CheckUstId(TextBox input, bool required) {
|
||||||
// TODO
|
// TODO
|
||||||
return new(true, "Not implemented yet");
|
return new(true, "Not implemented yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult CheckMgNr(TextBox input, bool optional, AppDbContext ctx, Member? m) {
|
public static ValidationResult CheckMgNr(TextBox input, bool required, AppDbContext ctx, Member? m) {
|
||||||
var res = CheckNumeric(input, optional);
|
var res = CheckNumeric(input, required);
|
||||||
if (!res.IsValid) {
|
if (!res.IsValid) {
|
||||||
return res;
|
return res;
|
||||||
} else if (optional && input.Text.Length == 0) {
|
} else if (!required && input.Text.Length == 0) {
|
||||||
return new(true, null);
|
return new(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,11 +272,11 @@ namespace Elwig.Helpers {
|
|||||||
return new(true, null);
|
return new(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult CheckPredecessorMgNr(TextBox input, bool optional, AppDbContext ctx) {
|
public static ValidationResult CheckPredecessorMgNr(TextBox input, bool required, AppDbContext ctx) {
|
||||||
var res = CheckNumeric(input, optional);
|
var res = CheckNumeric(input, required);
|
||||||
if (!res.IsValid) {
|
if (!res.IsValid) {
|
||||||
return res;
|
return res;
|
||||||
} else if (optional && input.Text.Length == 0) {
|
} else if (!required && input.Text.Length == 0) {
|
||||||
return new(true, null);
|
return new(true, null);
|
||||||
} else if (!Utils.MgNrExists(ctx, int.Parse(input.Text))) {
|
} else if (!Utils.MgNrExists(ctx, int.Parse(input.Text))) {
|
||||||
return new(false, "Ein Mitglied mit dieser Mitgliedsnummer existiert nicht");
|
return new(false, "Ein Mitglied mit dieser Mitgliedsnummer existiert nicht");
|
||||||
@ -287,12 +285,12 @@ namespace Elwig.Helpers {
|
|||||||
return new(true, null);
|
return new(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult CheckDate(TextBox input, bool optional) {
|
public static ValidationResult CheckDate(TextBox input, bool required) {
|
||||||
// TODO
|
// TODO
|
||||||
return new(true, "Not implemented yet");
|
return new(true, "Not implemented yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult CheckPartialDate(TextBox input, bool optional) {
|
public static ValidationResult CheckPartialDate(TextBox input, bool required) {
|
||||||
// TODO
|
// TODO
|
||||||
return new(true, "Not implemented yet");
|
return new(true, "Not implemented yet");
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ namespace Elwig.Windows {
|
|||||||
private bool IsCreating = false;
|
private bool IsCreating = false;
|
||||||
private List<string> TextFilter = new();
|
private List<string> TextFilter = new();
|
||||||
private readonly Control[] ExemptInputs;
|
private readonly Control[] ExemptInputs;
|
||||||
|
private readonly Control[] RequiredInputs;
|
||||||
private IEnumerable<TextBox> TextBoxInputs = Array.Empty<TextBox>();
|
private IEnumerable<TextBox> TextBoxInputs = Array.Empty<TextBox>();
|
||||||
private IEnumerable<ComboBox> ComboBoxInputs = Array.Empty<ComboBox>();
|
private IEnumerable<ComboBox> ComboBoxInputs = Array.Empty<ComboBox>();
|
||||||
private IEnumerable<CheckBox> CheckBoxInputs = Array.Empty<CheckBox>();
|
private IEnumerable<CheckBox> CheckBoxInputs = Array.Empty<CheckBox>();
|
||||||
@ -36,6 +37,11 @@ namespace Elwig.Windows {
|
|||||||
NewMemberButton, EditMemberButton, DeleteMemberButton,
|
NewMemberButton, EditMemberButton, DeleteMemberButton,
|
||||||
ResetButton, SaveButton, CancelButton
|
ResetButton, SaveButton, CancelButton
|
||||||
};
|
};
|
||||||
|
RequiredInputs = new Control[] {
|
||||||
|
MgNrInput, GivenNameInput, FamilyNameInput,
|
||||||
|
AddressInput, PlzInput,
|
||||||
|
BusinessSharesInput, BranchInput, DefaultKgInput
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs evt) {
|
private void Window_Loaded(object sender, RoutedEventArgs evt) {
|
||||||
@ -55,6 +61,10 @@ namespace Elwig.Windows {
|
|||||||
base.OnClosing(evt);
|
base.OnClosing(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool SenderIsRequired(object sender) {
|
||||||
|
return (sender is Control c) && RequiredInputs.Contains(c);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task RefreshMemberList() {
|
private async Task RefreshMemberList() {
|
||||||
await Context.Members.LoadAsync();
|
await Context.Members.LoadAsync();
|
||||||
await RefreshMemberListQuery();
|
await RefreshMemberListQuery();
|
||||||
@ -127,6 +137,14 @@ namespace Elwig.Windows {
|
|||||||
ActiveInput.IsChecked = true;
|
ActiveInput.IsChecked = true;
|
||||||
ContactPostInput.IsChecked = true;
|
ContactPostInput.IsChecked = true;
|
||||||
FillOriginalValues();
|
FillOriginalValues();
|
||||||
|
foreach (var input in RequiredInputs) {
|
||||||
|
if (input is TextBox tb && tb.Text.Length == 0) {
|
||||||
|
Utils.SetInputInvalid(input);
|
||||||
|
Valid[input] = false;
|
||||||
|
} else if (input is ComboBox cb && cb.SelectedItem == null) {
|
||||||
|
Utils.SetInputInvalid(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MemberList_SelectionChanged(object sender, RoutedEventArgs evt) {
|
private void MemberList_SelectionChanged(object sender, RoutedEventArgs evt) {
|
||||||
@ -178,8 +196,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async void SaveButton_Click(object sender, RoutedEventArgs evt) {
|
private async void SaveButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
Member m = IsEditing ? (Member)MemberList.SelectedItem : Context.CreateProxy<Member>();
|
Member m = await UpdateMember(IsEditing ? (Member)MemberList.SelectedItem : Context.CreateProxy<Member>());
|
||||||
await UpdateMember(m);
|
|
||||||
IsEditing = false;
|
IsEditing = false;
|
||||||
IsCreating = false;
|
IsCreating = false;
|
||||||
MemberList.IsEnabled = true;
|
MemberList.IsEnabled = true;
|
||||||
@ -196,6 +213,7 @@ namespace Elwig.Windows {
|
|||||||
if (IsEditing) {
|
if (IsEditing) {
|
||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
} else if (IsCreating) {
|
} else if (IsCreating) {
|
||||||
|
ClearInputs();
|
||||||
InitInputs();
|
InitInputs();
|
||||||
}
|
}
|
||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
@ -302,7 +320,7 @@ namespace Elwig.Windows {
|
|||||||
ActiveMemberInput.IsEnabled = true;
|
ActiveMemberInput.IsEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UpdateMember(Member m) {
|
private async Task<Member> UpdateMember(Member m) {
|
||||||
int newMgNr = int.Parse(MgNrInput.Text);
|
int newMgNr = int.Parse(MgNrInput.Text);
|
||||||
m.PredecessorMgNr = (PredecessorMgNrInput.Text == "") ? null : int.Parse(PredecessorMgNrInput.Text);
|
m.PredecessorMgNr = (PredecessorMgNrInput.Text == "") ? null : int.Parse(PredecessorMgNrInput.Text);
|
||||||
m.Prefix = (PrefixInput.Text == "") ? null : PrefixInput.Text;
|
m.Prefix = (PrefixInput.Text == "") ? null : PrefixInput.Text;
|
||||||
@ -354,6 +372,8 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
if (newMgNr != m.MgNr) {
|
if (newMgNr != m.MgNr) {
|
||||||
await Context.Database.ExecuteSqlAsync($"UPDATE member SET mgnr = {newMgNr} WHERE mgnr = {m.MgNr}");
|
await Context.Database.ExecuteSqlAsync($"UPDATE member SET mgnr = {newMgNr} WHERE mgnr = {m.MgNr}");
|
||||||
|
await Context.Members.LoadAsync();
|
||||||
|
m = await Context.Members.FindAsync(newMgNr);
|
||||||
}
|
}
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
if (tr != null) await tr.ReloadAsync();
|
if (tr != null) await tr.ReloadAsync();
|
||||||
@ -361,6 +381,8 @@ namespace Elwig.Windows {
|
|||||||
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
||||||
MessageBox.Show(str, "Mitglied aktualisieren", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show(str, "Mitglied aktualisieren", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillInputs(Member m) {
|
private void FillInputs(Member m) {
|
||||||
@ -502,7 +524,7 @@ namespace Elwig.Windows {
|
|||||||
RadioButtonInputs.Any(InputHasChanged);
|
RadioButtonInputs.Any(InputHasChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdatePlz(TextBox plzInput, ComboBox ortInput, bool optional) {
|
private void UpdatePlz(TextBox plzInput, ComboBox ortInput, bool required) {
|
||||||
if (plzInput.Text.Length == 4) {
|
if (plzInput.Text.Length == 4) {
|
||||||
int plz = int.Parse(plzInput.Text);
|
int plz = int.Parse(plzInput.Text);
|
||||||
ortInput.ItemsSource = Context.Postleitzahlen.Where(p => p.Plz == plz).ToHashSet();
|
ortInput.ItemsSource = Context.Postleitzahlen.Where(p => p.Plz == plz).ToHashSet();
|
||||||
@ -515,20 +537,20 @@ namespace Elwig.Windows {
|
|||||||
} else {
|
} else {
|
||||||
Utils.ClearInputState(ortInput);
|
Utils.ClearInputState(ortInput);
|
||||||
}
|
}
|
||||||
Valid[plzInput] = optional || (ortInput.ItemsSource != null);
|
Valid[plzInput] = !required || (ortInput.ItemsSource != null);
|
||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InputTextChanged(TextBox input, bool optional, Func<TextBox, bool, ValidationResult> checker) {
|
private void InputTextChanged(TextBox input, bool required, Func<TextBox, bool, ValidationResult> checker) {
|
||||||
InputTextChanged(input, optional, (tb, opt, ctx) => checker(tb, opt));
|
InputTextChanged(input, required, (tb, opt, ctx) => checker(tb, opt));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InputTextChanged(TextBox input, bool optional, Func<TextBox, bool, AppDbContext, ValidationResult> checker) {
|
private void InputTextChanged(TextBox input, bool required, Func<TextBox, bool, AppDbContext, ValidationResult> checker) {
|
||||||
InputTextChanged(input, optional, (tb, opt, ctx, m) => checker(tb, opt, ctx));
|
InputTextChanged(input, required, (tb, opt, ctx, m) => checker(tb, opt, ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InputTextChanged(TextBox input, bool optional, Func<TextBox, bool, AppDbContext, Member, ValidationResult> checker) {
|
private void InputTextChanged(TextBox input, bool required, Func<TextBox, bool, AppDbContext, Member, ValidationResult> checker) {
|
||||||
var res = checker(input, optional, Context, (Member)MemberList.SelectedItem);
|
var res = checker(input, required, Context, (Member)MemberList.SelectedItem);
|
||||||
Valid[input] = res.IsValid;
|
Valid[input] = res.IsValid;
|
||||||
if (res.IsValid) {
|
if (res.IsValid) {
|
||||||
if (InputHasChanged(input)) {
|
if (InputHasChanged(input)) {
|
||||||
@ -542,16 +564,16 @@ namespace Elwig.Windows {
|
|||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InputLostFocus(TextBox input, bool optional, Func<TextBox, bool, ValidationResult> checker, string? msg = null) {
|
private void InputLostFocus(TextBox input, bool required, Func<TextBox, bool, ValidationResult> checker, string? msg = null) {
|
||||||
InputLostFocus(input, optional, (tb, optional, ctx) => checker(tb, optional), msg);
|
InputLostFocus(input, required, (tb, required, ctx) => checker(tb, required), msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InputLostFocus(TextBox input, bool optional, Func<TextBox, bool, AppDbContext, ValidationResult> checker, string? msg = null) {
|
private void InputLostFocus(TextBox input, bool required, Func<TextBox, bool, AppDbContext, ValidationResult> checker, string? msg = null) {
|
||||||
InputLostFocus(input, optional, (tb, optional, ctx, m) => checker(tb, optional, ctx), msg);
|
InputLostFocus(input, required, (tb, required, ctx, m) => checker(tb, required, ctx), msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InputLostFocus(TextBox input, bool optional, Func<TextBox, bool, AppDbContext, Member?, ValidationResult> checker, string? msg = null) {
|
private void InputLostFocus(TextBox input, bool required, Func<TextBox, bool, AppDbContext, Member?, ValidationResult> checker, string? msg = null) {
|
||||||
var res = checker(input, optional, Context, (Member)MemberList.SelectedItem);
|
var res = checker(input, required, Context, (Member)MemberList.SelectedItem);
|
||||||
if (!res.IsValid)
|
if (!res.IsValid)
|
||||||
MessageBox.Show(res.ErrorContent.ToString(), msg ?? res.ErrorContent.ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
|
MessageBox.Show(res.ErrorContent.ToString(), msg ?? res.ErrorContent.ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
}
|
}
|
||||||
@ -578,11 +600,17 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private void TextBox_TextChanged(object sender, RoutedEventArgs evt) {
|
private void TextBox_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
var input = (TextBox)sender;
|
var input = (TextBox)sender;
|
||||||
|
if (SenderIsRequired(input) && input.Text.Length == 0) {
|
||||||
|
Valid[input] = false;
|
||||||
|
Utils.SetInputInvalid(input);
|
||||||
|
} else {
|
||||||
|
Valid[input] = true;
|
||||||
if (InputHasChanged(input)) {
|
if (InputHasChanged(input)) {
|
||||||
Utils.SetInputChanged(input);
|
Utils.SetInputChanged(input);
|
||||||
} else {
|
} else {
|
||||||
Utils.ClearInputState(input);
|
Utils.ClearInputState(input);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -599,99 +627,99 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void NumericInput_TextChanged(object sender, RoutedEventArgs evt) {
|
private void NumericInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
InputTextChanged((TextBox)sender, false, Validator.CheckNumeric);
|
InputTextChanged((TextBox)sender, SenderIsRequired(sender), Validator.CheckNumeric);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MgNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
private void MgNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
InputTextChanged((TextBox)sender, false, Validator.CheckMgNr);
|
InputTextChanged((TextBox)sender, SenderIsRequired(sender), Validator.CheckMgNr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MgNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
private void MgNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||||
InputLostFocus((TextBox)sender, false, Validator.CheckMgNr);
|
InputLostFocus((TextBox)sender, SenderIsRequired(sender), Validator.CheckMgNr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PredecessorMgNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
private void PredecessorMgNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
InputTextChanged((TextBox)sender, true, Validator.CheckPredecessorMgNr);
|
InputTextChanged((TextBox)sender, SenderIsRequired(sender), Validator.CheckPredecessorMgNr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PredecessorMgNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
private void PredecessorMgNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||||
InputLostFocus((TextBox)sender, true, Validator.CheckPredecessorMgNr);
|
InputLostFocus((TextBox)sender, SenderIsRequired(sender), Validator.CheckPredecessorMgNr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BirthdayInput_TextChanged(object sender, RoutedEventArgs evt) {
|
private void BirthdayInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
InputTextChanged((TextBox)sender, true, Validator.CheckPartialDate);
|
InputTextChanged((TextBox)sender, SenderIsRequired(sender), Validator.CheckPartialDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PlzInput_TextChanged(object sender, RoutedEventArgs evt) {
|
private void PlzInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
InputTextChanged((TextBox)sender, false, Validator.CheckPlz);
|
InputTextChanged((TextBox)sender, SenderIsRequired(sender), Validator.CheckPlz);
|
||||||
UpdatePlz((TextBox)sender, OrtInput, false);
|
UpdatePlz((TextBox)sender, OrtInput, SenderIsRequired(sender));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PlzInput_LostFocus(object sender, RoutedEventArgs evt) {
|
private void PlzInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||||
InputLostFocus((TextBox)sender, true, Validator.CheckPlz);
|
InputLostFocus((TextBox)sender, SenderIsRequired(sender), Validator.CheckPlz);
|
||||||
UpdatePlz((TextBox)sender, OrtInput, false);
|
UpdatePlz((TextBox)sender, OrtInput, SenderIsRequired(sender));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PhoneNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
private void PhoneNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
InputTextChanged((TextBox)sender, true, Validator.CheckPhoneNumber);
|
InputTextChanged((TextBox)sender, SenderIsRequired(sender), Validator.CheckPhoneNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PhoneNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
private void PhoneNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||||
InputLostFocus((TextBox)sender, true, Validator.CheckPhoneNumber);
|
InputLostFocus((TextBox)sender, SenderIsRequired(sender), Validator.CheckPhoneNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EmailInput_TextChanged(object sender, RoutedEventArgs evt) {
|
private void EmailInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
InputTextChanged((TextBox)sender, true, Validator.CheckEmailAddress);
|
InputTextChanged((TextBox)sender, SenderIsRequired(sender), Validator.CheckEmailAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EmailInput_LostFocus(object sender, RoutedEventArgs evt) {
|
private void EmailInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||||
InputLostFocus((TextBox)sender, true, Validator.CheckEmailAddress);
|
InputLostFocus((TextBox)sender, SenderIsRequired(sender), Validator.CheckEmailAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void IbanInput_TextChanged(object sender, RoutedEventArgs evt) {
|
private void IbanInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
InputTextChanged((TextBox)sender, true, Validator.CheckIban);
|
InputTextChanged((TextBox)sender, SenderIsRequired(sender), Validator.CheckIban);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void IbanInput_LostFocus(object sender, RoutedEventArgs evt) {
|
private void IbanInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||||
InputLostFocus((TextBox)sender, true, Validator.CheckIban);
|
InputLostFocus((TextBox)sender, SenderIsRequired(sender), Validator.CheckIban);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BicInput_TextChanged(object sender, RoutedEventArgs evt) {
|
private void BicInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
InputTextChanged((TextBox)sender, true, Validator.CheckBic);
|
InputTextChanged((TextBox)sender, SenderIsRequired(sender), Validator.CheckBic);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BicInput_LostFocus(object sender, RoutedEventArgs evt) {
|
private void BicInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||||
InputLostFocus((TextBox)sender, true, Validator.CheckBic);
|
InputLostFocus((TextBox)sender, SenderIsRequired(sender), Validator.CheckBic);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UstIdInput_TextChanged(object sender, RoutedEventArgs evt) {
|
private void UstIdInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
InputTextChanged((TextBox)sender, true, Validator.CheckUstId);
|
InputTextChanged((TextBox)sender, SenderIsRequired(sender), Validator.CheckUstId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UstIdInput_LostFocus(object sender, RoutedEventArgs evt) {
|
private void UstIdInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||||
InputLostFocus((TextBox)sender, true, Validator.CheckUstId);
|
InputLostFocus((TextBox)sender, SenderIsRequired(sender), Validator.CheckUstId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LfbisNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
private void LfbisNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
InputTextChanged((TextBox)sender, true, Validator.CheckLfbisNr);
|
InputTextChanged((TextBox)sender, SenderIsRequired(sender), Validator.CheckLfbisNr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LfbisNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
private void LfbisNrInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||||
InputLostFocus((TextBox)sender, true, Validator.CheckLfbisNr);
|
InputLostFocus((TextBox)sender, SenderIsRequired(sender), Validator.CheckLfbisNr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BillingPlzInput_TextChanged(object sender, RoutedEventArgs evt) {
|
private void BillingPlzInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
InputTextChanged((TextBox)sender, true, Validator.CheckPlz);
|
InputTextChanged((TextBox)sender, SenderIsRequired(sender), Validator.CheckPlz);
|
||||||
UpdatePlz((TextBox)sender, BillingOrtInput, true);
|
UpdatePlz((TextBox)sender, BillingOrtInput, SenderIsRequired(sender));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BillingPlzInput_LostFocus(object sender, RoutedEventArgs evt) {
|
private void BillingPlzInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||||
InputLostFocus((TextBox)sender, true, Validator.CheckPlz);
|
InputLostFocus((TextBox)sender, SenderIsRequired(sender), Validator.CheckPlz);
|
||||||
UpdatePlz((TextBox)sender, BillingOrtInput, true);
|
UpdatePlz((TextBox)sender, BillingOrtInput, SenderIsRequired(sender));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DateInput_TextChanged(object sender, RoutedEventArgs evt) {
|
private void DateInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||||
InputTextChanged((TextBox)sender, true, Validator.CheckDate);
|
InputTextChanged((TextBox)sender, SenderIsRequired(sender), Validator.CheckDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user