diff --git a/src/BreCalClient/EditShipcallControl.xaml.cs b/src/BreCalClient/EditShipcallControl.xaml.cs index 322b534..65ae975 100644 --- a/src/BreCalClient/EditShipcallControl.xaml.cs +++ b/src/BreCalClient/EditShipcallControl.xaml.cs @@ -205,15 +205,23 @@ namespace BreCalClient case ShipcallType.Departure: isEnabled &= this.comboBoxDepartureBerth.SelectedItem != null; isEnabled &= this.datePickerETD.Value.HasValue; + if(this.datePickerETD.Value.HasValue) + isEnabled &= (this.datePickerETD.Value.Value > DateTime.Now); break; case ShipcallType.Arrival: isEnabled &= this.comboBoxArrivalBerth.SelectedItem != null; isEnabled &= this.datePickerETA.Value.HasValue; + if(this.datePickerETA.Value.HasValue) + isEnabled &= (this.datePickerETA.Value.Value > DateTime.Now); break; case ShipcallType.Shifting: isEnabled &= ((this.comboBoxDepartureBerth.SelectedItem != null) && (this.comboBoxArrivalBerth.SelectedItem != null)); isEnabled &= this.datePickerETD.Value.HasValue; isEnabled &= this.datePickerETA.Value.HasValue; + if (this.datePickerETD.Value.HasValue) + isEnabled &= (this.datePickerETD.Value.Value > DateTime.Now); + if (this.datePickerETA.Value.HasValue) + isEnabled &= (this.datePickerETA.Value.Value > DateTime.Now); break; } } diff --git a/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs b/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs index 8a38a07..e7c2bb7 100644 --- a/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs +++ b/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs @@ -4,6 +4,7 @@ using BreCalClient.misc.Model; using System; +using System.Runtime.Serialization; using System.Windows; using static BreCalClient.Extensions; @@ -70,9 +71,16 @@ namespace BreCalClient private void buttonOK_Click(object sender, RoutedEventArgs e) { - this.CopyToModel(); - this.DialogResult = true; - this.Close(); + if (!CheckValues(out string message)) + { + MessageBox.Show(message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); + } + else + { + this.CopyToModel(); + this.DialogResult = true; + this.Close(); + } } private void buttonCancel_Click(object sender, RoutedEventArgs e) @@ -85,6 +93,49 @@ namespace BreCalClient #region private methods + private bool CheckValues(out string message) + { + message = ""; + + if (this.datePickerETA.Value.HasValue && (this.datePickerETA.Value.Value < DateTime.Now) && (this.datePickerETA_End.Value == null)) + { + message = BreCalClient.Resources.Resources.textETAInThePast; + return false; + } + + if(this.datePickerETA_End.Value.HasValue && this.datePickerETA_End.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textETDInThePast; + return false; + } + + if(this.datePickerETA.Value.HasValue && this.datePickerETA_End.Value.HasValue && this.datePickerETA.Value > this.datePickerETA_End.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + if (this.datePickerTidalWindowFrom.Value.HasValue && (this.datePickerTidalWindowFrom.Value.Value < DateTime.Now) && (this.datePickerTidalWindowTo.Value == null)) + { + message = BreCalClient.Resources.Resources.textTideTimesInThePast; + return false; + } + + if (this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowTo.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textTideTimesInThePast; + return false; + } + + if (this.datePickerTidalWindowFrom.Value.HasValue && this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowFrom.Value > this.datePickerTidalWindowTo.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + return true; + } + private void CopyToModel() { if (this.ShipcallModel.Shipcall != null) diff --git a/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs b/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs index 0a778fd..17dc94b 100644 --- a/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs +++ b/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs @@ -80,9 +80,16 @@ namespace BreCalClient private void buttonOK_Click(object sender, RoutedEventArgs e) { - this.CopyToModel(); - this.DialogResult = true; - this.Close(); + if (!CheckValues(out string message)) + { + System.Windows.MessageBox.Show(message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); + } + else + { + this.CopyToModel(); + this.DialogResult = true; + this.Close(); + } } private void buttonCancel_Click(object sender, RoutedEventArgs e) @@ -95,6 +102,50 @@ namespace BreCalClient #region private methods + + private bool CheckValues(out string message) + { + message = ""; + + if (this.datePickerETD.Value.HasValue && (this.datePickerETD.Value.Value < DateTime.Now) && (this.datePickerETD_End.Value == null)) + { + message = BreCalClient.Resources.Resources.textETAInThePast; + return false; + } + + if (this.datePickerETD_End.Value.HasValue && this.datePickerETD_End.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textETDInThePast; + return false; + } + + if (this.datePickerETD.Value.HasValue && this.datePickerETD_End.Value.HasValue && this.datePickerETD.Value > this.datePickerETD_End.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + if (this.datePickerTidalWindowFrom.Value.HasValue && (this.datePickerTidalWindowFrom.Value.Value < DateTime.Now) && (this.datePickerTidalWindowTo.Value == null)) + { + message = BreCalClient.Resources.Resources.textTideTimesInThePast; + return false; + } + + if (this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowTo.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textTideTimesInThePast; + return false; + } + + if (this.datePickerTidalWindowFrom.Value.HasValue && this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowFrom.Value > this.datePickerTidalWindowTo.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + return true; + } + private void CopyToModel() { if (this.ShipcallModel.Shipcall != null) diff --git a/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs b/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs index 5fa79ad..f0cf0e9 100644 --- a/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs +++ b/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs @@ -71,9 +71,16 @@ namespace BreCalClient private void buttonOK_Click(object sender, RoutedEventArgs e) { - this.CopyToModel(); - this.DialogResult = true; - this.Close(); + if (!CheckValues(out string message)) + { + System.Windows.MessageBox.Show(message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); + } + else + { + this.CopyToModel(); + this.DialogResult = true; + this.Close(); + } } private void buttonCancel_Click(object sender, RoutedEventArgs e) @@ -86,6 +93,67 @@ namespace BreCalClient #region private methods + private bool CheckValues(out string message) + { + message = ""; + + if (this.datePickerETA.Value.HasValue && (this.datePickerETA.Value.Value < DateTime.Now) && (this.datePickerETA_End.Value == null)) + { + message = BreCalClient.Resources.Resources.textETAInThePast; + return false; + } + + if (this.datePickerETA_End.Value.HasValue && this.datePickerETA_End.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textETDInThePast; + return false; + } + + if (this.datePickerETA.Value.HasValue && this.datePickerETA_End.Value.HasValue && this.datePickerETA.Value > this.datePickerETA_End.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + if (this.datePickerETD.Value.HasValue && (this.datePickerETD.Value.Value < DateTime.Now) && (this.datePickerETD_End.Value == null)) + { + message = BreCalClient.Resources.Resources.textETAInThePast; + return false; + } + + if (this.datePickerETD_End.Value.HasValue && this.datePickerETD_End.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textETDInThePast; + return false; + } + + if (this.datePickerETD.Value.HasValue && this.datePickerETD_End.Value.HasValue && this.datePickerETD.Value > this.datePickerETD_End.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + if (this.datePickerTidalWindowFrom.Value.HasValue && (this.datePickerTidalWindowFrom.Value.Value < DateTime.Now) && (this.datePickerTidalWindowTo.Value == null)) + { + message = BreCalClient.Resources.Resources.textTideTimesInThePast; + return false; + } + + if (this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowTo.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textTideTimesInThePast; + return false; + } + + if (this.datePickerTidalWindowFrom.Value.HasValue && this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowFrom.Value > this.datePickerTidalWindowTo.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + return true; + } + private void CopyToModel() { if (this.ShipcallModel.Shipcall != null) diff --git a/src/BreCalClient/EditTimesControl.xaml b/src/BreCalClient/EditTimesControl.xaml index ad03ed9..03cac40 100644 --- a/src/BreCalClient/EditTimesControl.xaml +++ b/src/BreCalClient/EditTimesControl.xaml @@ -44,7 +44,7 @@ - + diff --git a/src/BreCalClient/EditTimesControl.xaml.cs b/src/BreCalClient/EditTimesControl.xaml.cs index dfd841d..74e7e0a 100644 --- a/src/BreCalClient/EditTimesControl.xaml.cs +++ b/src/BreCalClient/EditTimesControl.xaml.cs @@ -46,9 +46,16 @@ namespace BreCalClient private void buttonOK_Click(object sender, RoutedEventArgs e) { - this.CopyToModel(); - this.DialogResult = true; - this.Close(); + if (!CheckValues(out string message)) + { + System.Windows.MessageBox.Show(message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); + } + else + { + this.CopyToModel(); + this.DialogResult = true; + this.Close(); + } } private void buttonCancel_Click(object sender, RoutedEventArgs e) @@ -85,6 +92,44 @@ namespace BreCalClient #region private methods + private bool CheckValues(out string message) + { + + message = ""; + + if (this.datePickerETABerth.Value.HasValue && (this.datePickerETABerth.Value.Value < DateTime.Now) && (this.datePickerETABerth_End.Value == null)) + { + message = BreCalClient.Resources.Resources.textETAInThePast; + return false; + } + + if (this.datePickerETABerth_End.Value.HasValue && this.datePickerETABerth_End.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textETDInThePast; + return false; + } + + if (this.datePickerETABerth.Value.HasValue && this.datePickerETABerth_End.Value.HasValue && this.datePickerETABerth.Value > this.datePickerETABerth_End.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + if (this.datePickerLockTime.Value.HasValue && (this.datePickerLockTime.Value.Value < DateTime.Now)) + { + message = BreCalClient.Resources.Resources.textLockTimeInThePast; + return false; + } + + if (this.datePickerZoneEntry.Value.HasValue && this.datePickerZoneEntry.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textZoneEntryInThePast; + return false; + } + + return true; + } + private void CopyToModel() { this.Times.Remarks = this.textBoxRemarks.Text.Trim().Truncate(512); diff --git a/src/BreCalClient/EditTimesTerminalControl.xaml.cs b/src/BreCalClient/EditTimesTerminalControl.xaml.cs index 6071ba9..6e9af6a 100644 --- a/src/BreCalClient/EditTimesTerminalControl.xaml.cs +++ b/src/BreCalClient/EditTimesTerminalControl.xaml.cs @@ -3,6 +3,7 @@ // using BreCalClient.misc.Model; +using System; using System.Windows; namespace BreCalClient @@ -61,9 +62,16 @@ namespace BreCalClient private void buttonOK_Click(object sender, RoutedEventArgs e) { - this.CopyToModel(); - this.DialogResult = true; - this.Close(); + if (!CheckValues(out string message)) + { + System.Windows.MessageBox.Show(message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); + } + else + { + this.CopyToModel(); + this.DialogResult = true; + this.Close(); + } } private void buttonCancel_Click(object sender, RoutedEventArgs e) @@ -95,6 +103,50 @@ namespace BreCalClient #region private methods + private bool CheckValues(out string message) + { + + message = ""; + + if (this.datePickerOperationStart.Value.HasValue && (this.datePickerOperationStart.Value.Value < DateTime.Now) && (this.datePickerOperationStart_End.Value == null)) + { + message = BreCalClient.Resources.Resources.textOperationStartInThePast; + return false; + } + + if (this.datePickerOperationStart_End.Value.HasValue && this.datePickerOperationStart_End.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textOperationStartInThePast; + return false; + } + + if (this.datePickerOperationStart.Value.HasValue && this.datePickerOperationStart_End.Value.HasValue && this.datePickerOperationStart.Value > this.datePickerOperationStart_End.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + if (this.datePickerOperationEnd.Value.HasValue && (this.datePickerOperationEnd.Value.Value < DateTime.Now) && (this.datePickerOperationEnd_End.Value == null)) + { + message = BreCalClient.Resources.Resources.textOperationEndInThePast; + return false; + } + + if (this.datePickerOperationEnd_End.Value.HasValue && this.datePickerOperationEnd_End.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textOperationEndInThePast; + return false; + } + + if (this.datePickerOperationEnd.Value.HasValue && this.datePickerOperationEnd_End.Value.HasValue && this.datePickerOperationEnd.Value > this.datePickerOperationEnd_End.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + return true; + } + private void CopyToModel() { this.Times.PierSide = this.comboBoxPierside.SelectedIndex switch diff --git a/src/BreCalClient/Resources/Resources.Designer.cs b/src/BreCalClient/Resources/Resources.Designer.cs index 492ef15..aeada56 100644 --- a/src/BreCalClient/Resources/Resources.Designer.cs +++ b/src/BreCalClient/Resources/Resources.Designer.cs @@ -389,6 +389,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Both tide times are required. + /// + public static string textBothTideTimesNecessary { + get { + return ResourceManager.GetString("textBothTideTimesNecessary", resourceCulture); + } + } + /// /// Looks up a localized string similar to BSMD right to edit granted. /// @@ -623,6 +632,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Some interval end times are before start times. + /// + public static string textEndValueBeforeStartValue { + get { + return ResourceManager.GetString("textEndValueBeforeStartValue", resourceCulture); + } + } + /// /// Looks up a localized string similar to Ship / remark. /// @@ -632,6 +650,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Error. + /// + public static string textError { + get { + return ResourceManager.GetString("textError", resourceCulture); + } + } + /// /// Looks up a localized string similar to ETA berth. /// @@ -641,6 +668,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to ETA value is in the past. + /// + public static string textETAInThePast { + get { + return ResourceManager.GetString("textETAInThePast", resourceCulture); + } + } + /// /// Looks up a localized string similar to ETD berth. /// @@ -650,6 +686,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to ETD value is in the past. + /// + public static string textETDInThePast { + get { + return ResourceManager.GetString("textETDInThePast", resourceCulture); + } + } + /// /// Looks up a localized string similar to Exit. /// @@ -740,6 +785,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Lock time is in the past. + /// + public static string textLockTimeInThePast { + get { + return ResourceManager.GetString("textLockTimeInThePast", resourceCulture); + } + } + /// /// Looks up a localized string similar to Login. /// @@ -830,6 +884,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Operation end is in the past. + /// + public static string textOperationEndInThePast { + get { + return ResourceManager.GetString("textOperationEndInThePast", resourceCulture); + } + } + /// /// Looks up a localized string similar to Operations end. /// @@ -848,6 +911,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Operation start is in the past. + /// + public static string textOperationStartInThePast { + get { + return ResourceManager.GetString("textOperationStartInThePast", resourceCulture); + } + } + /// /// Looks up a localized string similar to Outgoing. /// @@ -1145,6 +1217,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Times for the tide window are in the past. + /// + public static string textTideTimesInThePast { + get { + return ResourceManager.GetString("textTideTimesInThePast", resourceCulture); + } + } + /// /// Looks up a localized string similar to Timestamp. /// @@ -1262,6 +1343,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Warning. + /// + public static string textWarning { + get { + return ResourceManager.GetString("textWarning", resourceCulture); + } + } + /// /// Looks up a localized string similar to Width. /// @@ -1280,6 +1370,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Zone entry time is in the past. + /// + public static string textZoneEntryInThePast { + get { + return ResourceManager.GetString("textZoneEntryInThePast", resourceCulture); + } + } + /// /// Looks up a localized string similar to Zone entry. /// diff --git a/src/BreCalClient/Resources/Resources.de.resx b/src/BreCalClient/Resources/Resources.de.resx index a681ad9..18947eb 100644 --- a/src/BreCalClient/Resources/Resources.de.resx +++ b/src/BreCalClient/Resources/Resources.de.resx @@ -508,4 +508,37 @@ Alle Eintragungen zurücksetzen? + + Beide Tidenzeiten sollten angegeben werden (von - bis) + + + Endzeit liegt vor Startzeit + + + Error + + + Zeitpunkt ETA liegt in der Vergangenheit + + + Zeitpunkt ETD liegt in der Vergangenheit + + + Schleusenzeit liegt in der Vergangenheit + + + Operation Endzeit liegt in der Vergangenheit + + + Operation Startzeit liegt in der Vergangenheit + + + Tidenzeit liegt in der Vergangenheit + + + Warnung + + + Zeit Reviereintritt liegt in der Vergangenheit + \ No newline at end of file diff --git a/src/BreCalClient/Resources/Resources.resx b/src/BreCalClient/Resources/Resources.resx index 1cf2a78..14cf0f9 100644 --- a/src/BreCalClient/Resources/Resources.resx +++ b/src/BreCalClient/Resources/Resources.resx @@ -214,6 +214,9 @@ Berths + + Both tide times are required + BSMD right to edit granted @@ -292,15 +295,27 @@ E-mail + + Some interval end times are before start times + Ship / remark + + Error + ETA berth + + ETA value is in the past + ETD berth + + ETD value is in the past + Exit @@ -331,6 +346,9 @@ Lock time + + Lock time is in the past + Login @@ -361,12 +379,18 @@ Operation + + Operation end is in the past + Operations end Operations start + + Operation start is in the past + Outgoing @@ -466,6 +490,9 @@ Tidal window + + Times for the tide window are in the past + Timestamp @@ -505,12 +532,18 @@ Voyage + + Warning + Width Wrong username or password + + Zone entry time is in the past + Zone entry