1502 lines
68 KiB
C#
1502 lines
68 KiB
C#
// Copyright (c) 2017 schick Informatik
|
|
// Description: Detailansicht für BPOL, CREW(D), PAS(D)
|
|
//
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.Win32;
|
|
using System.Windows;
|
|
using System.IO;
|
|
using System.Windows.Controls;
|
|
using ENI2.EditControls;
|
|
using ENI2.Util;
|
|
using ENI2.Locode;
|
|
using ClosedXML.Excel;
|
|
using bsmd.database;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Linq;
|
|
|
|
namespace ENI2.DetailViewControls
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for BorderPoliceDetailControl.xaml
|
|
/// </summary>
|
|
public partial class BorderPoliceDetailControl : DetailBaseControl
|
|
{
|
|
private Message _bpolMessage;
|
|
private Message _crewMessage;
|
|
private Message _crewdMessage;
|
|
private Message _pasMessage;
|
|
private Message _pasdMessage;
|
|
private Message _secMessage;
|
|
private BPOL _bpol;
|
|
private SEC _sec;
|
|
|
|
public BorderPoliceDetailControl()
|
|
{
|
|
InitializeComponent();
|
|
this.Loaded += BorderPoliceDetailControl_Loaded;
|
|
|
|
}
|
|
|
|
private void BorderPoliceDetailControl_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
this.RegisterCheckboxChange(this.checkBoxCruiseShip, Message.NotificationClass.BPOL);
|
|
this.RegisterCheckboxChange(this.checkBoxStowaways, Message.NotificationClass.BPOL);
|
|
}
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
foreach (Message aMessage in this.Messages)
|
|
{
|
|
if (aMessage.MessageNotificationClass == Message.NotificationClass.BPOL) { this._bpolMessage = aMessage; this.ControlMessages.Add(aMessage); }
|
|
if (aMessage.MessageNotificationClass == Message.NotificationClass.CREWA) { this._crewMessage = aMessage; this.ControlMessages.Add(aMessage); }
|
|
if (aMessage.MessageNotificationClass == Message.NotificationClass.PASA) { this._pasMessage = aMessage; this.ControlMessages.Add(aMessage); }
|
|
if (aMessage.MessageNotificationClass == Message.NotificationClass.CREWD) { this._crewdMessage = aMessage; this.ControlMessages.Add(aMessage); }
|
|
if (aMessage.MessageNotificationClass == Message.NotificationClass.PASD) { this._pasdMessage = aMessage; this.ControlMessages.Add(aMessage); }
|
|
|
|
if (aMessage.MessageNotificationClass == Message.NotificationClass.SEC)
|
|
{
|
|
this._secMessage = aMessage;
|
|
if (this._secMessage.Elements.Count > 0) this._sec = this._secMessage.Elements[0] as SEC;
|
|
}
|
|
|
|
}
|
|
|
|
#region init BPOL
|
|
|
|
if (this._bpolMessage == null)
|
|
{
|
|
this._bpolMessage = this.Core.CreateMessage(Message.NotificationClass.BPOL);
|
|
this.Messages.Add(this._bpolMessage);
|
|
}
|
|
|
|
BPOL bpol = null;
|
|
if (this._bpolMessage.Elements.Count > 0)
|
|
bpol = this._bpolMessage.Elements[0] as BPOL;
|
|
if (bpol == null)
|
|
{
|
|
bpol = new BPOL
|
|
{
|
|
MessageCore = this.Core,
|
|
MessageHeader = this._bpolMessage
|
|
};
|
|
_bpolMessage.Elements.Add(bpol);
|
|
}
|
|
|
|
this.groupBoxBorderPolice.DataContext = bpol;
|
|
this._bpol = 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;
|
|
|
|
#endregion
|
|
|
|
#region init CREWA
|
|
|
|
if (this._crewMessage == null)
|
|
{
|
|
this._crewMessage = this.Core.CreateMessage(Message.NotificationClass.CREWA);
|
|
this.Messages.Add(this._crewMessage);
|
|
}
|
|
|
|
this.groupBoxCrewList.DataContext = this._crewMessage;
|
|
|
|
this.dataGridCrewList.Initialize();
|
|
this.dataGridCrewList.ItemsSource = this._crewMessage.Elements;
|
|
this.dataGridCrewList.AddingNewItem += DataGridCrewList_AddingNewItem;
|
|
this.dataGridCrewList.EditRequested += DataGridCrewList_EditRequested;
|
|
this.dataGridCrewList.DeleteRequested += DataGridCrewList_DeleteRequested;
|
|
this.dataGridCrewList.CreateRequested += DataGridCrewList_CreateRequested;
|
|
this.dataGridCrewList.RefreshGrid += DataGridCrewList_RefreshGrid;
|
|
this.dataGridCrewList.MultiEditRequested += DataGridCrewList_MultiEditRequested;
|
|
|
|
if(this._crewMessage.Elements.Count > 0)
|
|
{
|
|
this.checkBoxCrewNotificationSchengen.IsChecked = ((CREW)this._crewMessage.Elements[0]).NotificationSchengen;
|
|
this.checkBoxCrewNotificationPAX.IsChecked = ((CREW)this._crewMessage.Elements[0]).NotificationPAX;
|
|
}
|
|
|
|
// extra menu copy to CREWD
|
|
{
|
|
this.dataGridCrewList.ContextMenu.Items.Add(new Separator());
|
|
MenuItem copyCREWAItem = new MenuItem();
|
|
copyCREWAItem.Header = Properties.Resources.textCopyToCREWD;
|
|
copyCREWAItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
|
|
copyCREWAItem.Click += CopyCREWAItem_Click;
|
|
this.dataGridCrewList.ContextMenu.Items.Add(copyCREWAItem);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region init CREWD
|
|
|
|
if (this._crewdMessage == null)
|
|
{
|
|
this._crewdMessage = this.Core.CreateMessage(Message.NotificationClass.CREWD);
|
|
this.Messages.Add(this._crewdMessage);
|
|
}
|
|
|
|
this.groupBoxCrewListDeparture.DataContext = this._crewdMessage;
|
|
|
|
this.dataGridCrewListDeparture.Initialize();
|
|
this.dataGridCrewListDeparture.ItemsSource = this._crewdMessage.Elements;
|
|
this.dataGridCrewListDeparture.AddingNewItem += DataGridCrewListDeparture_AddingNewItem;
|
|
this.dataGridCrewListDeparture.EditRequested += DataGridCrewListDeparture_EditRequested;
|
|
this.dataGridCrewListDeparture.DeleteRequested += DataGridCrewListDeparture_DeleteRequested;
|
|
this.dataGridCrewListDeparture.CreateRequested += DataGridCrewListDeparture_CreateRequested;
|
|
this.dataGridCrewListDeparture.RefreshGrid += DataGridCrewListDeparture_RefreshGrid;
|
|
this.dataGridCrewListDeparture.MultiEditRequested += DataGridCrewListDeparture_MultiEditRequested;
|
|
|
|
if (this._crewdMessage.Elements.Count > 0)
|
|
{
|
|
this.checkBoxCrewNotificationSchengenDeparture.IsChecked = ((CREWD)this._crewdMessage.Elements[0]).NotificationSchengen;
|
|
this.checkBoxCrewNotificationPAXDeparture.IsChecked = ((CREWD)this._crewdMessage.Elements[0]).NotificationPAX;
|
|
}
|
|
|
|
// extra menu copy to CREWA
|
|
{
|
|
this.dataGridCrewListDeparture.ContextMenu.Items.Add(new Separator());
|
|
MenuItem copyCREWDItem = new MenuItem();
|
|
copyCREWDItem.Header = Properties.Resources.textCopyToCREWA;
|
|
copyCREWDItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
|
|
copyCREWDItem.Click += CopyCREWDItem_Click;
|
|
this.dataGridCrewListDeparture.ContextMenu.Items.Add(copyCREWDItem);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region init PASA
|
|
|
|
if (this._pasMessage == null)
|
|
{
|
|
this._pasMessage = this.Core.CreateMessage(Message.NotificationClass.PASA);
|
|
this.Messages.Add(this._pasMessage);
|
|
}
|
|
|
|
this.groupBoxPassengerList.DataContext = this._pasMessage;
|
|
|
|
this.dataGridPassengerList.Initialize();
|
|
this.dataGridPassengerList.ItemsSource = this._pasMessage.Elements;
|
|
this.dataGridPassengerList.AddingNewItem += DataGridPassengerList_AddingNewItem;
|
|
this.dataGridPassengerList.EditRequested += DataGridPassengerList_EditRequested;
|
|
this.dataGridPassengerList.DeleteRequested += DataGridPassengerList_DeleteRequested;
|
|
this.dataGridPassengerList.CreateRequested += DataGridPassengerList_CreateRequested;
|
|
this.dataGridPassengerList.RefreshGrid += DataGridPassengerList_RefreshGrid;
|
|
this.dataGridPassengerList.MultiEditRequested += DataGridPassengerList_MultiEditRequested;
|
|
|
|
if (this._pasMessage.Elements.Count > 0)
|
|
{
|
|
this.checkBoxPasNotificationSchengen.IsChecked = ((PAS)this._pasMessage.Elements[0]).NotificationSchengen;
|
|
this.checkBoxPasNotificationPAX.IsChecked = ((PAS)this._pasMessage.Elements[0]).NotificationPAX;
|
|
}
|
|
|
|
// extra menu copy to PASD
|
|
{
|
|
this.dataGridPassengerList.ContextMenu.Items.Add(new Separator());
|
|
MenuItem copyPASAItem = new MenuItem();
|
|
copyPASAItem.Header = Properties.Resources.textCopyToPASD;
|
|
copyPASAItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
|
|
copyPASAItem.Click += CopyPASAItem_Click;
|
|
this.dataGridPassengerList.ContextMenu.Items.Add(copyPASAItem);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region init PASD
|
|
|
|
if (this._pasdMessage == null)
|
|
{
|
|
this._pasdMessage = this.Core.CreateMessage(Message.NotificationClass.PASD);
|
|
this.Messages.Add(this._pasdMessage);
|
|
}
|
|
|
|
this.groupBoxPassengerListDeparture.DataContext = this._pasdMessage;
|
|
|
|
this.dataGridPassengerListDeparture.Initialize();
|
|
this.dataGridPassengerListDeparture.ItemsSource = this._pasdMessage.Elements;
|
|
this.dataGridPassengerListDeparture.AddingNewItem += DataGridPassengerListDeparture_AddingNewItem;
|
|
this.dataGridPassengerListDeparture.EditRequested += DataGridPassengerListDeparture_EditRequested;
|
|
this.dataGridPassengerListDeparture.DeleteRequested += DataGridPassengerListDeparture_DeleteRequested;
|
|
this.dataGridPassengerListDeparture.CreateRequested += DataGridPassengerListDeparture_CreateRequested;
|
|
this.dataGridPassengerListDeparture.RefreshGrid += DataGridPassengerListDeparture_RefreshGrid;
|
|
this.dataGridPassengerListDeparture.MultiEditRequested += DataGridPassengerListDeparture_MultiEditRequested;
|
|
|
|
if (this._pasdMessage.Elements.Count > 0)
|
|
{
|
|
this.checkBoxPasNotificationSchengenDeparture.IsChecked = ((PASD)this._pasdMessage.Elements[0]).NotificationSchengen;
|
|
this.checkBoxPasNotificationPAXDeparture.IsChecked = ((PASD)this._pasdMessage.Elements[0]).NotificationPAX;
|
|
}
|
|
|
|
// extra menu copy to PASA
|
|
{
|
|
this.dataGridPassengerListDeparture.ContextMenu.Items.Add(new Separator());
|
|
MenuItem copyPASDItem = new MenuItem();
|
|
copyPASDItem.Header = Properties.Resources.textCopyToPASA;
|
|
copyPASDItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
|
|
copyPASDItem.Click += CopyPASDItem_Click;
|
|
this.dataGridPassengerListDeparture.ContextMenu.Items.Add(copyPASDItem);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
public override int SelectedTabIndex
|
|
{
|
|
get { return this.mainFrame.SelectedIndex; }
|
|
set { this.mainFrame.SelectedIndex = value; }
|
|
}
|
|
|
|
#region Grid copy handlers
|
|
|
|
private void CopyPASDItem_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (this.dataGridPassengerListDeparture.SelectedItems != null)
|
|
{
|
|
foreach (PASD pasd in this.dataGridPassengerListDeparture.SelectedItems)
|
|
{
|
|
PAS pasa = new PAS();
|
|
pasa.MessageHeader = this._pasMessage;
|
|
pasa.CopyFromPAS(pasd);
|
|
pasa.IsDeparture = false;
|
|
pasa.Identifier = DatabaseEntity.GetNewIdentifier(this._pasMessage.Elements);
|
|
this._pasMessage.Elements.Add(pasa);
|
|
this.SublistElementChanged(Message.NotificationClass.PASA);
|
|
}
|
|
this.CheckPASA();
|
|
}
|
|
}
|
|
|
|
private void CopyPASAItem_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (this.dataGridPassengerList.SelectedItems != null)
|
|
{
|
|
foreach (PAS pasa in this.dataGridPassengerList.SelectedItems)
|
|
{
|
|
PASD pasd = new PASD();
|
|
pasd.MessageHeader = this._pasdMessage;
|
|
pasd.CopyFromPAS(pasa);
|
|
pasd.IsDeparture = true;
|
|
pasd.Identifier = DatabaseEntity.GetNewIdentifier(this._pasdMessage.Elements);
|
|
this._pasdMessage.Elements.Add(pasd);
|
|
this.SublistElementChanged(Message.NotificationClass.PASD);
|
|
}
|
|
this.CheckPASD();
|
|
}
|
|
}
|
|
|
|
private void CopyCREWDItem_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (this.dataGridCrewListDeparture.SelectedItems != null)
|
|
{
|
|
foreach (CREWD crewd in this.dataGridCrewListDeparture.SelectedItems)
|
|
{
|
|
CREW crewa = new CREW();
|
|
crewa.MessageHeader = this._crewMessage;
|
|
crewa.CopyFromCREW(crewd);
|
|
crewa.IsDeparture = false;
|
|
crewa.Identifier = DatabaseEntity.GetNewIdentifier(this._crewMessage.Elements);
|
|
this._crewMessage.Elements.Add(crewa);
|
|
this.SublistElementChanged(Message.NotificationClass.CREWA);
|
|
}
|
|
this.CheckCREWA();
|
|
}
|
|
}
|
|
|
|
private void CopyCREWAItem_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if(this.dataGridCrewList.SelectedItems != null)
|
|
{
|
|
foreach(CREW crewa in this.dataGridCrewList.SelectedItems)
|
|
{
|
|
CREWD crewd = new CREWD();
|
|
crewd.MessageHeader = this._crewdMessage;
|
|
crewd.CopyFromCREW(crewa);
|
|
crewd.IsDeparture = true;
|
|
crewd.Identifier = DatabaseEntity.GetNewIdentifier(this._crewdMessage.Elements);
|
|
this._crewdMessage.Elements.Add(crewd);
|
|
this.SublistElementChanged(Message.NotificationClass.CREWD);
|
|
}
|
|
this.CheckCREWD();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Check Schengen / PAX flags and sync
|
|
|
|
private void CheckCREWA()
|
|
{
|
|
if (this._crewMessage.Elements.Count == 0) return;
|
|
CREW firstCREW = this._crewMessage.Elements[0] as CREW;
|
|
if (this._crewMessage.Elements.Count == 1)
|
|
{
|
|
firstCREW.NotificationSchengen = true;
|
|
this.checkBoxCrewNotificationSchengen.IsChecked = true;
|
|
}
|
|
else
|
|
{
|
|
for (int i = 1; i < this._crewMessage.Elements.Count; i++)
|
|
{
|
|
((CREW)this._crewMessage.Elements[i]).NotificationSchengen = firstCREW.NotificationSchengen;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void CheckCREWD()
|
|
{
|
|
if (this._crewdMessage.Elements.Count == 0) return;
|
|
CREWD firstCREW = this._crewdMessage.Elements[0] as CREWD;
|
|
if (this._crewdMessage.Elements.Count == 1)
|
|
{
|
|
firstCREW.NotificationSchengen = true;
|
|
this.checkBoxCrewNotificationSchengenDeparture.IsChecked = true;
|
|
}
|
|
else
|
|
{
|
|
for (int i = 1; i < this._crewdMessage.Elements.Count; i++)
|
|
{
|
|
((CREWD)this._crewdMessage.Elements[i]).NotificationSchengen = firstCREW.NotificationSchengen;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void CheckPASA()
|
|
{
|
|
if(this._pasMessage.Elements.Count == 0) return;
|
|
PAS firstPAS = this._pasMessage.Elements[0] as PAS;
|
|
if(this._pasMessage.Elements.Count == 1)
|
|
{
|
|
firstPAS.NotificationSchengen = true;
|
|
this.checkBoxPasNotificationSchengen.IsChecked = true;
|
|
}
|
|
else
|
|
{
|
|
for (int i = 1; i < this._pasMessage.Elements.Count; i++)
|
|
{
|
|
((PAS)this._pasMessage.Elements[i]).NotificationSchengen = firstPAS.NotificationSchengen;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void CheckPASD()
|
|
{
|
|
if(this._pasdMessage.Elements.Count == 0) return;
|
|
PASD firstPAS = this._pasdMessage.Elements[0] as PASD;
|
|
if (this._pasdMessage.Elements.Count == 1)
|
|
{
|
|
firstPAS.NotificationSchengen = true;
|
|
this.checkBoxPasNotificationSchengenDeparture.IsChecked = true;
|
|
}
|
|
else
|
|
{
|
|
for (int i = 1; i < this._pasdMessage.Elements.Count; i++)
|
|
{
|
|
((PASD)this._pasdMessage.Elements[i]).NotificationSchengen = firstPAS.NotificationSchengen;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region SetEnabled
|
|
|
|
public override void SetEnabled(bool enabled)
|
|
{
|
|
this.groupBoxBorderPolice.IsEnabled = enabled;
|
|
this.groupBoxCrewList.IsEnabled = enabled;
|
|
this.groupBoxPassengerList.IsEnabled = enabled;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region port of itinerary grid
|
|
|
|
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<DatabaseEntity>(_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();
|
|
}
|
|
|
|
private void buttonImportFromSEC_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 passenger grid arrival
|
|
|
|
private void DataGridPassengerList_CreateRequested()
|
|
{
|
|
EditPASDialog epd = new EditPASDialog
|
|
{
|
|
PAS = new PAS()
|
|
};
|
|
epd.PAS.Identifier = PAS.GetNewIdentifier(_pasMessage.Elements);
|
|
epd.PAS.MessageHeader = this._pasMessage;
|
|
|
|
epd.AddClicked += () =>
|
|
{
|
|
epd.CopyValuesToEntity();
|
|
if (!this._pasMessage.Elements.Contains(epd.PAS))
|
|
{
|
|
this._pasMessage.Elements.Add(epd.PAS);
|
|
this.CheckPASA();
|
|
}
|
|
this.dataGridPassengerList.Items.Refresh();
|
|
epd.PAS = new PAS
|
|
{
|
|
MessageHeader = this._pasMessage,
|
|
Identifier = PAS.GetNewIdentifier(_pasMessage.Elements)
|
|
};
|
|
this.SublistElementChanged(Message.NotificationClass.PASA);
|
|
};
|
|
|
|
if (epd.ShowDialog() ?? false)
|
|
{
|
|
if (!this._pasMessage.Elements.Contains(epd.PAS))
|
|
{
|
|
_pasMessage.Elements.Add(epd.PAS);
|
|
this.CheckPASA();
|
|
}
|
|
this.dataGridPassengerList.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.PASA);
|
|
}
|
|
}
|
|
|
|
private void DataGridPassengerList_DeleteRequested(DatabaseEntity obj)
|
|
{
|
|
if (obj is PAS pas)
|
|
{
|
|
// are you sure dialog is in base class
|
|
_pasMessage.Elements.Remove(pas);
|
|
DBManager.Instance.Delete(pas);
|
|
}
|
|
}
|
|
|
|
private void DataGridPassengerList_RefreshGrid()
|
|
{
|
|
DatabaseEntity.ResetIdentifiers(_pasMessage.Elements);
|
|
this.SublistElementChanged(Message.NotificationClass.PASA);
|
|
this.dataGridPassengerList.Items.Refresh();
|
|
}
|
|
|
|
private void DataGridPassengerList_EditRequested(DatabaseEntity obj)
|
|
{
|
|
EditPASDialog epd = new EditPASDialog
|
|
{
|
|
PAS = obj as PAS
|
|
};
|
|
|
|
epd.AddClicked += () =>
|
|
{
|
|
epd.CopyValuesToEntity();
|
|
if (!_pasMessage.Elements.Contains(epd.PAS))
|
|
{
|
|
_pasMessage.Elements.Add(epd.PAS);
|
|
this.CheckPASA();
|
|
}
|
|
this.dataGridPassengerList.Items.Refresh();
|
|
epd.PAS = new PAS
|
|
{
|
|
Identifier = PAS.GetNewIdentifier(_pasMessage.Elements),
|
|
MessageHeader = _pasMessage
|
|
};
|
|
this.SublistElementChanged(Message.NotificationClass.PASA);
|
|
};
|
|
|
|
if (epd.ShowDialog() ?? false)
|
|
{
|
|
if (!_pasMessage.Elements.Contains(epd.PAS))
|
|
{
|
|
_pasMessage.Elements.Add(epd.PAS);
|
|
this.CheckPASA();
|
|
}
|
|
epd.PAS.IsDirty = true;
|
|
this.dataGridPassengerList.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.PASA);
|
|
}
|
|
}
|
|
|
|
private void DataGridPassengerList_AddingNewItem(object sender, AddingNewItemEventArgs e)
|
|
{
|
|
this.DataGridPassengerList_CreateRequested();
|
|
}
|
|
|
|
private void DataGridPassengerList_MultiEditRequested(List<DatabaseEntity> databaseEntities)
|
|
{
|
|
List<PAS> pasList = new List<PAS>();
|
|
foreach (PAS apas in databaseEntities.Cast<PAS>())
|
|
pasList.Add(apas);
|
|
|
|
// write common values of all PAS entities to template entity
|
|
PAS pas = PAS.CreateCommon(pasList);
|
|
|
|
EditPASDialog dialog = new EditPASDialog();
|
|
dialog.PAS = pas;
|
|
dialog.AddVisible = false;
|
|
if (dialog.ShowDialog() ?? false)
|
|
{
|
|
// write back changed values from pas to all entities and mark them as changed
|
|
PAS.WriteTemplateToList(pas, pasList);
|
|
|
|
this.SublistElementChanged(Message.NotificationClass.PASA);
|
|
this.dataGridPassengerList.Items.Refresh();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region passenger grid departure
|
|
|
|
private void DataGridPassengerListDeparture_CreateRequested()
|
|
{
|
|
EditPASDialog epd = new EditPASDialog
|
|
{
|
|
PAS = new PASD()
|
|
};
|
|
epd.PAS.IsDeparture = true;
|
|
epd.PAS.Identifier = PASD.GetNewIdentifier(_pasdMessage.Elements);
|
|
epd.PAS.MessageHeader = this._pasdMessage;
|
|
|
|
epd.AddClicked += () =>
|
|
{
|
|
epd.CopyValuesToEntity();
|
|
if (!this._pasdMessage.Elements.Contains(epd.PAS))
|
|
{
|
|
this._pasdMessage.Elements.Add(epd.PAS);
|
|
this.CheckPASD();
|
|
}
|
|
this.dataGridPassengerListDeparture.Items.Refresh();
|
|
epd.PAS = new PASD
|
|
{
|
|
IsDeparture = true,
|
|
MessageHeader = this._pasdMessage,
|
|
Identifier = PASD.GetNewIdentifier(_pasdMessage.Elements)
|
|
};
|
|
this.SublistElementChanged(Message.NotificationClass.PASD);
|
|
};
|
|
|
|
if (epd.ShowDialog() ?? false)
|
|
{
|
|
if (!this._pasdMessage.Elements.Contains(epd.PAS))
|
|
{
|
|
_pasdMessage.Elements.Add(epd.PAS);
|
|
this.CheckPASD();
|
|
}
|
|
this.dataGridPassengerListDeparture.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.PASD);
|
|
}
|
|
}
|
|
|
|
private void DataGridPassengerListDeparture_DeleteRequested(DatabaseEntity obj)
|
|
{
|
|
if (obj is PASD pasd)
|
|
{
|
|
// are you sure dialog is in base class
|
|
_pasdMessage.Elements.Remove(pasd);
|
|
DBManager.Instance.Delete(pasd);
|
|
}
|
|
}
|
|
|
|
private void DataGridPassengerListDeparture_RefreshGrid()
|
|
{
|
|
DatabaseEntity.ResetIdentifiers(_pasdMessage.Elements);
|
|
this.SublistElementChanged(Message.NotificationClass.PASD);
|
|
this.dataGridPassengerListDeparture.Items.Refresh();
|
|
}
|
|
|
|
private void DataGridPassengerListDeparture_EditRequested(DatabaseEntity obj)
|
|
{
|
|
EditPASDialog epd = new EditPASDialog
|
|
{
|
|
PAS = obj as PASD
|
|
};
|
|
|
|
epd.AddClicked += () =>
|
|
{
|
|
epd.CopyValuesToEntity();
|
|
if (!_pasMessage.Elements.Contains(epd.PAS))
|
|
{
|
|
_pasMessage.Elements.Add(epd.PAS);
|
|
this.CheckPASD();
|
|
}
|
|
this.dataGridPassengerListDeparture.Items.Refresh();
|
|
epd.PAS = new PASD
|
|
{
|
|
IsDeparture = true,
|
|
Identifier = PASD.GetNewIdentifier(_pasdMessage.Elements),
|
|
MessageHeader = _pasdMessage
|
|
};
|
|
this.SublistElementChanged(Message.NotificationClass.PASD);
|
|
};
|
|
|
|
if (epd.ShowDialog() ?? false)
|
|
{
|
|
if (!_pasdMessage.Elements.Contains(epd.PAS))
|
|
{
|
|
_pasdMessage.Elements.Add(epd.PAS);
|
|
this.CheckPASD();
|
|
}
|
|
epd.PAS.IsDirty = true;
|
|
this.dataGridPassengerListDeparture.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.PASD);
|
|
}
|
|
}
|
|
|
|
private void DataGridPassengerListDeparture_AddingNewItem(object sender, AddingNewItemEventArgs e)
|
|
{
|
|
this.DataGridPassengerListDeparture_CreateRequested();
|
|
}
|
|
|
|
private void DataGridPassengerListDeparture_MultiEditRequested(List<DatabaseEntity> databaseEntities)
|
|
{
|
|
List<PAS> pasList = new List<PAS>();
|
|
foreach (PAS apas in databaseEntities.Cast<PAS>())
|
|
pasList.Add(apas);
|
|
|
|
// write common values of all PAS entities to template entity
|
|
PAS pas = PAS.CreateCommon(pasList);
|
|
|
|
EditPASDialog dialog = new EditPASDialog();
|
|
dialog.PAS = pas;
|
|
dialog.AddVisible = false;
|
|
if (dialog.ShowDialog() ?? false)
|
|
{
|
|
// write back changed values from pas to all entities and mark them as changed
|
|
PAS.WriteTemplateToList(pas, pasList);
|
|
|
|
this.SublistElementChanged(Message.NotificationClass.PASD);
|
|
this.dataGridPassengerListDeparture.Items.Refresh();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region crew grid arrival
|
|
|
|
private void DataGridCrewList_CreateRequested()
|
|
{
|
|
EditCREWDialog ecd = new EditCREWDialog
|
|
{
|
|
CREW = new CREW()
|
|
};
|
|
ecd.CREW.Identifier = CREW.GetNewIdentifier(_crewMessage.Elements);
|
|
ecd.CREW.MessageHeader = this._crewMessage;
|
|
|
|
ecd.AddClicked += () =>
|
|
{
|
|
ecd.CopyValuesToEntity();
|
|
if (!this._crewMessage.Elements.Contains(ecd.CREW))
|
|
{
|
|
this._crewMessage.Elements.Add(ecd.CREW);
|
|
this.CheckCREWA();
|
|
}
|
|
this.dataGridCrewList.Items.Refresh();
|
|
ecd.CREW = new CREW
|
|
{
|
|
MessageHeader = this._crewMessage,
|
|
Identifier = CREW.GetNewIdentifier(_crewMessage.Elements)
|
|
};
|
|
this.SublistElementChanged(Message.NotificationClass.CREWA);
|
|
};
|
|
|
|
if (ecd.ShowDialog() ?? false)
|
|
{
|
|
if (!this._crewMessage.Elements.Contains(ecd.CREW))
|
|
{
|
|
_crewMessage.Elements.Add(ecd.CREW);
|
|
this.CheckCREWA();
|
|
}
|
|
this.dataGridCrewList.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.CREWA);
|
|
}
|
|
}
|
|
|
|
private void DataGridCrewList_DeleteRequested(DatabaseEntity obj)
|
|
{
|
|
if (obj is CREW crew)
|
|
{
|
|
// are you sure dialog is in base class
|
|
_crewMessage.Elements.Remove(crew);
|
|
DBManager.Instance.Delete(crew);
|
|
}
|
|
}
|
|
|
|
private void DataGridCrewList_RefreshGrid()
|
|
{
|
|
DatabaseEntity.ResetIdentifiers(_crewMessage.Elements);
|
|
this.SublistElementChanged(Message.NotificationClass.CREWA);
|
|
this.dataGridCrewList.Items.Refresh();
|
|
}
|
|
|
|
private void DataGridCrewList_EditRequested(DatabaseEntity obj)
|
|
{
|
|
EditCREWDialog ecd = new EditCREWDialog
|
|
{
|
|
CREW = obj as CREW
|
|
};
|
|
|
|
ecd.AddClicked += () =>
|
|
{
|
|
ecd.CopyValuesToEntity();
|
|
if (!_crewMessage.Elements.Contains(ecd.CREW))
|
|
{
|
|
_crewMessage.Elements.Add(ecd.CREW);
|
|
this.CheckCREWA();
|
|
}
|
|
this.dataGridCrewList.Items.Refresh();
|
|
ecd.CREW = new CREW
|
|
{
|
|
Identifier = CREW.GetNewIdentifier(_crewMessage.Elements),
|
|
MessageHeader = _crewMessage
|
|
};
|
|
this.SublistElementChanged(Message.NotificationClass.CREWA);
|
|
};
|
|
|
|
if (ecd.ShowDialog() ?? false)
|
|
{
|
|
if (!_crewMessage.Elements.Contains(ecd.CREW))
|
|
{
|
|
_crewMessage.Elements.Add(ecd.CREW);
|
|
this.CheckCREWA();
|
|
}
|
|
ecd.CREW.IsDirty = true;
|
|
this.dataGridCrewList.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.CREWA);
|
|
}
|
|
}
|
|
|
|
private void DataGridCrewList_AddingNewItem(object sender, AddingNewItemEventArgs e)
|
|
{
|
|
this.DataGridCrewList_CreateRequested();
|
|
}
|
|
|
|
private void DataGridCrewList_MultiEditRequested(List<DatabaseEntity> databaseEntities)
|
|
{
|
|
List<CREW> crewList = new List<CREW>();
|
|
foreach (CREW acrew in databaseEntities.Cast<CREW>())
|
|
crewList.Add(acrew);
|
|
|
|
// write common values of all CREW entities to template entity
|
|
CREW crew = CREW.CreateCommon(crewList);
|
|
|
|
EditCREWDialog dialog = new EditCREWDialog();
|
|
dialog.CREW = crew;
|
|
dialog.AddVisible = false;
|
|
if(dialog.ShowDialog() ?? false)
|
|
{
|
|
// write back changed values from crew to all entities and mark them as changed
|
|
CREW.WriteTemplateToList(crew, crewList);
|
|
|
|
this.SublistElementChanged(Message.NotificationClass.CREWA);
|
|
this.dataGridCrewList.Items.Refresh();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region crew grid departure
|
|
|
|
private void DataGridCrewListDeparture_CreateRequested()
|
|
{
|
|
EditCREWDialog ecd = new EditCREWDialog
|
|
{
|
|
CREW = new CREWD()
|
|
};
|
|
ecd.CREW.IsDeparture = true;
|
|
ecd.CREW.Identifier = CREWD.GetNewIdentifier(_crewdMessage.Elements);
|
|
ecd.CREW.MessageHeader = this._crewdMessage;
|
|
|
|
ecd.AddClicked += () =>
|
|
{
|
|
ecd.CopyValuesToEntity();
|
|
if (!this._crewdMessage.Elements.Contains(ecd.CREW))
|
|
{
|
|
this._crewdMessage.Elements.Add(ecd.CREW);
|
|
this.CheckCREWD();
|
|
}
|
|
this.dataGridCrewListDeparture.Items.Refresh();
|
|
ecd.CREW = new CREWD
|
|
{
|
|
IsDeparture = true,
|
|
MessageHeader = this._crewdMessage,
|
|
Identifier = CREWD.GetNewIdentifier(_crewdMessage.Elements)
|
|
};
|
|
this.SublistElementChanged(Message.NotificationClass.CREWD);
|
|
};
|
|
|
|
if (ecd.ShowDialog() ?? false)
|
|
{
|
|
if (!this._crewdMessage.Elements.Contains(ecd.CREW))
|
|
{
|
|
_crewdMessage.Elements.Add(ecd.CREW);
|
|
this.CheckCREWD();
|
|
}
|
|
this.dataGridCrewListDeparture.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.CREWD);
|
|
}
|
|
}
|
|
|
|
private void DataGridCrewListDeparture_DeleteRequested(DatabaseEntity obj)
|
|
{
|
|
if (obj is CREWD crewd)
|
|
{
|
|
// are you sure dialog is in base class
|
|
_crewdMessage.Elements.Remove(crewd);
|
|
DBManager.Instance.Delete(crewd);
|
|
}
|
|
}
|
|
|
|
private void DataGridCrewListDeparture_RefreshGrid()
|
|
{
|
|
DatabaseEntity.ResetIdentifiers(_crewdMessage.Elements);
|
|
this.SublistElementChanged(Message.NotificationClass.CREWD);
|
|
this.dataGridCrewListDeparture.Items.Refresh();
|
|
}
|
|
|
|
private void DataGridCrewListDeparture_EditRequested(DatabaseEntity obj)
|
|
{
|
|
EditCREWDialog ecd = new EditCREWDialog
|
|
{
|
|
CREW = obj as CREWD
|
|
};
|
|
|
|
ecd.AddClicked += () =>
|
|
{
|
|
ecd.CopyValuesToEntity();
|
|
if (!_crewdMessage.Elements.Contains(ecd.CREW))
|
|
{
|
|
_crewdMessage.Elements.Add(ecd.CREW);
|
|
this.CheckCREWD();
|
|
}
|
|
this.dataGridCrewListDeparture.Items.Refresh();
|
|
ecd.CREW = new CREWD
|
|
{
|
|
IsDeparture = true,
|
|
Identifier = CREWD.GetNewIdentifier(_crewdMessage.Elements),
|
|
MessageHeader = _crewdMessage
|
|
};
|
|
this.SublistElementChanged(Message.NotificationClass.CREWD);
|
|
};
|
|
|
|
if (ecd.ShowDialog() ?? false)
|
|
{
|
|
if (!_crewdMessage.Elements.Contains(ecd.CREW))
|
|
{
|
|
_crewdMessage.Elements.Add(ecd.CREW);
|
|
this.CheckCREWD();
|
|
}
|
|
ecd.CREW.IsDirty = true;
|
|
this.dataGridCrewListDeparture.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.CREWD);
|
|
}
|
|
}
|
|
|
|
private void DataGridCrewListDeparture_AddingNewItem(object sender, AddingNewItemEventArgs e)
|
|
{
|
|
this.DataGridCrewListDeparture_CreateRequested();
|
|
}
|
|
|
|
private void DataGridCrewListDeparture_MultiEditRequested(List<DatabaseEntity> databaseEntities)
|
|
{
|
|
List<CREW> crewList = new List<CREW>();
|
|
foreach (CREW acrew in databaseEntities.Cast<CREW>())
|
|
crewList.Add(acrew);
|
|
|
|
// write common values of all CREW entities to template entity
|
|
CREW crew = CREW.CreateCommon(crewList);
|
|
|
|
EditCREWDialog dialog = new EditCREWDialog();
|
|
dialog.CREW = crew;
|
|
dialog.AddVisible = false;
|
|
if (dialog.ShowDialog() ?? false)
|
|
{
|
|
// write back changed values from crew to all entities and mark them as changed
|
|
CREW.WriteTemplateToList(crew, crewList);
|
|
|
|
this.SublistElementChanged(Message.NotificationClass.CREWD);
|
|
this.dataGridCrewListDeparture.Items.Refresh();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Excel import
|
|
|
|
private void buttonImportExcelCrew_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
OpenFileDialog ofd = new OpenFileDialog
|
|
{
|
|
Filter = "Excel Files|*.xls;*.xlsx"
|
|
};
|
|
if (ofd.ShowDialog() ?? false)
|
|
{
|
|
try
|
|
{
|
|
using (var workbook = new XLWorkbook(ofd.FileName))
|
|
{
|
|
var worksheet = workbook.Worksheet(1); // Get first worksheet
|
|
var rows = worksheet.RangeUsed().RowsUsed().Skip(1); // Skip header row if present
|
|
|
|
List<CREW> importCrew = new List<CREW>();
|
|
|
|
foreach (var row in rows)
|
|
{
|
|
if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
|
|
|
|
// Check if we have at least 13 columns
|
|
if (worksheet.RangeUsed().ColumnCount() < 13)
|
|
{
|
|
throw new InvalidDataException("Sheet must have 13 columns of data");
|
|
}
|
|
|
|
CREW crew = new CREW();
|
|
|
|
// Check if first two cells are empty
|
|
if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
|
|
|
|
if (!row.Cell(1).IsEmpty()) crew.CrewMemberLastName = row.Cell(1).GetString().Clean();
|
|
if (crew.CrewMemberLastName?.Equals("Family Name") == true || string.IsNullOrWhiteSpace(crew.CrewMemberLastName)) continue;
|
|
|
|
if (!row.Cell(2).IsEmpty()) crew.CrewMemberFirstName = row.Cell(2).GetString().Clean();
|
|
if (!row.Cell(3).IsEmpty()) crew.CrewMemberGender = GlobalStructures.ParseGender(row.Cell(3).GetString());
|
|
if (!row.Cell(4).IsEmpty()) crew.CrewMemberDuty = row.Cell(4).GetString().Clean();
|
|
if (!row.Cell(5).IsEmpty()) crew.CrewMemberNationality = row.Cell(5).GetString().Substring(0, 2).ToUpper();
|
|
if (!row.Cell(6).IsEmpty()) crew.CrewMemberPlaceOfBirth = row.Cell(6).GetString().Clean();
|
|
if (!row.Cell(7).IsEmpty()) crew.CrewMemberCountryOfBirth = row.Cell(7).GetString().Substring(0, 2).ToUpper();
|
|
if (!row.Cell(8).IsEmpty()) crew.CrewMemberDateOfBirth = row.Cell(8).GetDateTime();
|
|
if (!row.Cell(9).IsEmpty()) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(row.Cell(9).GetString());
|
|
if (!row.Cell(10).IsEmpty()) crew.CrewMemberIdentityDocumentId = row.Cell(10).GetString().Clean();
|
|
if (!row.Cell(11).IsEmpty()) crew.CrewMemberIdentityDocumentIssuingState = row.Cell(11).GetString().Substring(0, 2).ToUpper();
|
|
if (!row.Cell(12).IsEmpty()) crew.CrewMemberIdentityDocumentExpiryDate = row.Cell(12).GetDateTime();
|
|
if (!row.Cell(13).IsEmpty()) crew.CrewMemberVisaNumber = row.Cell(13).GetString().Clean();
|
|
|
|
crew.MessageHeader = this._crewMessage;
|
|
crew.IsDirty = true;
|
|
crew.Identifier = CREW.GetNewIdentifier(this._crewMessage.Elements);
|
|
this._crewMessage.Elements.Add(crew);
|
|
importCrew.Add(crew);
|
|
}
|
|
|
|
if (importCrew.Count > 0)
|
|
{
|
|
this.dataGridCrewList.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.CREWA);
|
|
MessageBox.Show(String.Format(Properties.Resources.textCrewImported, importCrew.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void buttonImportExcelCrewDeparture_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
OpenFileDialog ofd = new OpenFileDialog
|
|
{
|
|
Filter = "Excel Files|*.xls;*.xlsx"
|
|
};
|
|
if (ofd.ShowDialog() ?? false)
|
|
{
|
|
try
|
|
{
|
|
using (var workbook = new XLWorkbook(ofd.FileName))
|
|
{
|
|
var worksheet = workbook.Worksheet(1); // Get first worksheet
|
|
var rows = worksheet.RangeUsed().RowsUsed().Skip(1); // Skip header row if present
|
|
|
|
List<CREWD> importCrew = new List<CREWD>();
|
|
|
|
foreach (var row in rows)
|
|
{
|
|
if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
|
|
|
|
// Check if we have at least 13 columns
|
|
if (worksheet.RangeUsed().ColumnCount() < 13)
|
|
{
|
|
throw new InvalidDataException("Sheet must have 13 columns of data");
|
|
}
|
|
|
|
CREWD crew = new CREWD();
|
|
crew.IsDeparture = true;
|
|
|
|
// Check if first two cells are empty
|
|
if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
|
|
|
|
if (!row.Cell(1).IsEmpty()) crew.CrewMemberLastName = row.Cell(1).GetString().Clean();
|
|
if (crew.CrewMemberLastName?.Equals("Family Name") == true || string.IsNullOrWhiteSpace(crew.CrewMemberLastName)) continue;
|
|
|
|
if (!row.Cell(2).IsEmpty()) crew.CrewMemberFirstName = row.Cell(2).GetString().Clean();
|
|
if (!row.Cell(3).IsEmpty()) crew.CrewMemberGender = GlobalStructures.ParseGender(row.Cell(3).GetString());
|
|
if (!row.Cell(4).IsEmpty()) crew.CrewMemberDuty = row.Cell(4).GetString().Clean();
|
|
if (!row.Cell(5).IsEmpty()) crew.CrewMemberNationality = row.Cell(5).GetString().Substring(0, 2).ToUpper();
|
|
if (!row.Cell(6).IsEmpty()) crew.CrewMemberPlaceOfBirth = row.Cell(6).GetString().Clean();
|
|
if (!row.Cell(7).IsEmpty()) crew.CrewMemberCountryOfBirth = row.Cell(7).GetString().Substring(0, 2).ToUpper();
|
|
if (!row.Cell(8).IsEmpty()) crew.CrewMemberDateOfBirth = row.Cell(8).GetDateTime();
|
|
if (!row.Cell(9).IsEmpty()) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(row.Cell(9).GetString());
|
|
if (!row.Cell(10).IsEmpty()) crew.CrewMemberIdentityDocumentId = row.Cell(10).GetString().Clean();
|
|
if (!row.Cell(11).IsEmpty()) crew.CrewMemberIdentityDocumentIssuingState = row.Cell(11).GetString().Substring(0, 2).ToUpper();
|
|
if (!row.Cell(12).IsEmpty()) crew.CrewMemberIdentityDocumentExpiryDate = row.Cell(12).GetDateTime();
|
|
if (!row.Cell(13).IsEmpty()) crew.CrewMemberVisaNumber = row.Cell(13).GetString().Clean();
|
|
|
|
crew.MessageHeader = this._crewdMessage;
|
|
crew.IsDirty = true;
|
|
crew.Identifier = CREWD.GetNewIdentifier(this._crewdMessage.Elements);
|
|
this._crewdMessage.Elements.Add(crew);
|
|
importCrew.Add(crew);
|
|
}
|
|
|
|
if (importCrew.Count > 0)
|
|
{
|
|
this.dataGridCrewListDeparture.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.CREWD);
|
|
MessageBox.Show(String.Format(Properties.Resources.textCrewImported, importCrew.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void buttonImportExcelPassenger_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
OpenFileDialog ofd = new OpenFileDialog
|
|
{
|
|
Filter = "Excel Files|*.xls;*.xlsx"
|
|
};
|
|
if (ofd.ShowDialog() ?? false)
|
|
{
|
|
try
|
|
{
|
|
using (var workbook = new XLWorkbook(ofd.FileName))
|
|
{
|
|
var worksheet = workbook.Worksheet(1);
|
|
var rows = worksheet.RangeUsed().RowsUsed().Skip(1); // Skip header row if present
|
|
|
|
List<PAS> importPassenger = new List<PAS>();
|
|
|
|
foreach (var row in rows)
|
|
{
|
|
if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
|
|
|
|
if (worksheet.RangeUsed().ColumnCount() < 17)
|
|
{
|
|
throw new InvalidDataException("Sheet must have 17 columns of data");
|
|
}
|
|
|
|
PAS pas = new PAS();
|
|
|
|
if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
|
|
|
|
if (!row.Cell(1).IsEmpty()) pas.PassengerLastName = row.Cell(1).GetString().Clean();
|
|
if (pas.PassengerLastName?.Equals("Family Name") == true || string.IsNullOrWhiteSpace(pas.PassengerLastName)) continue;
|
|
|
|
if (!row.Cell(2).IsEmpty()) pas.PassengerFirstName = row.Cell(2).GetString().Clean();
|
|
if (!row.Cell(3).IsEmpty()) pas.PassengerGender = GlobalStructures.ParseGender(row.Cell(3).GetString());
|
|
if (!row.Cell(4).IsEmpty()) pas.PassengerPortOfEmbarkation = row.Cell(4).GetString().Clean();
|
|
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfEmbarkation) == null)
|
|
pas.PassengerPortOfEmbarkation = null;
|
|
if (!row.Cell(5).IsEmpty()) pas.PassengerPortOfDisembarkation = row.Cell(5).GetString().Clean();
|
|
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfDisembarkation) == null)
|
|
pas.PassengerPortOfDisembarkation = null;
|
|
if (!row.Cell(6).IsEmpty()) pas.PassengerInTransit = GlobalStructures.ReadBoolean(row.Cell(6).GetString());
|
|
if (!row.Cell(7).IsEmpty()) pas.PassengerNationality = row.Cell(7).GetString().Substring(0, 2).ToUpper();
|
|
if (!row.Cell(8).IsEmpty()) pas.PassengerPlaceOfBirth = row.Cell(8).GetString().Clean();
|
|
if (!row.Cell(9).IsEmpty()) pas.PassengerCountryOfBirth = row.Cell(9).GetString().Substring(0, 2).ToUpper().Clean();
|
|
if (!row.Cell(10).IsEmpty()) pas.PassengerDateOfBirth = row.Cell(10).GetDateTime();
|
|
if (!row.Cell(11).IsEmpty()) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(row.Cell(11).GetString());
|
|
if (!row.Cell(12).IsEmpty()) pas.PassengerIdentityDocumentId = row.Cell(12).GetString().Clean();
|
|
if (!row.Cell(13).IsEmpty()) pas.PassengerIdentityDocumentIssuingState = row.Cell(13).GetString().Substring(0, 2).ToUpper();
|
|
if (!row.Cell(14).IsEmpty()) pas.PassengerIdentityDocumentExpiryDate = row.Cell(14).GetDateTime();
|
|
if (!row.Cell(15).IsEmpty()) pas.PassengerVisaNumber = row.Cell(15).GetString().Clean();
|
|
if (!row.Cell(16).IsEmpty()) pas.EmergencyCare = row.Cell(16).GetString().Clean();
|
|
if (!row.Cell(17).IsEmpty()) pas.EmergencyContactNumber = row.Cell(17).GetString().Clean();
|
|
|
|
pas.MessageHeader = this._pasMessage;
|
|
pas.IsDirty = true;
|
|
pas.Identifier = PAS.GetNewIdentifier(this._pasMessage.Elements);
|
|
this._pasMessage.Elements.Add(pas);
|
|
importPassenger.Add(pas);
|
|
}
|
|
|
|
if (importPassenger.Count > 0)
|
|
{
|
|
this.dataGridPassengerList.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.PASA);
|
|
MessageBox.Show(String.Format(Properties.Resources.textPassengerImported, importPassenger.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void buttonImportExcelPassengerDeparture_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
OpenFileDialog ofd = new OpenFileDialog
|
|
{
|
|
Filter = "Excel Files|*.xls;*.xlsx"
|
|
};
|
|
if (ofd.ShowDialog() ?? false)
|
|
{
|
|
try
|
|
{
|
|
using (var workbook = new XLWorkbook(ofd.FileName))
|
|
{
|
|
var worksheet = workbook.Worksheet(1);
|
|
var rows = worksheet.RangeUsed().RowsUsed().Skip(1); // Skip header row if present
|
|
|
|
List<PASD> importPassenger = new List<PASD>();
|
|
|
|
foreach (var row in rows)
|
|
{
|
|
if (row.RowNumber() > worksheet.RangeUsed().RowCount()) break;
|
|
|
|
if (worksheet.RangeUsed().ColumnCount() < 17)
|
|
{
|
|
throw new InvalidDataException("Sheet must have 17 columns of data");
|
|
}
|
|
|
|
PASD pas = new PASD();
|
|
|
|
if (row.Cell(1).IsEmpty() && row.Cell(2).IsEmpty()) continue;
|
|
|
|
if (!row.Cell(1).IsEmpty()) pas.PassengerLastName = row.Cell(1).GetString().Clean();
|
|
if (pas.PassengerLastName?.Equals("Family Name") == true || string.IsNullOrWhiteSpace(pas.PassengerLastName)) continue;
|
|
|
|
if (!row.Cell(2).IsEmpty()) pas.PassengerFirstName = row.Cell(2).GetString().Clean();
|
|
if (!row.Cell(3).IsEmpty()) pas.PassengerGender = GlobalStructures.ParseGender(row.Cell(3).GetString());
|
|
if (!row.Cell(4).IsEmpty()) pas.PassengerPortOfEmbarkation = row.Cell(4).GetString().Clean();
|
|
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfEmbarkation) == null)
|
|
pas.PassengerPortOfEmbarkation = null;
|
|
if (!row.Cell(5).IsEmpty()) pas.PassengerPortOfDisembarkation = row.Cell(5).GetString().Clean();
|
|
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfDisembarkation) == null)
|
|
pas.PassengerPortOfDisembarkation = null;
|
|
if (!row.Cell(6).IsEmpty()) pas.PassengerInTransit = GlobalStructures.ReadBoolean(row.Cell(6).GetString());
|
|
if (!row.Cell(7).IsEmpty()) pas.PassengerNationality = row.Cell(7).GetString().Substring(0, 2).ToUpper();
|
|
if (!row.Cell(8).IsEmpty()) pas.PassengerPlaceOfBirth = row.Cell(8).GetString().Clean();
|
|
if (!row.Cell(9).IsEmpty()) pas.PassengerCountryOfBirth = row.Cell(9).GetString().Substring(0, 2).ToUpper();
|
|
if (!row.Cell(10).IsEmpty()) pas.PassengerDateOfBirth = row.Cell(10).GetDateTime();
|
|
if (!row.Cell(11).IsEmpty()) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(row.Cell(11).GetString());
|
|
if (!row.Cell(12).IsEmpty()) pas.PassengerIdentityDocumentId = row.Cell(12).GetString().Clean();
|
|
if (!row.Cell(13).IsEmpty()) pas.PassengerIdentityDocumentIssuingState = row.Cell(13).GetString().Substring(0, 2).ToUpper();
|
|
if (!row.Cell(14).IsEmpty()) pas.PassengerIdentityDocumentExpiryDate = row.Cell(14).GetDateTime();
|
|
if (!row.Cell(15).IsEmpty()) pas.PassengerVisaNumber = row.Cell(15).GetString().Clean();
|
|
if (!row.Cell(16).IsEmpty()) pas.EmergencyCare = row.Cell(16).GetString().Clean();
|
|
if (!row.Cell(17).IsEmpty()) pas.EmergencyContactNumber = row.Cell(17).GetString().Clean();
|
|
|
|
pas.MessageHeader = this._pasdMessage;
|
|
pas.IsDirty = true;
|
|
pas.Identifier = PASD.GetNewIdentifier(this._pasdMessage.Elements);
|
|
this._pasdMessage.Elements.Add(pas);
|
|
importPassenger.Add(pas);
|
|
}
|
|
|
|
if (importPassenger.Count > 0)
|
|
{
|
|
this.dataGridPassengerListDeparture.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.PASD);
|
|
MessageBox.Show(String.Format(Properties.Resources.textPassengerImported, importPassenger.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Highlighting
|
|
|
|
public override void HighlightErrorMessageContainer()
|
|
{
|
|
if (this._bpolMessage.HasErrors)
|
|
HighlightService.HighlightControl(this.groupBoxBorderPolice, HighlightService.HighlightStyle.ERROR, this._bpolMessage);
|
|
if (this._crewMessage.HasErrors)
|
|
HighlightService.HighlightControl(this.groupBoxCrewList, HighlightService.HighlightStyle.ERROR, this._crewMessage);
|
|
if (this._pasMessage.HasErrors)
|
|
HighlightService.HighlightControl(this.groupBoxPassengerList, HighlightService.HighlightStyle.ERROR, this._pasMessage);
|
|
}
|
|
|
|
public override void HighlightViolationMessageContainer()
|
|
{
|
|
if (this._bpolMessage.HasViolations)
|
|
HighlightService.HighlightControl(this.groupBoxBorderPolice, HighlightService.HighlightStyle.VIOLATION, this._bpolMessage);
|
|
if (this._crewMessage.HasViolations)
|
|
HighlightService.HighlightControl(this.groupBoxCrewList, HighlightService.HighlightStyle.VIOLATION, this._crewMessage);
|
|
if (this._pasMessage.HasViolations)
|
|
HighlightService.HighlightControl(this.groupBoxPassengerList, HighlightService.HighlightStyle.VIOLATION, this._pasMessage);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Schengen/PAX checkboxes changed event handler
|
|
|
|
private void checkBoxCrewNotificationSchengen_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
foreach(CREW crew in _crewMessage.Elements.Cast<CREW>())
|
|
{
|
|
crew.NotificationSchengen = checkBoxCrewNotificationSchengen.IsChecked;
|
|
}
|
|
this.SublistElementChanged(Message.NotificationClass.CREWA);
|
|
}
|
|
|
|
private void checkBoxCrewNotificationPAX_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
foreach (CREW crew in _crewMessage.Elements.Cast<CREW>())
|
|
{
|
|
crew.NotificationPAX = checkBoxCrewNotificationPAX.IsChecked;
|
|
}
|
|
this.SublistElementChanged(Message.NotificationClass.CREWA);
|
|
}
|
|
|
|
private void checkBoxCrewNotificationSchengenDeparture_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
foreach(CREWD crewd in _crewdMessage.Elements.Cast<CREWD>())
|
|
{
|
|
crewd.NotificationSchengen = checkBoxCrewNotificationSchengenDeparture.IsChecked;
|
|
}
|
|
this.SublistElementChanged(Message.NotificationClass.CREWD);
|
|
}
|
|
|
|
private void checkBoxCrewNotificationPAXDeparture_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
foreach (CREWD crewd in _crewdMessage.Elements.Cast<CREWD>())
|
|
{
|
|
crewd.NotificationPAX = checkBoxCrewNotificationPAXDeparture.IsChecked;
|
|
}
|
|
this.SublistElementChanged(Message.NotificationClass.CREWD);
|
|
}
|
|
|
|
private void checkBoxPasNotificationSchengen_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
foreach(PAS pas in _pasMessage.Elements.Cast<PAS>())
|
|
{
|
|
pas.NotificationSchengen = checkBoxPasNotificationSchengen.IsChecked;
|
|
}
|
|
this.SublistElementChanged(Message.NotificationClass.PASA);
|
|
}
|
|
|
|
private void checkBoxPasNotificationPAX_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
foreach(PAS pas in _pasMessage.Elements.Cast<PAS>())
|
|
{
|
|
pas.NotificationPAX = checkBoxPasNotificationPAX.IsChecked;
|
|
}
|
|
this.SublistElementChanged(Message.NotificationClass.PASA);
|
|
}
|
|
|
|
private void checkBoxPasNotificationSchengenDeparture_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
foreach(PASD pasd in _pasdMessage.Elements.Cast<PASD>())
|
|
{
|
|
pasd.NotificationSchengen = checkBoxPasNotificationSchengenDeparture.IsChecked;
|
|
}
|
|
this.SublistElementChanged(Message.NotificationClass.PASD);
|
|
}
|
|
|
|
private void checkBoxPasNotificationPAXDeparture_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
foreach(PASD pasd in _pasdMessage.Elements.Cast<PASD>())
|
|
{
|
|
pasd.NotificationPAX = checkBoxPasNotificationPAXDeparture.IsChecked;
|
|
}
|
|
this.SublistElementChanged(Message.NotificationClass.PASD);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Buttons to delete all entries from CREWA CREWD PASA PASD
|
|
|
|
private async void buttonDeleteAllCrewA_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if(MessageBox.Show(Properties.Resources.textConfimDeleteAllEntries, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
|
|
{
|
|
foreach(CREW crewa in this._crewMessage.Elements.Cast<CREW>())
|
|
{
|
|
await DBManagerAsync.DeleteAsync(crewa);
|
|
}
|
|
this._crewMessage.Elements.Clear();
|
|
this.dataGridCrewList.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.CREWA);
|
|
}
|
|
}
|
|
|
|
private async void buttonDeleteAllCrewD_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (MessageBox.Show(Properties.Resources.textConfimDeleteAllEntries, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
|
|
{
|
|
foreach (CREWD crewd in this._crewdMessage.Elements.Cast<CREWD>())
|
|
{
|
|
await DBManagerAsync.DeleteAsync(crewd);
|
|
}
|
|
this._crewdMessage.Elements.Clear();
|
|
this.dataGridCrewListDeparture.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.CREWD);
|
|
}
|
|
}
|
|
|
|
private async void buttonDeleteAllPasA_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (MessageBox.Show(Properties.Resources.textConfimDeleteAllEntries, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
|
|
{
|
|
foreach (PAS pasa in this._pasMessage.Elements.Cast<PAS>())
|
|
{
|
|
await DBManagerAsync.DeleteAsync(pasa);
|
|
}
|
|
this._pasMessage.Elements.Clear();
|
|
this.dataGridPassengerList.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.PASA);
|
|
}
|
|
}
|
|
|
|
private async void buttonDeleteAllPasD_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (MessageBox.Show(Properties.Resources.textConfimDeleteAllEntries, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
|
|
{
|
|
foreach (PASD pasd in this._pasdMessage.Elements.Cast<PASD>())
|
|
{
|
|
await DBManagerAsync.DeleteAsync(pasd);
|
|
}
|
|
this._pasdMessage.Elements.Clear();
|
|
this.dataGridPassengerListDeparture.Items.Refresh();
|
|
this.SublistElementChanged(Message.NotificationClass.PASD);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|