Added sheet / logic part 7 CREW departure

This commit is contained in:
Daniel Schick 2025-01-29 15:07:54 +01:00
parent 579e704a1b
commit c4006d0585
8 changed files with 1260 additions and 711 deletions

View File

@ -182,6 +182,7 @@ namespace ENI2
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text4PreDeparture, MessageGroupControlType = typeof(PreDepartureControl), ImagePath = "Resources/arrow_up_right_green.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.text7CrewDeparture, MessageGroupControlType = typeof(CrewDepartureControl), ImagePath = "Resources/departure_worker.png" });
}
this.listBoxMessages.ItemsSource = this._listBoxList;

View File

@ -1173,7 +1173,7 @@ namespace ENI2.DetailViewControls
if (!reader.IsDBNull(11)) crew.CrewMemberIdentityDocumentExpiryDate = reader.GetDateTime(11);
if (!reader.IsDBNull(12)) crew.CrewMemberVisaNumber = this.getValueAsString(reader, 12);
crew.MessageHeader = this._crewMessage;
crew.MessageHeader = this._crewdMessage;
crew.IsDirty = true;
crew.Identifier = CREWD.GetNewIdentifier(this._crewdMessage.Elements);
this._crewdMessage.Elements.Add(crew);

View File

@ -493,6 +493,9 @@
<DesignTime>True</DesignTime>
<DependentUpon>Reference.svcmap</DependentUpon>
</Compile>
<Compile Include="SheetDisplayControls\CrewDepartureControl.xaml.cs">
<DependentUpon>CrewDepartureControl.xaml</DependentUpon>
</Compile>
<Compile Include="SheetDisplayControls\CrewPreArrivalControl.xaml.cs">
<DependentUpon>CrewPreArrivalControl.xaml</DependentUpon>
</Compile>
@ -820,6 +823,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="SheetDisplayControls\CrewDepartureControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SheetDisplayControls\CrewPreArrivalControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -830,6 +830,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to 10. Dangerous cargo data on arrival.
/// </summary>
public static string text10DangerousCargoArrival {
get {
return ResourceManager.GetString("text10DangerousCargoArrival", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 1.10 Maritime health data.
/// </summary>
@ -848,6 +857,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to 11. Dangerous cargo data on departure.
/// </summary>
public static string text11DangerousCargoDeparture {
get {
return ResourceManager.GetString("text11DangerousCargoDeparture", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 1.1 Previous port.
/// </summary>
@ -857,6 +875,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to 12. Actual time of arrival / departure.
/// </summary>
public static string text12ATAATD {
get {
return ResourceManager.GetString("text12ATAATD", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 1.2 Incoming voyage.
/// </summary>
@ -875,6 +902,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to 13. Waste receipts.
/// </summary>
public static string text13WasteReceipts {
get {
return ResourceManager.GetString("text13WasteReceipts", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 1.4 Outgoing voyage.
/// </summary>
@ -1190,6 +1226,33 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to 7. Crew data on departure.
/// </summary>
public static string text7CrewDeparture {
get {
return ResourceManager.GetString("text7CrewDeparture", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 8. Passenger data on arrival.
/// </summary>
public static string text8PassengerArrival {
get {
return ResourceManager.GetString("text8PassengerArrival", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 9. Passenger data on departure.
/// </summary>
public static string text9PassengerDeparture {
get {
return ResourceManager.GetString("text9PassengerDeparture", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to About ENI-2.
/// </summary>
@ -6032,9 +6095,9 @@ namespace ENI2.Properties {
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap arrival_user {
public static System.Drawing.Bitmap user_edit1 {
get {
object obj = ResourceManager.GetObject("arrival_user", resourceCulture);
object obj = ResourceManager.GetObject("user_edit1", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
@ -6042,9 +6105,9 @@ namespace ENI2.Properties {
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap arrival_worker {
public static System.Drawing.Bitmap user_edit2 {
get {
object obj = ResourceManager.GetObject("arrival_worker", resourceCulture);
object obj = ResourceManager.GetObject("user_edit2", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
@ -6052,9 +6115,9 @@ namespace ENI2.Properties {
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap departure_user {
public static System.Drawing.Bitmap user_edit3 {
get {
object obj = ResourceManager.GetObject("departure_user", resourceCulture);
object obj = ResourceManager.GetObject("user_edit3", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
@ -6062,9 +6125,9 @@ namespace ENI2.Properties {
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap departure_worker {
public static System.Drawing.Bitmap user_edit4 {
get {
object obj = ResourceManager.GetObject("departure_worker", resourceCulture);
object obj = ResourceManager.GetObject("user_edit4", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

View File

@ -586,17 +586,17 @@
<data name="user_edit" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\user_edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arrival_user" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrival_user.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="user_edit4" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\user_edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arrival_worker" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrival_worker.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="user_edit3" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\user_edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="departure_user" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\departure_user.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="user_edit2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\user_edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="departure_worker" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\departure_worker.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="user_edit1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\user_edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="textSave" xml:space="preserve">
<value>Save</value>
@ -2092,4 +2092,25 @@
<data name="text6CrewDataOnArrival" xml:space="preserve">
<value>6. Crew data on arrival</value>
</data>
<data name="text7CrewDeparture" xml:space="preserve">
<value>7. Crew data on departure</value>
</data>
<data name="text8PassengerArrival" xml:space="preserve">
<value>8. Passenger data on arrival</value>
</data>
<data name="text9PassengerDeparture" xml:space="preserve">
<value>9. Passenger data on departure</value>
</data>
<data name="text10DangerousCargoArrival" xml:space="preserve">
<value>10. Dangerous cargo data on arrival</value>
</data>
<data name="text11DangerousCargoDeparture" xml:space="preserve">
<value>11. Dangerous cargo data on departure</value>
</data>
<data name="text12ATAATD" xml:space="preserve">
<value>12. Actual time of arrival / departure</value>
</data>
<data name="text13WasteReceipts" xml:space="preserve">
<value>13. Waste receipts</value>
</data>
</root>

View File

@ -0,0 +1,64 @@
<src:DetailBaseControl xmlns:src="clr-namespace:ENI2"
x:Class="ENI2.SheetDisplayControls.CrewDepartureControl"
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.text7CrewDeparture}">
<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 Name="labelCrewNotificationSchengenDeparture" Content="{x:Static p:Resources.textNotificationSchengen}" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Right"/>
<CheckBox Name="checkBoxCrewNotificationSchengenDeparture" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxCrewNotificationSchengenDeparture_Click" Grid.Row="0" Grid.Column="1"/>
<Label Name="labelCrewNotificationPAXDeparture" Content="{x:Static p:Resources.textNotificationPAX}" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right"/>
<CheckBox Name="checkBoxCrewNotificationPAXDeparture" IsThreeState="False" VerticalAlignment="Center" Margin="10,0,0,0" Click="checkBoxCrewNotificationPAXDeparture_Click" Grid.Row="1" Grid.Column="1" />
<Button Grid.Row="3" Grid.Column="0" Name="buttonImportExcelCrewDeparture" Content="{x:Static p:Resources.textImportFromExcel}" Margin="2" Width="120" HorizontalAlignment="Right" VerticalAlignment="Center" Background="Transparent" Click="buttonImportExcelCrewDeparture_Click" />
<StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal">
<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}" />
<Button Name="buttonDeleteAllCrewD" Margin="2" Content="{x:Static p:Resources.textDeleteAllEntries}" Background="Transparent" Click="buttonDeleteAllCrewD_Click"/>
</StackPanel>
<enictrl:ENIDataGrid Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" 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.textCrewFunctionOnBoard}" Binding="{Binding CrewMemberDuty, Mode=TwoWay}" 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.textPlaceOfBirth}" Binding="{Binding CrewMemberPlaceOfBirth, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCountryOfBirth}" Binding="{Binding CrewMemberCountryOfBirth, 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.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*" />
<DataGridTextColumn Header="{x:Static p:Resources.textVisaNumber}" Binding="{Binding CrewMemberVisaNumber, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>
</ScrollViewer>
</GroupBox>
</src:DetailBaseControl>

View File

@ -0,0 +1,393 @@
// Copyright (c) 2025 - schick Informatik
// Description: Display control of formsheet Tab 7. Crew data departure
//
using bsmd.database;
using ENI2.EditControls;
using ENI2.Util;
using ExcelDataReader;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
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.Navigation;
using System.Windows.Shapes;
namespace ENI2.SheetDisplayControls
{
/// <summary>
/// Interaction logic for CrewDepartureControl.xaml
/// </summary>
public partial class CrewDepartureControl : DetailBaseControl
{
#region Fields
private Message _crewaMessage;
private Message _crewdMessage;
#endregion
#region Construction
public CrewDepartureControl()
{
InitializeComponent();
}
#endregion
#region public overrides
public override void Initialize()
{
base.Initialize();
foreach (Message aMessage in this.Messages)
{
if (aMessage.MessageNotificationClass == Message.NotificationClass.CREWA) { this._crewaMessage = aMessage; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.CREWD) { this._crewdMessage = aMessage; this.ControlMessages.Add(aMessage); }
}
#region init CREWD
if (this._crewdMessage == null)
{
this._crewdMessage = this.Core.CreateMessage(Message.NotificationClass.CREWD);
this.Messages.Add(this._crewdMessage);
}
this.dataGridCrewListDeparture.Initialize();
this.dataGridCrewListDeparture.ItemsSource = this._crewdMessage.Elements;
this.dataGridCrewListDeparture.AddingNewItem += DataGridCrewListDeparture_AddingNewItem;
this.dataGridCrewListDeparture.EditRequested += DataGridCrewListDeparture_EditRequested;
this.dataGridCrewListDeparture.DeleteRequested += DataGridCrewListDeparture_DeleteRequested;
this.dataGridCrewListDeparture.CreateRequested += DataGridCrewListDeparture_CreateRequested;
this.dataGridCrewListDeparture.RefreshGrid += DataGridCrewListDeparture_RefreshGrid;
this.dataGridCrewListDeparture.MultiEditRequested += DataGridCrewListDeparture_MultiEditRequested;
if (this._crewdMessage.Elements.Count > 0)
{
this.checkBoxCrewNotificationSchengenDeparture.IsChecked = ((CREWD)this._crewdMessage.Elements[0]).NotificationSchengen;
this.checkBoxCrewNotificationPAXDeparture.IsChecked = ((CREWD)this._crewdMessage.Elements[0]).NotificationPAX;
}
// extra menu copy to CREWA
{
this.dataGridCrewListDeparture.ContextMenu.Items.Add(new Separator());
MenuItem copyCREWDItem = new MenuItem();
copyCREWDItem.Header = Properties.Resources.textCopyToCREWA;
copyCREWDItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) };
copyCREWDItem.Click += CopyCREWDItem_Click; ;
this.dataGridCrewListDeparture.ContextMenu.Items.Add(copyCREWDItem);
}
#endregion
}
#endregion
#region event handler
private void checkBoxCrewNotificationSchengenDeparture_Click(object sender, RoutedEventArgs e)
{
foreach (CREWD crewd in _crewdMessage.Elements.Cast<CREWD>())
{
crewd.NotificationSchengen = checkBoxCrewNotificationSchengenDeparture.IsChecked;
}
this.SublistElementChanged(Message.NotificationClass.CREWD);
}
private void checkBoxCrewNotificationPAXDeparture_Click(object sender, RoutedEventArgs e)
{
foreach (CREWD crewd in _crewdMessage.Elements.Cast<CREWD>())
{
crewd.NotificationSchengen = checkBoxCrewNotificationSchengenDeparture.IsChecked;
}
this.SublistElementChanged(Message.NotificationClass.CREWD);
}
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 (IExcelDataReader reader = ExcelReaderFactory.CreateReader(stream))
{
List<CREWD> importCrew = new List<CREWD>();
try
{
do
{
while (reader.Read())
{
if (reader.FieldCount < 13)
{
throw new InvalidDataException("Sheet must have 13 columns of data");
}
CREWD crew = new CREWD();
crew.IsDeparture = true;
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
if (!reader.IsDBNull(0)) crew.CrewMemberLastName = reader.GetString(0);
if (crew.CrewMemberLastName.Equals("Family Name") || (crew.CrewMemberLastName.Trim().Length == 0)) continue;
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.CrewMemberDuty = reader.GetString(3).Clean();
if (!reader.IsDBNull(4)) crew.CrewMemberNationality = reader.GetString(4).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(5)) crew.CrewMemberPlaceOfBirth = reader.GetString(5);
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(8)) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(8));
if (!reader.IsDBNull(9)) crew.CrewMemberIdentityDocumentId = this.getValueAsString(reader, 9);
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(12)) crew.CrewMemberVisaNumber = this.getValueAsString(reader, 12);
crew.MessageHeader = this._crewdMessage;
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 async void buttonDeleteAllCrewD_Click(object sender, RoutedEventArgs e)
{
if (MessageBox.Show(Properties.Resources.textConfimDeleteAllEntries, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
{
foreach (CREWD crewd in this._crewdMessage.Elements.Cast<CREWD>())
{
await DBManagerAsync.DeleteAsync(crewd);
}
this._crewdMessage.Elements.Clear();
this.dataGridCrewListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.CREWD);
}
}
private void CopyCREWDItem_Click(object sender, RoutedEventArgs e)
{
if (this.dataGridCrewListDeparture.SelectedItems != null)
{
foreach (CREWD crewd in this.dataGridCrewListDeparture.SelectedItems)
{
CREW crewa = new CREW();
crewa.MessageHeader = this._crewaMessage;
crewa.CopyFromCREW(crewd);
crewa.IsDeparture = false;
crewa.Identifier = DatabaseEntity.GetNewIdentifier(this._crewaMessage.Elements);
this._crewaMessage.Elements.Add(crewa);
this.SublistElementChanged(Message.NotificationClass.CREWA);
}
}
}
#endregion
#region crew grid departure
private void DataGridCrewListDeparture_CreateRequested()
{
EditCREWDialog ecd = new EditCREWDialog
{
CREW = new CREWD()
};
ecd.CREW.IsDeparture = true;
ecd.CREW.Identifier = CREWD.GetNewIdentifier(_crewdMessage.Elements);
ecd.CREW.MessageHeader = this._crewdMessage;
ecd.AddClicked += () =>
{
ecd.CopyValuesToEntity();
if (!this._crewdMessage.Elements.Contains(ecd.CREW))
{
this._crewdMessage.Elements.Add(ecd.CREW);
this.CheckCREWD();
}
this.dataGridCrewListDeparture.Items.Refresh();
ecd.CREW = new CREWD
{
IsDeparture = true,
MessageHeader = this._crewdMessage,
Identifier = CREWD.GetNewIdentifier(_crewdMessage.Elements)
};
this.SublistElementChanged(Message.NotificationClass.CREWD);
};
if (ecd.ShowDialog() ?? false)
{
if (!this._crewdMessage.Elements.Contains(ecd.CREW))
{
_crewdMessage.Elements.Add(ecd.CREW);
this.CheckCREWD();
}
this.dataGridCrewListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.CREWD);
}
}
private void DataGridCrewListDeparture_DeleteRequested(DatabaseEntity obj)
{
if (obj is CREWD crewd)
{
// are you sure dialog is in base class
_crewdMessage.Elements.Remove(crewd);
DBManager.Instance.Delete(crewd);
}
}
private void DataGridCrewListDeparture_RefreshGrid()
{
DatabaseEntity.ResetIdentifiers(_crewdMessage.Elements);
this.SublistElementChanged(Message.NotificationClass.CREWD);
this.dataGridCrewListDeparture.Items.Refresh();
}
private void DataGridCrewListDeparture_EditRequested(DatabaseEntity obj)
{
EditCREWDialog ecd = new EditCREWDialog
{
CREW = obj as CREWD
};
ecd.AddClicked += () =>
{
ecd.CopyValuesToEntity();
if (!_crewdMessage.Elements.Contains(ecd.CREW))
{
_crewdMessage.Elements.Add(ecd.CREW);
this.CheckCREWD();
}
this.dataGridCrewListDeparture.Items.Refresh();
ecd.CREW = new CREWD
{
IsDeparture = true,
Identifier = CREWD.GetNewIdentifier(_crewdMessage.Elements),
MessageHeader = _crewdMessage
};
this.SublistElementChanged(Message.NotificationClass.CREWD);
};
if (ecd.ShowDialog() ?? false)
{
if (!_crewdMessage.Elements.Contains(ecd.CREW))
{
_crewdMessage.Elements.Add(ecd.CREW);
this.CheckCREWD();
}
ecd.CREW.IsDirty = true;
this.dataGridCrewListDeparture.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.CREWD);
}
}
private void DataGridCrewListDeparture_AddingNewItem(object sender, AddingNewItemEventArgs e)
{
this.DataGridCrewListDeparture_CreateRequested();
}
private void DataGridCrewListDeparture_MultiEditRequested(List<DatabaseEntity> databaseEntities)
{
List<CREW> crewList = new List<CREW>();
foreach (CREW acrew in databaseEntities.Cast<CREW>())
crewList.Add(acrew);
// write common values of all CREW entities to template entity
CREW crew = CREW.CreateCommon(crewList);
EditCREWDialog dialog = new EditCREWDialog();
dialog.CREW = crew;
dialog.AddVisible = false;
if (dialog.ShowDialog() ?? false)
{
// write back changed values from crew to all entities and mark them as changed
CREW.WriteTemplateToList(crew, crewList);
this.SublistElementChanged(Message.NotificationClass.CREWD);
this.dataGridCrewListDeparture.Items.Refresh();
}
}
#endregion
#region private methods
private void CheckCREWD()
{
if (this._crewdMessage.Elements.Count == 0) return;
CREWD firstCREW = this._crewdMessage.Elements[0] as CREWD;
if (this._crewdMessage.Elements.Count == 1)
{
firstCREW.NotificationSchengen = true;
this.checkBoxCrewNotificationSchengenDeparture.IsChecked = true;
}
else
{
for (int i = 1; i < this._crewdMessage.Elements.Count; i++)
{
((CREWD)this._crewdMessage.Elements[i]).NotificationSchengen = firstCREW.NotificationSchengen;
}
}
}
private 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
}
}

View File

@ -19,12 +19,12 @@
<ColumnDefinition Width=".65*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="36" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="8" />
<RowDefinition Height="28" />
<RowDefinition Height="480" />
<RowDefinition Height="640" />
</Grid.RowDefinitions>
<Label HorizontalContentAlignment="Right" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textNameMaster}" Name="label_nameMaster" Margin="0,0,10,0"/>