Test version for assisted import of CREW table (even if larger)

This commit is contained in:
Daniel Schick 2022-09-09 11:51:27 +02:00
parent 76be225712
commit 3c6201bad7
10 changed files with 142 additions and 77 deletions

View File

@ -36,8 +36,8 @@
<MinimumRequiredVersion>5.4.0.0</MinimumRequiredVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.html</WebPage>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>7.5.0.0</ApplicationVersion>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>7.5.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>

View File

@ -52,7 +52,7 @@
<CalendarDateRange Start="1/1/2199" End="1/1/9999"/>
</DatePicker.BlackoutDates>
</DatePicker>
<ComboBox Grid.Row="4" Grid.Column="1" Name="comboBoxIdDocType" Margin="2" IsEditable="True" StaysOpenOnEdit="True" IsTextSearchEnabled="True" ContextMenu="{DynamicResource ClearContextMenu}" />
<ComboBox Grid.Row="4" Grid.Column="1" Name="comboBoxIdDocType" Margin="2" IsEditable="True" StaysOpenOnEdit="True" IsTextSearchEnabled="True" SelectedValuePath="Key" DisplayMemberPath="Value" ContextMenu="{DynamicResource ClearContextMenu}" />
<!-- <ComboBox Grid.Row="4" Grid.Column="3" Width="auto" Name="comboBoxCountryOfBirth" Margin="2" SelectedValuePath="Key" DisplayMemberPath="Value" IsEditable="True" StaysOpenOnEdit="True" IsTextSearchEnabled="True" ContextMenu="{DynamicResource ClearContextMenu}"/>-->
<TextBox Grid.Row="5" Grid.Column="3" Width="auto" Name="textBoxIdDocNumber" Margin="2" MaxLength="100" VerticalContentAlignment="Center" />
<TextBox Grid.Row="5" Grid.Column="1" Width="auto" Name="textBoxVisaNumber" Margin="2" MaxLength="100" VerticalContentAlignment="Center"/>

View File

@ -31,18 +31,13 @@ namespace ENI2.EditControls
this.textBoxLastName.Text = this.CREW.CrewMemberLastName;
this.textBoxFirstName.Text = this.CREW.CrewMemberFirstName;
this.comboBoxGender.ItemsSource = GlobalStructures.GenderDict;
//this.comboBoxGender.KeyUp += ComboBox_KeyUp;
this.comboBoxGender.SelectedIndex = this.CREW.CrewMemberGender ?? -1;
if (this.CREW.CrewMemberGender == 9)
this.comboBoxGender.SelectedIndex = 3;
this.comboBoxGender.SelectedValue = (this.CREW.CrewMemberGender == null) ? null : this.CREW.CrewMemberGender.ToString();
this.textBoxPlaceOfBirth.Text = this.CREW.CrewMemberPlaceOfBirth;
this.comboBoxNationality.ItemsSource = bsmd.database.CREW.NationalityDict;
//this.comboBoxNationality.KeyUp += ComboBox_KeyUp;
this.comboBoxNationality.SelectedValue = this.CREW.CrewMemberNationality;
this.datePickerDateOfBirth.SelectedDate = this.CREW.CrewMemberDateOfBirth;
this.comboBoxIdDocType.ItemsSource = GlobalStructures.IDDocTypeList;
//this.comboBoxIdDocType.KeyUp += ComboBox_KeyUp;
this.comboBoxIdDocType.SelectedIndex = this.CREW.CrewMemberIdentityDocumentType ?? -1;
this.comboBoxIdDocType.ItemsSource = GlobalStructures.IDDocTypeDict;
this.comboBoxIdDocType.SelectedValue = (this.CREW.CrewMemberIdentityDocumentType == null) ? null : this.CREW.CrewMemberIdentityDocumentType.ToString();
this.textBoxIdDocNumber.Text = this.CREW.CrewMemberIdentityDocumentId;
this.textBoxVisaNumber.Text = this.CREW.CrewMemberVisaNumber;
this.comboBoxIssuingState.ItemsSource = bsmd.database.CREW.NationalityDict;
@ -62,14 +57,14 @@ 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.SelectedValue;
this.CREW.CrewMemberGender = (this.comboBoxGender.SelectedIndex == -1) ? null : (byte?) byte.Parse((string) this.comboBoxGender.SelectedValue);
this.CREW.CrewMemberPlaceOfBirth = this.textBoxPlaceOfBirth.Text.Trim();
this.CREW.CrewMemberNationality = (this.comboBoxNationality.SelectedValue == null) ? "" : (string)this.comboBoxNationality.SelectedValue;
this.CREW.CrewMemberNationality = (this.comboBoxNationality.SelectedValue == null) ? "" : (string) this.comboBoxNationality.SelectedValue;
this.CREW.CrewMemberDateOfBirth = this.datePickerDateOfBirth.SelectedDate;
this.CREW.CrewMemberIdentityDocumentType = (this.comboBoxIdDocType.SelectedIndex == -1) ? null : (byte?)this.comboBoxIdDocType.SelectedIndex;
this.CREW.CrewMemberIdentityDocumentType = (this.comboBoxIdDocType.SelectedIndex == -1) ? null : (byte?) byte.Parse((string)this.comboBoxIdDocType.SelectedValue);
this.CREW.CrewMemberIdentityDocumentId = this.textBoxIdDocNumber.Text.Trim();
this.CREW.CrewMemberVisaNumber = this.textBoxVisaNumber.Text.Trim();
this.CREW.CrewMemberIdentityDocumentIssuingState = (this.comboBoxIssuingState.SelectedValue == null) ? "" : (string)this.comboBoxIssuingState.SelectedValue;
this.CREW.CrewMemberIdentityDocumentIssuingState = (this.comboBoxIssuingState.SelectedValue == null) ? "" : (string) this.comboBoxIssuingState.SelectedValue;
this.CREW.CrewMemberIdentityDocumentExpiryDate = this.datePickerExpiryDate.SelectedDate;
// this.CREW.CrewMemberCountryOfBirth = (this.comboBoxCountryOfBirth.SelectedValue == null) ? "" : (string)this.comboBoxCountryOfBirth.SelectedValue;
// this.CREW.Effects = this.textBoxEffects.Text.Trim();

View File

@ -56,7 +56,7 @@
<CalendarDateRange Start="1/1/2199" End="1/1/9999"/>
</DatePicker.BlackoutDates>
</DatePicker>
<ComboBox Grid.Row="3" Grid.Column="1" Name="comboBoxIdDocType" Margin="2" IsEditable="True" StaysOpenOnEdit="True" IsTextSearchEnabled="True" />
<ComboBox Grid.Row="3" Grid.Column="1" Name="comboBoxIdDocType" Margin="2" IsEditable="True" SelectedValuePath="Key" DisplayMemberPath="Value" StaysOpenOnEdit="True" IsTextSearchEnabled="True" />
<!--<ComboBox Grid.Row="3" Grid.Column="3" Name="comboBoxCountryOfBirth" Margin="2" SelectedValuePath="Key" DisplayMemberPath="Value" IsEditable="True" StaysOpenOnEdit="True" IsTextSearchEnabled="True" />-->
<TextBox Grid.Row="4" Grid.Column="3" Width="auto" Name="textBoxIdDocNumber" Margin="2" MaxLength="100" VerticalContentAlignment="Center" />
<TextBox Grid.Row="4" Grid.Column="1" Width="auto" Name="textBoxVisaNumber" Margin="2" MaxLength="100" VerticalContentAlignment="Center" />

View File

@ -30,18 +30,13 @@ namespace ENI2.EditControls
this.textBoxLastName.Text = this.PAS.PassengerLastName;
this.textBoxFirstName.Text = this.PAS.PassengerFirstName;
this.comboBoxGender.ItemsSource = GlobalStructures.GenderDict;
//this.comboBoxGender.KeyUp += ComboBox_KeyUp;
this.comboBoxGender.SelectedIndex = this.PAS.PassengerGender ?? -1;
if (this.PAS.PassengerGender == 9)
this.comboBoxGender.SelectedIndex = 3;
this.comboBoxGender.SelectedValue = this.PAS.PassengerGender ?? -1;
this.textBoxPlaceOfBirth.Text = this.PAS.PassengerPlaceOfBirth;
this.comboBoxNationality.ItemsSource = bsmd.database.CREW.NationalityDict;
//this.comboBoxNationality.KeyUp += ComboBox_KeyUp;
this.comboBoxNationality.SelectedValue = this.PAS.PassengerNationality;
this.datePickerDateOfBirth.SelectedDate = this.PAS.PassengerDateOfBirth;
this.comboBoxIdDocType.ItemsSource = GlobalStructures.IDDocTypeList;
//this.comboBoxIdDocType.KeyUp += ComboBox_KeyUp;
this.comboBoxIdDocType.SelectedIndex = this.PAS.PassengerIdentityDocumentType ?? -1;
this.comboBoxIdDocType.ItemsSource = GlobalStructures.IDDocTypeDict;
this.comboBoxIdDocType.SelectedValue = this.PAS.PassengerIdentityDocumentType ?? null;
this.textBoxIdDocNumber.Text = this.PAS.PassengerIdentityDocumentId;
this.textBoxVisaNumber.Text = this.PAS.PassengerVisaNumber;
this.locodePortOfEmbarkation.LocodeValue = this.PAS.PassengerPortOfEmbarkation;
@ -66,11 +61,11 @@ 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.SelectedValue;
this.PAS.PassengerGender = (this.comboBoxGender.SelectedIndex == -1) ? null : (byte?)byte.Parse((string)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;
this.PAS.PassengerIdentityDocumentType = (this.comboBoxIdDocType.SelectedIndex == -1) ? null : (byte?)this.comboBoxIdDocType.SelectedIndex;
this.PAS.PassengerIdentityDocumentType = (this.comboBoxIdDocType.SelectedIndex == -1) ? null : (byte?) byte.Parse((string)this.comboBoxIdDocType.SelectedValue);
this.PAS.PassengerIdentityDocumentId = this.textBoxIdDocNumber.Text.Trim();
this.PAS.PassengerVisaNumber = this.textBoxVisaNumber.Text.Trim();
this.PAS.PassengerPortOfEmbarkation = this.locodePortOfEmbarkation.LocodeValue;

View File

@ -7,7 +7,7 @@
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">
Title="Fix imported value" Height="200" Width="500" WindowStyle="SingleBorderWindow" Background="AliceBlue" Loaded="EditWindowBase_Loaded">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80" />

View File

@ -27,8 +27,7 @@ namespace ENI2.EditControls
{
public FixImportDialog()
{
InitializeComponent();
this.comboBoxValues.ItemsSource = this.SelectionValues;
InitializeComponent();
}
public string SelectedValue
@ -47,11 +46,15 @@ namespace ENI2.EditControls
public string ValueType
{
get { return this.textBlockValue.Text; }
set { this.textBlockValue.Text = value; }
get { return this.textBlockType.Text; }
set { this.textBlockType.Text = value; }
}
public Dictionary<string, string> SelectionValues { get; set; }
private void EditWindowBase_Loaded(object sender, RoutedEventArgs e)
{
this.comboBoxValues.ItemsSource = this.SelectionValues;
}
}
}

View File

@ -1240,8 +1240,8 @@ namespace ENI2.Excel
{
if (gender.Equals("male", StringComparison.OrdinalIgnoreCase) || gender.Equals("m", StringComparison.OrdinalIgnoreCase)) result = 1;
if (gender.Equals("female", StringComparison.OrdinalIgnoreCase) || gender.Equals("f", StringComparison.OrdinalIgnoreCase)) result = 2;
if (gender.Equals("not_applicable", StringComparison.OrdinalIgnoreCase) || gender.Equals("n", StringComparison.OrdinalIgnoreCase)) result = 9;
if (gender.Equals("not_known", StringComparison.OrdinalIgnoreCase)) result = 0;
if (gender.Equals("not_applicable", StringComparison.OrdinalIgnoreCase) || gender.Equals("not applicable", StringComparison.OrdinalIgnoreCase) || gender.Equals("n", StringComparison.OrdinalIgnoreCase)) result = 9;
if (gender.Equals("not_known", StringComparison.OrdinalIgnoreCase) || gender.Equals("not known", StringComparison.OrdinalIgnoreCase)) result = 0;
if (gender.Equals("other", StringComparison.OrdinalIgnoreCase) || gender.Equals("d", StringComparison.OrdinalIgnoreCase) || gender.Equals("diverse", StringComparison.OrdinalIgnoreCase)) result = 9;
}
return result;

View File

@ -2065,7 +2065,7 @@ namespace ENI2.Excel
// 5.9.22: Changed this area to work like reading from a Dakosy Sheet (by values in rows, not cell names)
bool? notificationSchengen = reader.ReadBoolean("CREW.NotificationSchengen");
bool? notificationPax = reader.ReadBoolean("CREW.NotificationPAX");
bool? notificationPax = reader.ReadBoolean("CREW.NotificationPAX");
for (int i = 0; i < 1000; i++)
{
@ -2086,45 +2086,20 @@ namespace ENI2.Excel
crew.CrewMemberLastName = lastName;
crew.CrewMemberFirstName = reader.ReadCellAsText(sheetTitle, string.Format("D{0}", i + 18));
string gender = reader.ReadCellAsText(sheetTitle, string.Format("E{0}", i + 18));
crew.CrewMemberGender = DakosyUtil.ParseGender(gender);
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.CrewMemberGender = ReadGender(reader.ReadCellAsText(sheetTitle, string.Format("E{0}", i + 18)));
crew.CrewMemberDuty = reader.ReadCellAsText(sheetTitle, string.Format("F{0}", i + 18));
crew.CrewMemberNationality = reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18));
crew.CrewMemberNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18)));
crew.CrewMemberPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("H{0}", i + 18));
crew.CrewMemberCountryOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18));
crew.CrewMemberDateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("J{0}", i + 18));
string idDocType = reader.ReadCellAsText(sheetTitle, string.Format("I{0}", i + 18));
crew.CrewMemberIdentityDocumentType = DakosyUtil.ParseDocumentType(idDocType);
crew.CrewMemberIdentityDocumentType = ReadDocumentType(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 18)));
crew.CrewMemberIdentityDocumentId = reader.ReadCellAsText(sheetTitle, string.Format("L{0}", i + 18));
crew.CrewMemberVisaNumber = reader.ReadCellAsText(sheetTitle, string.Format("O{0}", i + 18));
crew.CrewMemberIdentityDocumentIssuingState = reader.ReadCellAsText(sheetTitle, string.Format("M{0}", i + 18));
crew.CrewMemberIdentityDocumentIssuingState = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("M{0}", i + 18)));
if (crew.CrewMemberIdentityDocumentIssuingState.IsNullOrEmpty() && isOldVersion)
crew.CrewMemberIdentityDocumentIssuingState = "XX";
crew.CrewMemberIdentityDocumentExpiryDate = reader.ReadCellAsDateTime(sheetTitle, string.Format("N{0}", i + 18));
@ -2463,5 +2438,102 @@ namespace ENI2.Excel
#endregion
#region "Semi-Manual" import functions (may open interactive dialog)
public static byte? ReadGender(string gender)
{
byte? result = DakosyUtil.ParseGender(gender);
if (!gender.IsNullOrEmpty() && !result.HasValue)
{
// special treatment / callback
if (_genderImportDict.ContainsKey(gender))
{
result = byte.Parse(_genderImportDict[gender]); // we have mapped this before
}
else
{
FixImportDialog fid = new FixImportDialog();
fid.Value = gender;
fid.ValueType = "Gender";
fid.SelectionValues = Util.GlobalStructures.GenderDict;
if (fid.ShowDialog() ?? false)
{
if (!fid.SelectedValue.IsNullOrEmpty())
{
_genderImportDict[gender] = fid.SelectedValue;
result = byte.Parse(_genderImportDict[gender]);
}
}
}
}
return result;
}
public static byte? ReadDocumentType(string documentType)
{
byte? result = DakosyUtil.ParseDocumentType(documentType);
if (!documentType.IsNullOrEmpty() && !result.HasValue)
{
// special treatment / callback
if (_documentTypeImportDict.ContainsKey(documentType))
{
result = byte.Parse(_documentTypeImportDict[documentType]); // we have mapped this before
}
else
{
FixImportDialog fid = new FixImportDialog();
fid.Value = documentType;
fid.ValueType = "Document type";
fid.SelectionValues = Util.GlobalStructures.IDDocTypeDict;
if (fid.ShowDialog() ?? false)
{
if (!fid.SelectedValue.IsNullOrEmpty())
{
_genderImportDict[documentType] = fid.SelectedValue;
result = byte.Parse(_genderImportDict[documentType]);
}
}
}
}
return result;
}
public static string ReadNationality(string nationality)
{
string result = null;
if(CREW.NationalityDict.ContainsKey(nationality))
{
result = nationality;
}
else if(_countryImportDict.ContainsKey(nationality))
{
result = _countryImportDict[nationality];
}
else // we cannot find whatever this is..
{
FixImportDialog fid = new FixImportDialog();
fid.Value = nationality;
fid.ValueType = "Nationality";
fid.SelectionValues = CREW.NationalityDict;
if(fid.ShowDialog() ?? false)
{
if(!fid.SelectedValue.IsNullOrEmpty())
{
_countryImportDict[nationality] = fid.SelectedValue;
result = fid.SelectedValue;
}
}
}
return result;
}
#endregion
}
}

View File

@ -12,24 +12,24 @@ using ENI2.Locode;
namespace ENI2.Util
{
static class GlobalStructures
{
{
public static Dictionary<int, string> GenderDict = new Dictionary<int, string>
public static Dictionary<string, string> GenderDict = new Dictionary<string, string>
{
{ 0, Properties.Resources.textNotKnown },
{ 1, Properties.Resources.textMale },
{ 2, Properties.Resources.textFemale },
{ 9, Properties.Resources.textNotApplicable }
{ "0", Properties.Resources.textNotKnown },
{ "1", Properties.Resources.textMale },
{ "2", Properties.Resources.textFemale },
{ "9", Properties.Resources.textNotApplicable }
};
public static string[] IDDocTypeList =
public static Dictionary<string, string> IDDocTypeDict = new Dictionary<string, string>
{
Properties.Resources.textIdentityCard,
Properties.Resources.textPassport,
Properties.Resources.textMusterBook,
Properties.Resources.textPhotoId,
Properties.Resources.textResidencePermit,
Properties.Resources.textOtherLegalIdentityDocument
{ "0", Properties.Resources.textIdentityCard },
{ "1", Properties.Resources.textPassport },
{ "2", Properties.Resources.textMusterBook },
{ "3", Properties.Resources.textPhotoId },
{ "4", Properties.Resources.textResidencePermit },
{ "5", Properties.Resources.textOtherLegalIdentityDocument }
};
public static byte[] ShipSecurityLevels = { 1, 2, 3 };