diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml.cs index 94e33b18..897eaddb 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml.cs +++ b/ENI-2/ENI2/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml.cs @@ -7,6 +7,9 @@ using System.Windows; using bsmd.database; using ENI2.EditControls; using ENI2.Util; +using System.Windows.Controls; +using System.Windows.Media.Imaging; +using System; namespace ENI2.DetailViewControls { @@ -18,6 +21,7 @@ namespace ENI2.DetailViewControls private Message _hazMessage; private HAZ haz; + private HAZ hazd; // referenz auf HAZD, falls das hier HAZA ist und wir Positionen kopieren wollen public DangerousGoodsDetailControl() { @@ -30,8 +34,8 @@ namespace ENI2.DetailViewControls this.RegisterCheckboxChange(this.checkBoxDangerousGoodsOnBoard, this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA); this.RegisterCheckboxChange(this.checkBoxDGManifestOnBoard, this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA); this.RegisterCheckboxChange(this.checkBoxMoUBaltic, this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA); - this.RegisterComboboxIndexChange(this.comboBoxVesselClass, this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA); - } + this.RegisterComboboxIndexChange(this.comboBoxVesselClass, this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA); + } public bool IsDeparture { get; set; } @@ -47,7 +51,28 @@ namespace ENI2.DetailViewControls } else { - if (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) { this._hazMessage = aMessage; this.ControlMessages.Add(aMessage); } + if (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) + { + this._hazMessage = aMessage; + this.ControlMessages.Add(aMessage); + } + if (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) + { + if(aMessage != null) + { + if (aMessage.Elements.Count > 0) + this.hazd = aMessage.Elements[0] as HAZ; + if (this.hazd == null) + { + this.hazd = new HAZ(); + this.hazd.MessageCore = this.Core; + this.hazd.MessageHeader = aMessage; + aMessage.Elements.Add(this.hazd); + SublistElementChanged(Message.NotificationClass.HAZD); + } + this.ControlMessages.Add(aMessage); + } + } } } @@ -113,8 +138,151 @@ namespace ENI2.DetailViewControls #endregion + if (!this.haz.IsDeparture) + { + #region Extra Menüpunkte um Positionen nach HAZD zu kopieren + + this.dataGridIBCItems.ContextMenu.Items.Add(new Separator()); + MenuItem copyIBCItem = new MenuItem(); + copyIBCItem.Header = Properties.Resources.textCopyToHAZD; + copyIBCItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) }; + copyIBCItem.Click += new RoutedEventHandler(this.copyIBC); + this.dataGridIBCItems.ContextMenu.Items.Add(copyIBCItem); + + this.dataGridIGCItems.ContextMenu.Items.Add(new Separator()); + MenuItem copyItemIGC = new MenuItem(); + copyItemIGC.Header = Properties.Resources.textCopyToHAZD; + copyItemIGC.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) }; + copyItemIGC.Click += new RoutedEventHandler(this.copyIGC); + this.dataGridIGCItems.ContextMenu.Items.Add(copyItemIGC); + + this.dataGridIMDGItems.ContextMenu.Items.Add(new Separator()); + MenuItem copyItemIMDG = new MenuItem(); + copyItemIMDG.Header = Properties.Resources.textCopyToHAZD; + copyItemIMDG.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) }; + copyItemIMDG.Click += new RoutedEventHandler(this.copyIMDG); + this.dataGridIMDGItems.ContextMenu.Items.Add(copyItemIMDG); + + this.dataGridIMSBCItems.ContextMenu.Items.Add(new Separator()); + MenuItem copyItemIMSBC = new MenuItem(); + copyItemIMSBC.Header = Properties.Resources.textCopyToHAZD; + copyItemIMSBC.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) }; + copyItemIMSBC.Click += new RoutedEventHandler(this.copyIMSBC); + this.dataGridIMSBCItems.ContextMenu.Items.Add(copyItemIMSBC); + + this.dataGridMARPOLItems.ContextMenu.Items.Add(new Separator()); + MenuItem copyItemMARPOL = new MenuItem(); + copyItemMARPOL.Header = Properties.Resources.textCopyToHAZD; + copyItemMARPOL.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) }; + copyItemMARPOL.Click += new RoutedEventHandler(this.copyMARPOL); + this.dataGridMARPOLItems.ContextMenu.Items.Add(copyItemMARPOL); + + #endregion + + } + + this._initialized = true; } + #region Copy event handler + + private void copyMARPOL(object sender, RoutedEventArgs e) + { + // aus dem aktuell selektierten MARPOL Element ein neues MARPOL Element machen und nach HAZD kopieren + if ((this.dataGridMARPOLItems.SelectedItems != null) && (this.dataGridMARPOLItems.SelectedItems.Count == 1)) + { + MARPOL_Annex_I_Position selectedMARPOL = this.dataGridMARPOLItems.SelectedItems[0] as MARPOL_Annex_I_Position; + if (selectedMARPOL != null) + { + MARPOL_Annex_I_Position copyMARPOL = new MARPOL_Annex_I_Position(); + copyMARPOL.MessageHeader = this.hazd.MessageHeader; + copyMARPOL.HAZ = this.hazd; + copyMARPOL.CopyFromMARPOL(selectedMARPOL); + copyMARPOL.Identifier = DatabaseEntity.GetNewIdentifier(this.hazd.MARPOLPositions); + this.hazd.MARPOLPositions.Add(copyMARPOL); + this.SublistElementChanged(Message.NotificationClass.HAZD); + } + } + } + + private void copyIMSBC(object sender, RoutedEventArgs e) + { + // aus dem aktuell selektierten IMBSC Element ein neues IMBSC Element machen und nach HAZD kopieren + if ((this.dataGridIMSBCItems.SelectedItems != null) && (this.dataGridIMSBCItems.SelectedItems.Count == 1)) + { + IMSBCPosition selectedIMSBC = this.dataGridIMSBCItems.SelectedItems[0] as IMSBCPosition; + if (selectedIMSBC != null) + { + IMSBCPosition copyIMSBC = new IMSBCPosition(); + copyIMSBC.MessageHeader = this.hazd.MessageHeader; + copyIMSBC.HAZ = this.hazd; + copyIMSBC.CopyFromIMSBC(selectedIMSBC); + copyIMSBC.Identifier = DatabaseEntity.GetNewIdentifier(this.hazd.IMSBCPositions); + this.hazd.IMSBCPositions.Add(copyIMSBC); + this.SublistElementChanged(Message.NotificationClass.HAZD); + } + } + } + + private void copyIMDG(object sender, RoutedEventArgs e) + { + // aus dem aktuell selektierten IMDG Element ein neues IMDG Element machen und nach HAZD kopieren + if ((this.dataGridIMDGItems.SelectedItems != null) && (this.dataGridIMDGItems.SelectedItems.Count == 1)) + { + IMDGPosition selectedIMDG = this.dataGridIMDGItems.SelectedItems[0] as IMDGPosition; + if (selectedIMDG != null) + { + IMDGPosition copyIMDG = new IMDGPosition(); + copyIMDG.MessageHeader = this.hazd.MessageHeader; + copyIMDG.HAZ = this.hazd; + copyIMDG.CopyFromIMDG(selectedIMDG); + copyIMDG.Identifier = DatabaseEntity.GetNewIdentifier(this.hazd.IMDGPositions); + this.hazd.IMDGPositions.Add(copyIMDG); + this.SublistElementChanged(Message.NotificationClass.HAZD); + } + } + } + + private void copyIGC(object sender, RoutedEventArgs e) + { + // aus dem aktuell selektierten IGC Element ein neues IGC Element machen und nach HAZD kopieren + if ((this.dataGridIGCItems.SelectedItems != null) && (this.dataGridIGCItems.SelectedItems.Count == 1)) + { + IGCPosition selectedIGC = this.dataGridIGCItems.SelectedItems[0] as IGCPosition; + if (selectedIGC != null) + { + IGCPosition copyIGC = new IGCPosition(); + copyIGC.MessageHeader = this.hazd.MessageHeader; + copyIGC.HAZ = this.hazd; + copyIGC.CopyFromIGC(selectedIGC); + copyIGC.Identifier = DatabaseEntity.GetNewIdentifier(this.hazd.IGCPositions); + this.hazd.IGCPositions.Add(copyIGC); + this.SublistElementChanged(Message.NotificationClass.HAZD); + } + } + } + + private void copyIBC(object sender, RoutedEventArgs e) + { + // aus dem aktuell selektierten IBC Element ein neues IBC Element machen und nach HAZD kopieren + if ((this.dataGridIBCItems.SelectedItems != null) && (this.dataGridIBCItems.SelectedItems.Count == 1)) + { + IBCPosition selectedIBC = this.dataGridIBCItems.SelectedItems[0] as IBCPosition; + if (selectedIBC != null) + { + IBCPosition copyIBC = new IBCPosition(); + copyIBC.MessageHeader = this.hazd.MessageHeader; + copyIBC.HAZ = this.hazd; + copyIBC.CopyFromIBC(selectedIBC); + copyIBC.Identifier = DatabaseEntity.GetNewIdentifier(this.hazd.IBCPositions); + this.hazd.IBCPositions.Add(copyIBC); + this.SublistElementChanged(Message.NotificationClass.HAZD); + } + } + } + + #endregion + #region MARPOL datagrid handlers private void DataGridMARPOLItems_DeleteRequested(DatabaseEntity obj) diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/MaritimeHealthDeclarationDetailControl.xaml b/ENI-2/ENI2/ENI2/DetailViewControls/MaritimeHealthDeclarationDetailControl.xaml index 561ead12..40416b17 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/MaritimeHealthDeclarationDetailControl.xaml +++ b/ENI-2/ENI2/ENI2/DetailViewControls/MaritimeHealthDeclarationDetailControl.xaml @@ -124,7 +124,7 @@ SelectionMode="Single" AutoGenerateColumns="False" Margin="0,5,0,0"> - + @@ -146,7 +146,7 @@ - + diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/PSC72hDetailControl.xaml b/ENI-2/ENI2/ENI2/DetailViewControls/PSC72hDetailControl.xaml index 28ce3b37..863a8528 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/PSC72hDetailControl.xaml +++ b/ENI-2/ENI2/ENI2/DetailViewControls/PSC72hDetailControl.xaml @@ -39,7 +39,7 @@