diff --git a/ENI2/DetailRootControl.xaml.cs b/ENI2/DetailRootControl.xaml.cs
index df7a3bfa..85be3bca 100644
--- a/ENI2/DetailRootControl.xaml.cs
+++ b/ENI2/DetailRootControl.xaml.cs
@@ -179,6 +179,8 @@ namespace ENI2
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textOverview, MessageGroupControlType = typeof(OverViewDetailControl), ImagePath = "Resources/documents.png" });
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.listBoxMessages.ItemsSource = this._listBoxList;
diff --git a/ENI2/DetailViewControls/TowageDetailControl.xaml.cs b/ENI2/DetailViewControls/TowageDetailControl.xaml.cs
index 2ad50d4f..ac889ba6 100644
--- a/ENI2/DetailViewControls/TowageDetailControl.xaml.cs
+++ b/ENI2/DetailViewControls/TowageDetailControl.xaml.cs
@@ -71,7 +71,7 @@ namespace ENI2.DetailViewControls
private void copyItemToTOWA(object sender, RoutedEventArgs e)
{
- // aus dem aktuell selektierten TOWA Element ein neues TOWD Element machen
+ // aus dem aktuell selektierten TOWD Element ein neues TOWA Element machen
if (this.dataGridTowageOnDeparture.SelectedItems != null)
{
foreach (TOWD selectedTOWD in this.dataGridTowageOnDeparture.SelectedItems)
@@ -166,8 +166,7 @@ namespace ENI2.DetailViewControls
private void DataGridTowageOnDeparture_DeleteRequested(DatabaseEntity obj)
{
- TOWD towd = obj as TOWD;
- if (towd != null)
+ if (obj is TOWD towd)
{
// are you sure dialog is in base class
this._towdMessage.Elements.Remove(towd);
@@ -245,8 +244,7 @@ namespace ENI2.DetailViewControls
private void DataGridTowageOnArrival_DeleteRequested(DatabaseEntity obj)
{
- TOWA towa = obj as TOWA;
- if (towa != null)
+ if (obj is TOWA towa)
{
// are you sure dialog is in base class
this._towaMessage.Elements.Remove(towa);
diff --git a/ENI2/ENI2.csproj b/ENI2/ENI2.csproj
index 1e49dfc4..c03fa5dc 100644
--- a/ENI2/ENI2.csproj
+++ b/ENI2/ENI2.csproj
@@ -496,6 +496,9 @@
PortControl.xaml
+
+ PreArrivalControl.xaml
+
VoyageControl.xaml
@@ -812,6 +815,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 2c61a66a..ff7479e1 100644
--- a/ENI2/Properties/Resources.Designer.cs
+++ b/ENI2/Properties/Resources.Designer.cs
@@ -1028,6 +1028,60 @@ namespace ENI2.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to 3.1 General.
+ ///
+ public static string text31General {
+ get {
+ return ResourceManager.GetString("text31General", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to 3.2 Persons on board on arrival.
+ ///
+ public static string text32PersonsOnBoard {
+ get {
+ return ResourceManager.GetString("text32PersonsOnBoard", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to 3.3 Bunker on arrival.
+ ///
+ public static string text33BunkerOnArrival {
+ get {
+ return ResourceManager.GetString("text33BunkerOnArrival", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to 3.4 Dangerous cargo on board on arrival.
+ ///
+ public static string text34DangerousCargo {
+ get {
+ return ResourceManager.GetString("text34DangerousCargo", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to 3.5 Tow (barge, pontoon, etc.) on arrival.
+ ///
+ public static string text36TowOnArrival {
+ get {
+ return ResourceManager.GetString("text36TowOnArrival", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to 3. Pre-arrival.
+ ///
+ public static string text3PreArrival {
+ get {
+ return ResourceManager.GetString("text3PreArrival", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to About ENI-2.
///
@@ -1172,6 +1226,15 @@ namespace ENI2.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Are any security-related matters to report?.
+ ///
+ public static string textAreMatterToReport {
+ get {
+ return ResourceManager.GetString("textAreMatterToReport", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Are you sure?.
///
@@ -3512,6 +3575,15 @@ namespace ENI2.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to if yes, description of matters to report.
+ ///
+ public static string textMatterToReport {
+ get {
+ return ResourceManager.GetString("textMatterToReport", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Max acitivity.
///
diff --git a/ENI2/Properties/Resources.resx b/ENI2/Properties/Resources.resx
index 3589e214..a1e4a9c6 100644
--- a/ENI2/Properties/Resources.resx
+++ b/ENI2/Properties/Resources.resx
@@ -2002,4 +2002,28 @@
Official use
+
+ 3. Pre-arrival
+
+
+ 3.1 General
+
+
+ 3.2 Persons on board on arrival
+
+
+ 3.3 Bunker on arrival
+
+
+ 3.4 Dangerous cargo on board on arrival
+
+
+ 3.5 Tow (barge, pontoon, etc.) on arrival
+
+
+ Are any security-related matters to report?
+
+
+ if yes, description of matters to report
+
\ No newline at end of file
diff --git a/ENI2/SheetDisplayControls/PortControl.xaml.cs b/ENI2/SheetDisplayControls/PortControl.xaml.cs
index 47346814..e3a0b57a 100644
--- a/ENI2/SheetDisplayControls/PortControl.xaml.cs
+++ b/ENI2/SheetDisplayControls/PortControl.xaml.cs
@@ -11,17 +11,9 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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
{
@@ -87,8 +79,7 @@ namespace ENI2.SheetDisplayControls
{
base.Initialize();
foreach (Message aMessage in this.Messages)
- {
- if (aMessage.Elements.Count == 0) continue;
+ {
if (aMessage.MessageNotificationClass == Message.NotificationClass.LADG) { this._ladgMessage = aMessage; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.SERV) { this._servMessage = aMessage; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.NOA_NOD) { this._noa_nod = aMessage.Elements[0] as NOA_NOD; this.ControlMessages.Add(aMessage); }
diff --git a/ENI2/SheetDisplayControls/PreArrivalControl.xaml b/ENI2/SheetDisplayControls/PreArrivalControl.xaml
new file mode 100644
index 00000000..3cbe601f
--- /dev/null
+++ b/ENI2/SheetDisplayControls/PreArrivalControl.xaml
@@ -0,0 +1,124 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ENI2/SheetDisplayControls/PreArrivalControl.xaml.cs b/ENI2/SheetDisplayControls/PreArrivalControl.xaml.cs
new file mode 100644
index 00000000..467bc0bc
--- /dev/null
+++ b/ENI2/SheetDisplayControls/PreArrivalControl.xaml.cs
@@ -0,0 +1,381 @@
+// Copyright (c) 2025 - schick Informatik
+// Description: Display control of formsheet Tab 3. Pre-Arrival
+//
+
+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
+{
+ ///
+ /// Interaction logic for PreArrivalControl.xaml
+ ///
+ public partial class PreArrivalControl : DetailBaseControl
+ {
+ #region Fields
+
+ private TIEFA _tiefa;
+ private SEC _sec;
+ private NOA_NOD _noa_nod;
+ private POBA _poba;
+ private Message _brkaMessage;
+ private Message _brkdMessage;
+ private HAZ _haz;
+ private Message _towaMessage;
+ private Message _towdMessage;
+
+ private bool _ctxInitialized = false;
+
+ #endregion
+
+ #region Construction
+
+ public PreArrivalControl()
+ {
+ InitializeComponent();
+ Loaded += PreArrivalControl_Loaded;
+ }
+
+ #endregion
+
+ #region public override
+
+ public override void Initialize()
+ {
+
+ base.Initialize();
+ foreach (Message aMessage in this.Messages)
+ {
+ if (aMessage.MessageNotificationClass == Message.NotificationClass.TIEFA) { this._tiefa = aMessage.Elements[0] as TIEFA; this.ControlMessages.Add(aMessage); }
+ if (aMessage.MessageNotificationClass == Message.NotificationClass.SEC) { this._sec = aMessage.Elements[0] as SEC; this.ControlMessages.Add(aMessage); }
+ if (aMessage.MessageNotificationClass == Message.NotificationClass.NOA_NOD) { this._noa_nod = aMessage.Elements[0] as NOA_NOD; this.ControlMessages.Add(aMessage); }
+ if (aMessage.MessageNotificationClass == Message.NotificationClass.POBA) { this._poba = aMessage.Elements[0] as POBA; 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.HAZA) { 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); }
+ }
+
+ // 3.1
+ this.doubleUpDownDraught.DataContext = this._tiefa;
+ this.comboBoxCurrentShipSecurityLevel.ItemsSource = Util.GlobalStructures.ShipSecurityLevels;
+ this.comboBoxCurrentShipSecurityLevel.DataContext = this._sec;
+ this.checkBox_IsAnchored.DataContext = this._noa_nod;
+ this.checkBox_AreMatterToReport.DataContext = this._sec;
+ this.textBoxMatterToReport.DataContext = this._sec;
+
+ // 3.2
+ this.integerUpDownPersonsOnBoard.DataContext = this._poba;
+ this.integerUpDownCrewMemberOnBoard.DataContext = this._poba;
+ this.integerUpDownPassengersOnBoard.DataContext = this._poba;
+ this.integerUpDownStowawaysOnBoard.DataContext = this._poba;
+
+ // 3.3
+ this.dataGridBKRA.Initialize();
+ this.dataGridBKRA.ItemsSource = this._brkaMessage.Elements;
+ this.dataGridBKRA.AddingNewItem += DataGridBKRA_AddingNewItem;
+ this.dataGridBKRA.EditRequested += DataGridBKRA_EditRequested;
+ this.dataGridBKRA.DeleteRequested += DataGridBKRA_DeleteRequested;
+ this.dataGridBKRA.CreateRequested += DataGridBKRA_CreateRequested;
+
+ // 3.4
+ this.checkBoxDangerousGoodsOnBoard.DataContext = this._haz;
+
+ // 3.5
+ if (this._towaMessage == null)
+ {
+ this._towaMessage = this.Core.CreateMessage(Message.NotificationClass.TOWA);
+ this.Messages.Add(this._towaMessage);
+ }
+ this.dataGridTowageOnArrival.Initialize();
+ this.dataGridTowageOnArrival.ItemsSource = this._towaMessage.Elements;
+ this.dataGridTowageOnArrival.AddingNewItem += DataGridTowageOnArrival_AddingNewItem;
+ this.dataGridTowageOnArrival.EditRequested += DataGridTowageOnArrival_EditRequested;
+ this.dataGridTowageOnArrival.DeleteRequested += DataGridTowageOnArrival_DeleteRequested;
+ this.dataGridTowageOnArrival.CreateRequested += DataGridTowageOnArrival_CreateRequested;
+
+
+ }
+
+ #endregion
+
+ private void PreArrivalControl_Loaded(object sender, RoutedEventArgs e)
+ {
+ // 3.1
+ this.RegisterDoubleUpDownChange(this.doubleUpDownDraught, Message.NotificationClass.TIEFA);
+ this.RegisterComboboxIndexChange(this.comboBoxCurrentShipSecurityLevel, Message.NotificationClass.SEC);
+ this.RegisterCheckboxChange(this.checkBox_IsAnchored, Message.NotificationClass.NOA_NOD);
+ this.RegisterCheckboxChange(this.checkBox_AreMatterToReport, Message.NotificationClass.SEC);
+ this.RegisterTextboxChange(this.textBoxMatterToReport, Message.NotificationClass.SEC);
+
+ // 3.2
+ this.RegisterIntegerUpDownChange(this.integerUpDownCrewMemberOnBoard, Message.NotificationClass.POBA);
+ this.RegisterIntegerUpDownChange(this.integerUpDownPassengersOnBoard, Message.NotificationClass.POBA);
+ this.RegisterIntegerUpDownChange(this.integerUpDownPersonsOnBoard, Message.NotificationClass.POBA);
+ this.RegisterIntegerUpDownChange(this.integerUpDownStowawaysOnBoard, Message.NotificationClass.POBA);
+
+ // 3.3
+ this.dataGridBKRA.CellEditEnding += (obj, ev) => { this.SublistElementChanged(Message.NotificationClass.BKRA); };
+
+ // Extra Menüpunkt um alle Bunker Positionen nach BKRD zu kopieren
+
+ if (!_ctxInitialized)
+ {
+ this.dataGridBKRA.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.dataGridBKRA.ContextMenu.Items.Add(copyBKRItem);
+ }
+
+ // 3.4
+ this.RegisterCheckboxChange(this.checkBoxDangerousGoodsOnBoard, Message.NotificationClass.HAZA);
+
+ // 3.5
+
+ if (!_ctxInitialized)
+ {
+
+ this.dataGridTowageOnArrival.ContextMenu.Items.Add(new Separator());
+ MenuItem copyItem = new MenuItem();
+ copyItem.Header = string.Format(Properties.Resources.textCopyTo, "TOWD");
+ copyItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
+ copyItem.Click += new RoutedEventHandler(this.copyTOWAItem);
+ this.dataGridTowageOnArrival.ContextMenu.Items.Add(copyItem);
+ }
+
+ _ctxInitialized = true;
+ }
+
+ private void copyBKR(object sender, RoutedEventArgs e)
+ {
+ if (this.dataGridBKRA.SelectedItems != null)
+ {
+ foreach (BRKA brka in this.dataGridBKRA.SelectedItems)
+ {
+ BRKD copyBRKD = new BRKD();
+ copyBRKD.MessageHeader = this._brkdMessage;
+ copyBRKD.CopyFromBKRA(brka);
+ copyBRKD.Identifier = DatabaseEntity.GetNewIdentifier(this._brkdMessage.Elements);
+ this._brkdMessage.Elements.Add(copyBRKD);
+ this.SublistElementChanged(Message.NotificationClass.BKRD);
+ }
+ }
+ }
+
+ private void copyTOWAItem(object sender, RoutedEventArgs e)
+ {
+ // aus dem aktuell selektierten TOWA Element ein neues TOWD Element machen
+ if (this.dataGridTowageOnArrival.SelectedItems != null)
+ {
+ foreach (TOWA selectedTOWA in this.dataGridTowageOnArrival.SelectedItems)
+ {
+ TOWD copyTOWD = new TOWD();
+ copyTOWD.MessageHeader = _towdMessage;
+ copyTOWD.CopyFromTOWA(selectedTOWA);
+ copyTOWD.Identifier = TOWD.GetNewIdentifier(this._towdMessage.Elements);
+ this._towdMessage.Elements.Add(copyTOWD);
+ this.SublistElementChanged(Message.NotificationClass.TOWD);
+ }
+ }
+ }
+
+ #region BKRA grid events
+
+ private void DataGridBKRA_CreateRequested()
+ {
+ this.dataGridBKRA.CancelEdit();
+ this.dataGridBKRA.CancelEdit();
+ EditBKRDialog ebd = new EditBKRDialog();
+ ebd.BRKA = new BRKA();
+ ebd.BRKA.Identifier = BRKA.GetNewIdentifier(this._brkaMessage.Elements);
+ ebd.BRKA.MessageHeader = _brkaMessage;
+ ebd.IsDeparture = false;
+
+ ebd.AddClicked += () =>
+ {
+ ebd.CopyValuesToEntity();
+ if (!this._brkaMessage.Elements.Contains(ebd.BRKA))
+ this._brkaMessage.Elements.Add(ebd.BRKA);
+ this.dataGridBKRA.Items.Refresh();
+
+ ebd.BRKA = new BRKA();
+ ebd.BRKA.Identifier = BRKA.GetNewIdentifier(this._brkaMessage.Elements);
+ ebd.BRKA.MessageHeader = _brkaMessage;
+ this.SublistElementChanged(Message.NotificationClass.BKRA);
+ };
+
+ if (ebd.ShowDialog() ?? false)
+ {
+ if (!_brkaMessage.Elements.Contains(ebd.BRKA))
+ _brkaMessage.Elements.Add(ebd.BRKA);
+ this.dataGridBKRA.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.BKRA);
+ }
+ }
+
+ private void DataGridBKRA_DeleteRequested(DatabaseEntity obj)
+ {
+ if (obj is BRKA brka)
+ {
+ this.dataGridBKRA.CancelEdit();
+ this.dataGridBKRA.CancelEdit();
+ // are you sure dialog is in base class
+ DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(brka);
+ this._brkaMessage.Elements.Remove(brka);
+ DatabaseEntity.ResetIdentifiers(this._brkaMessage.Elements);
+ this.SublistElementChanged(Message.NotificationClass.BKRA);
+ this.dataGridBKRA.Items.Refresh();
+ }
+ }
+
+ private void DataGridBKRA_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.dataGridBKRA.CancelEdit(DataGridEditingUnit.Row);
+ this.dataGridBKRA.CommitEdit(DataGridEditingUnit.Row, true);
+
+ EditBKRDialog eld = new EditBKRDialog();
+ eld.IsDeparture = false;
+ eld.BRKA = obj as BRKA;
+
+ eld.AddClicked += () =>
+ {
+ eld.CopyValuesToEntity();
+ if (!_brkaMessage.Elements.Contains(eld.BRKA))
+ _brkaMessage.Elements.Add(eld.BRKA);
+ this.dataGridBKRA.ItemsSource = null;
+ this.dataGridBKRA.ItemsSource = this._brkaMessage.Elements;
+ eld.BRKA = new BRKA();
+ eld.BRKA.Identifier = BRKA.GetNewIdentifier(this._brkaMessage.Elements);
+ eld.BRKA.MessageHeader = _brkaMessage;
+ this.SublistElementChanged(Message.NotificationClass.BKRA);
+ };
+
+ if (eld.ShowDialog() ?? false)
+ {
+ if (!_brkaMessage.Elements.Contains(eld.BRKA))
+ _brkaMessage.Elements.Add(eld.BRKA);
+ this.dataGridBKRA.ItemsSource = null;
+ this.dataGridBKRA.ItemsSource = this._brkaMessage.Elements;
+ this.SublistElementChanged(Message.NotificationClass.BKRA);
+ }
+ }
+
+ private void DataGridBKRA_AddingNewItem(object sender, System.Windows.Controls.AddingNewItemEventArgs e)
+ {
+ this.DataGridBKRA_CreateRequested();
+ }
+
+ #endregion
+
+ #region TOWA grid
+
+ private void DataGridTowageOnArrival_CreateRequested()
+ {
+ EditTOWDialog ebd = new EditTOWDialog();
+ ebd.IsDeparture = false;
+ ebd.TOWA = new TOWA();
+ ebd.TOWA.Identifier = TOWA.GetNewIdentifier(this._towaMessage.Elements);
+ ebd.TOWA.MessageHeader = this._towaMessage;
+
+ ebd.AddClicked += () =>
+ {
+ ebd.CopyValuesToEntity();
+ if (!this._towaMessage.Elements.Contains(ebd.TOWA))
+ this._towaMessage.Elements.Add(ebd.TOWA);
+ this.dataGridTowageOnArrival.Items.Refresh();
+ ebd.TOWA = new TOWA();
+ ebd.TOWA.MessageHeader = _towaMessage;
+ ebd.TOWA.Identifier = TOWA.GetNewIdentifier(this._towaMessage.Elements);
+ this.SublistElementChanged(Message.NotificationClass.TOWA);
+ };
+
+ if (ebd.ShowDialog() ?? false)
+ {
+ if (!this._towaMessage.Elements.Contains(ebd.TOWA))
+ _towaMessage.Elements.Add(ebd.TOWA);
+ this.dataGridTowageOnArrival.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.TOWA);
+ }
+ }
+
+ private void DataGridTowageOnArrival_DeleteRequested(DatabaseEntity obj)
+ {
+ if (obj is TOWA towa)
+ {
+ // are you sure dialog is in base class
+ this._towaMessage.Elements.Remove(towa);
+ DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(towa);
+ DatabaseEntity.ResetIdentifiers(this._towaMessage.Elements);
+ this.SublistElementChanged(Message.NotificationClass.TOWA);
+ this.dataGridTowageOnArrival.Items.Refresh();
+ }
+ }
+
+ private void DataGridTowageOnArrival_EditRequested(DatabaseEntity obj)
+ {
+ EditTOWDialog eld = new EditTOWDialog();
+ eld.IsDeparture = false;
+ eld.TOWA = obj as TOWA;
+
+ eld.AddClicked += () =>
+ {
+ eld.CopyValuesToEntity();
+ if (!_towaMessage.Elements.Contains(eld.TOWA))
+ _towaMessage.Elements.Add(eld.TOWA);
+ this.dataGridTowageOnArrival.Items.Refresh();
+
+ eld.TOWA = new TOWA();
+ eld.TOWA.Identifier = TOWA.GetNewIdentifier(this._towaMessage.Elements);
+ eld.TOWA.MessageHeader = _towaMessage;
+ this.SublistElementChanged(Message.NotificationClass.TOWA);
+ };
+
+ if (eld.ShowDialog() ?? false)
+ {
+ if (!this._towaMessage.Elements.Contains(eld.TOWA))
+ this._towaMessage.Elements.Add(eld.TOWA);
+ this.dataGridTowageOnArrival.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.TOWA);
+ }
+ }
+
+ private void DataGridTowageOnArrival_AddingNewItem(object sender, System.Windows.Controls.AddingNewItemEventArgs e)
+ {
+ this.DataGridTowageOnArrival_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
+
+
+ }
+}