diff --git a/ENI2/DetailRootControl.xaml.cs b/ENI2/DetailRootControl.xaml.cs
index 85be3bca..82642aef 100644
--- a/ENI2/DetailRootControl.xaml.cs
+++ b/ENI2/DetailRootControl.xaml.cs
@@ -15,7 +15,6 @@ using ENI2.Util;
using ENI2.EditControls;
using System.Windows.Input;
-using Microsoft.Office.Interop.Excel;
using System.Linq;
using ENI2.SheetDisplayControls;
@@ -180,7 +179,7 @@ namespace ENI2
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text1Voyage, MessageGroupControlType = typeof(VoyageControl), ImagePath = "Resources/ship2.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text2PortCall, MessageGroupControlType = typeof(PortControl), ImagePath = "Resources/anchor.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text3PreArrival, MessageGroupControlType = typeof(PreArrivalControl), ImagePath = "Resources/arrow_down_right_red.png" });
-
+ this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text4PreDeparture, MessageGroupControlType = typeof(PreDepartureControl), ImagePath = "Resources/arrow_up_right_green.png" });
}
this.listBoxMessages.ItemsSource = this._listBoxList;
diff --git a/ENI2/ENI2.csproj b/ENI2/ENI2.csproj
index c03fa5dc..036e6652 100644
--- a/ENI2/ENI2.csproj
+++ b/ENI2/ENI2.csproj
@@ -499,6 +499,9 @@
PreArrivalControl.xaml
+
+ PreDepartureControl.xaml
+
VoyageControl.xaml
@@ -819,6 +822,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/ENI2/Properties/Resources.Designer.cs b/ENI2/Properties/Resources.Designer.cs
index ff7479e1..0982619a 100644
--- a/ENI2/Properties/Resources.Designer.cs
+++ b/ENI2/Properties/Resources.Designer.cs
@@ -1082,6 +1082,60 @@ namespace ENI2.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to 4.1 General.
+ ///
+ public static string text41General {
+ get {
+ return ResourceManager.GetString("text41General", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to 4.2 Persons on board on departure.
+ ///
+ public static string text42PersonsOnBoard {
+ get {
+ return ResourceManager.GetString("text42PersonsOnBoard", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to 4.3 Bunker on departure.
+ ///
+ public static string text43BunkerOnDeparture {
+ get {
+ return ResourceManager.GetString("text43BunkerOnDeparture", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to 4.4 Dangerous cargo on board on departure.
+ ///
+ public static string text44DangerousCargo {
+ get {
+ return ResourceManager.GetString("text44DangerousCargo", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to 4.5 Tow (barge, pontoon etc.) on departure.
+ ///
+ public static string text45TowOnDeparture {
+ get {
+ return ResourceManager.GetString("text45TowOnDeparture", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to 4. Pre-departure.
+ ///
+ public static string text4PreDeparture {
+ get {
+ return ResourceManager.GetString("text4PreDeparture", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to About ENI-2.
///
diff --git a/ENI2/Properties/Resources.resx b/ENI2/Properties/Resources.resx
index a1e4a9c6..15929ee0 100644
--- a/ENI2/Properties/Resources.resx
+++ b/ENI2/Properties/Resources.resx
@@ -2026,4 +2026,22 @@
if yes, description of matters to report
+
+ 4. Pre-departure
+
+
+ 4.2 Persons on board on departure
+
+
+ 4.3 Bunker on departure
+
+
+ 4.4 Dangerous cargo on board on departure
+
+
+ 4.5 Tow (barge, pontoon etc.) on departure
+
+
+ 4.1 General
+
\ No newline at end of file
diff --git a/ENI2/SheetDisplayControls/PreArrivalControl.xaml b/ENI2/SheetDisplayControls/PreArrivalControl.xaml
index 3cbe601f..efc5e14f 100644
--- a/ENI2/SheetDisplayControls/PreArrivalControl.xaml
+++ b/ENI2/SheetDisplayControls/PreArrivalControl.xaml
@@ -10,7 +10,7 @@
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:local="clr-namespace:ENI2.SheetDisplayControls"
mc:Ignorable="d"
- d:DesignHeight="2450" d:DesignWidth="800">
+ d:DesignHeight="850" d:DesignWidth="800">
diff --git a/ENI2/SheetDisplayControls/PreArrivalControl.xaml.cs b/ENI2/SheetDisplayControls/PreArrivalControl.xaml.cs
index 467bc0bc..22321246 100644
--- a/ENI2/SheetDisplayControls/PreArrivalControl.xaml.cs
+++ b/ENI2/SheetDisplayControls/PreArrivalControl.xaml.cs
@@ -5,19 +5,9 @@
using bsmd.database;
using ENI2.EditControls;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
namespace ENI2.SheetDisplayControls
{
diff --git a/ENI2/SheetDisplayControls/PreDepartureControl.xaml b/ENI2/SheetDisplayControls/PreDepartureControl.xaml
new file mode 100644
index 00000000..79a5a6ee
--- /dev/null
+++ b/ENI2/SheetDisplayControls/PreDepartureControl.xaml
@@ -0,0 +1,116 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ENI2/SheetDisplayControls/PreDepartureControl.xaml.cs b/ENI2/SheetDisplayControls/PreDepartureControl.xaml.cs
new file mode 100644
index 00000000..8d30ae82
--- /dev/null
+++ b/ENI2/SheetDisplayControls/PreDepartureControl.xaml.cs
@@ -0,0 +1,357 @@
+// Copyright (c) 2025 - schick Informatik
+// Description: Display control of formsheet Tab 4. Pre-Departure
+//
+
+using bsmd.database;
+using ENI2.EditControls;
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media.Imaging;
+
+
+namespace ENI2.SheetDisplayControls
+{
+ ///
+ /// Interaction logic for PreDepartureControl.xaml
+ ///
+ public partial class PreDepartureControl : DetailBaseControl
+ {
+ #region Fields
+
+ private TIEFD _tiefd;
+ private POBD _pobd;
+ private Message _brkaMessage;
+ private Message _brkdMessage;
+ private HAZ _haz;
+ private Message _towaMessage;
+ private Message _towdMessage;
+
+ private bool _ctxInitialized = false;
+
+ #endregion
+
+ #region Construction
+
+ public PreDepartureControl()
+ {
+ InitializeComponent();
+ Loaded += PreDepartureControl_Loaded;
+ }
+
+ #endregion
+
+ #region public override
+
+ public override void Initialize()
+ {
+
+ base.Initialize();
+ foreach (Message aMessage in this.Messages)
+ {
+ if (aMessage.MessageNotificationClass == Message.NotificationClass.TIEFD) { this._tiefd = aMessage.Elements[0] as TIEFD; this.ControlMessages.Add(aMessage); }
+ if (aMessage.MessageNotificationClass == Message.NotificationClass.POBD) { this._pobd = aMessage.Elements[0] as POBD; this.ControlMessages.Add(aMessage); }
+ if (aMessage.MessageNotificationClass == Message.NotificationClass.BKRA) { this._brkaMessage = aMessage; this.ControlMessages.Add(aMessage); }
+ if (aMessage.MessageNotificationClass == Message.NotificationClass.BKRD) { this._brkdMessage = aMessage; this.ControlMessages.Add(aMessage); }
+ if (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) { this._haz = aMessage.Elements[0] as HAZ; this.ControlMessages.Add(aMessage); }
+ if (aMessage.MessageNotificationClass == Message.NotificationClass.TOWA) { this._towaMessage = aMessage; this.ControlMessages.Add(aMessage); }
+ if (aMessage.MessageNotificationClass == Message.NotificationClass.TOWD) { this._towdMessage = aMessage; this.ControlMessages.Add(aMessage); }
+ }
+
+ // 4.1
+ this.doubleUpDownDraught.DataContext = this._tiefd;
+
+ // 4.2
+ this.integerUpDownPersonsOnBoard.DataContext = this._pobd;
+ this.integerUpDownCrewMemberOnBoard.DataContext = this._pobd;
+ this.integerUpDownPassengersOnBoard.DataContext = this._pobd;
+ this.integerUpDownStowawaysOnBoard.DataContext = this._pobd;
+
+ // 4.3
+ this.dataGridBKRD.Initialize();
+ this.dataGridBKRD.ItemsSource = this._brkaMessage.Elements;
+ this.dataGridBKRD.AddingNewItem += DataGridBKRD_AddingNewItem;
+ this.dataGridBKRD.EditRequested += DataGridBKRD_EditRequested;
+ this.dataGridBKRD.DeleteRequested += DataGridBKRD_DeleteRequested;
+ this.dataGridBKRD.CreateRequested += DataGridBKRD_CreateRequested;
+
+ // 4.4
+ this.checkBoxDangerousGoodsOnBoard.DataContext = this._haz;
+
+ // 4.5
+ if (this._towdMessage == null)
+ {
+ this._towdMessage = this.Core.CreateMessage(Message.NotificationClass.TOWD);
+ this.Messages.Add(this._towdMessage);
+ }
+ this.dataGridTowageOnDeparture.Initialize();
+ this.dataGridTowageOnDeparture.ItemsSource = this._towdMessage.Elements;
+ this.dataGridTowageOnDeparture.AddingNewItem += DataGridTowageOnDeparture_AddingNewItem;
+ this.dataGridTowageOnDeparture.EditRequested += DataGridTowageOnDeparture_EditRequested;
+ this.dataGridTowageOnDeparture.DeleteRequested += DataGridTowageOnDeparture_DeleteRequested;
+ this.dataGridTowageOnDeparture.CreateRequested += DataGridTowageOnDeparture_CreateRequested;
+ }
+
+ #endregion
+
+ private void PreDepartureControl_Loaded(object sender, RoutedEventArgs e)
+ {
+ // 4.1
+ this.RegisterDoubleUpDownChange(this.doubleUpDownDraught, Message.NotificationClass.TIEFA);
+
+ // 4.2
+ this.RegisterIntegerUpDownChange(this.integerUpDownCrewMemberOnBoard, Message.NotificationClass.POBD);
+ this.RegisterIntegerUpDownChange(this.integerUpDownPassengersOnBoard, Message.NotificationClass.POBD);
+ this.RegisterIntegerUpDownChange(this.integerUpDownPersonsOnBoard, Message.NotificationClass.POBD);
+ this.RegisterIntegerUpDownChange(this.integerUpDownStowawaysOnBoard, Message.NotificationClass.POBD);
+
+ // 4.3
+ this.dataGridBKRD.CellEditEnding += (obj, ev) => { this.SublistElementChanged(Message.NotificationClass.BKRD); };
+
+ // Extra Menüpunkt um alle Bunker Positionen nach BKRA zu kopieren
+
+ if (!_ctxInitialized)
+ {
+ this.dataGridBKRD.ContextMenu.Items.Add(new Separator());
+ MenuItem copyBKRItem = new MenuItem();
+ copyBKRItem.Header = Properties.Resources.textCopyToBKRD;
+ copyBKRItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
+ copyBKRItem.Click += this.copyBKR;
+ this.dataGridBKRD.ContextMenu.Items.Add(copyBKRItem);
+ }
+
+ // 4.4
+ this.RegisterCheckboxChange(this.checkBoxDangerousGoodsOnBoard, Message.NotificationClass.HAZD);
+
+ // 4.5
+
+ if (!_ctxInitialized)
+ {
+
+ this.dataGridTowageOnDeparture.ContextMenu.Items.Add(new Separator());
+ MenuItem copyItem = new MenuItem();
+ copyItem.Header = string.Format(Properties.Resources.textCopyTo, "TOWA");
+ copyItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
+ copyItem.Click += new RoutedEventHandler(this.copyTOWAItem);
+ this.dataGridTowageOnDeparture.ContextMenu.Items.Add(copyItem);
+ }
+
+ _ctxInitialized = true;
+ }
+
+ private void copyBKR(object sender, RoutedEventArgs e)
+ {
+ if (this.dataGridBKRD.SelectedItems != null)
+ {
+ foreach (BRKD brkd in this.dataGridBKRD.SelectedItems)
+ {
+ BRKA copyBRKA = new BRKA();
+ copyBRKA.MessageHeader = this._brkdMessage;
+ copyBRKA.CopyFromBKRD(brkd);
+ copyBRKA.Identifier = DatabaseEntity.GetNewIdentifier(this._brkaMessage.Elements);
+ this._brkaMessage.Elements.Add(copyBRKA);
+ this.SublistElementChanged(Message.NotificationClass.BKRA);
+ }
+ }
+ }
+
+ private void copyTOWAItem(object sender, RoutedEventArgs e)
+ {
+ // aus dem aktuell selektierten TOWD Element ein neues TOWA Element machen
+ if (this.dataGridTowageOnDeparture.SelectedItems != null)
+ {
+ foreach (TOWD selectedTOWD in this.dataGridTowageOnDeparture.SelectedItems)
+ {
+ TOWA copyTOWA = new TOWA();
+ copyTOWA.MessageHeader = _towaMessage;
+ copyTOWA.CopyFromTOWD(selectedTOWD);
+ copyTOWA.Identifier = TOWA.GetNewIdentifier(this._towaMessage.Elements);
+ this._towaMessage.Elements.Add(copyTOWA);
+ this.SublistElementChanged(Message.NotificationClass.TOWA);
+ }
+ }
+ }
+
+ #region BKRD grid events
+
+ private void DataGridBKRD_CreateRequested()
+ {
+ this.dataGridBKRD.CancelEdit();
+ this.dataGridBKRD.CancelEdit();
+ EditBKRDialog ebd = new EditBKRDialog();
+ ebd.BRKD = new BRKD();
+ ebd.BRKD.Identifier = BRKD.GetNewIdentifier(this._brkdMessage.Elements);
+ ebd.BRKD.MessageHeader = _brkdMessage;
+ ebd.IsDeparture = true;
+
+ ebd.AddClicked += () =>
+ {
+ ebd.CopyValuesToEntity();
+ if (!this._brkdMessage.Elements.Contains(ebd.BRKD))
+ this._brkdMessage.Elements.Add(ebd.BRKD);
+ this.dataGridBKRD.Items.Refresh();
+
+ ebd.BRKD = new BRKD();
+ ebd.BRKD.Identifier = BRKD.GetNewIdentifier(this._brkdMessage.Elements);
+ ebd.BRKD.MessageHeader = _brkdMessage;
+ this.SublistElementChanged(Message.NotificationClass.BKRD);
+ };
+
+ if (ebd.ShowDialog() ?? false)
+ {
+ if (!_brkdMessage.Elements.Contains(ebd.BRKD))
+ _brkdMessage.Elements.Add(ebd.BRKD);
+ this.dataGridBKRD.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.BKRD);
+ }
+ }
+
+ private void DataGridBKRD_DeleteRequested(DatabaseEntity obj)
+ {
+ if (obj is BRKD brkd)
+ {
+ this.dataGridBKRD.CancelEdit();
+ this.dataGridBKRD.CancelEdit();
+ // are you sure dialog is in base class
+ DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(brkd);
+ this._brkdMessage.Elements.Remove(brkd);
+ DatabaseEntity.ResetIdentifiers(this._brkdMessage.Elements);
+ this.SublistElementChanged(Message.NotificationClass.BKRD);
+ this.dataGridBKRD.Items.Refresh();
+ }
+ }
+
+ private void DataGridBKRD_EditRequested(DatabaseEntity obj)
+ {
+ // I am not shitting you: this has to be called TWICE(!) in a row in order to work
+ // see: https://stackoverflow.com/questions/20204592/wpf-datagrid-refresh-is-not-allowed-during-an-addnew-or-edititem-transaction-m
+ this.dataGridBKRD.CancelEdit(DataGridEditingUnit.Row);
+ this.dataGridBKRD.CommitEdit(DataGridEditingUnit.Row, true);
+
+ EditBKRDialog eld = new EditBKRDialog();
+ eld.IsDeparture = true;
+ eld.BRKD = obj as BRKD;
+
+ eld.AddClicked += () =>
+ {
+ eld.CopyValuesToEntity();
+ if (!_brkdMessage.Elements.Contains(eld.BRKD))
+ _brkdMessage.Elements.Add(eld.BRKD);
+ this.dataGridBKRD.ItemsSource = null;
+ this.dataGridBKRD.ItemsSource = this._brkdMessage.Elements;
+ eld.BRKD = new BRKD();
+ eld.BRKD.Identifier = BRKD.GetNewIdentifier(this._brkdMessage.Elements);
+ eld.BRKD.MessageHeader = _brkdMessage;
+ this.SublistElementChanged(Message.NotificationClass.BKRD);
+ };
+
+ if (eld.ShowDialog() ?? false)
+ {
+ if (!_brkdMessage.Elements.Contains(eld.BRKD))
+ _brkdMessage.Elements.Add(eld.BRKD);
+ this.dataGridBKRD.ItemsSource = null;
+ this.dataGridBKRD.ItemsSource = this._brkaMessage.Elements;
+ this.SublistElementChanged(Message.NotificationClass.BKRD);
+ }
+ }
+
+ private void DataGridBKRD_AddingNewItem(object sender, System.Windows.Controls.AddingNewItemEventArgs e)
+ {
+ this.DataGridBKRD_CreateRequested();
+ }
+
+ #endregion
+
+ #region TOWD grid
+
+ private void DataGridTowageOnDeparture_CreateRequested()
+ {
+ EditTOWDialog ebd = new EditTOWDialog();
+ ebd.IsDeparture = true;
+ ebd.TOWD = new TOWD();
+ ebd.TOWD.Identifier = TOWD.GetNewIdentifier(this._towdMessage.Elements);
+ ebd.TOWD.MessageHeader = this._towdMessage;
+
+ ebd.AddClicked += () =>
+ {
+ ebd.CopyValuesToEntity();
+ if (!this._towdMessage.Elements.Contains(ebd.TOWD))
+ this._towdMessage.Elements.Add(ebd.TOWD);
+ this.dataGridTowageOnDeparture.Items.Refresh();
+ ebd.TOWD = new TOWD();
+ ebd.TOWD.MessageHeader = _towdMessage;
+ ebd.TOWD.Identifier = TOWD.GetNewIdentifier(this._towdMessage.Elements);
+ this.SublistElementChanged(Message.NotificationClass.TOWD);
+ };
+
+ if (ebd.ShowDialog() ?? false)
+ {
+ if (!this._towdMessage.Elements.Contains(ebd.TOWD))
+ _towdMessage.Elements.Add(ebd.TOWD);
+ this.dataGridTowageOnDeparture.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.TOWD);
+ }
+ }
+
+ private void DataGridTowageOnDeparture_DeleteRequested(DatabaseEntity obj)
+ {
+ if (obj is TOWD towd)
+ {
+ // are you sure dialog is in base class
+ this._towdMessage.Elements.Remove(towd);
+ DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(towd);
+ DatabaseEntity.ResetIdentifiers(this._towdMessage.Elements);
+ this.SublistElementChanged(Message.NotificationClass.TOWD);
+ this.dataGridTowageOnDeparture.Items.Refresh();
+ }
+ }
+
+ private void DataGridTowageOnDeparture_EditRequested(DatabaseEntity obj)
+ {
+ EditTOWDialog eld = new EditTOWDialog();
+ eld.IsDeparture = true;
+ eld.TOWD = obj as TOWD;
+
+ eld.AddClicked += () =>
+ {
+ eld.CopyValuesToEntity();
+ if (!_towdMessage.Elements.Contains(eld.TOWD))
+ _towdMessage.Elements.Add(eld.TOWD);
+ this.dataGridTowageOnDeparture.Items.Refresh();
+
+ eld.TOWD = new TOWD();
+ eld.TOWD.Identifier = TOWD.GetNewIdentifier(this._towdMessage.Elements);
+ eld.TOWD.MessageHeader = _towdMessage;
+ this.SublistElementChanged(Message.NotificationClass.TOWD);
+ };
+
+ if (eld.ShowDialog() ?? false)
+ {
+ if (!this._towdMessage.Elements.Contains(eld.TOWD))
+ this._towdMessage.Elements.Add(eld.TOWD);
+ this.dataGridTowageOnDeparture.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.TOWD);
+ }
+ }
+
+ private void DataGridTowageOnDeparture_AddingNewItem(object sender, System.Windows.Controls.AddingNewItemEventArgs e)
+ {
+ this.DataGridTowageOnDeparture_CreateRequested();
+ }
+
+ #endregion
+
+ #region mouse wheel
+
+ private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
+ {
+ ScrollViewer scv = (ScrollViewer)sender;
+ scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
+ e.Handled = true;
+ }
+
+ #endregion
+
+ }
+}
+