Fixed situation where end time was reset after from time left 24h window

This commit is contained in:
Daniel Schick 2024-11-11 11:01:31 +01:00
parent 2576127b79
commit 9bb847242c
5 changed files with 163 additions and 179 deletions

View File

@ -104,31 +104,24 @@ namespace BreCalClient
{
message = "";
if (this.datePickerETA.Value.IsTooOld() && (this.datePickerETA.Value != this.Times.EtaBerth))
if ((this.datePickerETA.Value != this.Times.EtaBerth) || (this.datePickerETA_End.Value != this.Times.EtaBerth)) // something has changed
{
if (datePickerETA.Value.IsTooOld() || datePickerETA_End.Value.IsTooOld())
{
message = BreCalClient.Resources.Resources.textETAInThePast;
return false;
}
if(this.datePickerETA_End.Value.IsTooOld() && (this.datePickerETA_End.Value != this.Times.EtaIntervalEnd))
{
message = BreCalClient.Resources.Resources.textETAInThePast;
return false;
}
if(this.datePickerETA.Value.HasValue && this.datePickerETA_End.Value.HasValue && this.datePickerETA.Value > this.datePickerETA_End.Value)
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.IsTooOld() && (this.datePickerTidalWindowTo.Value == null) && (this.datePickerTidalWindowFrom.Value != this.ShipcallModel.Shipcall?.TidalWindowFrom))
{
message = BreCalClient.Resources.Resources.textTideTimesInThePast;
return false;
}
if (this.datePickerTidalWindowTo.Value.IsTooOld() && (this.datePickerTidalWindowTo.Value != this.ShipcallModel.Shipcall?.TidalWindowTo))
if((this.datePickerTidalWindowFrom.Value != this.ShipcallModel.Shipcall?.TidalWindowFrom) || (this.datePickerTidalWindowTo.Value != this.ShipcallModel.Shipcall?.TidalWindowTo)) // something has changed
{
if(datePickerTidalWindowTo.Value.IsTooOld() || this.datePickerTidalWindowFrom.Value.IsTooOld())
{
message = BreCalClient.Resources.Resources.textTideTimesInThePast;
return false;
@ -140,11 +133,12 @@ namespace BreCalClient
return false;
}
if((this.datePickerTidalWindowFrom.Value.HasValue && !this.datePickerTidalWindowTo.Value.HasValue) || (!this.datePickerTidalWindowFrom.Value.HasValue && this.datePickerTidalWindowTo.Value.HasValue))
if ((this.datePickerTidalWindowFrom.Value.HasValue && !this.datePickerTidalWindowTo.Value.HasValue) || (!this.datePickerTidalWindowFrom.Value.HasValue && this.datePickerTidalWindowTo.Value.HasValue))
{
message = BreCalClient.Resources.Resources.textTidalBothValues;
return false;
}
}
if(this.datePickerETA.Value.IsTooFar() || this.datePickerETA_End.Value.IsTooFar() || this.datePickerTidalWindowFrom.Value.IsTooFar() || this.datePickerTidalWindowTo.Value.IsTooFar())
{
@ -152,6 +146,12 @@ namespace BreCalClient
return false;
}
if((this.datePickerETA_End.Value.HasValue && !this.datePickerETA.Value.HasValue) || (this.datePickerTidalWindowTo.Value.HasValue && !this.datePickerTidalWindowFrom.Value.HasValue))
{
message = BreCalClient.Resources.Resources.textStartTimeMissing;
return false;
}
return true;
}

View File

@ -4,15 +4,8 @@
using BreCalClient.misc.Model;
using System;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Controls;
using Xceed.Wpf.Toolkit;
using static BreCalClient.Extensions;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media;
namespace BreCalClient
{
@ -114,16 +107,13 @@ namespace BreCalClient
{
message = "";
if (this.datePickerETD.Value.IsTooOld() && (this.datePickerETD.Value != this.Times.EtdBerth))
if((this.datePickerETD.Value != this.Times.EtdBerth) || (this.datePickerETD_End.Value != this.Times.EtdIntervalEnd))
{
if (datePickerETD.Value.IsTooOld() || datePickerETD_End.Value.IsTooOld())
{
message = BreCalClient.Resources.Resources.textETDInThePast;
return false;
}
if (this.datePickerETD_End.Value.IsTooOld() && (this.datePickerETD_End.Value != this.Times.EtdIntervalEnd))
{
message = BreCalClient.Resources.Resources.textETDInThePast;
return false;
}
if (this.datePickerETD.Value.HasValue && this.datePickerETD_End.Value.HasValue && this.datePickerETD.Value > this.datePickerETD_End.Value)
@ -132,16 +122,13 @@ namespace BreCalClient
return false;
}
if (this.datePickerTidalWindowFrom.Value.IsTooOld() && (this.datePickerTidalWindowTo.Value == null) && (this.datePickerTidalWindowFrom.Value != this.ShipcallModel.Shipcall?.TidalWindowFrom))
if((this.datePickerTidalWindowFrom.Value != this.ShipcallModel.Shipcall?.TidalWindowFrom) || (this.datePickerTidalWindowTo.Value != this.ShipcallModel.Shipcall?.TidalWindowTo))
{
if (this.datePickerTidalWindowTo.Value.IsTooOld() || this.datePickerTidalWindowFrom.Value.IsTooOld())
{
message = BreCalClient.Resources.Resources.textTideTimesInThePast;
return false;
}
if (this.datePickerTidalWindowTo.Value.IsTooOld() && (this.datePickerTidalWindowTo.Value != this.ShipcallModel.Shipcall?.TidalWindowTo))
{
message = BreCalClient.Resources.Resources.textTideTimesInThePast;
return false;
}
if (this.datePickerTidalWindowFrom.Value.HasValue && this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowFrom.Value > this.datePickerTidalWindowTo.Value)
@ -162,6 +149,12 @@ namespace BreCalClient
return false;
}
if((this.datePickerETD_End.Value.HasValue && !this.datePickerETD.Value.HasValue) || (this.datePickerTidalWindowTo.Value.HasValue && !this.datePickerTidalWindowFrom.Value.HasValue))
{
message = BreCalClient.Resources.Resources.textStartTimeMissing;
return false;
}
return true;
}

View File

@ -108,16 +108,14 @@ namespace BreCalClient
{
message = "";
if (this.datePickerETA.Value.IsTooOld() && (this.datePickerETA.Value != this.Times.EtaBerth))
if((this.datePickerETA.Value != this.Times.EtaBerth) || (this.datePickerETA_End.Value != this.Times.EtaIntervalEnd))
{
if (this.datePickerETA.Value.IsTooOld() && this.datePickerETA_End.Value.IsTooOld())
{
message = BreCalClient.Resources.Resources.textETAInThePast;
return false;
}
if (this.datePickerETA_End.Value.IsTooOld() && (this.datePickerETA_End.Value != this.Times.EtaIntervalEnd))
{
message = BreCalClient.Resources.Resources.textETAInThePast;
return false;
}
if (this.datePickerETA.Value.HasValue && this.datePickerETA_End.Value.HasValue && this.datePickerETA.Value > this.datePickerETA_End.Value)
@ -126,16 +124,13 @@ namespace BreCalClient
return false;
}
if (this.datePickerETD.Value.IsTooOld() && (this.datePickerETD.Value != this.Times.EtdBerth))
if((this.datePickerETD.Value != this.Times.EtdBerth) || (this.datePickerETD_End.Value != this.Times.EtdIntervalEnd))
{
if (this.datePickerETD.Value.IsTooOld() || this.datePickerETD_End.Value.IsTooOld())
{
message = BreCalClient.Resources.Resources.textETDInThePast;
return false;
}
if (this.datePickerETD_End.Value.IsTooOld() && (this.datePickerETD_End.Value != this.Times.EtdIntervalEnd))
{
message = BreCalClient.Resources.Resources.textETDInThePast;
return false;
}
if (this.datePickerETD.Value.HasValue && this.datePickerETD_End.Value.HasValue && this.datePickerETD.Value > this.datePickerETD_End.Value)
@ -144,16 +139,13 @@ namespace BreCalClient
return false;
}
if (this.datePickerTidalWindowFrom.Value.IsTooOld() && (this.datePickerTidalWindowTo.Value == null) && (this.datePickerTidalWindowFrom.Value != this.ShipcallModel.Shipcall?.TidalWindowFrom))
if((this.datePickerTidalWindowFrom.Value != this.ShipcallModel.Shipcall?.TidalWindowFrom) || (this.datePickerTidalWindowTo.Value != this.ShipcallModel.Shipcall?.TidalWindowTo))
{
if (this.datePickerTidalWindowFrom.Value.IsTooOld() && this.datePickerTidalWindowTo.Value.IsTooOld())
{
message = BreCalClient.Resources.Resources.textTideTimesInThePast;
return false;
}
if (this.datePickerTidalWindowTo.Value.IsTooOld() && (this.datePickerTidalWindowTo.Value != this.ShipcallModel.Shipcall?.TidalWindowTo))
{
message = BreCalClient.Resources.Resources.textTideTimesInThePast;
return false;
}
if (this.datePickerTidalWindowFrom.Value.HasValue && this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowFrom.Value > this.datePickerTidalWindowTo.Value)

View File

@ -5,7 +5,6 @@
using BreCalClient.misc.Model;
using System;
using System.Runtime.Serialization;
using System.Windows;
using System.Windows.Media.Imaging;
using Xceed.Wpf.Toolkit;
@ -99,16 +98,13 @@ namespace BreCalClient
message = "";
if (this.datePickerETABerth.Value.IsTooOld() && (this.datePickerETABerth_End.Value == null) && (this.datePickerETABerth.Value != this.Times.EtaBerth))
if ((this.datePickerETABerth.Value != this.Times.EtaBerth) || (this.datePickerETABerth_End.Value != this.Times.EtaIntervalEnd))
{
if (this.datePickerETABerth.Value.IsTooOld() || this.datePickerETABerth_End.Value.IsTooOld())
{
message = BreCalClient.Resources.Resources.textETAInThePast;
return false;
}
if (this.datePickerETABerth_End.Value.IsTooOld() && this.datePickerETABerth_End.Value != this.Times.EtaIntervalEnd)
{
message = BreCalClient.Resources.Resources.textETAInThePast;
return false;
}
if (this.datePickerETABerth.Value.HasValue && this.datePickerETABerth_End.Value.HasValue && this.datePickerETABerth.Value > this.datePickerETABerth_End.Value)
@ -117,16 +113,13 @@ namespace BreCalClient
return false;
}
if (this.datePickerETDBerth.Value.IsTooOld() && (this.datePickerETDBerth_End.Value == null) && (this.datePickerETDBerth.Value != this.Times.EtdBerth))
if((this.datePickerETDBerth.Value != this.Times.EtdBerth) || (this.datePickerETDBerth_End.Value != this.Times.EtdIntervalEnd))
{
if(this.datePickerETDBerth.Value.IsTooOld() || this.datePickerETDBerth_End.Value.IsTooOld())
{
message = BreCalClient.Resources.Resources.textETDInThePast;
return false;
}
if (this.datePickerETDBerth_End.Value.IsTooOld() && this.datePickerETDBerth_End.Value != this.Times.EtdIntervalEnd)
{
message = BreCalClient.Resources.Resources.textETDInThePast;
return false;
}
if (this.datePickerETDBerth.Value.HasValue && this.datePickerETDBerth_End.Value.HasValue && this.datePickerETDBerth.Value > this.datePickerETDBerth_End.Value)
@ -154,6 +147,12 @@ namespace BreCalClient
return false;
}
if((this.datePickerETABerth_End.Value.HasValue && !this.datePickerETABerth.Value.HasValue) || (this.datePickerETDBerth_End.Value.HasValue && !this.datePickerETDBerth.Value.HasValue))
{
message = BreCalClient.Resources.Resources.textStartTimeMissing;
return false;
}
return true;
}

View File

@ -111,16 +111,13 @@ namespace BreCalClient
message = "";
if (this.datePickerOperationStart.Value.IsTooOld() && (this.datePickerOperationStart_End.Value == null) && (this.datePickerOperationStart.Value != this.Times.OperationsStart))
if((this.datePickerOperationStart.Value != this.Times.OperationsStart) || (this.datePickerOperationStart_End.Value != this.Times.EtaIntervalEnd))
{
if(this.datePickerOperationStart.Value.IsTooOld() || this.datePickerOperationStart_End.Value.IsTooOld())
{
message = BreCalClient.Resources.Resources.textOperationStartInThePast;
return false;
}
if (this.datePickerOperationStart_End.Value.IsTooOld() && (this.datePickerOperationStart_End.Value != this.Times.EtaIntervalEnd))
{
message = BreCalClient.Resources.Resources.textOperationStartInThePast;
return false;
}
if (this.datePickerOperationStart.Value.HasValue && this.datePickerOperationStart_End.Value.HasValue && this.datePickerOperationStart.Value > this.datePickerOperationStart_End.Value)
@ -129,16 +126,13 @@ namespace BreCalClient
return false;
}
if (this.datePickerOperationEnd.Value.IsTooOld() && (this.datePickerOperationEnd_End.Value == null) && (this.datePickerOperationEnd.Value != this.Times.OperationsEnd))
if ((this.datePickerOperationEnd.Value != this.Times.OperationsEnd) || (this.datePickerOperationEnd_End.Value != this.Times.EtdIntervalEnd))
{
if(this.datePickerOperationEnd.Value.IsTooOld() || this.datePickerOperationEnd_End.Value.IsTooOld())
{
message = BreCalClient.Resources.Resources.textOperationEndInThePast;
return false;
}
if (this.datePickerOperationEnd_End.Value.IsTooOld() && (this.datePickerOperationEnd_End.Value != this.Times.EtdIntervalEnd))
{
message = BreCalClient.Resources.Resources.textOperationEndInThePast;
return false;
}
if (this.datePickerOperationEnd.Value.HasValue && this.datePickerOperationEnd_End.Value.HasValue && this.datePickerOperationEnd.Value > this.datePickerOperationEnd_End.Value)
@ -153,6 +147,12 @@ namespace BreCalClient
return false;
}
if((this.datePickerOperationEnd_End.Value.HasValue && !this.datePickerOperationEnd.Value.HasValue) || (this.datePickerOperationStart_End.Value.HasValue && !this.datePickerOperationStart.Value.HasValue))
{
message = BreCalClient.Resources.Resources.textStartTimeMissing;
return false;
}
return true;
}