Draft is now a required field.

There is now logic in each agent window that checks the required fields if they
change and enable the OK button accordingly
This commit is contained in:
Daniel Schick 2024-03-28 11:14:32 +01:00
parent a845135650
commit 87eaf124d9
10 changed files with 211 additions and 91 deletions

View File

@ -44,9 +44,9 @@
</Grid> </Grid>
<Label Content="ETA" x:Name="labelETA" Grid.Column="0" Grid.Row="1" HorizontalContentAlignment="Right" FontWeight="Bold"/> <Label Content="ETA" x:Name="labelETA" Grid.Column="0" Grid.Row="1" HorizontalContentAlignment="Right" FontWeight="Bold"/>
<xctk:DateTimePicker x:Name="datePickerETA" Grid.Column="1" Grid.Row="1" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm"/> <xctk:DateTimePicker x:Name="datePickerETA" Grid.Column="1" Grid.Row="1" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm" ValueChanged="datePickerETA_ValueChanged"/>
<Label Content="{x:Static p:Resources.textBerth}" Grid.Column="0" Grid.Row="2" HorizontalContentAlignment="Right" FontWeight="Bold"/> <Label Content="{x:Static p:Resources.textBerth}" Grid.Column="0" Grid.Row="2" HorizontalContentAlignment="Right" FontWeight="Bold"/>
<ComboBox Name="comboBoxArrivalBerth" Grid.Column="1" Grid.Row="2" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id"> <ComboBox Name="comboBoxArrivalBerth" Grid.Column="1" Grid.Row="2" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id" SelectionChanged="comboBoxArrivalBerth_SelectionChanged">
</ComboBox> </ComboBox>
<Label Content="{x:Static p:Resources.textPierside}" Grid.Column="0" Grid.Row="3" HorizontalContentAlignment="Right" /> <Label Content="{x:Static p:Resources.textPierside}" Grid.Column="0" Grid.Row="3" HorizontalContentAlignment="Right" />
@ -61,8 +61,8 @@
</ComboBox> </ComboBox>
<Label Content="{x:Static p:Resources.textBerthRemarks}" Grid.Column="0" Grid.Row="4" HorizontalContentAlignment="Right" /> <Label Content="{x:Static p:Resources.textBerthRemarks}" Grid.Column="0" Grid.Row="4" HorizontalContentAlignment="Right" />
<TextBox x:Name="textBoxBerthRemarks" Grid.Column="1" Grid.Row="4" Margin="2" Grid.RowSpan="2" VerticalContentAlignment="Top" AcceptsReturn="True" MaxLength="512"/> <TextBox x:Name="textBoxBerthRemarks" Grid.Column="1" Grid.Row="4" Margin="2" Grid.RowSpan="2" VerticalContentAlignment="Top" AcceptsReturn="True" MaxLength="512"/>
<Label Content="{x:Static p:Resources.textDraft}" Grid.Column="0" Grid.Row="6" HorizontalContentAlignment="Right" /> <Label Content="{x:Static p:Resources.textDraft}" Grid.Column="0" Grid.Row="6" HorizontalContentAlignment="Right" FontWeight="Bold" />
<xctk:DoubleUpDown x:Name="doubleUpDownDraft" Grid.Column="1" Grid.Row="6" Margin="2" FormatString="N2" Minimum="0" Maximum="50" MaxLength="5"/> <xctk:DoubleUpDown x:Name="doubleUpDownDraft" Grid.Column="1" Grid.Row="6" Margin="2" FormatString="N2" Minimum="0" Maximum="50" MaxLength="5" ValueChanged="doubleUpDownDraft_ValueChanged"/>
<Label Content="{x:Static p:Resources.textTidalWindow}" FontWeight="DemiBold" Grid.Column="0" Grid.Row="7" HorizontalContentAlignment="Right"/> <Label Content="{x:Static p:Resources.textTidalWindow}" FontWeight="DemiBold" Grid.Column="0" Grid.Row="7" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textFrom}" Grid.Column="0" Grid.Row="8" HorizontalContentAlignment="Right"/> <Label Content="{x:Static p:Resources.textFrom}" Grid.Column="0" Grid.Row="8" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textTo}" Grid.Column="0" Grid.Row="9" HorizontalContentAlignment="Right"/> <Label Content="{x:Static p:Resources.textTo}" Grid.Column="0" Grid.Row="9" HorizontalContentAlignment="Right"/>

View File

@ -14,6 +14,12 @@ namespace BreCalClient
/// </summary> /// </summary>
public partial class EditTimesAgencyIncomingControl : Window, IEditTimesControl public partial class EditTimesAgencyIncomingControl : Window, IEditTimesControl
{ {
#region Fields
bool _editing = false;
#endregion
#region Construction #region Construction
public EditTimesAgencyIncomingControl() public EditTimesAgencyIncomingControl()
@ -55,10 +61,10 @@ namespace BreCalClient
allowBSMD = p.IsFlagSet(ParticipantFlag.ALLOW_BSMD); allowBSMD = p.IsFlagSet(ParticipantFlag.ALLOW_BSMD);
} }
bool enableControls = (this.Times.ParticipantId == App.Participant.Id) || _editing = (this.Times.ParticipantId == App.Participant.Id) ||
(App.Participant.IsTypeFlagSet(ParticipantType.BSMD) && allowBSMD); (App.Participant.IsTypeFlagSet(ParticipantType.BSMD) && allowBSMD);
this.EnableControls(enableControls); this.EnableControls();
} }
@ -240,37 +246,50 @@ namespace BreCalClient
} }
} }
private void EnableControls(bool isEnabled) private void EnableControls()
{ {
this.datePickerETA.IsEnabled = isEnabled; this.datePickerETA.IsEnabled = _editing;
this.comboBoxArrivalBerth.IsEnabled = isEnabled; this.comboBoxArrivalBerth.IsEnabled = _editing;
this.comboBoxPierside.IsEnabled = isEnabled; this.comboBoxPierside.IsEnabled = _editing;
this.textBoxBerthRemarks.IsEnabled = isEnabled; this.textBoxBerthRemarks.IsEnabled = _editing;
this.doubleUpDownDraft.IsEnabled = isEnabled; this.doubleUpDownDraft.IsEnabled = _editing;
this.datePickerTidalWindowFrom.IsEnabled = isEnabled; this.datePickerTidalWindowFrom.IsEnabled = _editing;
this.datePickerTidalWindowTo.IsEnabled = isEnabled; this.datePickerTidalWindowTo.IsEnabled = _editing;
this.checkBoxCanceled.IsEnabled = isEnabled; this.checkBoxCanceled.IsEnabled = _editing;
this.checkBoxAnchored.IsEnabled = isEnabled; this.checkBoxAnchored.IsEnabled = _editing;
this.comboBoxTug.IsEnabled = isEnabled; this.comboBoxTug.IsEnabled = _editing;
this.integerUpDownRecommendedTugs.IsEnabled = isEnabled; this.integerUpDownRecommendedTugs.IsEnabled = _editing;
this.comboBoxPilot.IsEnabled = isEnabled; this.comboBoxPilot.IsEnabled = _editing;
this.comboBoxMooring.IsEnabled = isEnabled; this.comboBoxMooring.IsEnabled = _editing;
this.checkBoxMooredLock.IsEnabled = isEnabled; this.checkBoxMooredLock.IsEnabled = _editing;
this.comboBoxTerminal.IsEnabled = isEnabled; this.comboBoxTerminal.IsEnabled = _editing;
this.checkBoxBunkering.IsEnabled = isEnabled; this.checkBoxBunkering.IsEnabled = _editing;
this.checkBoxReplenishingTerminal.IsEnabled = isEnabled; this.checkBoxReplenishingTerminal.IsEnabled = _editing;
this.checkBoxReplenishingLock.IsEnabled = isEnabled; this.checkBoxReplenishingLock.IsEnabled = _editing;
this.textBoxRemarks.IsEnabled = isEnabled; this.textBoxRemarks.IsEnabled = _editing;
this.buttonOK.IsEnabled = isEnabled; CheckOKButton();
}
private bool RequiredFieldsSet()
{
bool areSet = this.datePickerETA.Value.HasValue &&
this.doubleUpDownDraft.Value.HasValue &&
this.comboBoxArrivalBerth.SelectedIndex >= 0;
return areSet;
}
private void CheckOKButton()
{
this.buttonOK.IsEnabled = _editing && RequiredFieldsSet();
} }
#endregion #endregion
#region context menu handlers #region event handlers
private void contextMenuItemArrivalBerth_Click(object sender, RoutedEventArgs e) private void contextMenuItemArrivalBerth_Click(object sender, RoutedEventArgs e)
{ {
@ -305,6 +324,21 @@ namespace BreCalClient
private void contextMenuItemClearPierside_Click(object sender, RoutedEventArgs e) private void contextMenuItemClearPierside_Click(object sender, RoutedEventArgs e)
{ {
this.comboBoxPierside.SelectedIndex = -1; this.comboBoxPierside.SelectedIndex = -1;
}
private void doubleUpDownDraft_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
this.CheckOKButton();
}
private void datePickerETA_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
this.CheckOKButton();
}
private void comboBoxArrivalBerth_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
this.CheckOKButton();
} }
#endregion #endregion

View File

@ -40,10 +40,9 @@
</Grid> </Grid>
<Label Content="ETD" x:Name="labelETD" Grid.Column="0" Grid.Row="1" HorizontalContentAlignment="Right" FontWeight="Bold"/> <Label Content="ETD" x:Name="labelETD" Grid.Column="0" Grid.Row="1" HorizontalContentAlignment="Right" FontWeight="Bold"/>
<xctk:DateTimePicker x:Name="datePickerETD" Grid.Column="1" Grid.Row="1" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm"/> <xctk:DateTimePicker x:Name="datePickerETD" Grid.Column="1" Grid.Row="1" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm" ValueChanged="datePickerETD_ValueChanged"/>
<Label Content="{x:Static p:Resources.textBerth}" Grid.Column="0" Grid.Row="2" HorizontalContentAlignment="Right" FontWeight="Bold"/> <Label Content="{x:Static p:Resources.textBerth}" Grid.Column="0" Grid.Row="2" HorizontalContentAlignment="Right" FontWeight="Bold"/>
<ComboBox Name="comboBoxDepartureBerth" Grid.Column="1" Grid.Row="2" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id"> <ComboBox Name="comboBoxDepartureBerth" Grid.Column="1" Grid.Row="2" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id" SelectionChanged="comboBoxDepartureBerth_SelectionChanged" />
</ComboBox>
<Label Content="{x:Static p:Resources.textPierside}" Grid.Column="0" Grid.Row="3" HorizontalContentAlignment="Right" /> <Label Content="{x:Static p:Resources.textPierside}" Grid.Column="0" Grid.Row="3" HorizontalContentAlignment="Right" />
<ComboBox x:Name="comboBoxPierside" Grid.Column="1" Grid.Row="3" Margin="2" > <ComboBox x:Name="comboBoxPierside" Grid.Column="1" Grid.Row="3" Margin="2" >
<ComboBoxItem Content="{x:Static p:Resources.textPort}" /> <ComboBoxItem Content="{x:Static p:Resources.textPort}" />
@ -56,8 +55,8 @@
</ComboBox> </ComboBox>
<Label Content="{x:Static p:Resources.textBerthRemarks}" Grid.Column="0" Grid.Row="4" HorizontalContentAlignment="Right" /> <Label Content="{x:Static p:Resources.textBerthRemarks}" Grid.Column="0" Grid.Row="4" HorizontalContentAlignment="Right" />
<TextBox x:Name="textBoxBerthRemarks" Grid.Column="1" Grid.Row="4" Margin="2" Grid.RowSpan="2" VerticalContentAlignment="Top" AcceptsReturn="True" MaxLength="512"/> <TextBox x:Name="textBoxBerthRemarks" Grid.Column="1" Grid.Row="4" Margin="2" Grid.RowSpan="2" VerticalContentAlignment="Top" AcceptsReturn="True" MaxLength="512"/>
<Label Content="{x:Static p:Resources.textDraft}" Grid.Column="0" Grid.Row="6" HorizontalContentAlignment="Right" /> <Label Content="{x:Static p:Resources.textDraft}" Grid.Column="0" Grid.Row="6" HorizontalContentAlignment="Right" FontWeight="Bold"/>
<xctk:DoubleUpDown x:Name="doubleUpDownDraft" Grid.Column="1" Grid.Row="6" Margin="2" FormatString="N2" Minimum="0" Maximum="50" MaxLength="5"/> <xctk:DoubleUpDown x:Name="doubleUpDownDraft" Grid.Column="1" Grid.Row="6" Margin="2" FormatString="N2" Minimum="0" Maximum="50" MaxLength="5" ValueChanged="doubleUpDownDraft_ValueChanged"/>
<Label Content="{x:Static p:Resources.textTidalWindow}" FontWeight="DemiBold" Grid.Column="0" Grid.Row="7" HorizontalContentAlignment="Right"/> <Label Content="{x:Static p:Resources.textTidalWindow}" FontWeight="DemiBold" Grid.Column="0" Grid.Row="7" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textFrom}" Grid.Column="0" Grid.Row="8" HorizontalContentAlignment="Right"/> <Label Content="{x:Static p:Resources.textFrom}" Grid.Column="0" Grid.Row="8" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textTo}" Grid.Column="0" Grid.Row="9" HorizontalContentAlignment="Right"/> <Label Content="{x:Static p:Resources.textTo}" Grid.Column="0" Grid.Row="9" HorizontalContentAlignment="Right"/>

View File

@ -15,6 +15,12 @@ namespace BreCalClient
public partial class EditTimesAgencyOutgoingControl : Window, IEditTimesControl public partial class EditTimesAgencyOutgoingControl : Window, IEditTimesControl
{ {
#region Fields
bool _editing = false;
#endregion
#region Construction #region Construction
public EditTimesAgencyOutgoingControl() public EditTimesAgencyOutgoingControl()
@ -56,10 +62,10 @@ namespace BreCalClient
allowBSMD = p.IsFlagSet(ParticipantFlag.ALLOW_BSMD); allowBSMD = p.IsFlagSet(ParticipantFlag.ALLOW_BSMD);
} }
bool enableControls = (this.Times.ParticipantId == App.Participant.Id) || _editing = (this.Times.ParticipantId == App.Participant.Id) ||
(App.Participant.IsTypeFlagSet(ParticipantType.BSMD) && allowBSMD); (App.Participant.IsTypeFlagSet(ParticipantType.BSMD) && allowBSMD);
this.EnableControls(enableControls); this.EnableControls();
} }
@ -232,33 +238,46 @@ namespace BreCalClient
} }
} }
private void EnableControls(bool isEnabled) private void EnableControls()
{ {
this.datePickerETD.IsEnabled = isEnabled; this.datePickerETD.IsEnabled = _editing;
this.comboBoxDepartureBerth.IsEnabled = isEnabled; this.comboBoxDepartureBerth.IsEnabled = _editing;
this.comboBoxPierside.IsEnabled = isEnabled; this.comboBoxPierside.IsEnabled = _editing;
this.textBoxBerthRemarks.IsEnabled = isEnabled; this.textBoxBerthRemarks.IsEnabled = _editing;
this.doubleUpDownDraft.IsEnabled = isEnabled; this.doubleUpDownDraft.IsEnabled = _editing;
this.datePickerTidalWindowFrom.IsEnabled = isEnabled; this.datePickerTidalWindowFrom.IsEnabled = _editing;
this.datePickerTidalWindowTo.IsEnabled = isEnabled; this.datePickerTidalWindowTo.IsEnabled = _editing;
this.checkBoxCanceled.IsEnabled = isEnabled; this.checkBoxCanceled.IsEnabled = _editing;
this.comboBoxTug.IsEnabled = isEnabled; this.comboBoxTug.IsEnabled = _editing;
this.integerUpDownRecommendedTugs.IsEnabled = isEnabled; this.integerUpDownRecommendedTugs.IsEnabled = _editing;
this.comboBoxPilot.IsEnabled = isEnabled; this.comboBoxPilot.IsEnabled = _editing;
this.comboBoxMooring.IsEnabled = isEnabled; this.comboBoxMooring.IsEnabled = _editing;
this.checkBoxMooredLock.IsEnabled = isEnabled; this.checkBoxMooredLock.IsEnabled = _editing;
this.comboBoxTerminal.IsEnabled = isEnabled; this.comboBoxTerminal.IsEnabled = _editing;
this.checkBoxRainsensitiveCargo.IsEnabled = isEnabled; this.checkBoxRainsensitiveCargo.IsEnabled = _editing;
this.textBoxRemarks.IsEnabled = isEnabled; this.textBoxRemarks.IsEnabled = _editing;
this.buttonOK.IsEnabled = isEnabled; CheckOKButton();
}
private bool RequiredFieldsSet()
{
bool areSet = this.datePickerETD.Value.HasValue &&
this.doubleUpDownDraft.Value.HasValue &&
this.comboBoxDepartureBerth.SelectedIndex >= 0;
return areSet;
}
private void CheckOKButton()
{
this.buttonOK.IsEnabled = _editing && RequiredFieldsSet();
} }
#endregion #endregion
#region context menu handlers #region event handlers
private void contextMenuItemClearTug_Click(object sender, RoutedEventArgs e) private void contextMenuItemClearTug_Click(object sender, RoutedEventArgs e)
{ {
@ -293,6 +312,21 @@ namespace BreCalClient
private void contextMenuItemClearPierside_Click(object sender, RoutedEventArgs e) private void contextMenuItemClearPierside_Click(object sender, RoutedEventArgs e)
{ {
this.comboBoxPierside.SelectedIndex = -1; this.comboBoxPierside.SelectedIndex = -1;
}
private void datePickerETD_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
CheckOKButton();
}
private void comboBoxDepartureBerth_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
CheckOKButton();
}
private void doubleUpDownDraft_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
CheckOKButton();
} }
#endregion #endregion

View File

@ -45,7 +45,7 @@
<Image Margin="2" Grid.Column="1" Source="Resources/arrow_right_green.png" /> <Image Margin="2" Grid.Column="1" Source="Resources/arrow_right_green.png" />
</Grid> </Grid>
<Label Content="ETD" x:Name="labelETD" Grid.Column="0" Grid.Row="1" HorizontalContentAlignment="Right" FontWeight="Bold"/> <Label Content="ETD" x:Name="labelETD" Grid.Column="0" Grid.Row="1" HorizontalContentAlignment="Right" FontWeight="Bold"/>
<xctk:DateTimePicker x:Name="datePickerETD" Grid.Column="1" Grid.Row="1" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm"/> <xctk:DateTimePicker x:Name="datePickerETD" Grid.Column="1" Grid.Row="1" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm" ValueChanged="datePickerETD_ValueChanged"/>
<Label Content="{x:Static p:Resources.textTerminal}" Grid.Column="0" Grid.Row="2" HorizontalContentAlignment="Right"/> <Label Content="{x:Static p:Resources.textTerminal}" Grid.Column="0" Grid.Row="2" HorizontalContentAlignment="Right"/>
<ComboBox Name="comboBoxTerminal" Grid.Column="1" Grid.Row="2" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id"> <ComboBox Name="comboBoxTerminal" Grid.Column="1" Grid.Row="2" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id">
@ -57,11 +57,11 @@
</ComboBox> </ComboBox>
<Label Content="{x:Static p:Resources.textBerth}" Grid.Column="0" Grid.Row="3" HorizontalContentAlignment="Right" FontWeight="Bold"/> <Label Content="{x:Static p:Resources.textBerth}" Grid.Column="0" Grid.Row="3" HorizontalContentAlignment="Right" FontWeight="Bold"/>
<ComboBox Name="comboBoxDepartureBerth" Grid.Column="1" Grid.Row="3" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id"> <ComboBox Name="comboBoxDepartureBerth" Grid.Column="1" Grid.Row="3" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id" SelectionChanged="comboBoxDepartureBerth_SelectionChanged">
</ComboBox> </ComboBox>
<Label Content="{x:Static p:Resources.textDraft}" Grid.Column="0" Grid.Row="4" HorizontalContentAlignment="Right" /> <Label Content="{x:Static p:Resources.textDraft}" Grid.Column="0" Grid.Row="4" HorizontalContentAlignment="Right" FontWeight="Bold"/>
<xctk:DoubleUpDown x:Name="doubleUpDownDraft" Grid.Column="1" Grid.Row="4" Margin="2" FormatString="N2" Minimum="0" Maximum="50" MaxLength="5"/> <xctk:DoubleUpDown x:Name="doubleUpDownDraft" Grid.Column="1" Grid.Row="4" Margin="2" FormatString="N2" Minimum="0" Maximum="50" MaxLength="5" ValueChanged="doubleUpDownDraft_ValueChanged"/>
<Label Content="{x:Static p:Resources.textTidalWindow}" FontWeight="DemiBold" Grid.Column="0" Grid.Row="5" HorizontalContentAlignment="Right"/> <Label Content="{x:Static p:Resources.textTidalWindow}" FontWeight="DemiBold" Grid.Column="0" Grid.Row="5" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textFrom}" Grid.Column="0" Grid.Row="6" HorizontalContentAlignment="Right"/> <Label Content="{x:Static p:Resources.textFrom}" Grid.Column="0" Grid.Row="6" HorizontalContentAlignment="Right"/>
<Label Content="{x:Static p:Resources.textTo}" Grid.Column="0" Grid.Row="7" HorizontalContentAlignment="Right"/> <Label Content="{x:Static p:Resources.textTo}" Grid.Column="0" Grid.Row="7" HorizontalContentAlignment="Right"/>
@ -76,11 +76,10 @@
<Image Margin="2" Grid.Column="1" Source="Resources/arrow_right_green.png" /> <Image Margin="2" Grid.Column="1" Source="Resources/arrow_right_green.png" />
</Grid> </Grid>
<Label Content="ETA" x:Name="labelETA" Grid.Column="0" Grid.Row="9" HorizontalContentAlignment="Right" FontWeight="Bold"/> <Label Content="ETA" x:Name="labelETA" Grid.Column="0" Grid.Row="9" HorizontalContentAlignment="Right" FontWeight="Bold"/>
<xctk:DateTimePicker x:Name="datePickerETA" Grid.Column="1" Grid.Row="9" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm"/> <xctk:DateTimePicker x:Name="datePickerETA" Grid.Column="1" Grid.Row="9" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm" ValueChanged="datePickerETA_ValueChanged"/>
<Label Content="{x:Static p:Resources.textBerth}" Grid.Column="0" Grid.Row="10" HorizontalContentAlignment="Right" FontWeight="Bold"/> <Label Content="{x:Static p:Resources.textBerth}" Grid.Column="0" Grid.Row="10" HorizontalContentAlignment="Right" FontWeight="Bold"/>
<ComboBox Name="comboBoxArrivalBerth" Grid.Column="1" Grid.Row="10" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id"> <ComboBox Name="comboBoxArrivalBerth" Grid.Column="1" Grid.Row="10" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id" SelectionChanged="comboBoxArrivalBerth_SelectionChanged" />
</ComboBox>
<Label Content="{x:Static p:Resources.textPierside}" Grid.Column="0" Grid.Row="11" HorizontalContentAlignment="Right" /> <Label Content="{x:Static p:Resources.textPierside}" Grid.Column="0" Grid.Row="11" HorizontalContentAlignment="Right" />
<ComboBox x:Name="comboBoxPiersideArrival" Grid.Column="1" Grid.Row="11" Margin="2" > <ComboBox x:Name="comboBoxPiersideArrival" Grid.Column="1" Grid.Row="11" Margin="2" >
<ComboBoxItem Content="{x:Static p:Resources.textPort}" /> <ComboBoxItem Content="{x:Static p:Resources.textPort}" />

View File

@ -14,6 +14,11 @@ namespace BreCalClient
/// </summary> /// </summary>
public partial class EditTimesAgencyShiftingControl : Window, IEditTimesControl public partial class EditTimesAgencyShiftingControl : Window, IEditTimesControl
{ {
#region Fields
bool _editing = false;
#endregion
#region Construction #region Construction
@ -57,10 +62,10 @@ namespace BreCalClient
allowBSMD = p.IsFlagSet(ParticipantFlag.ALLOW_BSMD); allowBSMD = p.IsFlagSet(ParticipantFlag.ALLOW_BSMD);
} }
bool enableControls = (this.Times.ParticipantId == App.Participant.Id) || _editing = (this.Times.ParticipantId == App.Participant.Id) ||
(App.Participant.IsTypeFlagSet(ParticipantType.BSMD) && allowBSMD); (App.Participant.IsTypeFlagSet(ParticipantType.BSMD) && allowBSMD);
this.EnableControls(enableControls); this.EnableControls();
} }
@ -247,35 +252,50 @@ namespace BreCalClient
} }
} }
private void EnableControls(bool isEnabled) private void EnableControls()
{ {
this.datePickerETD.IsEnabled = isEnabled; this.datePickerETD.IsEnabled = _editing;
this.comboBoxArrivalBerth.IsEnabled = isEnabled; this.comboBoxArrivalBerth.IsEnabled = _editing;
this.doubleUpDownDraft.IsEnabled = isEnabled; this.doubleUpDownDraft.IsEnabled = _editing;
this.datePickerTidalWindowFrom.IsEnabled = isEnabled; this.datePickerTidalWindowFrom.IsEnabled = _editing;
this.datePickerTidalWindowTo.IsEnabled = isEnabled; this.datePickerTidalWindowTo.IsEnabled = _editing;
this.datePickerETA.IsEnabled = isEnabled; this.datePickerETA.IsEnabled = _editing;
this.comboBoxDepartureBerth.IsEnabled = isEnabled; this.comboBoxDepartureBerth.IsEnabled = _editing;
this.comboBoxPiersideArrival.IsEnabled = isEnabled; this.comboBoxPiersideArrival.IsEnabled = _editing;
this.textBoxBerthRemarksArrival.IsEnabled = isEnabled; this.textBoxBerthRemarksArrival.IsEnabled = _editing;
this.checkBoxCanceled.IsEnabled = isEnabled; this.checkBoxCanceled.IsEnabled = _editing;
this.comboBoxTug.IsEnabled = isEnabled; this.comboBoxTug.IsEnabled = _editing;
this.integerUpDownRecommendedTugs.IsEnabled = isEnabled; this.integerUpDownRecommendedTugs.IsEnabled = _editing;
this.comboBoxPilot.IsEnabled = isEnabled; this.comboBoxPilot.IsEnabled = _editing;
this.comboBoxMooring.IsEnabled = isEnabled; this.comboBoxMooring.IsEnabled = _editing;
this.checkBoxMooredLock.IsEnabled = isEnabled; this.checkBoxMooredLock.IsEnabled = _editing;
this.comboBoxTerminal.IsEnabled = isEnabled; this.comboBoxTerminal.IsEnabled = _editing;
this.checkBoxRainsensitiveCargo.IsEnabled = isEnabled; this.checkBoxRainsensitiveCargo.IsEnabled = _editing;
this.textBoxRemarks.IsEnabled = isEnabled; this.textBoxRemarks.IsEnabled = _editing;
this.buttonOK.IsEnabled = isEnabled; CheckOKButton();
}
private bool RequiredFieldsSet()
{
bool areSet = this.datePickerETA.Value.HasValue &&
this.datePickerETD.Value.HasValue &&
this.doubleUpDownDraft.Value.HasValue &&
(this.comboBoxArrivalBerth.SelectedIndex >= 0) &&
(this.comboBoxDepartureBerth.SelectedIndex >= 0);
return areSet;
}
private void CheckOKButton()
{
this.buttonOK.IsEnabled = _editing && RequiredFieldsSet();
} }
#endregion #endregion
#region context menu handlers #region event handlers
private void contextMenuItemDepartureBerth_Click(object sender, RoutedEventArgs e) private void contextMenuItemDepartureBerth_Click(object sender, RoutedEventArgs e)
{ {
@ -316,6 +336,31 @@ namespace BreCalClient
private void contextMenuItemClearPierside_Click(object sender, RoutedEventArgs e) private void contextMenuItemClearPierside_Click(object sender, RoutedEventArgs e)
{ {
this.comboBoxPiersideArrival.SelectedIndex = -1; this.comboBoxPiersideArrival.SelectedIndex = -1;
}
private void datePickerETD_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
CheckOKButton();
}
private void comboBoxDepartureBerth_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
CheckOKButton();
}
private void doubleUpDownDraft_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
CheckOKButton();
}
private void datePickerETA_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
CheckOKButton();
}
private void comboBoxArrivalBerth_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
CheckOKButton();
} }
#endregion #endregion

View File

@ -498,7 +498,7 @@ namespace BreCalClient
{ {
ShipcallControl sc = new() ShipcallControl sc = new()
{ {
Height = 120, Height = 135,
ShipcallControlModel = scm ShipcallControlModel = scm
}; };
sc.EditTimesRequested += Sc_EditTimesRequested; sc.EditTimesRequested += Sc_EditTimesRequested;

View File

@ -218,7 +218,7 @@
<value>Zeitraum</value> <value>Zeitraum</value>
</data> </data>
<data name="textLengthWidth" xml:space="preserve"> <data name="textLengthWidth" xml:space="preserve">
<value>L/B</value> <value>L/B (m)</value>
</data> </data>
<data name="textLogin" xml:space="preserve"> <data name="textLogin" xml:space="preserve">
<value>Anmelden</value> <value>Anmelden</value>

View File

@ -7,7 +7,7 @@
xmlns:sets="clr-namespace:BreCalClient.Properties" xmlns:sets="clr-namespace:BreCalClient.Properties"
xmlns:db="clr-namespace:BreCalClient;assembly=BreCalDevelClient" xmlns:db="clr-namespace:BreCalClient;assembly=BreCalDevelClient"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="120" d:DesignWidth="800" Loaded="UserControl_Loaded"> d:DesignHeight="135" d:DesignWidth="800" Loaded="UserControl_Loaded">
<Border BorderBrush="LightGray" Margin="1" BorderThickness="1"> <Border BorderBrush="LightGray" Margin="1" BorderThickness="1">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@ -30,7 +30,7 @@
<RowDefinition Height=".125*"/> <RowDefinition Height=".125*"/>
<RowDefinition Height=".125*"/> <RowDefinition Height=".125*"/>
<RowDefinition Height=".05*"/> <RowDefinition Height=".125*"/>
<RowDefinition Height=".125*"/> <RowDefinition Height=".125*"/>
<RowDefinition Height=".125*"/> <RowDefinition Height=".125*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
@ -71,6 +71,12 @@
<Viewbox Grid.Row="3" Grid.Column="1" HorizontalAlignment="Left"> <Viewbox Grid.Row="3" Grid.Column="1" HorizontalAlignment="Left">
<TextBlock x:Name="textBlockLengthWidth" Padding="0"/> <TextBlock x:Name="textBlockLengthWidth" Padding="0"/>
</Viewbox> </Viewbox>
<Viewbox Grid.Row="4" Grid.Column="0" HorizontalAlignment="Left">
<TextBlock Text="{x:Static p:Resources.textDraft}" Padding="0" />
</Viewbox>
<Viewbox Grid.Row="4" Grid.Column="1" HorizontalAlignment="Left">
<TextBlock x:Name="textBlockDraft" Padding="0"/>
</Viewbox>
<Viewbox Grid.Row="5" Grid.Column="0" HorizontalAlignment="Left"> <Viewbox Grid.Row="5" Grid.Column="0" HorizontalAlignment="Left">
<TextBlock Text="ETA" x:Name="labelETA"/> <TextBlock Text="ETA" x:Name="labelETA"/>
</Viewbox> </Viewbox>

View File

@ -78,6 +78,7 @@ namespace BreCalClient
this.labelAgencyETAETDValue.Content = ""; this.labelAgencyETAETDValue.Content = "";
this.textBlockAgencyRemarks.Text = ""; this.textBlockAgencyRemarks.Text = "";
this.textBlockAgencyBerthRemarks.Text = ""; this.textBlockAgencyBerthRemarks.Text = "";
this.textBlockDraft.Text = "";
} }
_mooring = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.MOORING); _mooring = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.MOORING);
@ -306,14 +307,15 @@ namespace BreCalClient
Times? agencyTimes = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.AGENCY); Times? agencyTimes = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.AGENCY);
if (agencyTimes != null) if (agencyTimes != null)
{ {
this.labelAgencyBerth.Content = this.ShipcallControlModel?.GetBerthText(agencyTimes); this.labelAgencyBerth.Content = this.ShipcallControlModel?.GetBerthText(agencyTimes);
this.labelAgencyETAETDValue.Content = agencyTimes.EtaBerth.HasValue ? agencyTimes.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; this.labelAgencyETAETDValue.Content = agencyTimes.EtaBerth.HasValue ? agencyTimes.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockAgencyRemarks.Text = agencyTimes.Remarks; this.textBlockAgencyRemarks.Text = agencyTimes.Remarks;
this.textBlockAgencyBerthRemarks.Text = agencyTimes.BerthInfo; this.textBlockAgencyBerthRemarks.Text = agencyTimes.BerthInfo;
if (this.ShipcallControlModel?.Shipcall?.Type != ShipcallType.Arrival) if (this.ShipcallControlModel?.Shipcall?.Type != ShipcallType.Arrival)
{ {
this.labelAgencyETAETDValue.Content = agencyTimes.EtdBerth.HasValue ? agencyTimes.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -"; this.labelAgencyETAETDValue.Content = agencyTimes.EtdBerth.HasValue ? agencyTimes.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
} }
this.textBlockDraft.Text = ShipcallControlModel?.Shipcall?.Draft?.ToString("N2");
} }
else else
{ {
@ -322,6 +324,7 @@ namespace BreCalClient
this.labelAgencyETAETDValue.Content = "- / -"; this.labelAgencyETAETDValue.Content = "- / -";
this.textBlockAgencyRemarks.Text = ""; this.textBlockAgencyRemarks.Text = "";
this.textBlockAgencyBerthRemarks.Text = ""; this.textBlockAgencyBerthRemarks.Text = "";
this.textBlockDraft.Text = "";
} }
Times? mooringTimes = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.MOORING); Times? mooringTimes = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.MOORING);