added -1 day time logic to client
This commit is contained in:
parent
2ee9af4b9d
commit
6b5d876cd5
@ -205,25 +205,21 @@ 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);
|
||||
isEnabled &= !(this.datePickerETD.Value.IsTooOld() && this.datePickerETD.Value != this.ShipcallModel.Shipcall?.Etd);
|
||||
isEnabled &= !this.datePickerETD.Value.IsTooFar();
|
||||
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);
|
||||
isEnabled &= !(this.datePickerETA.Value.IsTooOld() && this.datePickerETA.Value != this.ShipcallModel.Shipcall?.Eta);
|
||||
isEnabled &= !this.datePickerETA.Value.IsTooFar();
|
||||
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);
|
||||
isEnabled &= !(this.datePickerETD.Value.IsTooOld() && this.datePickerETD.Value != this.ShipcallModel.Shipcall?.Etd);
|
||||
isEnabled &= !(this.datePickerETA.Value.IsTooOld() && this.datePickerETA.Value != this.ShipcallModel.Shipcall?.Eta);
|
||||
if (this.datePickerETA.Value.HasValue && this.datePickerETD.Value.HasValue)
|
||||
isEnabled &= (this.datePickerETA.Value.Value > this.datePickerETD.Value.Value);
|
||||
isEnabled &= !this.datePickerETD.Value.IsTooFar();
|
||||
|
||||
@ -97,13 +97,13 @@ namespace BreCalClient
|
||||
{
|
||||
message = "";
|
||||
|
||||
if (this.datePickerETA.Value.HasValue && (this.datePickerETA.Value.Value < DateTime.Now) && (this.datePickerETA_End.Value == null))
|
||||
if (this.datePickerETA.Value.IsTooOld() && (this.datePickerETA_End.Value == null) && (this.datePickerETA.Value != this.Times.EtaBerth))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textETAInThePast;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.datePickerETA_End.Value.HasValue && this.datePickerETA_End.Value < DateTime.Now)
|
||||
if(this.datePickerETA_End.Value.IsTooOld() && (this.datePickerETA_End.Value != this.Times.EtaIntervalEnd))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textETAInThePast;
|
||||
return false;
|
||||
@ -115,13 +115,13 @@ namespace BreCalClient
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.datePickerTidalWindowFrom.Value.HasValue && (this.datePickerTidalWindowFrom.Value.Value < DateTime.Now) && (this.datePickerTidalWindowTo.Value == null))
|
||||
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.HasValue && this.datePickerTidalWindowTo.Value < DateTime.Now)
|
||||
if (this.datePickerTidalWindowTo.Value.IsTooOld() && (this.datePickerTidalWindowTo.Value != this.ShipcallModel.Shipcall?.TidalWindowTo))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textTideTimesInThePast;
|
||||
return false;
|
||||
|
||||
@ -107,13 +107,13 @@ namespace BreCalClient
|
||||
{
|
||||
message = "";
|
||||
|
||||
if (this.datePickerETD.Value.HasValue && (this.datePickerETD.Value.Value < DateTime.Now) && (this.datePickerETD_End.Value == null))
|
||||
if (this.datePickerETD.Value.IsTooOld() && (this.datePickerETD_End.Value == null) && (this.datePickerETD.Value != this.Times.EtdBerth))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textETDInThePast;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.datePickerETD_End.Value.HasValue && this.datePickerETD_End.Value < DateTime.Now)
|
||||
if (this.datePickerETD_End.Value.IsTooOld() && (this.datePickerETD_End.Value != this.Times.EtdIntervalEnd))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textETDInThePast;
|
||||
return false;
|
||||
@ -125,13 +125,13 @@ namespace BreCalClient
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.datePickerTidalWindowFrom.Value.HasValue && (this.datePickerTidalWindowFrom.Value.Value < DateTime.Now) && (this.datePickerTidalWindowTo.Value == null))
|
||||
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.HasValue && this.datePickerTidalWindowTo.Value < DateTime.Now)
|
||||
if (this.datePickerTidalWindowTo.Value.IsTooOld() && (this.datePickerTidalWindowTo.Value != this.ShipcallModel.Shipcall?.TidalWindowTo))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textTideTimesInThePast;
|
||||
return false;
|
||||
|
||||
@ -97,13 +97,13 @@ namespace BreCalClient
|
||||
{
|
||||
message = "";
|
||||
|
||||
if (this.datePickerETA.Value.HasValue && (this.datePickerETA.Value.Value < DateTime.Now) && (this.datePickerETA_End.Value == null))
|
||||
if (this.datePickerETA.Value.IsTooOld() && (this.datePickerETA_End.Value == null) && (this.datePickerETA.Value != this.Times.EtaBerth))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textETAInThePast;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.datePickerETA_End.Value.HasValue && this.datePickerETA_End.Value < DateTime.Now)
|
||||
if (this.datePickerETA_End.Value.IsTooOld() && (this.datePickerETA_End.Value != this.Times.EtaIntervalEnd))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textETAInThePast;
|
||||
return false;
|
||||
@ -115,13 +115,13 @@ namespace BreCalClient
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.datePickerETD.Value.HasValue && (this.datePickerETD.Value.Value < DateTime.Now) && (this.datePickerETD_End.Value == null))
|
||||
if (this.datePickerETD.Value.IsTooOld() && (this.datePickerETD_End.Value == null) && (this.datePickerETD.Value != this.Times.EtdBerth))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textETDInThePast;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.datePickerETD_End.Value.HasValue && this.datePickerETD_End.Value < DateTime.Now)
|
||||
if (this.datePickerETD_End.Value.IsTooOld() && (this.datePickerETD_End.Value != this.Times.EtdIntervalEnd))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textETDInThePast;
|
||||
return false;
|
||||
@ -133,13 +133,13 @@ namespace BreCalClient
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.datePickerTidalWindowFrom.Value.HasValue && (this.datePickerTidalWindowFrom.Value.Value < DateTime.Now) && (this.datePickerTidalWindowTo.Value == null))
|
||||
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.HasValue && this.datePickerTidalWindowTo.Value < DateTime.Now)
|
||||
if (this.datePickerTidalWindowTo.Value.IsTooOld() && (this.datePickerTidalWindowTo.Value != this.ShipcallModel.Shipcall?.TidalWindowTo))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textTideTimesInThePast;
|
||||
return false;
|
||||
|
||||
@ -99,13 +99,13 @@ namespace BreCalClient
|
||||
|
||||
message = "";
|
||||
|
||||
if (this.datePickerETABerth.Value.HasValue && (this.datePickerETABerth.Value.Value < DateTime.Now) && (this.datePickerETABerth_End.Value == null))
|
||||
if (this.datePickerETABerth.Value.IsTooOld() && (this.datePickerETABerth_End.Value == null) && (this.datePickerETABerth.Value != this.Times.EtaBerth))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textETAInThePast;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.datePickerETABerth_End.Value.HasValue && this.datePickerETABerth_End.Value < DateTime.Now)
|
||||
if (this.datePickerETABerth_End.Value.IsTooOld() && this.datePickerETABerth_End.Value != this.Times.EtaIntervalEnd)
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textETAInThePast;
|
||||
return false;
|
||||
@ -117,13 +117,13 @@ namespace BreCalClient
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.datePickerETDBerth.Value.HasValue && (this.datePickerETDBerth.Value.Value < DateTime.Now) && (this.datePickerETABerth_End.Value == null))
|
||||
if (this.datePickerETDBerth.Value.IsTooOld() && (this.datePickerETDBerth_End.Value == null) && (this.datePickerETDBerth.Value != this.Times.EtdBerth))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textETDInThePast;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.datePickerETDBerth_End.Value.HasValue && this.datePickerETDBerth_End.Value < DateTime.Now)
|
||||
if (this.datePickerETDBerth_End.Value.IsTooOld() && this.datePickerETDBerth_End.Value != this.Times.EtdIntervalEnd)
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textETDInThePast;
|
||||
return false;
|
||||
@ -135,13 +135,13 @@ namespace BreCalClient
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.datePickerLockTime.Value.HasValue && (this.datePickerLockTime.Value.Value < DateTime.Now))
|
||||
if (this.datePickerLockTime.Value.IsTooOld() && (this.datePickerLockTime.Value != this.Times.LockTime))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textLockTimeInThePast;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.datePickerZoneEntry.Value.HasValue && this.datePickerZoneEntry.Value < DateTime.Now)
|
||||
if (this.datePickerZoneEntry.Value.IsTooOld() && (this.datePickerZoneEntry.Value != this.Times.ZoneEntry))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textZoneEntryInThePast;
|
||||
return false;
|
||||
|
||||
@ -108,13 +108,13 @@ namespace BreCalClient
|
||||
|
||||
message = "";
|
||||
|
||||
if (this.datePickerOperationStart.Value.HasValue && (this.datePickerOperationStart.Value.Value < DateTime.Now) && (this.datePickerOperationStart_End.Value == null))
|
||||
if (this.datePickerOperationStart.Value.IsTooOld() && (this.datePickerOperationStart_End.Value == null) && (this.datePickerOperationStart.Value != this.Times.OperationsStart))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textOperationStartInThePast;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.datePickerOperationStart_End.Value.HasValue && this.datePickerOperationStart_End.Value < DateTime.Now)
|
||||
if (this.datePickerOperationStart_End.Value.IsTooOld() && (this.datePickerOperationStart_End.Value != this.Times.EtaIntervalEnd))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textOperationStartInThePast;
|
||||
return false;
|
||||
@ -126,13 +126,13 @@ namespace BreCalClient
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.datePickerOperationEnd.Value.HasValue && (this.datePickerOperationEnd.Value.Value < DateTime.Now) && (this.datePickerOperationEnd_End.Value == null))
|
||||
if (this.datePickerOperationEnd.Value.IsTooOld() && (this.datePickerOperationEnd_End.Value == null) && (this.datePickerOperationEnd.Value != this.Times.OperationsEnd))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textOperationEndInThePast;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.datePickerOperationEnd_End.Value.HasValue && this.datePickerOperationEnd_End.Value < DateTime.Now)
|
||||
if (this.datePickerOperationEnd_End.Value.IsTooOld() && (this.datePickerOperationEnd_End.Value != this.Times.EtdIntervalEnd))
|
||||
{
|
||||
message = BreCalClient.Resources.Resources.textOperationEndInThePast;
|
||||
return false;
|
||||
|
||||
@ -69,6 +69,14 @@ namespace BreCalClient
|
||||
return datetime > DateTime.Now.AddYears(1);
|
||||
}
|
||||
|
||||
public static bool IsTooOld(this DateTime? datetime)
|
||||
{
|
||||
if (datetime == null) return false;
|
||||
{
|
||||
return datetime < DateTime.Now.AddDays(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsTypeFlagSet(this Participant participant, ParticipantType flag)
|
||||
{
|
||||
return (participant.Type & (uint)flag) != 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user