diff --git a/ENI2/DetailRootControl.xaml.cs b/ENI2/DetailRootControl.xaml.cs
index 330b66b1..c431ae30 100644
--- a/ENI2/DetailRootControl.xaml.cs
+++ b/ENI2/DetailRootControl.xaml.cs
@@ -155,7 +155,7 @@ namespace ENI2
shipEMailLabel.Text = aCore.HerbergEmailContactReportingVessel;
displayIdLabel.Text = aCore.DisplayId;
- // TODO: Hier muss es eine Unterscheidung geben, in welchem Darstellungs-Mode der Anlauf dargestellt wird (Classic oder Formblatt)
+ // Unterscheidung in welchem Darstellungs-Mode der Anlauf dargestellt wird (Classic oder Formblatt)
if (displayMode == ReportingParty.ShipcallDisplayModeEnum.CLASSIC)
{
@@ -176,6 +176,7 @@ namespace ENI2
}
else
{
+ 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" });
}
diff --git a/ENI2/SheetDisplayControls/VoyageControl.xaml b/ENI2/SheetDisplayControls/VoyageControl.xaml
index 3fa74b0f..8b3b93f0 100644
--- a/ENI2/SheetDisplayControls/VoyageControl.xaml
+++ b/ENI2/SheetDisplayControls/VoyageControl.xaml
@@ -10,75 +10,276 @@
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:local="clr-namespace:ENI2.SheetDisplayControls"
mc:Ignorable="d"
- d:DesignHeight="450" d:DesignWidth="800">
+ d:DesignHeight="2450" d:DesignWidth="800">
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
-
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ENI2/SheetDisplayControls/VoyageControl.xaml.cs b/ENI2/SheetDisplayControls/VoyageControl.xaml.cs
index 4b4cdc7b..0287c1a0 100644
--- a/ENI2/SheetDisplayControls/VoyageControl.xaml.cs
+++ b/ENI2/SheetDisplayControls/VoyageControl.xaml.cs
@@ -10,6 +10,11 @@ using System.Windows.Media;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using System;
+using ENI2.Util;
+using System.Collections.Generic;
+using ExcelDataReader;
+using Microsoft.Win32;
+using System.IO;
namespace ENI2.SheetDisplayControls
@@ -19,11 +24,1006 @@ namespace ENI2.SheetDisplayControls
///
public partial class VoyageControl : DetailBaseControl
{
+ #region Fields
+
+ private BPOL _bpol;
+ private NOA_NOD _noanod;
+ private SEC _sec;
+ private PRE72H _pre72h;
+ private INFO _info;
+ private STAT _stat;
+ private MDH _mdh;
+
+ private static readonly string[] shippingAreas = {
+ Properties.Resources.textShippingAreaNORTHBALTIC,
+ Properties.Resources.textShippingAreaEUROPE,
+ Properties.Resources.textShippingAreaOverseas
+ };
+
+ #endregion
+
+ #region Construction
+
public VoyageControl()
{
InitializeComponent();
+ Loaded += VoyageControl_Loaded;
}
+ #endregion
+
+ #region public override
+
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ foreach (Message aMessage in this.Messages)
+ {
+ if (aMessage.Elements.Count == 0) continue;
+ if (aMessage.MessageNotificationClass == Message.NotificationClass.BPOL) { this._bpol = aMessage.Elements[0] as BPOL; this.ControlMessages.Add(aMessage); }
+ if (aMessage.MessageNotificationClass == Message.NotificationClass.NOA_NOD) { this._noanod = aMessage.Elements[0] as NOA_NOD; 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.PRE72H) { this._pre72h = aMessage.Elements[0] as PRE72H; this.ControlMessages.Add(aMessage); }
+ if (aMessage.MessageNotificationClass == Message.NotificationClass.INFO) { this._info = aMessage.Elements[0] as INFO; this.ControlMessages.Add(aMessage); }
+ if (aMessage.MessageNotificationClass == Message.NotificationClass.STAT) { this._stat = aMessage.Elements[0] as STAT; this.ControlMessages.Add(aMessage); }
+ if (aMessage.MessageNotificationClass == Message.NotificationClass.MDH) { this._mdh = aMessage.Elements[0] as MDH; this.ControlMessages.Add(aMessage); }
+ }
+
+ // 1.1
+ this.locodeControl_LastPort.DataContext = _noanod;
+ this.dateTimePicker_ETDFromLastPort.DataContext = _noanod;
+
+ // 1.2
+ this.checkBoxKielCanalPassagePlanned_Checked(null, null);
+ this.checkBoxKielCanalPassagePlanned.DataContext = _sec;
+ this.dateTimePickerKielCanalPassagePlannedIncomming.DataContext = _sec;
+
+ // 1.3
+ this.locodePoC.DataContext = this.Core;
+ this.dateTimePickerETA.DataContext = this._noanod;
+ this.dateTimePickerETD.DataContext = this._noanod;
+ this.doubleUpDownPlannedPeriodOfStay.DataContext = this._pre72h;
+
+ // 1.4
+ this.checkBoxKielCanalPassagePlannedOutgoing.DataContext = this._sec;
+ this.dateTimePickerKielCanalPassagePlannedOutgoing.DataContext = _sec;
+
+ // 1.5
+ this.locodeControl_NextPort.DataContext = _noanod;
+ this.dateTimePicker_ETAToNextPort.DataContext = _noanod;
+
+ // 1.6
+ this.comboBoxShippingArea.ItemsSource = shippingAreas;
+ this.comboBoxShippingArea.DataContext = _info;
+ this.comboBoxTransportMode.ItemsSource = STAT.TransportModeDict;
+ this.comboBoxTransportMode.DataContext = _stat;
+
+ // 1.7
+ this.dataGridLast10PortFacilities.Initialize();
+ this.dataGridLast10PortFacilities.ItemsSource = _sec.LastTenPortFacilitesCalled;
+
+ this.dataGridLast10PortFacilities.AddingNewItem += DataGridLast10PortFacilities_AddingNewItem;
+ this.dataGridLast10PortFacilities.EditRequested += DataGridLast10PortFacilities_EditRequested;
+ this.dataGridLast10PortFacilities.DeleteRequested += DataGridLast10PortFacilities_DeleteRequested;
+ this.dataGridLast10PortFacilities.CreateRequested += DataGridLast10PortFacilities_CreateRequested;
+
+ // 1.8
+ this.dataGridShip2ShipActivities.Initialize();
+ foreach (ShipToShipActivitiesDuringLastTenPortFacilitiesCalled s2s in _sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled)
+ {
+ if (s2s.ShipToShipActivityTypeCode.HasValue && s2s.ShipToShipActivityType.IsNullOrEmpty() && GlobalStructures.Edifact8025.ContainsKey(s2s.ShipToShipActivityTypeCode.Value))
+ s2s.ShipToShipActivityType = GlobalStructures.Edifact8025[s2s.ShipToShipActivityTypeCode.Value];
+ }
+ this.dataGridShip2ShipActivities.ItemsSource = _sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled;
+ this.dataGridShip2ShipActivities.AddingNewItem += DataGridShip2ShipActivities_AddingNewItem;
+ this.dataGridShip2ShipActivities.EditRequested += DataGridShip2ShipActivities_EditRequested;
+ this.dataGridShip2ShipActivities.DeleteRequested += DataGridShip2ShipActivities_DeleteRequested;
+ this.dataGridShip2ShipActivities.CreateRequested += DataGridShip2ShipActivities_CreateRequested;
+
+ // 1.9
+ this.dataGridPortOfCallLast30Days.Initialize();
+ this.dataGridPortOfCallLast30Days.ItemsSource = _mdh.PortOfCallLast30Days;
+ this.dataGridPortOfCallLast30Days.AddingNewItem += DataGridPortOfCallLast30Days_AddingNewItem;
+ this.dataGridPortOfCallLast30Days.EditRequested += DataGridPortOfCallLast30Days_EditRequested;
+ this.dataGridPortOfCallLast30Days.DeleteRequested += DataGridPortOfCallLast30Days_DeleteRequested;
+ this.dataGridPortOfCallLast30Days.CreateRequested += DataGridPortOfCallLast30Days_CreateRequested;
+
+ // 1.10
+ this.checkBoxHasShipVisited.DataContext = _mdh;
+ this.checkBoxHasShipVisited.Checked += CheckBoxHasShipVisited_Checked;
+ this.checkBoxHasShipVisited.Unchecked += CheckBoxHasShipVisited_Checked;
+ this.CheckBoxHasShipVisited_Checked(null, null);
+ this.integerUpDownNumberOfDeaths.DataContext = _mdh;
+
+ this.checkBoxHavePersonsDied.DataContext = _mdh;
+ this.checkBoxHavePersonsDied.Checked += CheckBoxHavePersonsDied_Checked;
+ this.checkBoxHavePersonsDied.Unchecked += CheckBoxHavePersonsDied_Checked;
+ this.CheckBoxHavePersonsDied_Checked(null, null);
+
+ this.checkBoxTotalNumberSickHigherThan.DataContext = _mdh;
+ this.checkBoxTotalNumberSickHigherThan.Checked += CheckBoxTotalNumberSickHigherThan_Checked;
+ this.checkBoxTotalNumberSickHigherThan.Unchecked += CheckBoxTotalNumberSickHigherThan_Checked;
+ this.CheckBoxTotalNumberSickHigherThan_Checked(null, null);
+ this.integerUpDownNumberOfIllPersons.DataContext = _mdh;
+ this.checkBoxSickPersonsOnBoard.DataContext = _mdh;
+ this.checkBoxWasMedicalConsulted.DataContext = _mdh;
+ this.checkBoxAwareOfConditions.DataContext = _mdh;
+
+ this.checkBoxSanitaryMeasuresApplied.DataContext = _mdh;
+ this.checkBoxSanitaryMeasuresApplied.Checked += CheckBoxSanitaryMeasuresApplied_Checked;
+ this.checkBoxSanitaryMeasuresApplied.Unchecked += CheckBoxSanitaryMeasuresApplied_Checked;
+ this.CheckBoxSanitaryMeasuresApplied_Checked(null, null);
+
+ this.dataGridSanitaryMeasures.Initialize();
+ this.dataGridSanitaryMeasures.IsReadOnly = !(_mdh.SanitaryMeasuresApplied ?? false);
+ this.dataGridSanitaryMeasures.ItemsSource = _mdh.SanitaryMeasuresDetails;
+ this.dataGridSanitaryMeasures.AddingNewItem += DataGridSanitaryMeasures_AddingNewItem;
+ this.dataGridSanitaryMeasures.EditRequested += DataGridSanitaryMeasures_EditRequested;
+ this.dataGridSanitaryMeasures.DeleteRequested += DataGridSanitaryMeasures_DeleteRequested;
+ this.dataGridSanitaryMeasures.CreateRequested += DataGridSanitaryMeasures_CreateRequested;
+
+ this.checkBoxStowawaysOnBoard.DataContext = _mdh;
+ this.checkBoxStowawaysOnBoard.Checked += CheckBoxStowawaysOnBoard_Checked;
+ this.checkBoxStowawaysOnBoard.Unchecked += CheckBoxStowawaysOnBoard_Checked;
+ this.CheckBoxStowawaysOnBoard_Checked(null, null);
+ this.textBoxStowawaysJoiningLocation.DataContext = _mdh;
+ this.checkBoxSickAnimalsOrPets.DataContext = _mdh;
+
+ this.checkBoxHasShipVisited.DataContext = _mdh;
+ this.dataGridInfectedAreas.Initialize();
+ this.dataGridInfectedAreas.IsReadOnly = !(_mdh.InfectedAreaVisited ?? false);
+ this.dataGridInfectedAreas.ItemsSource = _mdh.InfectedAreas;
+ this.dataGridInfectedAreas.AddingNewItem += DataGridInfectedAreas_AddingNewItem;
+ this.dataGridInfectedAreas.EditRequested += DataGridInfectedAreas_EditRequested;
+ this.dataGridInfectedAreas.DeleteRequested += DataGridInfectedAreas_DeleteRequested;
+ this.dataGridInfectedAreas.CreateRequested += DataGridInfectedAreas_CreateRequested;
+
+
+
+ }
+
+ #endregion
+
+ #region event handler
+
+ private void VoyageControl_Loaded(object sender, RoutedEventArgs e)
+ {
+ // 1.1
+ this.RegisterLocodeChange(this.locodeControl_LastPort, Message.NotificationClass.NOA_NOD);
+ this.RegisterDateTimePickerChange(this.dateTimePicker_ETDFromLastPort, Message.NotificationClass.NOA_NOD);
+
+ // 1.2
+ this.RegisterCheckboxChange(this.checkBoxKielCanalPassagePlanned, Message.NotificationClass.SEC);
+ this.RegisterDateTimePickerChange(this.dateTimePickerKielCanalPassagePlannedIncomming, Message.NotificationClass.SEC);
+
+ // 1.3
+ this.locodePoC.PropertyChanged += (o, a) => this.OnNotificationClassChanged(null);
+ this.RegisterDateTimePickerChange(this.dateTimePickerETA, Message.NotificationClass.NOA_NOD);
+ this.RegisterDateTimePickerChange(this.dateTimePickerETD, Message.NotificationClass.NOA_NOD);
+ this.RegisterDoubleUpDownChange(this.doubleUpDownPlannedPeriodOfStay, Message.NotificationClass.PRE72H);
+
+ // 1.4
+ this.RegisterCheckboxChange(this.checkBoxKielCanalPassagePlannedOutgoing, Message.NotificationClass.SEC);
+ this.RegisterDateTimePickerChange(this.dateTimePickerKielCanalPassagePlannedOutgoing, Message.NotificationClass.SEC);
+
+ // 1.5
+ this.RegisterLocodeChange(this.locodeControl_NextPort, Message.NotificationClass.NOA_NOD);
+ this.RegisterDateTimePickerChange(this.dateTimePicker_ETAToNextPort, Message.NotificationClass.NOA_NOD);
+
+ // 1.6
+ this.RegisterComboboxIndexChange(this.comboBoxShippingArea, Message.NotificationClass.INFO);
+ this.RegisterComboboxValueChange(this.comboBoxTransportMode, Message.NotificationClass.STAT);
+
+ // 1.10
+ this.RegisterCheckboxChange(this.checkBoxAwareOfConditions, Message.NotificationClass.MDH);
+ this.RegisterCheckboxChange(this.checkBoxHasShipVisited, Message.NotificationClass.MDH);
+ this.RegisterCheckboxChange(this.checkBoxHavePersonsDied, Message.NotificationClass.MDH);
+ this.RegisterCheckboxChange(this.checkBoxIsSuspectedInfectious, Message.NotificationClass.MDH);
+ this.RegisterCheckboxChange(this.checkBoxSanitaryMeasuresApplied, Message.NotificationClass.MDH);
+ this.RegisterCheckboxChange(this.checkBoxSickAnimalsOrPets, Message.NotificationClass.MDH);
+ this.RegisterCheckboxChange(this.checkBoxSickPersonsOnBoard, Message.NotificationClass.MDH);
+ this.RegisterCheckboxChange(this.checkBoxStowawaysOnBoard, Message.NotificationClass.MDH);
+ this.RegisterCheckboxChange(this.checkBoxTotalNumberSickHigherThan, Message.NotificationClass.MDH);
+ this.RegisterCheckboxChange(this.checkBoxWasMedicalConsulted, Message.NotificationClass.MDH);
+ this.RegisterIntegerUpDownChange(this.integerUpDownNumberOfDeaths, Message.NotificationClass.MDH);
+ this.RegisterIntegerUpDownChange(this.integerUpDownNumberOfIllPersons, Message.NotificationClass.MDH);
+ this.RegisterTextboxChange(this.textBoxStowawaysJoiningLocation, Message.NotificationClass.MDH);
+
+ // 1.11
+ this.checkBoxCruiseShip.DataContext = _bpol;
+ this.dataGridPortOfItinerary.Initialize();
+ this.dataGridPortOfItinerary.ItemsSource = _bpol.PortOfItineraries;
+ this.dataGridPortOfItinerary.AddingNewItem += DataGridPortOfItinerary_AddingNewItem;
+ this.dataGridPortOfItinerary.EditRequested += DataGridPortOfItinerary_EditRequested;
+ this.dataGridPortOfItinerary.DeleteRequested += DataGridPortOfItinerary_DeleteRequested;
+ this.dataGridPortOfItinerary.CreateRequested += DataGridPortOfItinerary_CreateRequested;
+
+ }
+
+ private void checkBoxKielCanalPassagePlanned_Checked(object sender, RoutedEventArgs e)
+ {
+ this.dateTimePickerKielCanalPassagePlannedIncomming.IsEnabled = this.checkBoxKielCanalPassagePlanned.IsChecked ?? false;
+ this.dateTimePickerKielCanalPassagePlannedOutgoing.IsEnabled = this.checkBoxKielCanalPassagePlanned.IsChecked ?? false;
+ }
+
+ private void CheckBoxStowawaysOnBoard_Checked(object sender, RoutedEventArgs e)
+ {
+ this.textBoxStowawaysJoiningLocation.IsEnabled = this.checkBoxStowawaysOnBoard.IsChecked ?? false;
+ this.textBoxStowawaysJoiningLocation.IsReadOnly = !(this.checkBoxStowawaysOnBoard.IsChecked ?? false);
+ }
+
+ private void CheckBoxTotalNumberSickHigherThan_Checked(object sender, RoutedEventArgs e)
+ {
+ this.integerUpDownNumberOfIllPersons.IsEnabled = this.checkBoxTotalNumberSickHigherThan.IsChecked ?? false;
+ this.integerUpDownNumberOfDeaths.IsReadOnly = !(this.checkBoxTotalNumberSickHigherThan.IsChecked ?? false);
+ }
+
+ private void CheckBoxHavePersonsDied_Checked(object sender, RoutedEventArgs e)
+ {
+ this.integerUpDownNumberOfDeaths.IsEnabled = this.checkBoxHavePersonsDied.IsChecked ?? false;
+ this.integerUpDownNumberOfDeaths.IsReadOnly = !(this.checkBoxHavePersonsDied.IsChecked ?? false);
+ }
+
+ private void CheckBoxHasShipVisited_Checked(object sender, RoutedEventArgs e)
+ {
+ this.dataGridInfectedAreas.IsReadOnly = !(this.checkBoxHasShipVisited.IsChecked ?? false);
+ }
+
+ private void CheckBoxSanitaryMeasuresApplied_Checked(object sender, RoutedEventArgs e)
+ {
+ this.dataGridSanitaryMeasures.IsReadOnly = !(this.checkBoxSanitaryMeasuresApplied.IsChecked ?? false);
+ }
+
+ private void buttonImportExcelLast10PortFacilities_Click(object sender, RoutedEventArgs e)
+ {
+ OpenFileDialog ofd = new OpenFileDialog
+ {
+ Filter = "Excel Files|*.xls;*.xlsx"
+ };
+
+ if (ofd.ShowDialog() ?? false)
+ {
+ FileStream stream;
+ try
+ {
+ stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ using (var reader = ExcelReaderFactory.CreateReader(stream))
+ {
+ List importL10C = new List();
+
+ try
+ {
+ do
+ {
+ int cnt = 0;
+ while (reader.Read() && (cnt < 10))
+ {
+ if (((IExcelDataReader)reader).FieldCount < 8)
+ {
+ throw new InvalidDataException("Sheet must have 8 Columns of data");
+ }
+ LastTenPortFacilitiesCalled l10c = new LastTenPortFacilitiesCalled();
+ if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
+ if (!reader.IsDBNull(0)) l10c.PortFacilityPortName = reader.GetString(0);
+ if (!reader.IsDBNull(2)) l10c.PortFacilityPortCountry = reader.GetString(2);
+ if (!reader.IsDBNull(3)) l10c.PortFacilityPortLoCode = reader.GetString(3);
+ object o = null;
+ if (!reader.IsDBNull(4)) o = reader.GetValue(4);
+ if (o != null) l10c.PortFacilityDateOfArrival = Convert.ToDateTime(o);
+ if (!reader.IsDBNull(5)) o = reader.GetValue(5);
+ if (o != null) l10c.PortFacilityDateOfDeparture = Convert.ToDateTime(o);
+ // if (!reader.IsDBNull(4)) l10c.PortFacilityDateOfArrival = reader.GetDateTime(4);
+ // if (!reader.IsDBNull(5)) l10c.PortFacilityDateOfDeparture = reader.GetDateTime(5);
+ if (!reader.IsDBNull(6)) o = reader.GetValue(6);
+ if (o != null) l10c.PortFacilityShipSecurityLevel = Convert.ToByte(o);
+ if (!reader.IsDBNull(7)) o = reader.GetValue(7);
+ int gisis = Convert.ToInt32(o);
+ if (!reader.IsDBNull(7)) l10c.PortFacilityGISISCode = gisis.ToString().PadLeft(4, '0');
+ if (!reader.IsDBNull(8)) l10c.PortFacilitySecurityMattersToReport = reader.GetString(8);
+ if (l10c.PortFacilitySecurityMattersToReport.Equals("nil", StringComparison.CurrentCultureIgnoreCase))
+ l10c.PortFacilitySecurityMattersToReport = null;
+ if (!reader.IsDBNull(9)) l10c.PortFacilityGISISCodeLocode = reader.GetString(9);
+ l10c.SEC = this._sec;
+ l10c.IsDirty = true;
+ l10c.Identifier = LastTenPortFacilitiesCalled.GetNewIdentifier(this._sec.LastTenPortFacilitesCalled);
+ this._sec.LastTenPortFacilitesCalled.Add(l10c);
+ importL10C.Add(l10c);
+ cnt++;
+ }
+ } while (reader.NextResult());
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+
+ if (importL10C.Count > 0)
+ {
+ this.dataGridLast10PortFacilities.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.SEC);
+ MessageBox.Show(String.Format(Properties.Resources.textL10PImported, importL10C.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ }
+
+ stream.Close();
+ }
+ }
+
+ private void buttonImportFromL10P_Click(object sender, RoutedEventArgs e)
+ {
+ if (this._sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count > 0)
+ {
+ MessageBox.Show(Properties.Resources.textOnlyIfGridIsEmpty, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Warning);
+ }
+ else
+ {
+ foreach (LastTenPortFacilitiesCalled l10c in this._sec.LastTenPortFacilitesCalled)
+ {
+ ShipToShipActivitiesDuringLastTenPortFacilitiesCalled s2s = new ShipToShipActivitiesDuringLastTenPortFacilitiesCalled
+ {
+ SEC = this._sec,
+ Identifier = ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.GetNewIdentifier(this._sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled),
+ ShipToShipActivityLocationName = l10c.PortFacilityPortName,
+ ShipToShipActivityLocationLoCode = l10c.PortFacilityPortLoCode,
+ ShipToShipActivityDateFrom = l10c.PortFacilityDateOfArrival,
+ ShipToShipActivityDateTo = l10c.PortFacilityDateOfDeparture,
+ ShipToShipActivitySecurityMattersToReport = l10c.PortFacilitySecurityMattersToReport
+ };
+
+ this._sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Add(s2s);
+ }
+ if (this._sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count > 0)
+ {
+ this.dataGridShip2ShipActivities.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.SEC);
+ }
+ }
+ }
+
+ private void buttonImportFromSEC_Click(object sender, RoutedEventArgs e)
+ {
+ if (this._mdh.PortOfCallLast30Days.Count > 0)
+ {
+ MessageBox.Show(Properties.Resources.textOnlyIfGridIsEmpty, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Warning);
+ }
+ else
+ {
+ if (this._sec != null)
+ {
+ foreach (LastTenPortFacilitiesCalled l10fc in _sec.LastTenPortFacilitesCalled)
+ {
+ if (l10fc.PortFacilityDateOfDeparture.HasValue &&
+ ((DateTime.Now - l10fc.PortFacilityDateOfDeparture.Value).TotalDays < 31))
+ {
+ PortOfCallLast30Days poc30 = new PortOfCallLast30Days();
+ poc30.Identifier = PortOfCallLast30Days.GetNewIdentifier(this._mdh.PortOfCallLast30Days);
+ poc30.PortOfCallLast30DaysCrewMembersJoined = false;
+ poc30.PortOfCallLast30DaysDateOfDeparture = l10fc.PortFacilityDateOfDeparture;
+ poc30.PortOfCallLast30DaysLocode = l10fc.PortFacilityPortLoCode;
+ poc30.MDH = this._mdh;
+ this._mdh.PortOfCallLast30Days.Add(poc30);
+ }
+ }
+ if (this._mdh.PortOfCallLast30Days.Count > 0)
+ {
+ this.dataGridPortOfCallLast30Days.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.MDH);
+ }
+ }
+ }
+ }
+
+ private void buttonImportLast30DaysFromExcel_Click(object sender, RoutedEventArgs e)
+ {
+ OpenFileDialog ofd = new OpenFileDialog
+ {
+ Filter = "Excel Files|*.xls;*.xlsx"
+ };
+ if (ofd.ShowDialog() ?? false)
+ {
+ FileStream stream;
+ try
+ {
+ stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ using (var reader = ExcelReaderFactory.CreateReader(stream))
+ {
+ List importPoC30 = new List();
+
+ try
+ {
+ do
+ {
+ while (reader.Read())
+ {
+ if (reader.FieldCount < 3)
+ {
+ throw new InvalidDataException("Sheet must have at least 3 Columns of data");
+ }
+ PortOfCallLast30Days poc30 = new PortOfCallLast30Days();
+ if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
+ if (!reader.IsDBNull(0)) poc30.PortOfCallLast30DaysLocode = reader.GetString(0);
+ if (!reader.IsDBNull(1)) poc30.PortOfCallLast30DaysDateOfDeparture = reader.GetDateTime(1);
+ string boolString = "";
+ if (!reader.IsDBNull(2)) boolString = reader.GetString(2);
+ poc30.PortOfCallLast30DaysCrewMembersJoined = (boolString.Equals("y", StringComparison.OrdinalIgnoreCase) || (boolString.Equals("yes", StringComparison.OrdinalIgnoreCase)) ||
+ (boolString.Equals("j", StringComparison.OrdinalIgnoreCase)));
+
+ if (reader.FieldCount > 3)
+ {
+ string allNewCrew = reader.GetString(3)?.Trim();
+ if (!allNewCrew.IsNullOrEmpty())
+ {
+ string[] crewNames = allNewCrew.Split(',', ';');
+ for (int i = 0; i < crewNames.Length; i++)
+ {
+ string crewName = crewNames[i].Trim();
+ if (crewName.IsNullOrEmpty()) continue;
+ PortOfCallLast30DaysCrewJoinedShip poc30Crew = new PortOfCallLast30DaysCrewJoinedShip();
+ poc30Crew.PortOfCallLast30DaysCrewJoinedShipName = crewName;
+ poc30Crew.PortOfCallLast30Days = poc30;
+ poc30.CrewJoinedShip.Add(poc30Crew);
+
+ }
+ }
+ }
+
+ poc30.MDH = this._mdh;
+ this._mdh.PortOfCallLast30Days.Add(poc30);
+ importPoC30.Add(poc30);
+ }
+ } while (reader.NextResult());
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+
+ if (importPoC30.Count > 0)
+ {
+ this.dataGridPortOfCallLast30Days.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.MDH);
+ MessageBox.Show(String.Format(Properties.Resources.textPoC30Imported, importPoC30.Count), Properties.Resources.textCaptionInformation,
+ MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ }
+
+ stream.Close();
+ }
+ }
+
+ private void buttonImportPortOfItineraryFromSEC_Click(object sender, RoutedEventArgs e)
+ {
+ if (this._bpol.PortOfItineraries.Count > 0)
+ {
+ MessageBox.Show(Properties.Resources.textOnlyIfGridIsEmpty, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Warning);
+ }
+ else
+ {
+ if (this._sec != null)
+ {
+ foreach (LastTenPortFacilitiesCalled l10fc in _sec.LastTenPortFacilitesCalled)
+ {
+ //if (l10fc.PortFacilityDateOfDeparture.HasValue &&
+ //((DateTime.Now - l10fc.PortFacilityDateOfDeparture.Value).TotalDays < 31))
+ //{
+ DateTime? eta = null;
+ if (l10fc.PortFacilityDateOfArrival.HasValue)
+ {
+ eta = new DateTime(l10fc.PortFacilityDateOfArrival.Value.Year, l10fc.PortFacilityDateOfArrival.Value.Month,
+ l10fc.PortFacilityDateOfArrival.Value.Day, 11, 11, 11).ToUniversalTime();
+ }
+
+ PortOfItinerary poi = new PortOfItinerary
+ {
+ Identifier = PortOfItinerary.GetNewIdentifier(this._bpol.PortOfItineraries),
+ BPOL = this._bpol,
+ PortOfItineraryETA = eta,
+ PortOfItineraryLocode = l10fc.PortFacilityPortLoCode,
+ PortOfItineraryName = l10fc.PortFacilityPortName
+ };
+ this._bpol.PortOfItineraries.Add(poi);
+ //}
+ }
+ if (this._bpol.PortOfItineraries.Count > 0)
+ {
+ this.dataGridPortOfItinerary.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.BPOL);
+ }
+ }
+ }
+ }
+
+ #endregion
+
+ #region datagrid ship 2 ship activities
+
+ private void DataGridShip2ShipActivities_CreateRequested()
+ {
+ EditShip2ShipActivitiesDialog epd = new EditShip2ShipActivitiesDialog
+ {
+ ShipToShipActivity = new ShipToShipActivitiesDuringLastTenPortFacilitiesCalled()
+ };
+ epd.ShipToShipActivity.Identifier = ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.GetNewIdentifier(_sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled);
+ epd.ShipToShipActivity.SEC = this._sec;
+
+ epd.AddClicked += () =>
+ {
+ epd.CopyValuesToEntity();
+ if (!this._sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Contains(epd.ShipToShipActivity))
+ this._sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Add(epd.ShipToShipActivity);
+ this.dataGridShip2ShipActivities.Items.Refresh();
+ epd.ShipToShipActivity = new ShipToShipActivitiesDuringLastTenPortFacilitiesCalled
+ {
+ SEC = this._sec,
+ Identifier = ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.GetNewIdentifier(_sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled)
+ };
+ this.SublistElementChanged(Message.NotificationClass.SEC);
+ };
+
+ if (epd.ShowDialog() ?? false)
+ {
+ if (!_sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Contains(epd.ShipToShipActivity))
+ _sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Add(epd.ShipToShipActivity);
+ this.dataGridShip2ShipActivities.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.SEC);
+ }
+ }
+
+ private void DataGridShip2ShipActivities_DeleteRequested(DatabaseEntity obj)
+ {
+ if (obj is ShipToShipActivitiesDuringLastTenPortFacilitiesCalled s2s)
+ {
+ // are you sure dialog is in base class
+ _sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Remove(s2s);
+ DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(s2s);
+ List tmpList = new List(_sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled);
+ DatabaseEntity.ResetIdentifiers(tmpList);
+ this.SublistElementChanged(Message.NotificationClass.SEC);
+ this.dataGridShip2ShipActivities.Items.Refresh();
+ }
+ }
+
+ private void DataGridShip2ShipActivities_EditRequested(DatabaseEntity obj)
+ {
+ EditShip2ShipActivitiesDialog ecpd = new EditShip2ShipActivitiesDialog
+ {
+ ShipToShipActivity = obj as ShipToShipActivitiesDuringLastTenPortFacilitiesCalled
+ };
+ ecpd.AddClicked += () =>
+ {
+ ecpd.CopyValuesToEntity();
+ if (!_sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Contains(ecpd.ShipToShipActivity))
+ _sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Add(ecpd.ShipToShipActivity);
+ this.dataGridShip2ShipActivities.Items.Refresh();
+ ecpd.ShipToShipActivity = new ShipToShipActivitiesDuringLastTenPortFacilitiesCalled
+ {
+ SEC = this._sec,
+ Identifier = ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.GetNewIdentifier(_sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled)
+ };
+ this.SublistElementChanged(Message.NotificationClass.SEC);
+ };
+ if (ecpd.ShowDialog() ?? false)
+ {
+ if (!_sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Contains(ecpd.ShipToShipActivity))
+ _sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Add(ecpd.ShipToShipActivity);
+ this.dataGridShip2ShipActivities.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.SEC);
+ }
+ }
+
+ private void DataGridShip2ShipActivities_AddingNewItem(object sender, AddingNewItemEventArgs e)
+ {
+ this.DataGridShip2ShipActivities_CreateRequested();
+ }
+
+ #endregion
+
+ #region data grid last 10 port facilities
+
+ private void DataGridLast10PortFacilities_CreateRequested()
+ {
+ EditLast10PortFacilitiesDialog epd = new EditLast10PortFacilitiesDialog
+ {
+ LastTenPortFacilitiesCalled = new LastTenPortFacilitiesCalled()
+ };
+ epd.LastTenPortFacilitiesCalled.Identifier = LastTenPortFacilitiesCalled.GetNewIdentifier(_sec.LastTenPortFacilitesCalled);
+ epd.LastTenPortFacilitiesCalled.SEC = this._sec;
+
+ epd.AddClicked += () =>
+ {
+ epd.CopyValuesToEntity();
+ if (!this._sec.LastTenPortFacilitesCalled.Contains(epd.LastTenPortFacilitiesCalled))
+ this._sec.LastTenPortFacilitesCalled.Add(epd.LastTenPortFacilitiesCalled);
+ this.dataGridLast10PortFacilities.Items.Refresh();
+
+ epd.LastTenPortFacilitiesCalled = new LastTenPortFacilitiesCalled
+ {
+ SEC = this._sec,
+ Identifier = LastTenPortFacilitiesCalled.GetNewIdentifier(_sec.LastTenPortFacilitesCalled)
+ };
+ this.SublistElementChanged(Message.NotificationClass.SEC);
+ };
+
+ if (epd.ShowDialog() ?? false)
+ {
+ if (!_sec.LastTenPortFacilitesCalled.Contains(epd.LastTenPortFacilitiesCalled))
+ _sec.LastTenPortFacilitesCalled.Add(epd.LastTenPortFacilitiesCalled);
+ this.dataGridLast10PortFacilities.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.SEC);
+ }
+ }
+
+ private void DataGridLast10PortFacilities_DeleteRequested(DatabaseEntity obj)
+ {
+ if (obj is LastTenPortFacilitiesCalled l10c)
+ {
+ // are you sure dialog is in base class
+ _sec.LastTenPortFacilitesCalled.Remove(l10c);
+ DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(l10c);
+ List tmpList = new List(_sec.LastTenPortFacilitesCalled);
+ DatabaseEntity.ResetIdentifiers(tmpList);// );
+ this.SublistElementChanged(Message.NotificationClass.SEC);
+ this.dataGridLast10PortFacilities.Items.Refresh();
+ }
+ }
+
+ private void DataGridLast10PortFacilities_EditRequested(DatabaseEntity obj)
+ {
+ EditLast10PortFacilitiesDialog ecpd = new EditLast10PortFacilitiesDialog
+ {
+ LastTenPortFacilitiesCalled = obj as LastTenPortFacilitiesCalled
+ };
+ ecpd.AddClicked += () =>
+ {
+ ecpd.CopyValuesToEntity();
+ if (!_sec.LastTenPortFacilitesCalled.Contains(ecpd.LastTenPortFacilitiesCalled))
+ _sec.LastTenPortFacilitesCalled.Add(ecpd.LastTenPortFacilitiesCalled);
+ this.dataGridLast10PortFacilities.Items.Refresh();
+ ecpd.LastTenPortFacilitiesCalled = new LastTenPortFacilitiesCalled
+ {
+ SEC = this._sec,
+ Identifier = LastTenPortFacilitiesCalled.GetNewIdentifier(_sec.LastTenPortFacilitesCalled)
+ };
+ this.SublistElementChanged(Message.NotificationClass.SEC);
+ };
+ if (ecpd.ShowDialog() ?? false)
+ {
+ if (!_sec.LastTenPortFacilitesCalled.Contains(ecpd.LastTenPortFacilitiesCalled))
+ _sec.LastTenPortFacilitesCalled.Add(ecpd.LastTenPortFacilitiesCalled);
+ this.dataGridLast10PortFacilities.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.SEC);
+ }
+ }
+
+ private void DataGridLast10PortFacilities_AddingNewItem(object sender, AddingNewItemEventArgs e)
+ {
+ this.DataGridLast10PortFacilities_CreateRequested();
+ }
+
+ #endregion
+
+ #region data grid pot called during last 30 days
+
+ private void DataGridPortOfCallLast30Days_CreateRequested()
+ {
+ EditPortOfCallLast30DaysDialog epd = new EditPortOfCallLast30DaysDialog();
+ epd.PocLast30Days = new PortOfCallLast30Days();
+ epd.PocLast30Days.Identifier = PortOfCallLast30Days.GetNewIdentifier(_mdh.PortOfCallLast30Days);
+ epd.PocLast30Days.MDH = this._mdh;
+
+ epd.AddClicked += () =>
+ {
+ epd.CopyValuesToEntity();
+ if (!this._mdh.PortOfCallLast30Days.Contains(epd.PocLast30Days))
+ this._mdh.PortOfCallLast30Days.Add(epd.PocLast30Days);
+ this.dataGridPortOfCallLast30Days.Items.Refresh();
+ epd.PocLast30Days = new PortOfCallLast30Days();
+ epd.PocLast30Days.MDH = this._mdh;
+ epd.PocLast30Days.Identifier = PortOfCallLast30Days.GetNewIdentifier(_mdh.PortOfCallLast30Days);
+ this.SublistElementChanged(Message.NotificationClass.MDH);
+ };
+
+ if (epd.ShowDialog() ?? false)
+ {
+ if (!_mdh.PortOfCallLast30Days.Contains(epd.PocLast30Days))
+ _mdh.PortOfCallLast30Days.Add(epd.PocLast30Days);
+ this.dataGridPortOfCallLast30Days.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.MDH);
+ }
+ }
+
+ private void DataGridPortOfCallLast30Days_DeleteRequested(DatabaseEntity obj)
+ {
+ if (obj is PortOfCallLast30Days poc30d)
+ {
+ // are you sure dialog is in base class
+ _mdh.PortOfCallLast30Days.Remove(poc30d);
+ poc30d.DeleteElements();
+ DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(poc30d);
+ DatabaseEntity.ResetIdentifiers(new List(_mdh.PortOfCallLast30Days));
+ this.SublistElementChanged(Message.NotificationClass.MDH);
+ this.dataGridPortOfCallLast30Days.Items.Refresh();
+ }
+ }
+
+ private void DataGridPortOfCallLast30Days_EditRequested(DatabaseEntity obj)
+ {
+ EditPortOfCallLast30DaysDialog ecpd = new EditPortOfCallLast30DaysDialog();
+ ecpd.PocLast30Days = obj as PortOfCallLast30Days;
+ ecpd.AddClicked += () =>
+ {
+ ecpd.CopyValuesToEntity();
+ if (!_mdh.PortOfCallLast30Days.Contains(ecpd.PocLast30Days))
+ _mdh.PortOfCallLast30Days.Add(ecpd.PocLast30Days);
+ this.dataGridPortOfCallLast30Days.Items.Refresh();
+ ecpd.PocLast30Days = new PortOfCallLast30Days();
+ ecpd.PocLast30Days.MDH = this._mdh;
+ ecpd.PocLast30Days.Identifier = PortOfCallLast30Days.GetNewIdentifier(_mdh.PortOfCallLast30Days);
+ this.SublistElementChanged(Message.NotificationClass.MDH);
+ };
+ if (ecpd.ShowDialog() ?? false)
+ {
+ if (!_mdh.PortOfCallLast30Days.Contains(ecpd.PocLast30Days))
+ _mdh.PortOfCallLast30Days.Add(ecpd.PocLast30Days);
+ this.dataGridPortOfCallLast30Days.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.MDH);
+ }
+ }
+
+ private void DataGridPortOfCallLast30Days_AddingNewItem(object sender, AddingNewItemEventArgs e)
+ {
+ this.DataGridPortOfCallLast30Days_CreateRequested();
+ }
+
+ #endregion
+
+ #region data grid sanitary measures
+
+ private void DataGridSanitaryMeasures_CreateRequested()
+ {
+ EditSanitaryMeasureDialog epd = new EditSanitaryMeasureDialog();
+ epd.SanitaryMeasureDetail = new SanitaryMeasuresDetail();
+ epd.SanitaryMeasureDetail.Identifier = SanitaryMeasuresDetail.GetNewIdentifier(_mdh.SanitaryMeasuresDetails);
+ epd.SanitaryMeasureDetail.MDH = this._mdh;
+
+ epd.AddClicked += () =>
+ {
+ epd.CopyValuesToEntity();
+ if (!this._mdh.SanitaryMeasuresDetails.Contains(epd.SanitaryMeasureDetail))
+ this._mdh.SanitaryMeasuresDetails.Add(epd.SanitaryMeasureDetail);
+ this.dataGridSanitaryMeasures.Items.Refresh();
+ epd.SanitaryMeasureDetail = new SanitaryMeasuresDetail();
+ epd.SanitaryMeasureDetail.Identifier = SanitaryMeasuresDetail.GetNewIdentifier(_mdh.SanitaryMeasuresDetails);
+ epd.SanitaryMeasureDetail.MDH = this._mdh;
+ this.SublistElementChanged(Message.NotificationClass.MDH);
+ };
+
+ if (epd.ShowDialog() ?? false)
+ {
+ if (!_mdh.SanitaryMeasuresDetails.Contains(epd.SanitaryMeasureDetail))
+ _mdh.SanitaryMeasuresDetails.Add(epd.SanitaryMeasureDetail);
+ this.dataGridSanitaryMeasures.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.MDH);
+ }
+ }
+
+ private void DataGridSanitaryMeasures_DeleteRequested(DatabaseEntity obj)
+ {
+ if (obj is SanitaryMeasuresDetail smd)
+ {
+ // are you sure dialog is in base class
+ _mdh.SanitaryMeasuresDetails.Remove(smd);
+ DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(smd);
+ DatabaseEntity.ResetIdentifiers(new List(_mdh.SanitaryMeasuresDetails));
+ this.SublistElementChanged(Message.NotificationClass.MDH);
+ this.dataGridSanitaryMeasures.Items.Refresh();
+ }
+ }
+
+ private void DataGridSanitaryMeasures_EditRequested(DatabaseEntity obj)
+ {
+ EditSanitaryMeasureDialog ecpd = new EditSanitaryMeasureDialog();
+ ecpd.SanitaryMeasureDetail = obj as SanitaryMeasuresDetail;
+ ecpd.AddClicked += () =>
+ {
+ ecpd.CopyValuesToEntity();
+ if (!_mdh.SanitaryMeasuresDetails.Contains(ecpd.SanitaryMeasureDetail))
+ _mdh.SanitaryMeasuresDetails.Add(ecpd.SanitaryMeasureDetail);
+ this.dataGridSanitaryMeasures.Items.Refresh();
+ ecpd.SanitaryMeasureDetail = new SanitaryMeasuresDetail();
+ ecpd.SanitaryMeasureDetail.Identifier = SanitaryMeasuresDetail.GetNewIdentifier(_mdh.SanitaryMeasuresDetails);
+ ecpd.SanitaryMeasureDetail.MDH = this._mdh;
+ this.SublistElementChanged(Message.NotificationClass.MDH);
+ };
+ if (ecpd.ShowDialog() ?? false)
+ {
+ if (!_mdh.SanitaryMeasuresDetails.Contains(ecpd.SanitaryMeasureDetail))
+ _mdh.SanitaryMeasuresDetails.Add(ecpd.SanitaryMeasureDetail);
+ this.dataGridSanitaryMeasures.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.MDH);
+ }
+ }
+
+ private void DataGridSanitaryMeasures_AddingNewItem(object sender, AddingNewItemEventArgs e)
+ {
+ this.DataGridSanitaryMeasures_CreateRequested();
+ }
+
+ #endregion
+
+ #region data grid infected areas
+
+ private void DataGridInfectedAreas_CreateRequested()
+ {
+ EditInfectedAreaDialog epd = new EditInfectedAreaDialog();
+ epd.InfectedArea = new InfectedArea();
+ epd.InfectedArea.Identifier = InfectedArea.GetNewIdentifier(_mdh.InfectedAreas);
+ epd.InfectedArea.MDH = this._mdh;
+
+ epd.AddClicked += () =>
+ {
+ epd.CopyValuesToEntity();
+ if (!this._mdh.InfectedAreas.Contains(epd.InfectedArea))
+ this._mdh.InfectedAreas.Add(epd.InfectedArea);
+ this.dataGridInfectedAreas.Items.Refresh();
+ epd.InfectedArea = new InfectedArea();
+ epd.InfectedArea.MDH = this._mdh;
+ epd.InfectedArea.Identifier = InfectedArea.GetNewIdentifier(_mdh.InfectedAreas);
+ this.SublistElementChanged(Message.NotificationClass.MDH);
+ };
+
+ if (epd.ShowDialog() ?? false)
+ {
+ if (!this._mdh.InfectedAreas.Contains(epd.InfectedArea))
+ _mdh.InfectedAreas.Add(epd.InfectedArea);
+ this.dataGridInfectedAreas.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.MDH);
+ }
+ }
+
+ private void DataGridInfectedAreas_DeleteRequested(DatabaseEntity obj)
+ {
+ if (obj is InfectedArea ia)
+ {
+ // are you sure dialog is in base class
+ _mdh.InfectedAreas.Remove(ia);
+ DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(ia);
+ DatabaseEntity.ResetIdentifiers(new List(_mdh.InfectedAreas));
+ this.SublistElementChanged(Message.NotificationClass.MDH);
+ this.dataGridInfectedAreas.Items.Refresh();
+ }
+ }
+
+ private void DataGridInfectedAreas_EditRequested(DatabaseEntity obj)
+ {
+ EditInfectedAreaDialog ecpd = new EditInfectedAreaDialog();
+ ecpd.InfectedArea = obj as InfectedArea;
+ ecpd.AddClicked += () =>
+ {
+ ecpd.CopyValuesToEntity();
+ if (!_mdh.InfectedAreas.Contains(ecpd.InfectedArea))
+ _mdh.InfectedAreas.Add(ecpd.InfectedArea);
+ this.dataGridInfectedAreas.Items.Refresh();
+ ecpd.InfectedArea = new InfectedArea();
+ ecpd.InfectedArea.MDH = this._mdh;
+ ecpd.InfectedArea.Identifier = InfectedArea.GetNewIdentifier(_mdh.InfectedAreas);
+ this.SublistElementChanged(Message.NotificationClass.MDH);
+ };
+ if (ecpd.ShowDialog() ?? false)
+ {
+ if (!_mdh.InfectedAreas.Contains(ecpd.InfectedArea))
+ _mdh.InfectedAreas.Add(ecpd.InfectedArea);
+ this.dataGridInfectedAreas.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.MDH);
+ }
+ }
+
+ private void DataGridInfectedAreas_AddingNewItem(object sender, AddingNewItemEventArgs e)
+ {
+ this.DataGridInfectedAreas_CreateRequested();
+ }
+
+ #endregion
+
+ #region data grid port of itinerary
+
+ private void DataGridPortOfItinerary_CreateRequested()
+ {
+ EditPortOfItineraryDialog epid = new EditPortOfItineraryDialog
+ {
+ PortOfItinerary = new PortOfItinerary()
+ };
+ epid.PortOfItinerary.Identifier = PortOfItinerary.GetNewIdentifier(this._bpol.PortOfItineraries);
+ epid.PortOfItinerary.BPOL = this._bpol;
+
+ epid.AddClicked += () =>
+ {
+ epid.CopyValuesToEntity();
+ if (!this._bpol.PortOfItineraries.Contains(epid.PortOfItinerary))
+ this._bpol.PortOfItineraries.Add(epid.PortOfItinerary);
+ this.dataGridPortOfItinerary.Items.Refresh();
+ epid.PortOfItinerary = new PortOfItinerary
+ {
+ BPOL = _bpol,
+ Identifier = PortOfItinerary.GetNewIdentifier(this._bpol.PortOfItineraries)
+ };
+ this.SublistElementChanged(Message.NotificationClass.BPOL);
+ };
+
+ if (epid.ShowDialog() ?? false)
+ {
+ if (!_bpol.PortOfItineraries.Contains(epid.PortOfItinerary))
+ _bpol.PortOfItineraries.Add(epid.PortOfItinerary);
+ this.dataGridPortOfItinerary.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.BPOL);
+ }
+ }
+
+ private void DataGridPortOfItinerary_DeleteRequested(DatabaseEntity obj)
+ {
+ if (obj is PortOfItinerary poi)
+ {
+ // are you sure dialog is in base class
+ _bpol.PortOfItineraries.Remove(poi);
+ DBManager.Instance.Delete(poi);
+ DatabaseEntity.ResetIdentifiers(new List(_bpol.PortOfItineraries));
+ this.SublistElementChanged(Message.NotificationClass.BPOL);
+ this.dataGridPortOfItinerary.Items.Refresh();
+ }
+ }
+
+ private void DataGridPortOfItinerary_EditRequested(DatabaseEntity obj)
+ {
+ EditPortOfItineraryDialog epid = new EditPortOfItineraryDialog
+ {
+ PortOfItinerary = obj as PortOfItinerary
+ };
+
+ epid.AddClicked += () =>
+ {
+ epid.CopyValuesToEntity();
+ if (!_bpol.PortOfItineraries.Contains(epid.PortOfItinerary))
+ _bpol.PortOfItineraries.Add(epid.PortOfItinerary);
+ this.dataGridPortOfItinerary.Items.Refresh();
+ epid.PortOfItinerary = new PortOfItinerary
+ {
+ BPOL = this._bpol,
+ Identifier = PortOfItinerary.GetNewIdentifier(this._bpol.PortOfItineraries)
+ };
+ this.SublistElementChanged(Message.NotificationClass.BPOL);
+ };
+
+ if (epid.ShowDialog() ?? false)
+ {
+ if (!_bpol.PortOfItineraries.Contains(epid.PortOfItinerary))
+ this._bpol.PortOfItineraries.Add(epid.PortOfItinerary);
+ this.dataGridPortOfItinerary.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.BPOL);
+ }
+ }
+
+ private void DataGridPortOfItinerary_AddingNewItem(object sender, AddingNewItemEventArgs e)
+ {
+ this.DataGridPortOfItinerary_CreateRequested();
+ }
+
+ #endregion
+
#region mouse wheel
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
@@ -35,5 +1035,6 @@ namespace ENI2.SheetDisplayControls
#endregion
+
}
}