don't allow a changed port when creating departure after a new arrival

This commit is contained in:
Daniel Schick 2024-10-01 08:19:11 +02:00
parent 4b1f773c6f
commit e18188cd85
3 changed files with 18 additions and 14 deletions

View File

@ -57,7 +57,7 @@ namespace BreCalClient
{ {
if (!first) shipcallTypes.Add(shipcallType); if (!first) shipcallTypes.Add(shipcallType);
else first = false; else first = false;
} }
this.comboBoxArrivalBerth.ItemsSource = BreCalLists.Berths; this.comboBoxArrivalBerth.ItemsSource = BreCalLists.Berths;
this.comboBoxDepartureBerth.ItemsSource = BreCalLists.Berths; this.comboBoxDepartureBerth.ItemsSource = BreCalLists.Berths;
@ -87,21 +87,21 @@ namespace BreCalClient
} }
private void comboBoxShip_SelectionChanged(object sender, SelectionChangedEventArgs e) private void comboBoxShip_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
if (this.comboBoxShip.SelectedItem != null) if (this.comboBoxShip.SelectedItem != null)
{ {
ShipModel? ship = this.comboBoxShip.SelectedItem as ShipModel; ShipModel? ship = this.comboBoxShip.SelectedItem as ShipModel;
this.integerUpDownIMO.Value = ship?.Ship.Imo; this.integerUpDownIMO.Value = ship?.Ship.Imo;
this.textBoxCallsign.Text = ship?.Ship.Callsign; this.textBoxCallsign.Text = ship?.Ship.Callsign;
this.doubleUpDownLength.Value = ship?.Ship.Length; this.doubleUpDownLength.Value = ship?.Ship.Length;
this.doubleUpDownWidth.Value = ship?.Ship.Width; this.doubleUpDownWidth.Value = ship?.Ship.Width;
} }
else else
{ {
this.integerUpDownIMO.Value = null; this.integerUpDownIMO.Value = null;
this.textBoxCallsign.Text = string.Empty; this.textBoxCallsign.Text = string.Empty;
this.doubleUpDownLength.Value = null; this.doubleUpDownLength.Value = null;
this.doubleUpDownWidth.Value = null; this.doubleUpDownWidth.Value = null;
} }
this.CheckForCompletion(); this.CheckForCompletion();
} }
@ -119,7 +119,7 @@ namespace BreCalClient
{ {
switch (type) switch (type)
{ {
case ShipcallType.Arrival: case ShipcallType.Arrival:
this.datePickerETD.Visibility = Visibility.Hidden; this.datePickerETD.Visibility = Visibility.Hidden;
this.labelETD.Visibility = Visibility.Hidden; this.labelETD.Visibility = Visibility.Hidden;
this.datePickerETA.Visibility = Visibility.Visible; this.datePickerETA.Visibility = Visibility.Visible;
@ -176,7 +176,7 @@ namespace BreCalClient
this.comboBoxAgency.SelectedIndex = -1; this.comboBoxAgency.SelectedIndex = -1;
this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.AGENCY); this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.AGENCY);
} }
#endregion #endregion
#region private methods #region private methods
@ -210,7 +210,7 @@ namespace BreCalClient
if(this.datePickerETD.Value.HasValue) if(this.datePickerETD.Value.HasValue)
isEnabled &= (this.datePickerETD.Value.Value > DateTime.Now); isEnabled &= (this.datePickerETD.Value.Value > DateTime.Now);
isEnabled &= !this.datePickerETD.Value.IsTooFar(); isEnabled &= !this.datePickerETD.Value.IsTooFar();
break; break;
case ShipcallType.Arrival: case ShipcallType.Arrival:
isEnabled &= this.comboBoxArrivalBerth.SelectedItem != null; isEnabled &= this.comboBoxArrivalBerth.SelectedItem != null;
isEnabled &= this.datePickerETA.Value.HasValue; isEnabled &= this.datePickerETA.Value.HasValue;
@ -233,7 +233,7 @@ namespace BreCalClient
break; break;
} }
} }
isEnabled &= this.comboBoxAgency.SelectedItem != null; isEnabled &= this.comboBoxAgency.SelectedItem != null;
this.buttonOK.IsEnabled = isEnabled; this.buttonOK.IsEnabled = isEnabled;
@ -255,7 +255,7 @@ namespace BreCalClient
{ {
this.ShipcallModel.Shipcall.ArrivalBerthId = (this.comboBoxArrivalBerth.SelectedItem != null) ? ((Berth)this.comboBoxArrivalBerth.SelectedItem).Id : null; this.ShipcallModel.Shipcall.ArrivalBerthId = (this.comboBoxArrivalBerth.SelectedItem != null) ? ((Berth)this.comboBoxArrivalBerth.SelectedItem).Id : null;
this.ShipcallModel.Shipcall.DepartureBerthId = (this.comboBoxDepartureBerth.SelectedItem != null) ? ((Berth)this.comboBoxDepartureBerth.SelectedItem).Id : null; this.ShipcallModel.Shipcall.DepartureBerthId = (this.comboBoxDepartureBerth.SelectedItem != null) ? ((Berth)this.comboBoxDepartureBerth.SelectedItem).Id : null;
} }
else // shifting else // shifting
{ {
this.ShipcallModel.Shipcall.DepartureBerthId = (this.comboBoxArrivalBerth.SelectedItem != null) ? ((Berth)this.comboBoxArrivalBerth.SelectedItem).Id : null; this.ShipcallModel.Shipcall.DepartureBerthId = (this.comboBoxArrivalBerth.SelectedItem != null) ? ((Berth)this.comboBoxArrivalBerth.SelectedItem).Id : null;
@ -270,11 +270,11 @@ namespace BreCalClient
ParticipantAssignment pa = new() ParticipantAssignment pa = new()
{ {
ParticipantId = participant.Id, ParticipantId = participant.Id,
Type = (int)Extensions.ParticipantType.AGENCY Type = (int)Extensions.ParticipantType.AGENCY
}; };
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.AGENCY] = pa; this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.AGENCY] = pa;
} }
else else
{ {
// AGENCY was set before and now is set to nothing // AGENCY was set before and now is set to nothing
@ -351,7 +351,7 @@ namespace BreCalClient
} }
if (this.ShipcallModel.Shipcall.Participants == null) this.ShipcallModel.Shipcall.Participants = new(); if (this.ShipcallModel.Shipcall.Participants == null) this.ShipcallModel.Shipcall.Participants = new();
if(this.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY)) if(this.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY))
{ {
if (BreCalLists.ParticipantLookupDict.ContainsKey(this.ShipcallModel.AssignedParticipants[ParticipantType.AGENCY].ParticipantId)) if (BreCalLists.ParticipantLookupDict.ContainsKey(this.ShipcallModel.AssignedParticipants[ParticipantType.AGENCY].ParticipantId))
@ -363,6 +363,7 @@ namespace BreCalClient
if (BreCalLists.PortLookupDict.ContainsKey(this.ShipcallModel.Shipcall.PortId)) if (BreCalLists.PortLookupDict.ContainsKey(this.ShipcallModel.Shipcall.PortId))
this.comboBoxHarbour.SelectedValue = this.ShipcallModel.Shipcall.PortId; this.comboBoxHarbour.SelectedValue = this.ShipcallModel.Shipcall.PortId;
this.comboBoxHarbour.IsEnabled = this.ShipcallModel.AllowPortChange;
} }
} }
@ -422,7 +423,7 @@ namespace BreCalClient
private void comboBoxDepartureBerth_SelectionChanged(object sender, SelectionChangedEventArgs e) private void comboBoxDepartureBerth_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
this.CheckForCompletion(); this.CheckForCompletion();
} }
private void buttonEditShips_Click(object sender, RoutedEventArgs e) private void buttonEditShips_Click(object sender, RoutedEventArgs e)
{ {
@ -430,7 +431,7 @@ namespace BreCalClient
{ {
ShipApi = this.ShipApi ShipApi = this.ShipApi
}; };
shipListDialog.ShowDialog(); shipListDialog.ShowDialog();
// reload combobox // reload combobox

View File

@ -289,6 +289,7 @@ namespace BreCalClient
scmOut.Shipcall.ShipId = esc.ShipcallModel.Shipcall.ShipId; scmOut.Shipcall.ShipId = esc.ShipcallModel.Shipcall.ShipId;
scmOut.Shipcall.PortId = esc.ShipcallModel.Shipcall.PortId; scmOut.Shipcall.PortId = esc.ShipcallModel.Shipcall.PortId;
scmOut.Ship = esc.ShipcallModel.Ship; scmOut.Ship = esc.ShipcallModel.Ship;
scmOut.AllowPortChange = false;
DateTime eta = esc.ShipcallModel.Shipcall?.Eta ?? DateTime.Now; DateTime eta = esc.ShipcallModel.Shipcall?.Eta ?? DateTime.Now;
scmOut.Shipcall.Etd = eta.AddDays(2); scmOut.Shipcall.Etd = eta.AddDays(2);
scmOut.Shipcall.DepartureBerthId = esc.ShipcallModel.Shipcall?.ArrivalBerthId; scmOut.Shipcall.DepartureBerthId = esc.ShipcallModel.Shipcall?.ArrivalBerthId;

View File

@ -118,6 +118,8 @@ namespace BreCalClient
} }
} }
public bool AllowPortChange { get; set; } = true;
#endregion #endregion
#region public methods #region public methods