Abfangen und null setzen falls falsche Tastatureingabe (Datum, Datetime)

This commit is contained in:
Daniel Schick 2022-12-09 07:51:36 +01:00
parent 32ede83fd2
commit 652644bcb0
2 changed files with 5 additions and 3 deletions

View File

@ -109,7 +109,7 @@ namespace ENI2.Controls
thePicker.Value = new DateTime(year, month, day, hour, minute, 0); thePicker.Value = new DateTime(year, month, day, hour, minute, 0);
} }
catch (FormatException) { } catch (FormatException) { }
catch (ArgumentOutOfRangeException) { thePicker.Value = DateTime.Now; } catch (ArgumentOutOfRangeException) { thePicker.Value = null; }
} }
} }
@ -126,7 +126,7 @@ namespace ENI2.Controls
thePicker.SelectedDate = new DateTime(year, month, day, 0, 0, 0); thePicker.SelectedDate = new DateTime(year, month, day, 0, 0, 0);
} }
catch (FormatException) { } catch (FormatException) { }
catch (ArgumentOutOfRangeException) { thePicker.SelectedDate = DateTime.Now; } catch (ArgumentOutOfRangeException) { thePicker.SelectedDate = null; }
} }
} }

View File

@ -298,7 +298,9 @@ namespace ENI2
int year = Int32.Parse(timevalText.Substring(4, 4)); int year = Int32.Parse(timevalText.Substring(4, 4));
thePicker.SelectedDate = new DateTime(year, month, day, 0, 0, 0); thePicker.SelectedDate = new DateTime(year, month, day, 0, 0, 0);
} }
catch (FormatException) { } catch (Exception) {
thePicker.SelectedDate = null;
}
} }
} }