Changing CREW/PAS import logic, WIP (compiles)

This commit is contained in:
Daniel Schick 2022-09-05 15:20:23 +02:00
parent 61d2ca7552
commit 76be225712
10 changed files with 131 additions and 16 deletions

View File

@ -237,6 +237,9 @@
<Compile Include="EditControls\EditWasteReceivedDialog.xaml.cs">
<DependentUpon>EditWasteReceivedDialog.xaml</DependentUpon>
</Compile>
<Compile Include="EditControls\FixImportDialog.xaml.cs">
<DependentUpon>FixImportDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Excel\DakosyUtil.cs" />
<Compile Include="Excel\ExcelBase.cs" />
<Compile Include="Excel\ExcelComparer.cs" />
@ -644,6 +647,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="EditControls\FixImportDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="EditControls\MessageHistoryDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -43,7 +43,7 @@
<TextBox Grid.Row="0" Grid.Column="1" Width="auto" Name="textBoxDuty" Margin="2" MaxLength="100" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="1" Grid.Column="1" Width="auto" Name="textBoxLastName" Margin="2" MaxLength="100" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="1" Grid.Column="3" Width="auto" Name="textBoxFirstName" Margin="2" MaxLength="100" VerticalContentAlignment="Center"/>
<ComboBox Grid.Row="2" Grid.Column="1" Name="comboBoxGender" Margin="2" IsEditable="True" StaysOpenOnEdit="True" IsTextSearchEnabled="True" ContextMenu="{DynamicResource ClearContextMenu}"/>
<ComboBox Grid.Row="2" Grid.Column="1" Name="comboBoxGender" Margin="2" IsEditable="True" StaysOpenOnEdit="True" IsTextSearchEnabled="True" SelectedValuePath="Key" DisplayMemberPath="Value" ContextMenu="{DynamicResource ClearContextMenu}"/>
<TextBox Grid.Row="2" Grid.Column="3" Width="auto" Name="textBoxPlaceOfBirth" Margin="2" MaxLength="100" VerticalContentAlignment="Center"/>
<ComboBox Grid.Row="3" Grid.Column="1" Name="comboBoxNationality" Margin="2" SelectedValuePath="Key" DisplayMemberPath="Value" IsEditable="True" StaysOpenOnEdit="True" IsTextSearchEnabled="True" ContextMenu="{DynamicResource ClearContextMenu}"/>
<DatePicker Grid.Row="3" Grid.Column="3" Name="datePickerDateOfBirth" Margin="2" DisplayDateStart="1/1/1900" DisplayDateEnd="12/31/2199" PreviewKeyUp="DateTimePicker_PreviewKeyUpDate">

View File

@ -30,7 +30,7 @@ namespace ENI2.EditControls
this.textBoxDuty.Text = this.CREW.CrewMemberDuty;
this.textBoxLastName.Text = this.CREW.CrewMemberLastName;
this.textBoxFirstName.Text = this.CREW.CrewMemberFirstName;
this.comboBoxGender.ItemsSource = GlobalStructures.GenderList;
this.comboBoxGender.ItemsSource = GlobalStructures.GenderDict;
//this.comboBoxGender.KeyUp += ComboBox_KeyUp;
this.comboBoxGender.SelectedIndex = this.CREW.CrewMemberGender ?? -1;
if (this.CREW.CrewMemberGender == 9)
@ -62,8 +62,7 @@ namespace ENI2.EditControls
this.CREW.CrewMemberDuty = this.textBoxDuty.Text.Trim();
this.CREW.CrewMemberLastName = this.textBoxLastName.Text.Trim();
this.CREW.CrewMemberFirstName = this.textBoxFirstName.Text.Trim();
this.CREW.CrewMemberGender = (this.comboBoxGender.SelectedIndex == -1) ? null : (byte?) this.comboBoxGender.SelectedIndex;
if (this.CREW.CrewMemberGender == 3) this.CREW.CrewMemberGender = 9;
this.CREW.CrewMemberGender = (this.comboBoxGender.SelectedIndex == -1) ? null : (byte?) this.comboBoxGender.SelectedValue;
this.CREW.CrewMemberPlaceOfBirth = this.textBoxPlaceOfBirth.Text.Trim();
this.CREW.CrewMemberNationality = (this.comboBoxNationality.SelectedValue == null) ? "" : (string)this.comboBoxNationality.SelectedValue;
this.CREW.CrewMemberDateOfBirth = this.datePickerDateOfBirth.SelectedDate;

View File

@ -47,7 +47,7 @@
<TextBox Grid.Row="0" Grid.Column="1" Width="auto" Name="textBoxLastName" Margin="2" MaxLength="100" VerticalContentAlignment="Center" />
<TextBox Grid.Row="0" Grid.Column="3" Width="auto" Name="textBoxFirstName" Margin="2" MaxLength="100" VerticalContentAlignment="Center" />
<ComboBox Grid.Row="1" Grid.Column="1" Name="comboBoxGender" Margin="2" IsEditable="True" StaysOpenOnEdit="True" IsTextSearchEnabled="True"/>
<ComboBox Grid.Row="1" Grid.Column="1" Name="comboBoxGender" Margin="2" SelectedValuePath="Key" DisplayMemberPath="Value" IsEditable="True" StaysOpenOnEdit="True" IsTextSearchEnabled="True"/>
<TextBox Grid.Row="1" Grid.Column="3" Width="auto" Name="textBoxPlaceOfBirth" Margin="2" MaxLength="100" VerticalContentAlignment="Center" />
<ComboBox Grid.Row="2" Grid.Column="1" Name="comboBoxNationality" Margin="2" SelectedValuePath="Key" DisplayMemberPath="Value" IsEditable="True" StaysOpenOnEdit="True" IsTextSearchEnabled="True" />
<DatePicker Grid.Row="2" Grid.Column="3" Name="datePickerDateOfBirth" Margin="2" DisplayDateStart="1/1/1900" DisplayDateEnd="12/31/2199" PreviewKeyUp="DateTimePicker_PreviewKeyUpDate">

View File

@ -29,7 +29,7 @@ namespace ENI2.EditControls
// copy into fields
this.textBoxLastName.Text = this.PAS.PassengerLastName;
this.textBoxFirstName.Text = this.PAS.PassengerFirstName;
this.comboBoxGender.ItemsSource = GlobalStructures.GenderList;
this.comboBoxGender.ItemsSource = GlobalStructures.GenderDict;
//this.comboBoxGender.KeyUp += ComboBox_KeyUp;
this.comboBoxGender.SelectedIndex = this.PAS.PassengerGender ?? -1;
if (this.PAS.PassengerGender == 9)
@ -66,9 +66,7 @@ namespace ENI2.EditControls
// copy back
this.PAS.PassengerLastName = this.textBoxLastName.Text.Trim();
this.PAS.PassengerFirstName = this.textBoxFirstName.Text.Trim();
this.PAS.PassengerGender = (this.comboBoxGender.SelectedIndex == -1) ? null : (byte?)this.comboBoxGender.SelectedIndex;
if (this.PAS.PassengerGender == 3)
this.PAS.PassengerGender = 9;
this.PAS.PassengerGender = (this.comboBoxGender.SelectedIndex == -1) ? null : (byte?)this.comboBoxGender.SelectedValue;
this.PAS.PassengerPlaceOfBirth = this.textBoxPlaceOfBirth.Text.Trim();
this.PAS.PassengerNationality = (this.comboBoxNationality.SelectedValue == null) ? "" : (string)this.comboBoxNationality.SelectedValue;
this.PAS.PassengerDateOfBirth = this.datePickerDateOfBirth.SelectedDate;

View File

@ -0,0 +1,31 @@
<enictrl:EditWindowBase x:Class="ENI2.EditControls.FixImportDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:enictrl="clr-namespace:ENI2.Controls"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:local="clr-namespace:ENI2.EditControls"
mc:Ignorable="d"
Title="Fix imported value" Height="200" Width="500">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<Label Content="Type" Grid.Row="0" Grid.Column="0" />
<Label Content="Value" Grid.Row="1" Grid.Column="0" />
<Label Content="Selection" Grid.Row="2" Grid.Column="0" />
<TextBlock FontWeight="DemiBold" VerticalAlignment="Center" Name="textBlockType" Grid.Row="0" Grid.Column="1">bla</TextBlock>
<TextBlock FontWeight="DemiBold" VerticalAlignment="Center" Name="textBlockValue" Grid.Row="1" Grid.Column="1">bla</TextBlock>
<xctk:WatermarkComboBox Grid.Column="1" Grid.Row="2" x:Name="comboBoxValues" IsTextSearchEnabled="True" SelectedValuePath="Key" DisplayMemberPath="Value" Margin="2" IsEditable="True" Watermark="Select an appropriate value" />
</Grid>
</enictrl:EditWindowBase>

View File

@ -0,0 +1,57 @@
// Copyright (c) 2017- schick Informatik
// Description: Dialog to confirm values during excel import (e.g. CREW/PAS)
//
using System;
using System.Collections.Generic;
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.Shapes;
using ENI2.Controls;
namespace ENI2.EditControls
{
/// <summary>
/// Interaction logic for FixImportDialog.xaml
/// </summary>
public partial class FixImportDialog : EditWindowBase
{
public FixImportDialog()
{
InitializeComponent();
this.comboBoxValues.ItemsSource = this.SelectionValues;
}
public string SelectedValue
{
get
{
return this.comboBoxValues.SelectedValue as string;
}
}
public string Value
{
get { return this.textBlockValue.Text; }
set { this.textBlockValue.Text = value.Trim(); }
}
public string ValueType
{
get { return this.textBlockValue.Text; }
set { this.textBlockValue.Text = value; }
}
public Dictionary<string, string> SelectionValues { get; set; }
}
}

View File

@ -17,7 +17,7 @@ namespace ENI2.Excel
/// </summary>
public static class ExcelComparer
{
private static int diffColor = ColorTranslator.ToOle(Color.FromArgb(150, 150, 255)); // blue
private static readonly int diffColor = ColorTranslator.ToOle(Color.FromArgb(150, 150, 255)); // blue
private static bool GetSheetRange(Worksheet sheet, out int lastUsedRow, out int lastUsedColumn)
{

View File

@ -14,6 +14,7 @@ using System.Reflection;
using log4net;
using bsmd.database;
using ENI2.Locode;
using ENI2.EditControls;
namespace ENI2.Excel
{
@ -21,6 +22,10 @@ namespace ENI2.Excel
{
private static readonly ILog _log = LogManager.GetLogger(typeof(ExcelUtil));
private static Dictionary<string, string> _countryImportDict = new Dictionary<string, string>();
private static Dictionary<string, string> _genderImportDict = new Dictionary<string, string>();
private static Dictionary<string, string> _documentTypeImportDict = new Dictionary<string, string>();
#region Process Sheet (normal BSMD sheet import)
internal static bool ProcessSheet(ExcelReader reader, out string readMessage, MessageCore messageCore, List<Message.NotificationClass> notificationClasses)
@ -2087,7 +2092,25 @@ namespace ENI2.Excel
if(!gender.IsNullOrEmpty() && !crew.CrewMemberGender.HasValue)
{
// special treatment / callback
if (_genderImportDict.ContainsKey(gender))
{
crew.CrewMemberGender = DakosyUtil.ParseGender(_genderImportDict[gender]); // we have mapped this before
}
else
{
FixImportDialog fid = new FixImportDialog();
fid.Value = gender;
fid.ValueType = "Gender";
fid.SelectionValues = CREW.NationalityDict;
if(fid.ShowDialog() ?? false)
{
if(!fid.SelectedValue.IsNullOrEmpty())
{
_genderImportDict[gender] = fid.SelectedValue;
crew.CrewMemberGender = DakosyUtil.ParseGender(_genderImportDict[gender]);
}
}
}
}
crew.CrewMemberDuty = reader.ReadCellAsText(sheetTitle, string.Format("F{0}", i + 18));

View File

@ -14,12 +14,12 @@ namespace ENI2.Util
static class GlobalStructures
{
public static string[] GenderList =
public static Dictionary<int, string> GenderDict = new Dictionary<int, string>
{
Properties.Resources.textNotKnown,
Properties.Resources.textMale,
Properties.Resources.textFemale,
Properties.Resources.textNotApplicable
{ 0, Properties.Resources.textNotKnown },
{ 1, Properties.Resources.textMale },
{ 2, Properties.Resources.textFemale },
{ 9, Properties.Resources.textNotApplicable }
};
public static string[] IDDocTypeList =