Added sheet / logic part 8,9 PAS arrival/departure
This commit is contained in:
parent
c4006d0585
commit
f3e398e07d
@ -290,25 +290,11 @@ namespace ENI2.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.TimeFilterItemSource();
|
this.TimeFilterItemSource();
|
||||||
// this.SortItemSource();
|
|
||||||
this.dataGridPOCores.SelectedItem = null;
|
this.dataGridPOCores.SelectedItem = null;
|
||||||
busyControl.BusyState = Util.UIHelper.BusyStateEnum.NEUTRAL;
|
busyControl.BusyState = Util.UIHelper.BusyStateEnum.NEUTRAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string ReadFieldAsString(IExcelDataReader reader, int fieldNum)
|
|
||||||
{
|
|
||||||
if (fieldNum >= reader.FieldCount) return null;
|
|
||||||
if (reader.GetFieldType(fieldNum) == typeof(string))
|
|
||||||
return reader.GetString(fieldNum).Clean();
|
|
||||||
if (reader.GetFieldType(fieldNum) == typeof(DateTime))
|
|
||||||
return reader.GetDateTime(fieldNum).ToString();
|
|
||||||
if (reader.GetFieldType(fieldNum) == typeof(int))
|
|
||||||
return reader.GetInt32(fieldNum).ToString();
|
|
||||||
if (reader.GetFieldType(fieldNum) == typeof(double))
|
|
||||||
return ((int) reader.GetDouble(fieldNum)).ToString();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TimeFilterItemSource()
|
private void TimeFilterItemSource()
|
||||||
{
|
{
|
||||||
List<MaerskData> removeList = new List<MaerskData>();
|
List<MaerskData> removeList = new List<MaerskData>();
|
||||||
@ -332,15 +318,6 @@ namespace ENI2.Controls
|
|||||||
this.maerskDataList.Remove(md);
|
this.maerskDataList.Remove(md);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SortItemSource()
|
|
||||||
{
|
|
||||||
ObservableCollection<MaerskData> temp;
|
|
||||||
temp = new ObservableCollection<MaerskData>(this.maerskDataList.OrderBy(p => p.ColA));
|
|
||||||
this.maerskDataList.Clear();
|
|
||||||
foreach (MaerskData md in temp)
|
|
||||||
this.maerskDataList.Add(md);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region button event handler
|
#region button event handler
|
||||||
@ -410,27 +387,27 @@ namespace ENI2.Controls
|
|||||||
md.ETA = aDateTime;
|
md.ETA = aDateTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!reader.IsDBNull(1)) md.ColB = ReadFieldAsString(reader, 1);
|
if (!reader.IsDBNull(1)) md.ColB = reader.ReadAsString(1);
|
||||||
if (!reader.IsDBNull(2)) md.ColC = ReadFieldAsString(reader, 2);
|
if (!reader.IsDBNull(2)) md.ColC = reader.ReadAsString(2);
|
||||||
if (!reader.IsDBNull(3)) md.ColD = ReadFieldAsString(reader, 3);
|
if (!reader.IsDBNull(3)) md.ColD = reader.ReadAsString(3);
|
||||||
if (!reader.IsDBNull(4)) md.ColE = ReadFieldAsString(reader, 4);
|
if (!reader.IsDBNull(4)) md.ColE = reader.ReadAsString(4);
|
||||||
if (!reader.IsDBNull(5)) md.ColF = ReadFieldAsString(reader, 5);
|
if (!reader.IsDBNull(5)) md.ColF = reader.ReadAsString(5);
|
||||||
if (!reader.IsDBNull(6)) md.ColG = ReadFieldAsString(reader, 6);
|
if (!reader.IsDBNull(6)) md.ColG = reader.ReadAsString(6);
|
||||||
if (!reader.IsDBNull(7)) md.ColH = ReadFieldAsString(reader, 7);
|
if (!reader.IsDBNull(7)) md.ColH = reader.ReadAsString(7);
|
||||||
if (!reader.IsDBNull(8)) md.ColI = ReadFieldAsString(reader, 8);
|
if (!reader.IsDBNull(8)) md.ColI = reader.ReadAsString(8);
|
||||||
if (md.ColI != null)
|
if (md.ColI != null)
|
||||||
{
|
{
|
||||||
if ((md.ColI.Contains("bremerhaven", StringComparison.OrdinalIgnoreCase) && this.PortLocode.Equals("DEWVN")) ||
|
if ((md.ColI.Contains("bremerhaven", StringComparison.OrdinalIgnoreCase) && this.PortLocode.Equals("DEWVN")) ||
|
||||||
(md.ColI.Contains("eurogate", StringComparison.OrdinalIgnoreCase) && this.PortLocode.Equals("DEBRV")))
|
(md.ColI.Contains("eurogate", StringComparison.OrdinalIgnoreCase) && this.PortLocode.Equals("DEBRV")))
|
||||||
throw new InvalidOperationException($"{md.ColI} found in import to {PortLocode}, this is probably an error. Aborting import");
|
throw new InvalidOperationException($"{md.ColI} found in import to {PortLocode}, this is probably an error. Aborting import");
|
||||||
}
|
}
|
||||||
if (!reader.IsDBNull(9)) md.ColJ = ReadFieldAsString(reader, 9);
|
if (!reader.IsDBNull(9)) md.ColJ = reader.ReadAsString(9);
|
||||||
if (md.ColJ == null) continue;
|
if (md.ColJ == null) continue;
|
||||||
if (!(md.ColJ.Equals("msk", StringComparison.OrdinalIgnoreCase) || md.ColJ.Equals("sgl", StringComparison.OrdinalIgnoreCase))) continue; // skip operator we are not interested in
|
if (!(md.ColJ.Equals("msk", StringComparison.OrdinalIgnoreCase) || md.ColJ.Equals("sgl", StringComparison.OrdinalIgnoreCase))) continue; // skip operator we are not interested in
|
||||||
if (!reader.IsDBNull(10)) md.ColK = ReadFieldAsString(reader, 10);
|
if (!reader.IsDBNull(10)) md.ColK = reader.ReadAsString(10);
|
||||||
if (!reader.IsDBNull(11)) md.ColL = ReadFieldAsString(reader, 11);
|
if (!reader.IsDBNull(11)) md.ColL = reader.ReadAsString(11);
|
||||||
if (!reader.IsDBNull(12)) md.ColM = ReadFieldAsString(reader, 12);
|
if (!reader.IsDBNull(12)) md.ColM = reader.ReadAsString(12);
|
||||||
if (!reader.IsDBNull(13)) md.Remark = ReadFieldAsString(reader, 13);
|
if (!reader.IsDBNull(13)) md.Remark = reader.ReadAsString(13);
|
||||||
|
|
||||||
if(!md.ColF.IsNullOrEmpty())
|
if(!md.ColF.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
@ -516,7 +493,6 @@ namespace ENI2.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.TimeFilterItemSource();
|
this.TimeFilterItemSource();
|
||||||
// this.SortItemSource();
|
|
||||||
busyControl.BusyState = Util.UIHelper.BusyStateEnum.NEUTRAL;
|
busyControl.BusyState = Util.UIHelper.BusyStateEnum.NEUTRAL;
|
||||||
|
|
||||||
this.dataGridPOCores.Items.Refresh();
|
this.dataGridPOCores.Items.Refresh();
|
||||||
|
|||||||
@ -183,6 +183,8 @@ namespace ENI2
|
|||||||
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text5ShipData, MessageGroupControlType = typeof(ShipDataControl), ImagePath = "Resources/containership.png" });
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text5ShipData, MessageGroupControlType = typeof(ShipDataControl), ImagePath = "Resources/containership.png" });
|
||||||
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text6CrewDataOnArrival, MessageGroupControlType = typeof(CrewPreArrivalControl), ImagePath = "Resources/arrival_worker.png" });
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text6CrewDataOnArrival, MessageGroupControlType = typeof(CrewPreArrivalControl), ImagePath = "Resources/arrival_worker.png" });
|
||||||
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text7CrewDeparture, MessageGroupControlType = typeof(CrewDepartureControl), ImagePath = "Resources/departure_worker.png" });
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text7CrewDeparture, MessageGroupControlType = typeof(CrewDepartureControl), ImagePath = "Resources/departure_worker.png" });
|
||||||
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text8PassengerArrival, MessageGroupControlType = typeof(PassengerPreArrivalControl), ImagePath = "Resources/arrival_user.png" });
|
||||||
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text9PassengerDeparture, MessageGroupControlType = typeof(PassengerDepartureControl), ImagePath = "Resources/departure_user.png" });
|
||||||
}
|
}
|
||||||
|
|
||||||
this.listBoxMessages.ItemsSource = this._listBoxList;
|
this.listBoxMessages.ItemsSource = this._listBoxList;
|
||||||
|
|||||||
@ -239,7 +239,7 @@ namespace ENI2.DetailViewControls
|
|||||||
MenuItem copyPASDItem = new MenuItem();
|
MenuItem copyPASDItem = new MenuItem();
|
||||||
copyPASDItem.Header = Properties.Resources.textCopyToPASA;
|
copyPASDItem.Header = Properties.Resources.textCopyToPASA;
|
||||||
copyPASDItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
|
copyPASDItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
|
||||||
copyPASDItem.Click += CopyPASDItem_Click; ;
|
copyPASDItem.Click += CopyPASDItem_Click;
|
||||||
this.dataGridPassengerListDeparture.ContextMenu.Items.Add(copyPASDItem);
|
this.dataGridPassengerListDeparture.ContextMenu.Items.Add(copyPASDItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -678,7 +678,7 @@ namespace ENI2.DetailViewControls
|
|||||||
this._pasdMessage.Elements.Add(epd.PAS);
|
this._pasdMessage.Elements.Add(epd.PAS);
|
||||||
this.CheckPASD();
|
this.CheckPASD();
|
||||||
}
|
}
|
||||||
this.dataGridPassengerList.Items.Refresh();
|
this.dataGridPassengerListDeparture.Items.Refresh();
|
||||||
epd.PAS = new PASD
|
epd.PAS = new PASD
|
||||||
{
|
{
|
||||||
IsDeparture = true,
|
IsDeparture = true,
|
||||||
@ -732,7 +732,7 @@ namespace ENI2.DetailViewControls
|
|||||||
_pasMessage.Elements.Add(epd.PAS);
|
_pasMessage.Elements.Add(epd.PAS);
|
||||||
this.CheckPASD();
|
this.CheckPASD();
|
||||||
}
|
}
|
||||||
this.dataGridPassengerList.Items.Refresh();
|
this.dataGridPassengerListDeparture.Items.Refresh();
|
||||||
epd.PAS = new PASD
|
epd.PAS = new PASD
|
||||||
{
|
{
|
||||||
IsDeparture = true,
|
IsDeparture = true,
|
||||||
@ -1035,17 +1035,6 @@ namespace ENI2.DetailViewControls
|
|||||||
|
|
||||||
#region Excel import
|
#region Excel import
|
||||||
|
|
||||||
private string getValueAsString(IExcelDataReader reader, int index)
|
|
||||||
{
|
|
||||||
Type fieldType = reader.GetFieldType(index);
|
|
||||||
if (fieldType == null) return null;
|
|
||||||
if (fieldType == typeof(double))
|
|
||||||
return reader.GetDouble(index).ToString();
|
|
||||||
if (fieldType == typeof(int))
|
|
||||||
return reader.GetInt32(index).ToString();
|
|
||||||
return reader.GetString(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonImportExcelCrew_Click(object sender, RoutedEventArgs e)
|
private void buttonImportExcelCrew_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
OpenFileDialog ofd = new OpenFileDialog
|
OpenFileDialog ofd = new OpenFileDialog
|
||||||
@ -1091,10 +1080,10 @@ namespace ENI2.DetailViewControls
|
|||||||
if (!reader.IsDBNull(6)) crew.CrewMemberCountryOfBirth = reader.GetString(6).Substring(0, 2).ToUpper();
|
if (!reader.IsDBNull(6)) crew.CrewMemberCountryOfBirth = reader.GetString(6).Substring(0, 2).ToUpper();
|
||||||
if (!reader.IsDBNull(7)) crew.CrewMemberDateOfBirth = reader.GetDateTime(7);
|
if (!reader.IsDBNull(7)) crew.CrewMemberDateOfBirth = reader.GetDateTime(7);
|
||||||
if (!reader.IsDBNull(8)) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(8));
|
if (!reader.IsDBNull(8)) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(8));
|
||||||
if (!reader.IsDBNull(9)) crew.CrewMemberIdentityDocumentId = this.getValueAsString(reader, 9).Clean();
|
if (!reader.IsDBNull(9)) crew.CrewMemberIdentityDocumentId = reader.ReadAsString(9).Clean();
|
||||||
if (!reader.IsDBNull(10)) crew.CrewMemberIdentityDocumentIssuingState = reader.GetString(10).Substring(0, 2).ToUpper();
|
if (!reader.IsDBNull(10)) crew.CrewMemberIdentityDocumentIssuingState = reader.GetString(10).Substring(0, 2).ToUpper();
|
||||||
if (!reader.IsDBNull(11)) crew.CrewMemberIdentityDocumentExpiryDate = reader.GetDateTime(11);
|
if (!reader.IsDBNull(11)) crew.CrewMemberIdentityDocumentExpiryDate = reader.GetDateTime(11);
|
||||||
if (!reader.IsDBNull(12)) crew.CrewMemberVisaNumber = this.getValueAsString(reader, 12).Clean();
|
if (!reader.IsDBNull(12)) crew.CrewMemberVisaNumber = reader.ReadAsString(12).Clean();
|
||||||
|
|
||||||
crew.MessageHeader = this._crewMessage;
|
crew.MessageHeader = this._crewMessage;
|
||||||
crew.IsDirty = true;
|
crew.IsDirty = true;
|
||||||
@ -1168,10 +1157,10 @@ namespace ENI2.DetailViewControls
|
|||||||
if (!reader.IsDBNull(6)) crew.CrewMemberCountryOfBirth = reader.GetString(6).Substring(0, 2).ToUpper();
|
if (!reader.IsDBNull(6)) crew.CrewMemberCountryOfBirth = reader.GetString(6).Substring(0, 2).ToUpper();
|
||||||
if (!reader.IsDBNull(7)) crew.CrewMemberDateOfBirth = reader.GetDateTime(7);
|
if (!reader.IsDBNull(7)) crew.CrewMemberDateOfBirth = reader.GetDateTime(7);
|
||||||
if (!reader.IsDBNull(8)) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(8));
|
if (!reader.IsDBNull(8)) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(8));
|
||||||
if (!reader.IsDBNull(9)) crew.CrewMemberIdentityDocumentId = this.getValueAsString(reader, 9);
|
if (!reader.IsDBNull(9)) crew.CrewMemberIdentityDocumentId = reader.ReadAsString(9);
|
||||||
if (!reader.IsDBNull(10)) crew.CrewMemberIdentityDocumentIssuingState = reader.GetString(10).Substring(0, 2).ToUpper();
|
if (!reader.IsDBNull(10)) crew.CrewMemberIdentityDocumentIssuingState = reader.GetString(10).Substring(0, 2).ToUpper();
|
||||||
if (!reader.IsDBNull(11)) crew.CrewMemberIdentityDocumentExpiryDate = reader.GetDateTime(11);
|
if (!reader.IsDBNull(11)) crew.CrewMemberIdentityDocumentExpiryDate = reader.GetDateTime(11);
|
||||||
if (!reader.IsDBNull(12)) crew.CrewMemberVisaNumber = this.getValueAsString(reader, 12);
|
if (!reader.IsDBNull(12)) crew.CrewMemberVisaNumber = reader.ReadAsString(12);
|
||||||
|
|
||||||
crew.MessageHeader = this._crewdMessage;
|
crew.MessageHeader = this._crewdMessage;
|
||||||
crew.IsDirty = true;
|
crew.IsDirty = true;
|
||||||
@ -1250,12 +1239,12 @@ namespace ENI2.DetailViewControls
|
|||||||
if (!reader.IsDBNull(8)) pas.PassengerCountryOfBirth = reader.GetString(8).Substring(0, 2).ToUpper().Clean();
|
if (!reader.IsDBNull(8)) pas.PassengerCountryOfBirth = reader.GetString(8).Substring(0, 2).ToUpper().Clean();
|
||||||
if (!reader.IsDBNull(9)) pas.PassengerDateOfBirth = reader.GetDateTime(9);
|
if (!reader.IsDBNull(9)) pas.PassengerDateOfBirth = reader.GetDateTime(9);
|
||||||
if (!reader.IsDBNull(10)) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(10));
|
if (!reader.IsDBNull(10)) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(10));
|
||||||
if (!reader.IsDBNull(11)) pas.PassengerIdentityDocumentId = this.getValueAsString(reader, 11).Clean();
|
if (!reader.IsDBNull(11)) pas.PassengerIdentityDocumentId = reader.ReadAsString(11).Clean();
|
||||||
if (!reader.IsDBNull(12)) pas.PassengerIdentityDocumentIssuingState = reader.GetString(12).Substring(0, 2).ToUpper();
|
if (!reader.IsDBNull(12)) pas.PassengerIdentityDocumentIssuingState = reader.GetString(12).Substring(0, 2).ToUpper();
|
||||||
if (!reader.IsDBNull(13)) pas.PassengerIdentityDocumentExpiryDate = reader.GetDateTime(13);
|
if (!reader.IsDBNull(13)) pas.PassengerIdentityDocumentExpiryDate = reader.GetDateTime(13);
|
||||||
if (!reader.IsDBNull(14)) pas.PassengerVisaNumber = this.getValueAsString(reader, 14).Clean();
|
if (!reader.IsDBNull(14)) pas.PassengerVisaNumber = reader.ReadAsString(14).Clean();
|
||||||
if (!reader.IsDBNull(15)) pas.EmergencyCare = reader.GetString(15).Clean();
|
if (!reader.IsDBNull(15)) pas.EmergencyCare = reader.GetString(15).Clean();
|
||||||
if (!reader.IsDBNull(16)) pas.EmergencyContactNumber = this.getValueAsString(reader, 16).Clean();
|
if (!reader.IsDBNull(16)) pas.EmergencyContactNumber = reader.ReadAsString(16).Clean();
|
||||||
|
|
||||||
pas.MessageHeader = this._pasMessage;
|
pas.MessageHeader = this._pasMessage;
|
||||||
pas.IsDirty = true;
|
pas.IsDirty = true;
|
||||||
@ -1333,12 +1322,12 @@ namespace ENI2.DetailViewControls
|
|||||||
if (!reader.IsDBNull(8)) pas.PassengerCountryOfBirth = reader.GetString(8).Substring(0, 2).ToUpper();
|
if (!reader.IsDBNull(8)) pas.PassengerCountryOfBirth = reader.GetString(8).Substring(0, 2).ToUpper();
|
||||||
if (!reader.IsDBNull(9)) pas.PassengerDateOfBirth = reader.GetDateTime(9);
|
if (!reader.IsDBNull(9)) pas.PassengerDateOfBirth = reader.GetDateTime(9);
|
||||||
if (!reader.IsDBNull(10)) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(10));
|
if (!reader.IsDBNull(10)) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(10));
|
||||||
if (!reader.IsDBNull(11)) pas.PassengerIdentityDocumentId = this.getValueAsString(reader, 11);
|
if (!reader.IsDBNull(11)) pas.PassengerIdentityDocumentId = reader.ReadAsString(11);
|
||||||
if (!reader.IsDBNull(12)) pas.PassengerIdentityDocumentIssuingState = reader.GetString(12).Substring(0, 2).ToUpper();
|
if (!reader.IsDBNull(12)) pas.PassengerIdentityDocumentIssuingState = reader.GetString(12).Substring(0, 2).ToUpper();
|
||||||
if (!reader.IsDBNull(13)) pas.PassengerIdentityDocumentExpiryDate = reader.GetDateTime(13);
|
if (!reader.IsDBNull(13)) pas.PassengerIdentityDocumentExpiryDate = reader.GetDateTime(13);
|
||||||
if (!reader.IsDBNull(14)) pas.PassengerVisaNumber = this.getValueAsString(reader, 14);
|
if (!reader.IsDBNull(14)) pas.PassengerVisaNumber = reader.ReadAsString(14);
|
||||||
if (!reader.IsDBNull(15)) pas.EmergencyCare = reader.GetString(15);
|
if (!reader.IsDBNull(15)) pas.EmergencyCare = reader.GetString(15);
|
||||||
if (!reader.IsDBNull(16)) pas.EmergencyContactNumber = this.getValueAsString(reader, 16);
|
if (!reader.IsDBNull(16)) pas.EmergencyContactNumber = reader.ReadAsString(16);
|
||||||
|
|
||||||
pas.MessageHeader = this._pasMessage;
|
pas.MessageHeader = this._pasMessage;
|
||||||
pas.IsDirty = true;
|
pas.IsDirty = true;
|
||||||
|
|||||||
@ -499,6 +499,12 @@
|
|||||||
<Compile Include="SheetDisplayControls\CrewPreArrivalControl.xaml.cs">
|
<Compile Include="SheetDisplayControls\CrewPreArrivalControl.xaml.cs">
|
||||||
<DependentUpon>CrewPreArrivalControl.xaml</DependentUpon>
|
<DependentUpon>CrewPreArrivalControl.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="SheetDisplayControls\PassengerDepartureControl.xaml.cs">
|
||||||
|
<DependentUpon>PassengerDepartureControl.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="SheetDisplayControls\PassengerPreArrivalControl.xaml.cs">
|
||||||
|
<DependentUpon>PassengerPreArrivalControl.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="SheetDisplayControls\PortControl.xaml.cs">
|
<Compile Include="SheetDisplayControls\PortControl.xaml.cs">
|
||||||
<DependentUpon>PortControl.xaml</DependentUpon>
|
<DependentUpon>PortControl.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -528,6 +534,7 @@
|
|||||||
<Compile Include="Util\EnumToBooleanConverter.cs" />
|
<Compile Include="Util\EnumToBooleanConverter.cs" />
|
||||||
<Compile Include="Util\EnumToCollectionConverter.cs" />
|
<Compile Include="Util\EnumToCollectionConverter.cs" />
|
||||||
<Compile Include="Util\ExpandableListConverter.cs" />
|
<Compile Include="Util\ExpandableListConverter.cs" />
|
||||||
|
<Compile Include="Util\Extensions.cs" />
|
||||||
<Compile Include="Util\GlobalStructures.cs" />
|
<Compile Include="Util\GlobalStructures.cs" />
|
||||||
<Compile Include="Util\HighlightService.cs" />
|
<Compile Include="Util\HighlightService.cs" />
|
||||||
<Compile Include="Util\InverseBooleanConverter.cs" />
|
<Compile Include="Util\InverseBooleanConverter.cs" />
|
||||||
@ -831,6 +838,14 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="SheetDisplayControls\PassengerDepartureControl.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
<Page Include="SheetDisplayControls\PassengerPreArrivalControl.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="SheetDisplayControls\PortControl.xaml">
|
<Page Include="SheetDisplayControls\PortControl.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
@ -11,17 +11,9 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
|
|
||||||
namespace ENI2.SheetDisplayControls
|
namespace ENI2.SheetDisplayControls
|
||||||
{
|
{
|
||||||
@ -166,10 +158,10 @@ namespace ENI2.SheetDisplayControls
|
|||||||
if (!reader.IsDBNull(6)) crew.CrewMemberCountryOfBirth = reader.GetString(6).Substring(0, 2).ToUpper();
|
if (!reader.IsDBNull(6)) crew.CrewMemberCountryOfBirth = reader.GetString(6).Substring(0, 2).ToUpper();
|
||||||
if (!reader.IsDBNull(7)) crew.CrewMemberDateOfBirth = reader.GetDateTime(7);
|
if (!reader.IsDBNull(7)) crew.CrewMemberDateOfBirth = reader.GetDateTime(7);
|
||||||
if (!reader.IsDBNull(8)) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(8));
|
if (!reader.IsDBNull(8)) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(8));
|
||||||
if (!reader.IsDBNull(9)) crew.CrewMemberIdentityDocumentId = this.getValueAsString(reader, 9);
|
if (!reader.IsDBNull(9)) crew.CrewMemberIdentityDocumentId = reader.ReadAsString(9);
|
||||||
if (!reader.IsDBNull(10)) crew.CrewMemberIdentityDocumentIssuingState = reader.GetString(10).Substring(0, 2).ToUpper();
|
if (!reader.IsDBNull(10)) crew.CrewMemberIdentityDocumentIssuingState = reader.GetString(10).Substring(0, 2).ToUpper();
|
||||||
if (!reader.IsDBNull(11)) crew.CrewMemberIdentityDocumentExpiryDate = reader.GetDateTime(11);
|
if (!reader.IsDBNull(11)) crew.CrewMemberIdentityDocumentExpiryDate = reader.GetDateTime(11);
|
||||||
if (!reader.IsDBNull(12)) crew.CrewMemberVisaNumber = this.getValueAsString(reader, 12);
|
if (!reader.IsDBNull(12)) crew.CrewMemberVisaNumber = reader.ReadAsString(12);
|
||||||
|
|
||||||
crew.MessageHeader = this._crewdMessage;
|
crew.MessageHeader = this._crewdMessage;
|
||||||
crew.IsDirty = true;
|
crew.IsDirty = true;
|
||||||
@ -375,17 +367,6 @@ namespace ENI2.SheetDisplayControls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string getValueAsString(IExcelDataReader reader, int index)
|
|
||||||
{
|
|
||||||
Type fieldType = reader.GetFieldType(index);
|
|
||||||
if (fieldType == null) return null;
|
|
||||||
if (fieldType == typeof(double))
|
|
||||||
return reader.GetDouble(index).ToString();
|
|
||||||
if (fieldType == typeof(int))
|
|
||||||
return reader.GetInt32(index).ToString();
|
|
||||||
return reader.GetString(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -196,10 +196,10 @@ namespace ENI2.SheetDisplayControls
|
|||||||
if (!reader.IsDBNull(6)) crew.CrewMemberCountryOfBirth = reader.GetString(6).Substring(0, 2).ToUpper();
|
if (!reader.IsDBNull(6)) crew.CrewMemberCountryOfBirth = reader.GetString(6).Substring(0, 2).ToUpper();
|
||||||
if (!reader.IsDBNull(7)) crew.CrewMemberDateOfBirth = reader.GetDateTime(7);
|
if (!reader.IsDBNull(7)) crew.CrewMemberDateOfBirth = reader.GetDateTime(7);
|
||||||
if (!reader.IsDBNull(8)) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(8));
|
if (!reader.IsDBNull(8)) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(8));
|
||||||
if (!reader.IsDBNull(9)) crew.CrewMemberIdentityDocumentId = this.getValueAsString(reader, 9).Clean();
|
if (!reader.IsDBNull(9)) crew.CrewMemberIdentityDocumentId = reader.ReadAsString(9).Clean();
|
||||||
if (!reader.IsDBNull(10)) crew.CrewMemberIdentityDocumentIssuingState = reader.GetString(10).Substring(0, 2).ToUpper();
|
if (!reader.IsDBNull(10)) crew.CrewMemberIdentityDocumentIssuingState = reader.GetString(10).Substring(0, 2).ToUpper();
|
||||||
if (!reader.IsDBNull(11)) crew.CrewMemberIdentityDocumentExpiryDate = reader.GetDateTime(11);
|
if (!reader.IsDBNull(11)) crew.CrewMemberIdentityDocumentExpiryDate = reader.GetDateTime(11);
|
||||||
if (!reader.IsDBNull(12)) crew.CrewMemberVisaNumber = this.getValueAsString(reader, 12).Clean();
|
if (!reader.IsDBNull(12)) crew.CrewMemberVisaNumber = reader.ReadAsString(12).Clean();
|
||||||
|
|
||||||
crew.MessageHeader = this._crewaMessage;
|
crew.MessageHeader = this._crewaMessage;
|
||||||
crew.IsDirty = true;
|
crew.IsDirty = true;
|
||||||
@ -353,17 +353,6 @@ namespace ENI2.SheetDisplayControls
|
|||||||
|
|
||||||
#region private methods
|
#region private methods
|
||||||
|
|
||||||
private string getValueAsString(IExcelDataReader reader, int index)
|
|
||||||
{
|
|
||||||
Type fieldType = reader.GetFieldType(index);
|
|
||||||
if (fieldType == null) return null;
|
|
||||||
if (fieldType == typeof(double))
|
|
||||||
return reader.GetDouble(index).ToString();
|
|
||||||
if (fieldType == typeof(int))
|
|
||||||
return reader.GetInt32(index).ToString();
|
|
||||||
return reader.GetString(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckCREWA()
|
private void CheckCREWA()
|
||||||
{
|
{
|
||||||
if (this._crewaMessage.Elements.Count == 0) return;
|
if (this._crewaMessage.Elements.Count == 0) return;
|
||||||
|
|||||||
70
ENI2/SheetDisplayControls/PassengerDepartureControl.xaml
Normal file
70
ENI2/SheetDisplayControls/PassengerDepartureControl.xaml
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<src:DetailBaseControl xmlns:src="clr-namespace:ENI2"
|
||||||
|
x:Class="ENI2.SheetDisplayControls.PassengerDepartureControl"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:p="clr-namespace:ENI2.Properties"
|
||||||
|
xmlns:enictrl="clr-namespace:ENI2.Controls"
|
||||||
|
xmlns:util="clr-namespace:ENI2.Util"
|
||||||
|
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||||
|
xmlns:local="clr-namespace:ENI2.SheetDisplayControls"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="1450" d:DesignWidth="800">
|
||||||
|
<GroupBox Name="portCallGroupBox" Header="{x:Static p:Resources.text9PassengerDeparture}">
|
||||||
|
<ScrollViewer PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width=".35*"/>
|
||||||
|
<ColumnDefinition Width=".65*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<RowDefinition Height="28" />
|
||||||
|
<RowDefinition Height="28" />
|
||||||
|
<RowDefinition Height="8" />
|
||||||
|
<RowDefinition Height="28" />
|
||||||
|
<RowDefinition Height="640" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<Label Grid.Row="0" Grid.Column="0" Name="labelPasNotificationSchengenDeparture" Content="{x:Static p:Resources.textNotificationSchengen}" HorizontalAlignment="Right" />
|
||||||
|
<CheckBox Grid.Row="0" Grid.Column="1" Name="checkBoxPasNotificationSchengenDeparture" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxPasNotificationSchengenDeparture_Click"/>
|
||||||
|
<Label Grid.Row="1" Grid.Column="0" Name="labelPasNotificationPAXDeparture" Content="{x:Static p:Resources.textNotificationPAX}" HorizontalAlignment="Right"/>
|
||||||
|
<CheckBox Grid.Row="1" Grid.Column="1" Name="checkBoxPasNotificationPAXDeparture" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxPasNotificationPAXDeparture_Click"/>
|
||||||
|
|
||||||
|
<Button Name="buttonImportExcelPassengerDeparture" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textImportFromExcel}" Margin="2" Width="120" HorizontalAlignment="Right" VerticalAlignment="Center" Background="Transparent" Click="buttonImportExcelPassengerDeparture_Click" />
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal">
|
||||||
|
<TextBlock Margin="20, 0, 0, 0" Name="textBlockNumPasEntriesDeparture" FontWeight="Bold" Text="{Binding Elements.Count}" VerticalAlignment="Center"/>
|
||||||
|
<Label Name="labelPasEntryCountDeparture" Content="{x:Static p:Resources.textEntries}" />
|
||||||
|
<Button Name="buttonDeleteAllPasD" Margin="2" Content="{x:Static p:Resources.textDeleteAllEntries}" Background="Transparent" Click="buttonDeleteAllPasD_Click"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<enictrl:ENIDataGrid Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" x:Name="dataGridPassengerListDeparture" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
|
||||||
|
AutoGenerateColumns="False" Margin="0,5,0,0">
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textLastName}" Binding="{Binding PassengerLastName, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textFirstName}" Binding="{Binding PassengerFirstName, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textGender}" Binding="{Binding PassengerGenderDisplay}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textPortOfEmbarkation}" Binding="{Binding PassengerPortOfEmbarkation}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textPortOfDisembarkation}" Binding="{Binding PassengerPortOfDisembarkation}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridCheckBoxColumn Header="{x:Static p:Resources.textTransitPassenger}" Binding="{Binding PassengerInTransit}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textNationality}" Binding="{Binding PassengerNationality}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textPlaceOfBirth}" Binding="{Binding PassengerPlaceOfBirth}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textCountryOfBirth}" Binding="{Binding PassengerCountryOfBirth, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textDateOfBirth}" Binding="{Binding PassengerDateOfBirth, StringFormat=\{0:dd.MM.yyyy\}}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textIdDocType}" Binding="{Binding PassengerIdentityDocumentTypeDisplay}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textIdDocNumber}" Binding="{Binding PassengerIdentityDocumentId}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textDocumentIssuingState}" Binding="{Binding PassengerIdentityDocumentIssuingState}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textDocumentExpiryDate}" Binding="{Binding PassengerIdentityDocumentExpiryDate, StringFormat=\{0:dd.MM.yyyy\}}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textVisaNumber}" Binding="{Binding PassengerVisaNumber}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textEmergencyCare}" Binding="{Binding EmergencyCare, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textEmergencyContactNumber}" Binding="{Binding EmergencyContactNumber, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</enictrl:ENIDataGrid>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</ScrollViewer>
|
||||||
|
</GroupBox>
|
||||||
|
</src:DetailBaseControl>
|
||||||
379
ENI2/SheetDisplayControls/PassengerDepartureControl.xaml.cs
Normal file
379
ENI2/SheetDisplayControls/PassengerDepartureControl.xaml.cs
Normal file
@ -0,0 +1,379 @@
|
|||||||
|
// Copyright (c) 2025 - schick Informatik
|
||||||
|
// Description: Display control of formsheet Tab 9. Pas data departure
|
||||||
|
//
|
||||||
|
|
||||||
|
using bsmd.database;
|
||||||
|
using ENI2.EditControls;
|
||||||
|
using ENI2.Locode;
|
||||||
|
using ENI2.Util;
|
||||||
|
using ExcelDataReader;
|
||||||
|
using Microsoft.Win32;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
|
namespace ENI2.SheetDisplayControls
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for PassengerDepartureControl.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class PassengerDepartureControl : DetailBaseControl
|
||||||
|
{
|
||||||
|
|
||||||
|
#region Fields
|
||||||
|
|
||||||
|
private Message _pasMessage;
|
||||||
|
private Message _pasdMessage;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Construction
|
||||||
|
|
||||||
|
public PassengerDepartureControl()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region public override
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
foreach (Message aMessage in this.Messages)
|
||||||
|
{
|
||||||
|
if (aMessage.MessageNotificationClass == Message.NotificationClass.PASA) { this._pasMessage = aMessage; this.ControlMessages.Add(aMessage); }
|
||||||
|
if (aMessage.MessageNotificationClass == Message.NotificationClass.PASD) { this._pasdMessage = aMessage; this.ControlMessages.Add(aMessage); }
|
||||||
|
}
|
||||||
|
|
||||||
|
#region init PASD
|
||||||
|
|
||||||
|
if (this._pasdMessage == null)
|
||||||
|
{
|
||||||
|
this._pasdMessage = this.Core.CreateMessage(Message.NotificationClass.PASD);
|
||||||
|
this.Messages.Add(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
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region event handler
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonImportExcelPassengerDeparture_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<PASD> importPassenger = new List<PASD>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
if (((IExcelDataReader)reader).FieldCount < 17)
|
||||||
|
{
|
||||||
|
throw new InvalidDataException("Sheet must have 17 columns of data");
|
||||||
|
}
|
||||||
|
|
||||||
|
PASD pas = new PASD();
|
||||||
|
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
|
||||||
|
if (!reader.IsDBNull(0)) pas.PassengerLastName = reader.GetValue(0).ToString();
|
||||||
|
if (pas.PassengerLastName.Equals("Family Name") || (pas.PassengerLastName.Trim().Length == 0)) continue;
|
||||||
|
if (!reader.IsDBNull(1)) pas.PassengerFirstName = reader.GetValue(1).ToString();
|
||||||
|
if (!reader.IsDBNull(2)) pas.PassengerGender = GlobalStructures.ParseGender(reader.GetString(2));
|
||||||
|
if (!reader.IsDBNull(3)) pas.PassengerPortOfEmbarkation = reader.GetString(3);
|
||||||
|
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfEmbarkation) == null)
|
||||||
|
pas.PassengerPortOfEmbarkation = null;
|
||||||
|
if (!reader.IsDBNull(4)) pas.PassengerPortOfDisembarkation = reader.GetString(4);
|
||||||
|
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfDisembarkation) == null)
|
||||||
|
pas.PassengerPortOfDisembarkation = null;
|
||||||
|
if (!reader.IsDBNull(5)) pas.PassengerInTransit = GlobalStructures.ReadBoolean(reader.GetString(5));
|
||||||
|
if (!reader.IsDBNull(6)) pas.PassengerNationality = reader.GetString(6).Substring(0, 2).ToUpper();
|
||||||
|
if (!reader.IsDBNull(7)) pas.PassengerPlaceOfBirth = reader.GetString(7);
|
||||||
|
if (!reader.IsDBNull(8)) pas.PassengerCountryOfBirth = reader.GetString(8).Substring(0, 2).ToUpper();
|
||||||
|
if (!reader.IsDBNull(9)) pas.PassengerDateOfBirth = reader.GetDateTime(9);
|
||||||
|
if (!reader.IsDBNull(10)) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(10));
|
||||||
|
if (!reader.IsDBNull(11)) pas.PassengerIdentityDocumentId = reader.ReadAsString( 11);
|
||||||
|
if (!reader.IsDBNull(12)) pas.PassengerIdentityDocumentIssuingState = reader.GetString(12).Substring(0, 2).ToUpper();
|
||||||
|
if (!reader.IsDBNull(13)) pas.PassengerIdentityDocumentExpiryDate = reader.GetDateTime(13);
|
||||||
|
if (!reader.IsDBNull(14)) pas.PassengerVisaNumber = reader.ReadAsString(14);
|
||||||
|
if (!reader.IsDBNull(15)) pas.EmergencyCare = reader.GetString(15);
|
||||||
|
if (!reader.IsDBNull(16)) pas.EmergencyContactNumber = reader.ReadAsString(16);
|
||||||
|
|
||||||
|
pas.MessageHeader = this._pasMessage;
|
||||||
|
pas.IsDirty = true;
|
||||||
|
pas.Identifier = PASD.GetNewIdentifier(this._pasdMessage.Elements);
|
||||||
|
this._pasdMessage.Elements.Add(pas);
|
||||||
|
importPassenger.Add(pas);
|
||||||
|
}
|
||||||
|
} while (reader.NextResult());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stream.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
#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 private methods
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
69
ENI2/SheetDisplayControls/PassengerPreArrivalControl.xaml
Normal file
69
ENI2/SheetDisplayControls/PassengerPreArrivalControl.xaml
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<src:DetailBaseControl xmlns:src="clr-namespace:ENI2"
|
||||||
|
x:Class="ENI2.SheetDisplayControls.PassengerPreArrivalControl"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:p="clr-namespace:ENI2.Properties"
|
||||||
|
xmlns:enictrl="clr-namespace:ENI2.Controls"
|
||||||
|
xmlns:util="clr-namespace:ENI2.Util"
|
||||||
|
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||||
|
xmlns:local="clr-namespace:ENI2.SheetDisplayControls"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="1450" d:DesignWidth="800">
|
||||||
|
<GroupBox Name="portCallGroupBox" Header="{x:Static p:Resources.text8PassengerArrival}">
|
||||||
|
<ScrollViewer PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width=".35*"/>
|
||||||
|
<ColumnDefinition Width=".65*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<RowDefinition Height="28" />
|
||||||
|
<RowDefinition Height="28" />
|
||||||
|
<RowDefinition Height="8" />
|
||||||
|
<RowDefinition Height="28" />
|
||||||
|
<RowDefinition Height="640" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<CheckBox Grid.Column="1" Name="checkBoxPasNotificationSchengen" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxPasNotificationSchengen_Click" />
|
||||||
|
<Label Name="labelPasNotificationSchengen" Content="{x:Static p:Resources.textNotificationSchengen}" HorizontalAlignment="Right" />
|
||||||
|
<CheckBox Grid.Column="1" Grid.Row="1" Name="checkBoxPasNotificationPAX" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxPasNotificationPAX_Click"/>
|
||||||
|
<Label Grid.Column="0" Grid.Row="1" Name="labelPasNotificationPAX" Content="{x:Static p:Resources.textNotificationPAX}" HorizontalAlignment="Right" />
|
||||||
|
<Button Grid.Column="0" Grid.Row="3" Name="buttonImportExcelPassenger" Content="{x:Static p:Resources.textImportFromExcel}" Margin="2" Width="120" HorizontalAlignment="Right" VerticalAlignment="Center" Background="Transparent" Click="buttonImportExcelPassenger_Click" />
|
||||||
|
<StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal">
|
||||||
|
<TextBlock Margin="20, 0, 0, 0" Name="textBlockNumPasEntries" FontWeight="Bold" Text="{Binding Elements.Count}" VerticalAlignment="Center"/>
|
||||||
|
<Label Name="labelPasEntryCount" Content="{x:Static p:Resources.textEntries}" />
|
||||||
|
<Button Name="buttonDeleteAllPasA" Margin="2" Content="{x:Static p:Resources.textDeleteAllEntries}" Background="Transparent" Click="buttonDeleteAllPasA_Click"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<enictrl:ENIDataGrid Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" x:Name="dataGridPassengerList" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
|
||||||
|
AutoGenerateColumns="False" Margin="0,5,0,0">
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textLastName}" Binding="{Binding PassengerLastName, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textFirstName}" Binding="{Binding PassengerFirstName, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textGender}" Binding="{Binding PassengerGenderDisplay}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textPortOfEmbarkation}" Binding="{Binding PassengerPortOfEmbarkation}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textPortOfDisembarkation}" Binding="{Binding PassengerPortOfDisembarkation}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridCheckBoxColumn Header="{x:Static p:Resources.textTransitPassenger}" Binding="{Binding PassengerInTransit}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textNationality}" Binding="{Binding PassengerNationality}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textPlaceOfBirth}" Binding="{Binding PassengerPlaceOfBirth}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textCountryOfBirth}" Binding="{Binding PassengerCountryOfBirth, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textDateOfBirth}" Binding="{Binding PassengerDateOfBirth, StringFormat=\{0:dd.MM.yyyy\}}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textIdDocType}" Binding="{Binding PassengerIdentityDocumentTypeDisplay}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textIdDocNumber}" Binding="{Binding PassengerIdentityDocumentId}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textDocumentIssuingState}" Binding="{Binding PassengerIdentityDocumentIssuingState}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textDocumentExpiryDate}" Binding="{Binding PassengerIdentityDocumentExpiryDate, StringFormat=\{0:dd.MM.yyyy\}}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textVisaNumber}" Binding="{Binding PassengerVisaNumber}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textEmergencyCare}" Binding="{Binding EmergencyCare, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
<DataGridTextColumn Header="{x:Static p:Resources.textEmergencyContactNumber}" Binding="{Binding EmergencyContactNumber, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
|
||||||
|
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</enictrl:ENIDataGrid>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</ScrollViewer>
|
||||||
|
</GroupBox>
|
||||||
|
</src:DetailBaseControl>
|
||||||
376
ENI2/SheetDisplayControls/PassengerPreArrivalControl.xaml.cs
Normal file
376
ENI2/SheetDisplayControls/PassengerPreArrivalControl.xaml.cs
Normal file
@ -0,0 +1,376 @@
|
|||||||
|
// Copyright (c) 2025 - schick Informatik
|
||||||
|
// Description: Display control of formsheet Tab 8. Pas data arrival
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
using bsmd.database;
|
||||||
|
using ENI2.EditControls;
|
||||||
|
using ENI2.Locode;
|
||||||
|
using ENI2.Util;
|
||||||
|
using ExcelDataReader;
|
||||||
|
using Microsoft.Win32;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
|
namespace ENI2.SheetDisplayControls
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for PassengerPreArrivalControl.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class PassengerPreArrivalControl : DetailBaseControl
|
||||||
|
{
|
||||||
|
#region Fields
|
||||||
|
|
||||||
|
private Message _pasMessage;
|
||||||
|
private Message _pasdMessage;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Construction
|
||||||
|
|
||||||
|
public PassengerPreArrivalControl()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region public overrides
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
foreach (Message aMessage in this.Messages)
|
||||||
|
{
|
||||||
|
if (aMessage.MessageNotificationClass == Message.NotificationClass.PASA) { this._pasMessage = aMessage; this.ControlMessages.Add(aMessage); }
|
||||||
|
if (aMessage.MessageNotificationClass == Message.NotificationClass.PASD) { this._pasdMessage = aMessage; this.ControlMessages.Add(aMessage); }
|
||||||
|
}
|
||||||
|
|
||||||
|
#region init PASA
|
||||||
|
|
||||||
|
if (this._pasMessage == null)
|
||||||
|
{
|
||||||
|
this._pasMessage = this.Core.CreateMessage(Message.NotificationClass.PASA);
|
||||||
|
this.Messages.Add(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
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region event handler
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonImportExcelPassenger_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<PAS> importPassenger = new List<PAS>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
if (((IExcelDataReader)reader).FieldCount < 17)
|
||||||
|
{
|
||||||
|
throw new InvalidDataException("Sheet must have 17 columns of data");
|
||||||
|
}
|
||||||
|
|
||||||
|
PAS pas = new PAS();
|
||||||
|
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
|
||||||
|
if (!reader.IsDBNull(0)) pas.PassengerLastName = reader.GetValue(0).ToString().Clean();
|
||||||
|
if (pas.PassengerLastName.Equals("Family Name") || (pas.PassengerLastName.Trim().Length == 0)) continue;
|
||||||
|
if (!reader.IsDBNull(1)) pas.PassengerFirstName = reader.GetValue(1).ToString().Clean();
|
||||||
|
if (!reader.IsDBNull(2)) pas.PassengerGender = GlobalStructures.ParseGender(reader.GetString(2));
|
||||||
|
if (!reader.IsDBNull(3)) pas.PassengerPortOfEmbarkation = reader.GetString(3).Clean();
|
||||||
|
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfEmbarkation) == null)
|
||||||
|
pas.PassengerPortOfEmbarkation = null;
|
||||||
|
if (!reader.IsDBNull(4)) pas.PassengerPortOfDisembarkation = reader.GetString(4).Clean();
|
||||||
|
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfDisembarkation) == null)
|
||||||
|
pas.PassengerPortOfDisembarkation = null;
|
||||||
|
if (!reader.IsDBNull(5)) pas.PassengerInTransit = GlobalStructures.ReadBoolean(reader.GetString(5));
|
||||||
|
if (!reader.IsDBNull(6)) pas.PassengerNationality = reader.GetString(6).Substring(0, 2).ToUpper();
|
||||||
|
if (!reader.IsDBNull(7)) pas.PassengerPlaceOfBirth = reader.GetString(7).Clean();
|
||||||
|
if (!reader.IsDBNull(8)) pas.PassengerCountryOfBirth = reader.GetString(8).Substring(0, 2).ToUpper().Clean();
|
||||||
|
if (!reader.IsDBNull(9)) pas.PassengerDateOfBirth = reader.GetDateTime(9);
|
||||||
|
if (!reader.IsDBNull(10)) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(10));
|
||||||
|
if (!reader.IsDBNull(11)) pas.PassengerIdentityDocumentId = reader.ReadAsString(11).Clean();
|
||||||
|
if (!reader.IsDBNull(12)) pas.PassengerIdentityDocumentIssuingState = reader.GetString(12).Substring(0, 2).ToUpper();
|
||||||
|
if (!reader.IsDBNull(13)) pas.PassengerIdentityDocumentExpiryDate = reader.GetDateTime(13);
|
||||||
|
if (!reader.IsDBNull(14)) pas.PassengerVisaNumber = reader.ReadAsString(14).Clean();
|
||||||
|
if (!reader.IsDBNull(15)) pas.EmergencyCare = reader.GetString(15).Clean();
|
||||||
|
if (!reader.IsDBNull(16)) pas.EmergencyContactNumber = reader.ReadAsString(16).Clean();
|
||||||
|
|
||||||
|
pas.MessageHeader = this._pasMessage;
|
||||||
|
pas.IsDirty = true;
|
||||||
|
pas.Identifier = PAS.GetNewIdentifier(this._pasMessage.Elements);
|
||||||
|
this._pasMessage.Elements.Add(pas);
|
||||||
|
importPassenger.Add(pas);
|
||||||
|
}
|
||||||
|
} while (reader.NextResult());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stream.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#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 private methods
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
30
ENI2/Util/Extensions.cs
Normal file
30
ENI2/Util/Extensions.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright (c) 2025- schick Informatik
|
||||||
|
// Description: Some extensions only relevant to ENI itself
|
||||||
|
//
|
||||||
|
|
||||||
|
using bsmd.database;
|
||||||
|
using ExcelDataReader;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace ENI2.Util
|
||||||
|
{
|
||||||
|
internal static class Extensions
|
||||||
|
{
|
||||||
|
|
||||||
|
public static string ReadAsString(this IExcelDataReader reader, int index)
|
||||||
|
{
|
||||||
|
if (index >= reader.FieldCount) return null;
|
||||||
|
Type fieldType = reader.GetFieldType(index);
|
||||||
|
if (fieldType == null) return null;
|
||||||
|
if (fieldType == typeof(string))
|
||||||
|
return reader.GetString(index).Clean();
|
||||||
|
if (fieldType == typeof(DateTime))
|
||||||
|
return reader.GetDateTime(index).ToString();
|
||||||
|
if (fieldType == typeof(int))
|
||||||
|
return reader.GetInt32(index).ToString();
|
||||||
|
if (fieldType == typeof(double))
|
||||||
|
return ((int)reader.GetDouble(index)).ToString();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user