DeliveryAdminWindow: Allow date and time to be edited

This commit is contained in:
2023-09-29 14:46:28 +02:00
parent 532bb826e1
commit 47d51ded51
4 changed files with 90 additions and 16 deletions

View File

@ -521,6 +521,36 @@ namespace Elwig.Helpers {
return new(true, null);
}
public static ValidationResult CheckTime(TextBox input, bool required) {
string text = "";
int pos = input.CaretIndex;
int v = 0;
for (int i = 0; i < input.Text.Length; i++) {
char ch = input.Text[i];
if (v >= 0 && v < 5 && v != 2 && char.IsAsciiDigit(ch)) {
if ((v == 0 && ch <= '2') || (v == 1 && (text[0] < '2' || ch <= '3')) || (v == 3 && ch <= '5') || v == 4) {
text += ch;
v++;
}
} else if (v == 2 && ch == ':') {
text += ch;
v++;
}
if (i == input.CaretIndex - 1)
pos = text.Length;
}
input.Text = text;
input.CaretIndex = pos;
if (text.Length == 0) {
return required ? new(false, "Wert ist nicht optional") : new(true, null);
} else if (v != 5) {
return new(false, "Zeit ist ungültig");
} else {
return new(true, null);
}
}
public static ValidationResult CheckFbNr(TextBox input, bool required, AppDbContext ctx, AreaCom? c) {
var res = CheckInteger(input, required);
if (!res.IsValid) {