Copy function BRKD to BRKA

This commit is contained in:
Daniel Schick 2022-05-26 08:05:24 +02:00
parent 6e38685531
commit c35ce294c5
4 changed files with 41 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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
}
}

View File

@ -126,6 +126,10 @@ namespace bsmd.database
}
}
#endregion
#region public funcs
public void CopyFromBKRA(BRKA brka)
{
if (brka == null) return;