From c35ce294c52e68773c4382ff2fa2af4806864412 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Thu, 26 May 2022 08:05:24 +0200 Subject: [PATCH] Copy function BRKD to BRKA --- .../ArrivalNotificationDetailControl.xaml.cs | 3 --- ...DepartureNotificationDetailControl.xaml.cs | 27 ++++++++++++++++++- bsmd.database/BKRA.cs | 11 ++++++++ bsmd.database/BRKD.cs | 4 +++ 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/ENI2/DetailViewControls/ArrivalNotificationDetailControl.xaml.cs b/ENI2/DetailViewControls/ArrivalNotificationDetailControl.xaml.cs index c2edf943..f7ef41a7 100644 --- a/ENI2/DetailViewControls/ArrivalNotificationDetailControl.xaml.cs +++ b/ENI2/DetailViewControls/ArrivalNotificationDetailControl.xaml.cs @@ -165,8 +165,6 @@ namespace ENI2.DetailViewControls private void copyBKR(object sender, RoutedEventArgs e) { - // aus dem aktuell selektierten IBC Element ein neues IBC Element machen und nach HAZD kopieren - foreach (BRKA brka in this.dataGridBKRA.Items) { BRKD copyBRKD = new BRKD(); @@ -176,7 +174,6 @@ namespace ENI2.DetailViewControls this._brkdMessage.Elements.Add(copyBRKD); this.SublistElementChanged(Message.NotificationClass.BKRD); } - } #region BKRA grid events diff --git a/ENI2/DetailViewControls/DepartureNotificationDetailControl.xaml.cs b/ENI2/DetailViewControls/DepartureNotificationDetailControl.xaml.cs index 31e81650..8d4c778d 100644 --- a/ENI2/DetailViewControls/DepartureNotificationDetailControl.xaml.cs +++ b/ENI2/DetailViewControls/DepartureNotificationDetailControl.xaml.cs @@ -9,6 +9,7 @@ using bsmd.database; using ENI2.EditControls; using ENI2.Util; using System.Windows.Controls; +using System.Windows.Media.Imaging; namespace ENI2.DetailViewControls { @@ -22,6 +23,7 @@ namespace ENI2.DetailViewControls private Message _tiefdMessage; private Message _pobdMessage; private Message _bkrdMessage; + private Message _brkaMessage; bool startupComplete = false; public DepartureNotificationDetailControl() @@ -51,6 +53,7 @@ namespace ENI2.DetailViewControls if (aMessage.MessageNotificationClass == Message.NotificationClass.TIEFD) { this._tiefdMessage = aMessage; this.ControlMessages.Add(aMessage); } if (aMessage.MessageNotificationClass == Message.NotificationClass.POBD) { this._pobdMessage = aMessage; this.ControlMessages.Add(aMessage); } if (aMessage.MessageNotificationClass == Message.NotificationClass.BKRD) { this._bkrdMessage = aMessage; this.ControlMessages.Add(aMessage); } + if (aMessage.MessageNotificationClass == Message.NotificationClass.BKRA) { this._brkaMessage = aMessage; this.ControlMessages.Add(aMessage); } } #region ATD @@ -147,6 +150,15 @@ namespace ENI2.DetailViewControls this.dataGridBKRD.DeleteRequested += DataGridBKRD_DeleteRequested; this.dataGridBKRD.CreateRequested += DataGridBKRD_CreateRequested; + // Extra Menüpunkt um alle Bunker Positionen nach BKRA zu kopieren + + this.dataGridBKRD.ContextMenu.Items.Add(new Separator()); + MenuItem copyBKRItem = new MenuItem(); + copyBKRItem.Header = string.Format(Properties.Resources.textCopyTo, "BKRA"); + copyBKRItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) }; + copyBKRItem.Click += this.copyBKR; + this.dataGridBKRD.ContextMenu.Items.Add(copyBKRItem); + #endregion } @@ -184,7 +196,7 @@ namespace ENI2.DetailViewControls } private void DataGridBKRD_DeleteRequested(DatabaseEntity obj) - { + { if (obj is BRKD brkd) { // are you sure dialog is in base class @@ -228,6 +240,19 @@ namespace ENI2.DetailViewControls this.DataGridBKRD_CreateRequested(); } + private void copyBKR(object sender, RoutedEventArgs e) + { + foreach (BRKD brkd in this.dataGridBKRD.Items) + { + BRKA copyBRKA = new BRKA(); + copyBRKA.MessageHeader = this._brkaMessage; + copyBRKA.CopyFromBKRD(brkd); + copyBRKA.Identifier = DatabaseEntity.GetNewIdentifier(this._brkaMessage.Elements); + this._brkaMessage.Elements.Add(copyBRKA); + this.SublistElementChanged(Message.NotificationClass.BKRA); + } + } + #endregion #region Highlighting diff --git a/bsmd.database/BKRA.cs b/bsmd.database/BKRA.cs index b638d07a..60a00365 100644 --- a/bsmd.database/BKRA.cs +++ b/bsmd.database/BKRA.cs @@ -130,5 +130,16 @@ namespace bsmd.database #endregion + #region public funcs + + public void CopyFromBKRD(BRKD brkd) + { + if (brkd == null) return; + this.BunkerFuelType = brkd.BunkerFuelType; + this.BunkerFuelQuantity_TNE = brkd.BunkerFuelQuantity_TNE; + } + + #endregion + } } \ No newline at end of file diff --git a/bsmd.database/BRKD.cs b/bsmd.database/BRKD.cs index 4f62cc2a..a81d9941 100644 --- a/bsmd.database/BRKD.cs +++ b/bsmd.database/BRKD.cs @@ -126,6 +126,10 @@ namespace bsmd.database } } + #endregion + + #region public funcs + public void CopyFromBKRA(BRKA brka) { if (brka == null) return;