Lookup für NST2007 Codes in LADG Detaildialog eingebaut.

Die dazu notwendigen Daten liegen in der SQLite Datenbank.
This commit is contained in:
Daniel Schick 2022-12-09 17:57:04 +01:00
parent ad5f873d04
commit d63cb8034d
10 changed files with 3132 additions and 25 deletions

View File

@ -106,6 +106,20 @@ namespace ENI2
} }
} }
public bool HasCriticalInfoMissing(out string messageText)
{
messageText = "";
// Hier haben wir Logik für Spezialfälle, z.B. dass für BRE und BRV bestimmte Meldeklassen gesendet werden *müssen*
if(this.Core.PoC.Equals("DEBRV") || this.Core.PoC.Equals("DEBRE"))
{
}
return false;
}
#endregion #endregion
#region Construction #region Construction

View File

@ -36,8 +36,8 @@
<MinimumRequiredVersion>5.4.0.0</MinimumRequiredVersion> <MinimumRequiredVersion>5.4.0.0</MinimumRequiredVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish> <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.html</WebPage> <WebPage>publish.html</WebPage>
<ApplicationRevision>3</ApplicationRevision> <ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>7.6.0.%2a</ApplicationVersion> <ApplicationVersion>7.7.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut> <CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted> <PublishWizardCompleted>true</PublishWizardCompleted>
@ -84,7 +84,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup /> <PropertyGroup />
<PropertyGroup> <PropertyGroup>
<ManifestCertificateThumbprint>F2C2D0164244EC89955EF50201EE24C2A300FF0B</ManifestCertificateThumbprint> <ManifestCertificateThumbprint>62DE8527C377957850DB503DA52FF66F664BD459</ManifestCertificateThumbprint>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignManifests>true</SignManifests> <SignManifests>true</SignManifests>

View File

@ -35,6 +35,8 @@ Copyright (c) 2017 schick Informatik
<Label Name="labelPortOfLoading" Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textCargoPortOfLoading}" /> <Label Name="labelPortOfLoading" Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textCargoPortOfLoading}" />
<Label Name="labelPortOfDischarge" Grid.Row="5" Grid.Column="0" Content="{x:Static p:Resources.textCargoPortOfDischarge}" /> <Label Name="labelPortOfDischarge" Grid.Row="5" Grid.Column="0" Content="{x:Static p:Resources.textCargoPortOfDischarge}" />
<Label Name="labelCodeNST3" Grid.Row="1" Grid.Column="2" Content="{x:Static p:Resources.textCargoCodeNST3}" /> <Label Name="labelCodeNST3" Grid.Row="1" Grid.Column="2" Content="{x:Static p:Resources.textCargoCodeNST3}" />
<Label Name="labelSearchNST2007" Grid.Row="3" Grid.Column="2" Content="{x:Static p:Resources.textSearchNST}" HorizontalAlignment="Right" />
<ComboBox Grid.Row="0" Grid.Column="1" Name="comboBoxHandlingType" Margin="2" IsEditable="True" StaysOpenOnEdit="True" IsTextSearchEnabled="True"/> <ComboBox Grid.Row="0" Grid.Column="1" Name="comboBoxHandlingType" Margin="2" IsEditable="True" StaysOpenOnEdit="True" IsTextSearchEnabled="True"/>
<ComboBox Grid.Row="0" Grid.Column="3" Name="comboBoxLACodes" Margin="2" IsEditable="True" SelectedValuePath="Key" DisplayMemberPath="Value" StaysOpenOnEdit="True" IsTextSearchEnabled="True"/> <ComboBox Grid.Row="0" Grid.Column="3" Name="comboBoxLACodes" Margin="2" IsEditable="True" SelectedValuePath="Key" DisplayMemberPath="Value" StaysOpenOnEdit="True" IsTextSearchEnabled="True"/>
@ -44,6 +46,20 @@ Copyright (c) 2017 schick Informatik
<xctk:DoubleUpDown Grid.Row="3" Grid.Column="1" Name="doubleUpDownGrossQuantity" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2,2,2,2" FormatString="N3" TextAlignment="Left"/> <xctk:DoubleUpDown Grid.Row="3" Grid.Column="1" Name="doubleUpDownGrossQuantity" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2,2,2,2" FormatString="N3" TextAlignment="Left"/>
<enictrl:LocodeControl Grid.Column="1" Grid.Row="4" Width="Auto" x:Name="locodeControl_PortOfLoading" /> <enictrl:LocodeControl Grid.Column="1" Grid.Row="4" Width="Auto" x:Name="locodeControl_PortOfLoading" />
<enictrl:LocodeControl Grid.Column="1" Grid.Row="5" Width="Auto" x:Name="locodeControl_PortOfDischarge" /> <enictrl:LocodeControl Grid.Column="1" Grid.Row="5" Width="Auto" x:Name="locodeControl_PortOfDischarge" />
<TextBox Grid.Row="3" Grid.Column="3" Margin="2" Name="textBoxSearchNSTList" TextChanged="textBoxSearchNSTList_TextChanged" VerticalContentAlignment="Center" />
<Grid Grid.Row="4" Grid.Column="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="28" />
</Grid.ColumnDefinitions>
<ComboBox Name="comboBoxSelectNST2007ListItem" Margin="2" DisplayMemberPath="Key" />
<Button Name="buttonSetTemplate" Margin="2" Click="buttonSetTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Apply template" HorizontalContentAlignment="Right" Grid.Column="1">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/check.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
</Grid>
</Grid> </Grid>
</enictrl:EditWindowBase> </enictrl:EditWindowBase>

View File

@ -2,13 +2,14 @@
// Description: LADG Bearbeitungsdialog // Description: LADG Bearbeitungsdialog
// //
using System;
using System.Linq;
using System.Windows; using System.Windows;
using System.Collections.Generic; using System.Collections.Generic;
using bsmd.database; using bsmd.database;
using ENI2.Controls; using ENI2.Controls;
using System.Collections.ObjectModel;
using System.Windows.Data;
namespace ENI2.EditControls namespace ENI2.EditControls
{ {
@ -30,13 +31,17 @@ namespace ENI2.EditControls
Properties.Resources.textDischarge Properties.Resources.textDischarge
}; };
private static List<KeyValuePair<string, string>> _nstList = null;
public EditLADGDialog() public EditLADGDialog()
{ {
InitializeComponent(); InitializeComponent();
Loaded += EditLADGDialog_Loaded; Loaded += EditLADGDialog_Loaded;
if (_nstList == null)
_nstList = LocalizedLookup.GetNST2007List();
} }
public LADG LADG { get; set; } public LADG LADG { get; set; }
public MessageCore Core { get; set; } public MessageCore Core { get; set; }
@ -55,16 +60,16 @@ namespace ENI2.EditControls
if (this.LADG.CargoHandlingType.HasValue) if (this.LADG.CargoHandlingType.HasValue)
this.comboBoxHandlingType.SelectedIndex = this.LADG.CargoHandlingType.Value; this.comboBoxHandlingType.SelectedIndex = this.LADG.CargoHandlingType.Value;
this.comboBoxLACodes.ItemsSource = LADG.LACodes; this.comboBoxLACodes.ItemsSource = LADG.LACodes;
this.comboBoxLACodes.SelectedValue = this.LADG.CargoLACode; this.comboBoxLACodes.SelectedValue = this.LADG.CargoLACode;
this.integerUpDownNumberOfItems.Value = this.LADG.CargoNumberOfItems; this.integerUpDownNumberOfItems.Value = this.LADG.CargoNumberOfItems;
this.doubleUpDownGrossQuantity.Value = this.LADG.CargoGrossQuantity_TNE; this.doubleUpDownGrossQuantity.Value = this.LADG.CargoGrossQuantity_TNE;
this.locodeControl_PortOfLoading.LocodeValue = this.LADG.PortOfLoading; this.locodeControl_PortOfLoading.LocodeValue = this.LADG.PortOfLoading;
this.locodeControl_PortOfDischarge.LocodeValue = this.LADG.PortOfDischarge; this.locodeControl_PortOfDischarge.LocodeValue = this.LADG.PortOfDischarge;
this.comboBoxLACodes.SelectedValue = this.LADG.CargoLACode; this.comboBoxLACodes.SelectedValue = this.LADG.CargoLACode;
this.comboBoxNSTCode.ItemsSource = LADG.CargoCodesNST; this.comboBoxNSTCode.ItemsSource = LADG.CargoCodesNST;
this.comboBoxNSTCode.SelectedValue = this.LADG.CargoCodeNST; this.comboBoxNSTCode.SelectedValue = this.LADG.CargoCodeNST;
this.comboBoxNSTCode.SelectionChanged += ComboBoxNSTCode_SelectionChanged; this.comboBoxNSTCode.SelectionChanged += ComboBoxNSTCode_SelectionChanged;
this.comboBoxNST3Code.ItemsSource = LADG.CargoCodesNST3; this.comboBoxNST3Code.ItemsSource = LADG.CargoCodesNST3;
@ -93,7 +98,7 @@ namespace ENI2.EditControls
{ {
if (this.comboBoxNSTCode.SelectedItem == null) return; if (this.comboBoxNSTCode.SelectedItem == null) return;
// filter ItemsSource von NST3 // filter ItemsSource von NST3
KeyValuePair<string, string> selectedItem = (KeyValuePair < string, string> ) this.comboBoxNSTCode.SelectedItem; KeyValuePair<string, string> selectedItem = (KeyValuePair < string, string> ) this.comboBoxNSTCode.SelectedItem;
string key = selectedItem.Key; string key = selectedItem.Key;
if (key.Length == 1) key = "0" + key; if (key.Length == 1) key = "0" + key;
List<KeyValuePair<string, string>> filteredItemsSource = new List<KeyValuePair<string, string>>(); List<KeyValuePair<string, string>> filteredItemsSource = new List<KeyValuePair<string, string>>();
@ -102,7 +107,7 @@ namespace ENI2.EditControls
if (aPair.Value.StartsWith(key)) if (aPair.Value.StartsWith(key))
filteredItemsSource.Add(aPair); filteredItemsSource.Add(aPair);
} }
this.comboBoxNST3Code.ItemsSource = filteredItemsSource; this.comboBoxNST3Code.ItemsSource = filteredItemsSource;
} }
private void EditLADGDialog_OKClicked() private void EditLADGDialog_OKClicked()
@ -110,7 +115,37 @@ namespace ENI2.EditControls
this.CopyValuesToEntity(); this.CopyValuesToEntity();
} }
#endregion #endregion
#region NST2007 list search/select event handler
private void textBoxSearchNSTList_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
if (textBoxSearchNSTList.Text.IsNullOrEmpty() || (textBoxSearchNSTList.Text.Length == 1))
{
this.comboBoxSelectNST2007ListItem.ItemsSource = null;
}
else
{
var result = _nstList.Where(kvp => kvp.Key.Contains(textBoxSearchNSTList.Text, StringComparison.OrdinalIgnoreCase));
this.comboBoxSelectNST2007ListItem.ItemsSource = result;
}
}
private void buttonSetTemplate_Click(object sender, RoutedEventArgs e)
{
if(this.comboBoxSelectNST2007ListItem.SelectedItem != null)
{
KeyValuePair<string, string> selectedTemplate = (KeyValuePair<string, string>) this.comboBoxSelectNST2007ListItem.SelectedItem;
if(selectedTemplate.Value.Length == 3)
{
this.comboBoxNSTCode.SelectedValue = selectedTemplate.Value.Substring(0, 2);
this.comboBoxNST3Code.SelectedValue = selectedTemplate.Value.Substring(2, 1);
}
}
}
#endregion
} }
} }

View File

@ -27,7 +27,7 @@ namespace ENI2
{ {
Dictionary<int, string> result = new Dictionary<int, string>(); Dictionary<int, string> result = new Dictionary<int, string>();
string query = string.Format("SELECT key, text FROM LADG_CargoHandlingCodes WHERE langKey = '{0}'", languageCode); string query = string.Format("SELECT key, text FROM LADG_CargoHandlingCodes WHERE langKey = '{0}'", languageCode);
SQLiteCommand cmd = new SQLiteCommand(query, _con); SQLiteCommand cmd = new SQLiteCommand(query, _con);
IDataReader reader = cmd.ExecuteReader(); IDataReader reader = cmd.ExecuteReader();
int key; int key;
@ -48,19 +48,19 @@ namespace ENI2
string query = string.Format("SELECT Code, PortArea FROM INFO_PortArea WHERE Locode = '{0}' ORDER BY PortArea", locode); string query = string.Format("SELECT Code, PortArea FROM INFO_PortArea WHERE Locode = '{0}' ORDER BY PortArea", locode);
SQLiteCommand cmd = new SQLiteCommand(query, _con); SQLiteCommand cmd = new SQLiteCommand(query, _con);
IDataReader reader = cmd.ExecuteReader(); IDataReader reader = cmd.ExecuteReader();
while(reader.Read()) while (reader.Read())
{ {
string code = null; string code = null;
string portarea = null; string portarea = null;
if (!reader.IsDBNull(0)) code = reader.GetString(0); if (!reader.IsDBNull(0)) code = reader.GetString(0);
if (!reader.IsDBNull(1)) portarea = reader.GetString(1); if (!reader.IsDBNull(1)) portarea = reader.GetString(1);
if((code != null) && (portarea != null)) if ((code != null) && (portarea != null))
{ {
result[code] = string.Format("{0}-{1}", code, portarea); result[code] = string.Format("{0}-{1}", code, portarea);
} }
} }
reader.Close(); reader.Close();
return result; return result;
} }
public static bool PortAreaExists(string locode, string portArea) public static bool PortAreaExists(string locode, string portArea)
@ -68,7 +68,7 @@ namespace ENI2
if (locode.IsNullOrEmpty() || portArea.IsNullOrEmpty()) return false; if (locode.IsNullOrEmpty() || portArea.IsNullOrEmpty()) return false;
string query = string.Format("SELECT COUNT(*) FROM INFO_PortArea WHERE Locode = '{0}' AND Code = '{1}'", locode, portArea); string query = string.Format("SELECT COUNT(*) FROM INFO_PortArea WHERE Locode = '{0}' AND Code = '{1}'", locode, portArea);
SQLiteCommand cmd = new SQLiteCommand(query, _con); SQLiteCommand cmd = new SQLiteCommand(query, _con);
long numResults = (long) cmd.ExecuteScalar(); long numResults = (long)cmd.ExecuteScalar();
return numResults > 0; return numResults > 0;
} }
@ -85,7 +85,7 @@ namespace ENI2
string query = string.Format("SELECT Code, Name FROM Nationality ORDER BY Code"); string query = string.Format("SELECT Code, Name FROM Nationality ORDER BY Code");
SQLiteCommand cmd = new SQLiteCommand(query, _con); SQLiteCommand cmd = new SQLiteCommand(query, _con);
IDataReader reader = cmd.ExecuteReader(); IDataReader reader = cmd.ExecuteReader();
while(reader.Read()) while (reader.Read())
{ {
string code = null; string code = null;
string name = null; string name = null;
@ -142,7 +142,7 @@ namespace ENI2
string query = string.Format("SELECT PortArea from INFO_PortArea WHERE Code = '{0}'", code); string query = string.Format("SELECT PortArea from INFO_PortArea WHERE Code = '{0}'", code);
SQLiteCommand cmd = new SQLiteCommand(query, _con); SQLiteCommand cmd = new SQLiteCommand(query, _con);
IDataReader reader = cmd.ExecuteReader(); IDataReader reader = cmd.ExecuteReader();
if(reader.Read()) if (reader.Read())
{ {
if (!reader.IsDBNull(0)) result = reader.GetString(0); if (!reader.IsDBNull(0)) result = reader.GetString(0);
} }
@ -182,7 +182,7 @@ namespace ENI2
if (!reader.IsDBNull(0)) code = reader.GetInt32(0); if (!reader.IsDBNull(0)) code = reader.GetInt32(0);
if (!reader.IsDBNull(1)) name = reader.GetString(1); if (!reader.IsDBNull(1)) name = reader.GetString(1);
if ((code != null) && (name != null)) if ((code != null) && (name != null))
result[(int) code] = string.Format("{0} {1}", code, name); result[(int)code] = string.Format("{0} {1}", code, name);
} }
reader.Close(); reader.Close();
return result; return result;
@ -235,7 +235,7 @@ namespace ENI2
} }
} }
reader.Close(); reader.Close();
return result; return result;
} }
public static List<LocodeDB.LocodeEntry> SSNAllLocodesForCityNameAsEntries(string city) public static List<LocodeDB.LocodeEntry> SSNAllLocodesForCityNameAsEntries(string city)
@ -250,7 +250,7 @@ namespace ENI2
{ {
if (!reader.IsDBNull(0) && !reader.IsDBNull(1)) if (!reader.IsDBNull(0) && !reader.IsDBNull(1))
{ {
LocodeDB.LocodeEntry entry = new LocodeDB.LocodeEntry(); LocodeDB.LocodeEntry entry = new LocodeDB.LocodeEntry();
entry.Locode = reader.GetString(0); entry.Locode = reader.GetString(0);
entry.Name = reader.GetString(1); entry.Name = reader.GetString(1);
results.Add(entry); results.Add(entry);
@ -269,5 +269,24 @@ namespace ENI2
return result; return result;
} }
public static List<KeyValuePair<string, string>> GetNST2007List()
{
List<KeyValuePair<string, string>> result = new List<KeyValuePair<string, string>>();
string query = string.Format("SELECT Description, NST2007 FROM LADG_NST2007 ORDER BY Description");
SQLiteCommand cmd = new SQLiteCommand(query, _con);
IDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
if (reader.IsDBNull(0)) continue;
string desc = reader.GetString(0);
string code = reader.GetString(1);
KeyValuePair<string, string> kvp = new KeyValuePair<string, string>(desc, code);
result.Add(kvp);
}
reader.Close();
return result;
}
} }
} }

View File

@ -185,7 +185,7 @@ namespace ENI2
} }
mBuilder.AppendLine(); mBuilder.AppendLine();
mBuilder.Append(Properties.Resources.textConfirmUnsentMessages); mBuilder.Append(Properties.Resources.textConfirmUnsentMessages);
if (MessageBox.Show(mBuilder.ToString(), Properties.Resources.textConfirmation, MessageBoxButton.YesNo, if (MessageBox.Show(mBuilder.ToString(), Properties.Resources.textConfirmation, MessageBoxButton.YesNo,
MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No) MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
e.Cancel = true; e.Cancel = true;
} }
@ -202,7 +202,7 @@ namespace ENI2
} }
mBuilder.AppendLine(); mBuilder.AppendLine();
mBuilder.Append(Properties.Resources.textConfirmUnconfirmedMessages); mBuilder.Append(Properties.Resources.textConfirmUnconfirmedMessages);
if (MessageBox.Show(mBuilder.ToString(), Properties.Resources.textConfirmation, MessageBoxButton.YesNo, if (MessageBox.Show(mBuilder.ToString(), Properties.Resources.textConfirmation, MessageBoxButton.YesNo,
MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No) MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
e.Cancel = true; e.Cancel = true;
} }

View File

@ -4245,6 +4245,15 @@ namespace ENI2.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to Search NST2007 list.
/// </summary>
public static string textSearchNST {
get {
return ResourceManager.GetString("textSearchNST", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to SEC - Security. /// Looks up a localized string similar to SEC - Security.
/// </summary> /// </summary>

View File

@ -1855,4 +1855,7 @@
<data name="textEditor" xml:space="preserve"> <data name="textEditor" xml:space="preserve">
<value>Editor</value> <value>Editor</value>
</data> </data>
<data name="textSearchNST" xml:space="preserve">
<value>Search NST2007 list</value>
</data>
</root> </root>

3011
misc/LADG_NST2007.csv Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.