Erweiterung ENI2: CREWD/PASD separater Reiter

This commit is contained in:
Daniel Schick 2022-01-23 14:44:20 +01:00
parent 20f1abe7c1
commit e087419d64
4 changed files with 627 additions and 12 deletions

View File

@ -49,7 +49,7 @@
</ScrollViewer>
</GroupBox>
</TabItem>
<TabItem Header="{x:Static p:Resources.textTabCrewList}" Name="tabCrewList">
<TabItem Header="{x:Static p:Resources.textCrewArrival}" Name="tabCrewArrival">
<GroupBox Name="groupBoxCrewList" Header="{x:Static p:Resources.textTabCrewList}">
<Grid>
<Grid.RowDefinitions>
@ -60,6 +60,11 @@
<Button Name="buttonImportExcelCrew" Content="{x:Static p:Resources.textImportFromExcel}" Margin="2" Width="120" HorizontalAlignment="Left" VerticalAlignment="Center" Background="Transparent" Click="buttonImportExcelCrew_Click" />
<TextBlock Margin="20, 0, 0, 0" Name="textBlockNumCrewEntries" FontWeight="Bold" Text="{Binding Elements.Count}" VerticalAlignment="Center"/>
<Label Name="labelCrewEntryCount" Content="{x:Static p:Resources.textEntries}" />
<CheckBox Name="checkBoxCrewNotificationSchengen" IsThreeState="True" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxCrewNotificationSchengen_Click"/>
<Label Name="labelCrewNotificationSchengen" Content="{x:Static p:Resources.textNotificationSchengen}" />
<CheckBox Name="checkBoxCrewNotificationPAX" IsThreeState="True" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxCrewNotificationPAX_Click"/>
<Label Name="labelCrewNotificationPAX" Content="{x:Static p:Resources.textNotificationPAX}" />
<TextBlock Margin="30,0,0,0" FontWeight="Bold" FontSize="16" Text="CREWA" VerticalAlignment="Center" />
</StackPanel>
<enictrl:ENIDataGrid Grid.Row="1" Grid.Column="0" x:Name="dataGridCrewList" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
AutoGenerateColumns="False" Margin="0,5,0,0">
@ -82,7 +87,45 @@
</Grid>
</GroupBox>
</TabItem>
<TabItem Header="{x:Static p:Resources.textTabPassengerList}" Name="tabPassengerList">
<TabItem Header="{x:Static p:Resources.textCrewDeparture}" Name="tabCrewDeparture">
<GroupBox Name="groupBoxCrewListDeparture" Header="{x:Static p:Resources.textTabCrewList}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal">
<Button Name="buttonImportExcelCrewDeparture" Content="{x:Static p:Resources.textImportFromExcel}" Margin="2" Width="120" HorizontalAlignment="Left" VerticalAlignment="Center" Background="Transparent" Click="buttonImportExcelCrewDeparture_Click" />
<TextBlock Margin="20, 0, 0, 0" Name="textBlockNumCrewEntriesDeparture" FontWeight="Bold" Text="{Binding Elements.Count}" VerticalAlignment="Center"/>
<Label Name="labelCrewEntryCountDeparture" Content="{x:Static p:Resources.textEntries}" />
<CheckBox Name="checkBoxCrewNotificationSchengenDeparture" IsThreeState="True" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxCrewNotificationSchengenDeparture_Click"/>
<Label Name="labelCrewNotificationSchengenDeparture" Content="{x:Static p:Resources.textNotificationSchengen}" />
<CheckBox Name="checkBoxCrewNotificationPAXDeparture" IsThreeState="True" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxCrewNotificationPAXDeparture_Click"/>
<Label Name="labelCrewNotificationPAXDeparture" Content="{x:Static p:Resources.textNotificationPAX}" />
<TextBlock Margin="30,0,0,0" FontWeight="Bold" FontSize="16" Text="CREWD" VerticalAlignment="Center" />
</StackPanel>
<enictrl:ENIDataGrid Grid.Row="1" Grid.Column="0" x:Name="dataGridCrewListDeparture" 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 CrewMemberLastName, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textFirstName}" Binding="{Binding CrewMemberFirstName, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textGender}" Binding="{Binding CrewMemberGenderDisplay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textNationality}" Binding="{Binding CrewMemberNationality, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCrewFunctionOnBoard}" Binding="{Binding CrewMemberDuty, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textPlaceOfBirth}" Binding="{Binding CrewMemberPlaceOfBirth, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDateOfBirth}" Binding="{Binding CrewMemberDateOfBirth, Mode=TwoWay, StringFormat=\{0:dd.MM.yyyy\}}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textIdDocType}" Binding="{Binding CrewMemberIdentityDocumentTypeDisplay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textIdDocNumber}" Binding="{Binding CrewMemberIdentityDocumentId, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textVisaNumber}" Binding="{Binding CrewMemberVisaNumber, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDocumentIssuingState}" Binding="{Binding CrewMemberIdentityDocumentIssuingState, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDocumentExpiryDate}" Binding="{Binding CrewMemberIdentityDocumentExpiryDate, Mode=TwoWay, StringFormat=\{0:dd.MM.yyyy\}}" IsReadOnly="True" Width="0.1*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>
</GroupBox>
</TabItem>
<TabItem Header="{x:Static p:Resources.textPasArrival}" Name="tabPassengerList">
<GroupBox Name="groupBoxPassengerList" Header="{x:Static p:Resources.textTabPassengerList}">
<Grid>
<Grid.RowDefinitions>
@ -93,6 +136,11 @@
<Button Name="buttonImportExcelPassenger" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textImportFromExcel}" Margin="2" Width="120" HorizontalAlignment="Left" VerticalAlignment="Center" Background="Transparent" Click="buttonImportExcelPassenger_Click" />
<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}" />
<CheckBox Name="checkBoxPasNotificationSchengen" IsThreeState="True" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxPasNotificationSchengen_Click"/>
<Label Name="labelPasNotificationSchengen" Content="{x:Static p:Resources.textNotificationSchengen}" />
<CheckBox Name="checkBoxPasNotificationPAX" IsThreeState="True" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxPasNotificationPAX_Click"/>
<Label Name="labelPasNotificationPAX" Content="{x:Static p:Resources.textNotificationPAX}" />
<TextBlock Margin="30,0,0,0" FontWeight="Bold" FontSize="16" Text="PASA" VerticalAlignment="Center" />
</StackPanel>
<enictrl:ENIDataGrid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" x:Name="dataGridPassengerList" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
AutoGenerateColumns="False" Margin="0,5,0,0">
@ -117,6 +165,46 @@
</Grid>
</GroupBox>
</TabItem>
<TabItem Header="{x:Static p:Resources.textPasDeparture}" Name="tabPassengerListDeparture">
<GroupBox Name="groupBoxPassengerListDeparture" Header="{x:Static p:Resources.textTabPassengerList}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal">
<Button Name="buttonImportExcelPassengerDeparture" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textImportFromExcel}" Margin="2" Width="120" HorizontalAlignment="Left" VerticalAlignment="Center" Background="Transparent" Click="buttonImportExcelPassengerDeparture_Click" />
<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}" />
<CheckBox Name="checkBoxPasNotificationSchengenDeparture" IsThreeState="True" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxPasNotificationSchengenDeparture_Click"/>
<Label Name="labelPasNotificationSchengenDeparture" Content="{x:Static p:Resources.textNotificationSchengen}" />
<CheckBox Name="checkBoxPasNotificationPAXDeparture" IsThreeState="True" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxPasNotificationPAXDeparture_Click"/>
<Label Name="labelPasNotificationPAXDeparture" Content="{x:Static p:Resources.textNotificationPAX}" />
<TextBlock Margin="30,0,0,0" FontWeight="Bold" FontSize="16" Text="PASD" VerticalAlignment="Center" />
</StackPanel>
<enictrl:ENIDataGrid Grid.Row="1" 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.textNationality}" Binding="{Binding PassengerNationality}" 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.textPlaceOfBirth}" Binding="{Binding PassengerPlaceOfBirth}" 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.textVisaNumber}" Binding="{Binding PassengerVisaNumber}" 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*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>
</GroupBox>
</TabItem>
</TabControl>
</src:DetailBaseControl>

View File

@ -23,9 +23,9 @@ namespace ENI2.DetailViewControls
{
private Message _bpolMessage;
private Message _crewMessage;
//private Message _crewdMessage;
private Message _crewdMessage;
private Message _pasMessage;
//private Message _pasdMessage;
private Message _pasdMessage;
private Message _secMessage;
private BPOL _bpol;
private SEC _sec;
@ -43,8 +43,6 @@ namespace ENI2.DetailViewControls
this.RegisterCheckboxChange(this.checkBoxStowaways, Message.NotificationClass.BPOL);
}
public override void Initialize()
{
base.Initialize();
@ -54,8 +52,8 @@ namespace ENI2.DetailViewControls
if (aMessage.MessageNotificationClass == Message.NotificationClass.BPOL) { this._bpolMessage = aMessage; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.CREW) { this._crewMessage = aMessage; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.PAS) { 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.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)
{
@ -97,7 +95,7 @@ namespace ENI2.DetailViewControls
#endregion
#region init CREW
#region init CREWA
if (this._crewMessage == null)
{
@ -117,7 +115,27 @@ namespace ENI2.DetailViewControls
#endregion
#region init PAS
#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;
#endregion
#region init PASA
if (this._pasMessage == null)
{
@ -137,6 +155,25 @@ namespace ENI2.DetailViewControls
#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;
#endregion
}
#region SetEnabled
@ -276,7 +313,7 @@ namespace ENI2.DetailViewControls
#endregion
#region passenger grid
#region passenger grid arrival
private void DataGridPassengerList_CreateRequested()
{
@ -365,7 +402,96 @@ namespace ENI2.DetailViewControls
#endregion
#region crew grid
#region passenger grid departure
private void DataGridPassengerListDeparture_CreateRequested()
{
EditPASDialog epd = new EditPASDialog
{
PAS = new PASD()
};
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.dataGridPassengerList.Items.Refresh();
epd.PAS = new PASD
{
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.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.dataGridPassengerList.Items.Refresh();
epd.PAS = new PASD
{
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);
epd.PAS.IsDirty = true;
this.dataGridPassengerListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.PASD);
}
}
private void DataGridPassengerListDeparture_AddingNewItem(object sender, AddingNewItemEventArgs e)
{
this.DataGridPassengerListDeparture_CreateRequested();
}
#endregion
#region crew grid arrival
private void DataGridCrewList_CreateRequested()
{
@ -454,6 +580,95 @@ namespace ENI2.DetailViewControls
#endregion
#region crew grid departure
private void DataGridCrewListDeparture_CreateRequested()
{
EditCREWDialog ecd = new EditCREWDialog
{
CREW = new CREW()
};
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.dataGridCrewListDeparture.Items.Refresh();
ecd.CREW = new CREWD
{
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.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
_crewMessage.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.dataGridCrewListDeparture.Items.Refresh();
ecd.CREW = new CREWD
{
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);
ecd.CREW.IsDirty = true;
this.dataGridCrewListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.CREWD);
}
}
private void DataGridCrewListDeparture_AddingNewItem(object sender, AddingNewItemEventArgs e)
{
this.DataGridCrewListDeparture_CreateRequested();
}
#endregion
#region Excel import
private string getValueAsString(IExcelDataReader reader, int index)
@ -543,6 +758,83 @@ namespace ENI2.DetailViewControls
}
}
private void buttonImportExcelCrewDeparture_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<CREWD> importCrew = new List<CREWD>();
try
{
do
{
while (reader.Read())
{
if (((IExcelDataReader)reader).FieldCount < 10)
{
throw new InvalidDataException("Sheet must have at least 10 Columns of data");
}
CREWD crew = new CREWD();
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
if (!reader.IsDBNull(0)) crew.CrewMemberLastName = reader.GetString(0);
if (!reader.IsDBNull(1)) crew.CrewMemberFirstName = reader.GetString(1);
if (!reader.IsDBNull(2)) crew.CrewMemberGender = GlobalStructures.ParseGender(reader.GetString(2));
if (!reader.IsDBNull(3)) crew.CrewMemberNationality = reader.GetString(3).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(4)) crew.CrewMemberDuty = reader.GetString(4);
if (!reader.IsDBNull(5)) crew.CrewMemberPlaceOfBirth = reader.GetString(5);
if (!reader.IsDBNull(6)) crew.CrewMemberDateOfBirth = reader.GetDateTime(6);
if (!reader.IsDBNull(7)) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(7));
if (!reader.IsDBNull(8)) crew.CrewMemberIdentityDocumentId = this.getValueAsString(reader, 8);
if (!reader.IsDBNull(9)) crew.CrewMemberVisaNumber = this.getValueAsString(reader, 9);
if (((IExcelDataReader)reader).FieldCount > 11)
{
if (!reader.IsDBNull(10)) crew.CrewMemberIdentityDocumentIssuingState = reader.GetString(10).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(11)) crew.CrewMemberIdentityDocumentExpiryDate = reader.GetDateTime(11);
}
crew.MessageHeader = this._crewMessage;
crew.IsDirty = true;
crew.Identifier = CREWD.GetNewIdentifier(this._crewdMessage.Elements);
this._crewdMessage.Elements.Add(crew);
importCrew.Add(crew);
}
} while (reader.NextResult());
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
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);
}
}
stream.Close();
}
}
private void buttonImportExcelPassenger_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog
@ -629,6 +921,92 @@ namespace ENI2.DetailViewControls
}
}
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 < 11)
{
throw new InvalidDataException("Sheet must have at least 11 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 (!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.PassengerNationality = reader.GetString(3).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(4)) pas.PassengerPortOfEmbarkation = reader.GetString(4);
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfEmbarkation) == null)
pas.PassengerPortOfEmbarkation = null;
if (!reader.IsDBNull(5)) pas.PassengerPortOfDisembarkation = reader.GetString(5);
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfDisembarkation) == null)
pas.PassengerPortOfDisembarkation = null;
if (!reader.IsDBNull(6)) pas.PassengerInTransit = GlobalStructures.ReadBoolean(reader.GetString(6));
if (!reader.IsDBNull(7)) pas.PassengerPlaceOfBirth = reader.GetString(7);
if (!reader.IsDBNull(8)) pas.PassengerDateOfBirth = reader.GetDateTime(8);
if (!reader.IsDBNull(9)) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(9));
if (!reader.IsDBNull(10)) pas.PassengerIdentityDocumentId = this.getValueAsString(reader, 10);
if (!reader.IsDBNull(11)) pas.PassengerVisaNumber = this.getValueAsString(reader, 11);
if (((IExcelDataReader)reader).FieldCount > 12)
{
if (!reader.IsDBNull(12)) pas.PassengerIdentityDocumentIssuingState = reader.GetString(12).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(13)) pas.PassengerIdentityDocumentExpiryDate = reader.GetDateTime(13);
}
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();
}
}
#endregion
#region Highlighting
@ -666,5 +1044,82 @@ namespace ENI2.DetailViewControls
#endregion
#region Schengen/PAX checkboxes changed event handler
private void checkBoxCrewNotificationSchengen_Click(object sender, RoutedEventArgs e)
{
foreach(CREW crew in _crewMessage.Elements)
{
crew.NotificationSchengen = checkBoxCrewNotificationSchengen.IsChecked;
}
this.SublistElementChanged(Message.NotificationClass.CREW);
}
private void checkBoxCrewNotificationPAX_Click(object sender, RoutedEventArgs e)
{
foreach (CREW crew in _crewMessage.Elements)
{
crew.NotificationPAX = checkBoxCrewNotificationPAX.IsChecked;
}
this.SublistElementChanged(Message.NotificationClass.CREW);
}
private void checkBoxCrewNotificationSchengenDeparture_Click(object sender, RoutedEventArgs e)
{
foreach(CREWD crewd in _crewdMessage.Elements)
{
crewd.NotificationSchengen = checkBoxCrewNotificationSchengenDeparture.IsChecked;
}
this.SublistElementChanged(Message.NotificationClass.CREWD);
}
private void checkBoxCrewNotificationPAXDeparture_Click(object sender, RoutedEventArgs e)
{
foreach (CREWD crewd in _crewdMessage.Elements)
{
crewd.NotificationPAX = checkBoxCrewNotificationPAXDeparture.IsChecked;
}
this.SublistElementChanged(Message.NotificationClass.CREWD);
}
private void checkBoxPasNotificationSchengen_Click(object sender, RoutedEventArgs e)
{
foreach(PAS pas in _pasMessage.Elements)
{
pas.NotificationSchengen = checkBoxPasNotificationSchengen.IsChecked;
}
this.SublistElementChanged(Message.NotificationClass.PAS);
}
private void checkBoxPasNotificationPAX_Click(object sender, RoutedEventArgs e)
{
foreach(PAS pas in _pasMessage.Elements)
{
pas.NotificationPAX = checkBoxPasNotificationPAX.IsChecked;
}
this.SublistElementChanged(Message.NotificationClass.PAS);
}
private void checkBoxPasNotificationSchengenDeparture_Click(object sender, RoutedEventArgs e)
{
foreach(PASD pasd in _pasdMessage.Elements)
{
pasd.NotificationSchengen = checkBoxPasNotificationSchengenDeparture.IsChecked;
}
this.SublistElementChanged(Message.NotificationClass.PASD);
}
private void checkBoxPasNotificationPAXDeparture_Click(object sender, RoutedEventArgs e)
{
foreach(PASD pasd in _pasdMessage.Elements)
{
pasd.NotificationPAX = checkBoxPasNotificationPAXDeparture.IsChecked;
}
this.SublistElementChanged(Message.NotificationClass.PASD);
}
#endregion
}
}

View File

@ -1615,6 +1615,24 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Crew arrival.
/// </summary>
public static string textCrewArrival {
get {
return ResourceManager.GetString("textCrewArrival", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Crew departure.
/// </summary>
public static string textCrewDeparture {
get {
return ResourceManager.GetString("textCrewDeparture", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Function on board.
/// </summary>
@ -3262,6 +3280,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Notification for PAX directive.
/// </summary>
public static string textNotificationPAX {
get {
return ResourceManager.GetString("textNotificationPAX", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Notifications.
/// </summary>
@ -3271,6 +3298,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Notification for Schengen regulation.
/// </summary>
public static string textNotificationSchengen {
get {
return ResourceManager.GetString("textNotificationSchengen", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Number of deaths.
/// </summary>
@ -3388,6 +3424,24 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Passenger arrival.
/// </summary>
public static string textPasArrival {
get {
return ResourceManager.GetString("textPasArrival", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Passenger departure.
/// </summary>
public static string textPasDeparture {
get {
return ResourceManager.GetString("textPasDeparture", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Passenger.
/// </summary>

View File

@ -1792,4 +1792,22 @@
<data name="textWasteReceived" xml:space="preserve">
<value>Waste received</value>
</data>
<data name="textCrewArrival" xml:space="preserve">
<value>Crew arrival</value>
</data>
<data name="textCrewDeparture" xml:space="preserve">
<value>Crew departure</value>
</data>
<data name="textNotificationPAX" xml:space="preserve">
<value>Notification for PAX directive</value>
</data>
<data name="textNotificationSchengen" xml:space="preserve">
<value>Notification for Schengen regulation</value>
</data>
<data name="textPasArrival" xml:space="preserve">
<value>Passenger arrival</value>
</data>
<data name="textPasDeparture" xml:space="preserve">
<value>Passenger departure</value>
</data>
</root>