From 652644bcb073fe8d24353918540a4e116f3d1da3 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Fri, 9 Dec 2022 07:51:36 +0100 Subject: [PATCH] Abfangen und null setzen falls falsche Tastatureingabe (Datum, Datetime) --- ENI2/Controls/EditWindowBase.cs | 4 ++-- ENI2/DetailBaseControl.cs | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ENI2/Controls/EditWindowBase.cs b/ENI2/Controls/EditWindowBase.cs index 4512d3c1..29790786 100644 --- a/ENI2/Controls/EditWindowBase.cs +++ b/ENI2/Controls/EditWindowBase.cs @@ -109,7 +109,7 @@ namespace ENI2.Controls thePicker.Value = new DateTime(year, month, day, hour, minute, 0); } 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); } catch (FormatException) { } - catch (ArgumentOutOfRangeException) { thePicker.SelectedDate = DateTime.Now; } + catch (ArgumentOutOfRangeException) { thePicker.SelectedDate = null; } } } diff --git a/ENI2/DetailBaseControl.cs b/ENI2/DetailBaseControl.cs index 70ecc986..1414ff28 100644 --- a/ENI2/DetailBaseControl.cs +++ b/ENI2/DetailBaseControl.cs @@ -298,7 +298,9 @@ namespace ENI2 int year = Int32.Parse(timevalText.Substring(4, 4)); thePicker.SelectedDate = new DateTime(year, month, day, 0, 0, 0); } - catch (FormatException) { } + catch (Exception) { + thePicker.SelectedDate = null; + } } }