Added sheet / logic to Part 2. Port

This commit is contained in:
Daniel Schick 2025-01-24 07:57:09 +01:00
parent e0e46b8613
commit ee1c17bb4f
10 changed files with 1567 additions and 13 deletions

View File

@ -178,6 +178,7 @@ namespace ENI2
{
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textOverview, MessageGroupControlType = typeof(OverViewDetailControl), ImagePath = "Resources/documents.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text1Voyage, MessageGroupControlType = typeof(VoyageControl), ImagePath = "Resources/ship2.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text2PortCall, MessageGroupControlType = typeof(PortControl), ImagePath = "Resources/anchor.png" });
}
this.listBoxMessages.ItemsSource = this._listBoxList;

View File

@ -18,13 +18,13 @@ namespace ENI2.DetailViewControls
private Message _pre72hMessage;
private static string[] hullConfiguration = {
private static readonly string[] hullConfiguration = {
Properties.Resources.textSingleHull,
Properties.Resources.textSingleHullBallast,
Properties.Resources.textDoubleHull
};
private static string[] conditionCargoTanks =
private static readonly string[] conditionCargoTanks =
{
Properties.Resources.textFull,
Properties.Resources.textEmpty,

View File

@ -416,7 +416,7 @@ namespace ENI2.DetailViewControls
private void CheckServiceEntryMaerskBHV()
{
bool found = false;
foreach(SERV serv in this._servMessage.Elements)
foreach(SERV serv in _servMessage.Elements.Cast<SERV>())
{
if (serv.ServiceBeneficiary.Equals("Maersk A/S, Esplanaden 50, DK-1263 Copenhagen K, VAT-ID: DK53139655"))
found = true;
@ -439,7 +439,7 @@ namespace ENI2.DetailViewControls
private void CheckServiceEntrySeaGoBHV()
{
bool found = false;
foreach (SERV serv in this._servMessage.Elements)
foreach (SERV serv in _servMessage.Elements.Cast<SERV>())
{
if (serv.ServiceBeneficiary.Equals("Sealand Europe A/S, Dampfaergevej 10, 3.tv, DK- 2100 Copenhagen, VAT-ID: DK53139655"))
found = true;
@ -462,7 +462,7 @@ namespace ENI2.DetailViewControls
private void CheckServiceEntryHoegh()
{
bool found = false;
foreach (SERV serv in this._servMessage.Elements)
foreach (SERV serv in _servMessage.Elements.Cast<SERV>())
{
if (serv.ServiceBeneficiary.Equals("Höegh Autoliners AS, Oslo, Norway"))
found = true;
@ -485,7 +485,7 @@ namespace ENI2.DetailViewControls
private void CheckServiceEntryFctJunge()
{
bool found = false;
foreach (SERV serv in this._servMessage.Elements)
foreach (SERV serv in _servMessage.Elements.Cast<SERV>())
{
if (serv.ServiceName.Equals("Fct Junge - Hamburg"))
found = true;
@ -508,7 +508,7 @@ namespace ENI2.DetailViewControls
private void CheckServiceEntryElbeBulk()
{
bool found = false;
foreach (SERV serv in this._servMessage.Elements)
foreach (SERV serv in _servMessage.Elements.Cast<SERV>())
{
if (serv.ServiceName.Equals("Elbe Bulk Schiffe - Hamburg"))
found = true;

View File

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

View File

@ -938,6 +938,96 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to 2.1 Reference numbers.
/// </summary>
public static string text21ReferenceNumbers {
get {
return ResourceManager.GetString("text21ReferenceNumbers", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 2.2 Port operations.
/// </summary>
public static string text22PortOperations {
get {
return ResourceManager.GetString("text22PortOperations", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 2.3 Agency.
/// </summary>
public static string text23Agency {
get {
return ResourceManager.GetString("text23Agency", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 2.4 Invoice (concerning mooring fees, disposal costs etc.).
/// </summary>
public static string text24Invoice {
get {
return ResourceManager.GetString("text24Invoice", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 2.5 Cargo on board related to incoming journey.
/// </summary>
public static string text25CargeOnBoard {
get {
return ResourceManager.GetString("text25CargeOnBoard", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 2.6 Cargo handled in port of call (cargo to discharge / load / transiting).
/// </summary>
public static string text26CargoPort {
get {
return ResourceManager.GetString("text26CargoPort", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 2.7 Waste (MARPOL) data.
/// </summary>
public static string text27Waste {
get {
return ResourceManager.GetString("text27Waste", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 2.8 Store information.
/// </summary>
public static string text28Store {
get {
return ResourceManager.GetString("text28Store", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 2.9 IMO crew effects declaration (IMO FAL form 4).
/// </summary>
public static string text29CrewEffects {
get {
return ResourceManager.GetString("text29CrewEffects", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 2. Port call.
/// </summary>
public static string text2PortCall {
get {
return ResourceManager.GetString("text2PortCall", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to About ENI-2.
/// </summary>
@ -3269,6 +3359,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Location on board.
/// </summary>
public static string textLocationOnBoard {
get {
return ResourceManager.GetString("textLocationOnBoard", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Lock.
/// </summary>
@ -3728,6 +3827,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Official use.
/// </summary>
public static string textOfficialUse {
get {
return ResourceManager.GetString("textOfficialUse", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to This only works if the grid is empty!.
/// </summary>
@ -4286,6 +4394,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Quantity unit.
/// </summary>
public static string textQuantityUnit {
get {
return ResourceManager.GetString("textQuantityUnit", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Check status.
/// </summary>
@ -4898,6 +5015,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Store.
/// </summary>
public static string textStore {
get {
return ResourceManager.GetString("textStore", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Stowage position.
/// </summary>
@ -5439,7 +5565,7 @@ namespace ENI2.Properties {
}
/// <summary>
/// Looks up a localized string similar to Voyage.
/// Looks up a localized string similar to 1. Voyage.
/// </summary>
public static string textVoyage {
get {

View File

@ -1913,7 +1913,7 @@
<value>This will delete all entries. Are you sure?</value>
</data>
<data name="textVoyage" xml:space="preserve">
<value>Voyage</value>
<value>1. Voyage</value>
</data>
<data name="text11PreviousPort" xml:space="preserve">
<value>1.1 Previous port</value>
@ -1960,4 +1960,46 @@
<data name="text1Voyage" xml:space="preserve">
<value>1. Voyage</value>
</data>
<data name="text2PortCall" xml:space="preserve">
<value>2. Port call</value>
</data>
<data name="text21ReferenceNumbers" xml:space="preserve">
<value>2.1 Reference numbers</value>
</data>
<data name="text22PortOperations" xml:space="preserve">
<value>2.2 Port operations</value>
</data>
<data name="text23Agency" xml:space="preserve">
<value>2.3 Agency</value>
</data>
<data name="text24Invoice" xml:space="preserve">
<value>2.4 Invoice (concerning mooring fees, disposal costs etc.)</value>
</data>
<data name="text25CargeOnBoard" xml:space="preserve">
<value>2.5 Cargo on board related to incoming journey</value>
</data>
<data name="text26CargoPort" xml:space="preserve">
<value>2.6 Cargo handled in port of call (cargo to discharge / load / transiting)</value>
</data>
<data name="text27Waste" xml:space="preserve">
<value>2.7 Waste (MARPOL) data</value>
</data>
<data name="text28Store" xml:space="preserve">
<value>2.8 Store information</value>
</data>
<data name="text29CrewEffects" xml:space="preserve">
<value>2.9 IMO crew effects declaration (IMO FAL form 4)</value>
</data>
<data name="textStore" xml:space="preserve">
<value>Store</value>
</data>
<data name="textQuantityUnit" xml:space="preserve">
<value>Quantity unit</value>
</data>
<data name="textLocationOnBoard" xml:space="preserve">
<value>Location on board</value>
</data>
<data name="textOfficialUse" xml:space="preserve">
<value>Official use</value>
</data>
</root>

View File

@ -0,0 +1,406 @@
<src:DetailBaseControl xmlns:src="clr-namespace:ENI2"
x:Class="ENI2.SheetDisplayControls.PortControl"
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="2450" d:DesignWidth="800">
<GroupBox Name="portCallGroupBox" Header="{x:Static p:Resources.text2PortCall}">
<ScrollViewer PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".35*"/>
<ColumnDefinition Width=".65*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="36" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="36" />
<RowDefinition Height="120" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="36" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="36" />
<RowDefinition Height="140" />
<RowDefinition Height="36" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="36" />
<RowDefinition Height="140" />
<RowDefinition Height="36" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="56" />
<RowDefinition Height="56" />
<RowDefinition Height="280" />
<RowDefinition Height="28" />
<RowDefinition Height="36" />
<RowDefinition Height="140" />
<RowDefinition Height="36" />
<RowDefinition Height="140" />
</Grid.RowDefinitions>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text21ReferenceNumbers}" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"/>
<Label HorizontalContentAlignment="Right" Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.textVisitTransitId}" Margin="0,0,10,0" />
<TextBox Name="textBoxDisplayId" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="1" IsReadOnly="True" Margin="2" VerticalContentAlignment="Center" />
<Label HorizontalAlignment="Right" Grid.Row="2" Grid.Column="0" Content="{x:Static p:Resources.textTicketNo}" Margin="0,0,10,0" />
<TextBox Name="textBoxTicketNo" Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="2" Text="{Binding TicketNo, Mode=TwoWay, Converter={util:TrimStringConverter}}" Margin="2" VerticalContentAlignment="Center" MaxLength="50"/>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text22PortOperations}" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"/>
<GroupBox Grid.Row="4" Grid.ColumnSpan="2" Name="groupBoxCallPurpose" Header="{x:Static p:Resources.textCallPurposes}" >
<enictrl:ENIDataGrid x:Name="dataGridCallPurposes" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
SelectionMode="Single" AutoGenerateColumns="False" Margin="0,5,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
<DataGridTextColumn Header="{x:Static p:Resources.textCode}" Binding="{Binding CallPurposeCode, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDescription}" Binding="{Binding CallPurposeDescription, Mode=TwoWay}" IsReadOnly="True" Width="0.9*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</GroupBox>
<Label HorizontalContentAlignment="Right" Grid.Row="5" Grid.Column="0" Content="{x:Static p:Resources.textPortArea}" Name="label_INFOPortArea" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<Grid Grid.Row="5" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".7*" />
<ColumnDefinition Width=".3*" />
</Grid.ColumnDefinitions>
<ComboBox Grid.Row="0" Grid.Column="0" Name="comboBoxPortArea" Margin="2" SelectedValue="{Binding PortArea}" SelectedValuePath="Key" DisplayMemberPath="Value" ContextMenu="{DynamicResource ClearContextMenu}" />
<Button Grid.Row="0" Grid.Column="1" x:Name="buttonSearchPortArea" Margin="2" Content="Lookup port area" Click="buttonSearchPortArea_Click" />
</Grid>
<Label HorizontalContentAlignment="Right" Grid.Row="6" Grid.Column="0" Content="{x:Static p:Resources.textRequestedPositionInPortOfCall}" Name="label_INFORequestedBerth" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<TextBox Grid.Row="6" Grid.Column="1" Name="textRequestedPostionInPortOfCall" Margin="2" Text="{Binding RequestedPositionInPortOfCall, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<Label HorizontalContentAlignment="Right" Grid.Row="7" Grid.Column="0" Content="{x:Static p:Resources.textSpecialRequirementsOfShipAtBerth}" Name="label_INFOSpecialRequirements" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<TextBox Grid.Row="7" Grid.Column="1" Grid.RowSpan="1" Name="textSpecialRequirements" Margin="2" Text="{Binding SpecialRequirementsOfShipAtBerth, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center" />
<Label HorizontalContentAlignment="Right" Grid.Row="8" Grid.Column="0" Content="{x:Static p:Resources.textConstructionCharacteristics}" Name="label_INFOConstructionCharacteristics" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<TextBox Grid.Row="8" Grid.Column="1" Grid.RowSpan="1" Name="textConstructionCharacteristics" Margin="2" Text="{Binding ConstructionCharacteristicsOfShip, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<Label Content="{x:Static p:Resources.textPlannedOperations}" Grid.Column="0" Grid.Row="9" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<TextBox Text="{Binding PlannedOperations, Mode=TwoWay, Converter={util:TrimStringConverter}}" Name="textBoxPlannedOperations" Grid.Column="1" Grid.Row="9" Margin="2,2,2,2" VerticalContentAlignment="Center" MaxLength="99"/>
<Label Content="{x:Static p:Resources.textPlannedInspection}" Grid.Column="0" Grid.Row="10" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<TextBox Text="{Binding PlannedWorks, Mode=TwoWay, Converter={util:TrimStringConverter}}" Name="textBoxPlannedWorks" Grid.Column="1" Grid.Row="10" Margin="2,2,2,2" MaxLength="255" />
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text23Agency}" Grid.Column="0" Grid.Row="11" Grid.ColumnSpan="2"/>
<Label HorizontalContentAlignment="Right" Grid.Row="12" Grid.Column="0" Content="{x:Static p:Resources.textAgentTemplate}" Name="labelAgentTemplate" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="14" Grid.Column="0" Content="{x:Static p:Resources.textCompanyName}" Name="label_AgentCompanyName" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="15" Grid.Column="0" Content="{x:Static p:Resources.textStreetNumber}" Name="label_AgentStreetAndNumber" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="16" Grid.Column="0" Content="{x:Static p:Resources.textPostalCode}" Name="label_AgentPostalCode" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="17" Grid.Column="0" Content="{x:Static p:Resources.textCity}" Name="label_AgentCity" Margin="0,0,10,0" />
<Label HorizontalContentAlignment="Right" Grid.Row="18" Grid.Column="0" Content="{x:Static p:Resources.textCountry}" Name="label_AgentCountry" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="19" Grid.Column="0" Content="{x:Static p:Resources.textPhone}" Name="label_AgentPhone" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="20" Grid.Column="0" Content="{x:Static p:Resources.textFax}" Name="label_AgentFax" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="21" Grid.Column="0" Content="{x:Static p:Resources.textEMail}" Name="label_AgentEMail" Margin="0,0,10,0" />
<Label HorizontalContentAlignment="Right" Grid.Row="22" Grid.Column="0" Content="{x:Static p:Resources.textLastName}" Name="label_AgentLastName" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="23" Grid.Column="0" Content="{x:Static p:Resources.textFirstName}" Name="label_AgentFirstName" Margin="0,0,10,0"/>
<ComboBox Grid.Row="12" Grid.Column="1" Name="comboBox_AgentTemplate" Margin="2" SelectedValuePath="Id" DisplayMemberPath="AgentTitle" SelectionChanged="comboBox_AgentTemplate_SelectionChanged" />
<Grid Grid.Column="0" Grid.Row="13" HorizontalAlignment="Right">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="26" />
</Grid.ColumnDefinitions>
<Button Name="buttonSetTemplate" Margin="2" Click="buttonSetTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Apply template" HorizontalContentAlignment="Right" IsEnabled="False">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/check.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
</Grid>
<Grid Grid.Row="13" Grid.Column="1" Name="gridTemplateControls" Visibility="Visible">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<!-- Name -->
<ColumnDefinition Width="26"/>
<!-- Save button -->
<ColumnDefinition Width="26"/>
<!-- Delete button -->
<ColumnDefinition Width="52"/>
<!-- Undo button -->
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" Margin="2" Name="textBoxTemplateTitle" VerticalContentAlignment="Center"/>
<Button Name="buttonSaveTemplate" Grid.Column="1" Grid.Row="0" Margin="2" Click="buttonSaveTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Save template">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/floppy_disk_blue.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
<Button Name="buttonDeleteTemplate" Grid.Column="2" Grid.Row="0" Margin="2" Click="buttonDeleteTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Delete template" IsEnabled="False">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/delete.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
<Button Name="buttonUndoTemplate" Grid.Column="3" Grid.Row="0" Margin="22,2,2,2" Click="buttonUndoTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Undo last overwrite" IsEnabled="False">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/undo.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
</Grid>
<TextBox Grid.Row="14" Grid.Column="1" Name="textBox_AgentCompanyName" MaxLength="99" Margin="2" Text="{Binding AgentCompanyName, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="15" Grid.Column="1" Name="textBox_AgentStreetAndNumber" MaxLength="99" Margin="2" Text="{Binding AgentStreetAndNumber, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="16" Grid.Column="1" Name="textBox_AgentPostalCode" MaxLength="99" Margin="2" Text="{Binding AgentPostalCode, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="17" Grid.Column="3" Name="textBox_AgentCity" MaxLength="99" Margin="2" Text="{Binding AgentCity, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="18" Grid.Column="1" Name="textBox_AgentCountry" MaxLength="99" Margin="2" Text="{Binding AgentCountry, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center" />
<TextBox Grid.Row="19" Grid.Column="1" Name="textBox_AgentPhone" MaxLength="99" Margin="2" Text="{Binding AgentPhone, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="20" Grid.Column="3" Name="textBox_AgentFax" MaxLength="99" Margin="2" Text="{Binding AgentFax, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="21" Grid.Column="1" Name="textBox_AgentEMail" MaxLength="99" Margin="2" Text="{Binding AgentEMail, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="22" Grid.Column="1" Name="textBox_AgentLastName" MaxLength="99" Margin="2" Text="{Binding AgentLastName, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBox Grid.Row="23" Grid.Column="3" Name="textBox_AgentFirstName" MaxLength="99" Margin="2" Text="{Binding AgentFirstName, Converter={util:TrimStringConverter}}" VerticalContentAlignment="Center"/>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text24Invoice}" Grid.Column="0" Grid.Row="24" Grid.ColumnSpan="2"/>
<GroupBox Name="servGroupBox" Header="{x:Static p:Resources.textServ}" Grid.Row="25" Grid.Column="0" Grid.ColumnSpan="2">
<enictrl:ENIDataGrid x:Name="dataGridSERV" 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.textServiceName}" Binding="{Binding ServiceName, Mode=TwoWay}" IsReadOnly="True" Width="0.3*" />
<DataGridTextColumn Header="{x:Static p:Resources.textServiceBeneficiary}" Binding="{Binding ServiceBeneficiary, Mode=TwoWay}" IsReadOnly="True" Width="0.3*" />
<DataGridTextColumn Header="{x:Static p:Resources.textServiceInvoiceRecipient}" Binding="{Binding ServiceInvoiceRecipient, Mode=TwoWay}" IsReadOnly="True" Width="0.4*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</GroupBox>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text25CargeOnBoard}" Grid.Column="0" Grid.Row="26" Grid.ColumnSpan="2"/>
<Label HorizontalContentAlignment="Right" Grid.Row="27" Grid.Column="0" Content="{x:Static p:Resources.textGeneralCargoDescription}" Name="label_GeneralCargoDescription" Margin="0,0,10,0"/>
<ComboBox Name="comboBoxGeneralDescriptionOfCargo" Grid.Row="27" Grid.Column="1" IsEditable="True" StaysOpenOnEdit="True" SelectedIndex="{Binding GeneralDescriptionOfCargo, Converter={util:ByteConverter}}" Margin="2" IsTextSearchEnabled="True"/>
<Label HorizontalContentAlignment="Right" Grid.Row="28" Grid.Column="0" Content="{x:Static p:Resources.textFumigatedBulkCargo}" Name="label_INFOFumigatedBulkCargo" VerticalContentAlignment="Center" Margin="0,0,10,0"/>
<CheckBox Grid.Row="28" Grid.Column="1" Name="checkBoxFumigatedBulkCargo" VerticalContentAlignment="Center" IsChecked="{Binding FumigatedBulkCargoBool, Mode=TwoWay}" Margin="2"/>
<Label Content="{x:Static p:Resources.textTankerCondition}" Grid.Column="0" Grid.Row="29" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<ComboBox Grid.Row="29" Grid.Column="1" Name="comboBoxConditionCargoBallastTanks" Margin="2" SelectedIndex="{Binding ConditionCargoBallastTanks, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={util:ByteConverter}}" IsEnabled="{Binding ElementName=checkBoxTanker, Path=IsChecked}" ContextMenu="{DynamicResource ClearContextMenu}"/>
<Label Content="{x:Static p:Resources.textTankerNatureOfCargo}" Grid.Column="0" Grid.Row="30" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<TextBox Text="{Binding NatureOfCargo, Mode=TwoWay, Converter={util:TrimStringConverter}}" Name="textBoxNatureOfCargo" Grid.Column="1" Grid.Row="30" Margin="2,2,2,2" IsEnabled="{Binding ElementName=checkBoxTanker, Path=IsChecked}" VerticalContentAlignment="Center" MaxLength="99" />
<Label Content="{x:Static p:Resources.textTankerVolumeOfCargo}" Grid.Column="0" Grid.Row="31" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<xctk:DoubleUpDown Grid.Row="31" Grid.Column="1" Name="doubleUpDownVolumeOfCargo" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2,2,2,2" FormatString="N3" Value="{Binding VolumeOfCargo, Mode=TwoWay}" IsEnabled="{Binding ElementName=checkBoxTanker, Path=IsChecked}" TextAlignment="Left"/>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text26CargoPort}" Grid.Column="0" Grid.Row="32" Grid.ColumnSpan="2"/>
<GroupBox Name="ladgGroupBox" Header="{x:Static p:Resources.textLadg}" Grid.Row="33" Grid.Column="0" Grid.ColumnSpan="2">
<enictrl:ENIDataGrid x:Name="dataGridLADG" 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.textCargoHandlingType}" Binding="{Binding CargoHandlingTypeDisplay}" IsReadOnly="True" Width="0.15*" />
<DataGridTextColumn Header="{x:Static p:Resources.textLACodes}" Binding="{Binding CargoLACode, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCargoCodeNST}" Binding="{Binding CargoCodeNST, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCargoCodeNST3}" Binding="{Binding CargoCodeNST_3, Mode=TwoWay}" IsReadOnly="True" Width="0.15*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCargoNumberOfItems}" IsReadOnly="False" Width="0.15*">
<DataGridTextColumn.Binding>
<Binding Path="CargoNumberOfItems" Mode="TwoWay">
<Binding.ValidationRules>
<util:NumberValidationRule MaxValue="9999999" />
</Binding.ValidationRules>
</Binding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textCargoGrossQuantity}" IsReadOnly="False" Width="0.15*">
<DataGridTextColumn.Binding>
<Binding Path="CargoGrossQuantity_TNE" Mode="TwoWay" StringFormat="N3">
<Binding.ValidationRules>
<util:NumberValidationRule MaxValue="1000000" MinValue="0" />
</Binding.ValidationRules>
</Binding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textCargoPortOfLoading}" Binding="{Binding PortOfLoading, Mode=TwoWay}" IsReadOnly="True" Width="0.15*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCargoPortOfDischarge}" Binding="{Binding PortOfDischarge, Mode=TwoWay}" IsReadOnly="True" Width="0.15*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</GroupBox>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text27Waste}" Grid.Column="0" Grid.Row="34" Grid.ColumnSpan="2"/>
<Label HorizontalContentAlignment="Right" Grid.Row="35" Grid.Column="0" Content="{x:Static p:Resources.textLastPortWasteDischarge}" Name="label_WasteLastPortDischarged" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="36" Grid.Column="0" Content="{x:Static p:Resources.textWasteDateLastDisposal}" Name="label_DateOfLastDisposal" Margin="0,0,10,0"/>
<Label HorizontalContentAlignment="Right" Grid.Row="37" Grid.Column="0" Content="{x:Static p:Resources.textWasteDisposalServiceProviders}" Name="label_WasteDisposalServiceProviders" Margin="0,0,10,0"/>
<enictrl:LocodeControl Grid.Row="35" Grid.Column="1" x:Name="locodeCtrlLastWastePort" LocodeValue="{Binding LastWasteDisposalPort, Mode=TwoWay}" LocodeSource="SSN" />
<DatePicker Grid.Row="36" Grid.Column="1" Name="datePickerDateLastDisposal" Margin="2" SelectedDate="{Binding LastWasteDisposalDate, Mode=TwoWay}" DisplayDateStart="1/1/1800" DisplayDateEnd="12/31/2199" PreviewKeyUp="DateTimePicker_PreviewKeyUpDate">
<DatePicker.BlackoutDates>
<CalendarDateRange Start="1/1/0001" End="12/31/1799"/>
<CalendarDateRange Start="1/1/2199" End="1/1/9999"/>
</DatePicker.BlackoutDates>
</DatePicker>
<TextBox Grid.Row="37" Grid.Column="1" Grid.ColumnSpan="2" Grid.RowSpan="1" Name="textBoxWasteDisposalServiceProviders" Text="{Binding WasteDisposalServiceProviderText, Converter={util:TrimStringConverter}}" Margin="2" />
<Label Grid.Row="38" Grid.Column="0" HorizontalContentAlignment="Right" Content="{x:Static p:Resources.textAgentTemplate}" Margin="0,0,10,0" />
<Grid Grid.Row="38" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".25*" />
<ColumnDefinition Width=".25*" />
<ColumnDefinition Width=".25*" />
<ColumnDefinition Width=".25*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<ComboBox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Name="comboBox_WSDPTemplate" Margin="2" SelectedValuePath="Id" DisplayMemberPath="Remark" SelectionChanged="comboBox_WSDPTemplate_SelectionChanged" />
<Grid Grid.Row="0" Grid.Column="2" Grid.ColumnSpan="2" Name="gridWasteTemplateControls" Visibility="Visible">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<!-- Name -->
<ColumnDefinition Width="26"/>
<!-- Save button -->
<ColumnDefinition Width="26"/>
<!-- Delete button -->
<ColumnDefinition Width="52"/>
<!-- Undo button -->
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" Margin="2" Name="textBoxWasteTemplateTitle" VerticalContentAlignment="Center"/>
<Button Name="buttonSaveWasteTemplate" Grid.Column="1" Grid.Row="0" Margin="2" Click="buttonSaveWasteTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Save template">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/floppy_disk_blue.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
<Button Name="buttonDeleteWasteTemplate" Grid.Column="2" Grid.Row="0" Margin="2" Click="buttonDeleteWasteTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Delete template" IsEnabled="False">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/delete.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
<Button Name="buttonUndoWasteTemplate" Grid.Column="3" Grid.Row="0" Margin="22,2,2,2" Click="buttonUndoWasteTemplate_Click" BorderThickness="0" Background="Transparent" ToolTip="Undo last overwrite" IsEnabled="False">
<StackPanel Orientation="Horizontal">
<Image Source="../Resources/undo.png" Margin="0,0,0,0" Height="20" Width="20" />
</StackPanel>
</Button>
</Grid>
<Button Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="1" Name="buttonAddMissingEntries" Content="{x:Static p:Resources.textAddMissingEntries}" Margin="2" Click="buttonAddMissingEntries_Click"/>
<Button Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="1" Name="buttonImportFromExcel" Content="{x:Static p:Resources.textImportFromExcel}" Margin="2" Click="buttonImportFromExcel_Click" />
</Grid>
<enictrl:ENIDataGrid x:Name="dataGridWaste" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" AutoGenerateColumns="False" Margin="0,5,0,0" Grid.Row="39" Grid.ColumnSpan="2" CanUserAddRows="False">
<DataGrid.Columns>
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
<DataGridTextColumn Header="{x:Static p:Resources.textCode}" Binding="{Binding WasteTypeDisplayGrid}" IsReadOnly="True" Width="0.2*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDescription}" Binding="{Binding WasteDescription}" IsReadOnly="True" Width="0.15*" />
<DataGridTemplateColumn IsReadOnly="True" Width="0.1*">
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{x:Static p:Resources.textWasteAmountToBeDisposed}" FontSize="10"/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextAlignment="Center" Text="{Binding WasteDisposalAmount_MTQ, StringFormat={}{0:N3}}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn IsReadOnly="True" Width="0.1*">
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{x:Static p:Resources.textWasteMaxCapacity}" FontSize="10"/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextAlignment="Center" Text="{Binding WasteCapacity_MTQ, StringFormat={}{0:N3}}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn IsReadOnly="True" Width="0.1*">
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{x:Static p:Resources.textWasteRetained}" FontSize="10"/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextAlignment="Center" Text="{Binding WasteAmountRetained_MTQ, StringFormat={}{0:N3}}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn IsReadOnly="True" Width="0.1*">
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{x:Static p:Resources.textWastePortOfDelivery}" FontSize="10"/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextAlignment="Center" Text="{Binding WasteDisposalPort}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn IsReadOnly="True" Width="0.12*">
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{x:Static p:Resources.textWasteGeneratedUntilNextPort}" FontSize="9"/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextAlignment="Center" Text="{Binding WasteAmountGeneratedTillNextPort_MTQ, StringFormat={}{0:N3}}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</enictrl:ENIDataGrid>
<Label HorizontalContentAlignment="Right" Grid.Row="40" Grid.Column="0" Content="{x:Static p:Resources.textNextWasteDisposalPort}" Name="label_NextWasteDisposalPort" Margin="0,0,10,0"/>
<enictrl:LocodeControl Grid.Row="40" Grid.Column="1" x:Name="locodeCtrlNextWastePort" LocodeValue="{Binding NextWasteDisposalPort, Mode=TwoWay}" LocodeSource="SSN" />
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text28Store}" Grid.Column="0" Grid.Row="41" Grid.ColumnSpan="2"/>
<GroupBox Name="storeGroupBox" Header="{x:Static p:Resources.textStore}" Grid.Row="42" Grid.Column="0" Grid.ColumnSpan="2">
<enictrl:ENIDataGrid x:Name="dataGridSTO" 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.textName}" Binding="{Binding Name}" IsReadOnly="True" Width="0.15*" />
<DataGridTextColumn Header="{x:Static p:Resources.textQuantity}" IsReadOnly="True" Width="0.1*">
<DataGridTextColumn.Binding>
<Binding Path="Quantity" Mode="TwoWay" StringFormat="N3">
<Binding.ValidationRules>
<util:NumberValidationRule MaxValue="1000000" MinValue="0" />
</Binding.ValidationRules>
</Binding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
<DataGridTextColumn Header="{x:Static p:Resources.textQuantityUnit}" Binding="{Binding QuantityUnit, Mode=TwoWay}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textLocationOnBoard}" Binding="{Binding LocationOnBoard, Mode=TwoWay}" IsReadOnly="True" Width="0.15*" />
<DataGridTextColumn Header="{x:Static p:Resources.textOfficialUse}" Binding="{Binding OfficialUse, Mode=TwoWay}" IsReadOnly="True" Width="0.15*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</GroupBox>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text29CrewEffects}" Grid.Column="0" Grid.Row="43" Grid.ColumnSpan="2"/>
<GroupBox Name="effectsGroupBox" Header="{x:Static p:Resources.textEffects}" Grid.Row="44" Grid.Column="0" Grid.ColumnSpan="2">
<enictrl:ENIDataGrid x:Name="dataGridEffects" 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.textEffects}" Binding="{Binding Effects}" IsReadOnly="True" Width="0.15*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</GroupBox>
</Grid>
</ScrollViewer>
</GroupBox>
</src:DetailBaseControl>

View File

@ -0,0 +1,974 @@
// Copyright (c) 2025 - schick Informatik
// Description: Display control of formsheet Tab 2. Port
//
using bsmd.database;
using ENI2.EditControls;
using ExcelDataReader;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 PortControl.xaml
/// </summary>
public partial class PortControl : DetailBaseControl
{
#region Fields
private Message _ladgMessage;
private Message _servMessage;
private NOA_NOD _noa_nod;
private INFO _info;
private PRE72H _pre72H;
private AGNT _agnt;
private SEC _sec;
private WAS _was;
private Message _stoMessage;
private Message _crewMessage;
private Dictionary<string, string> portAreas = null;
private static List<AGNT_Template> _agntTemplates = null;
private AGNT_Template _currentTemplate;
private AGNT_Template _undoTemplate;
private static List<WasteDisposalServiceProvider_Template> _wsdpTemplates = null;
private WasteDisposalServiceProvider_Template _currentWSDPTemplate;
private string _undoWSDPTemplate;
private static readonly string[] cargoDescriptions = {
"Container",
"Vehicles",
"Conventional general cargo",
"Dry bulk cargo",
"Liquid bulk cargo",
"In ballast"
};
private static readonly string[] conditionCargoTanks =
{
Properties.Resources.textFull,
Properties.Resources.textEmpty,
Properties.Resources.textInert
};
#endregion
#region Construction
public PortControl()
{
InitializeComponent();
Loaded += PortControl_Loaded;
}
#endregion
#region public override
public async override void Initialize()
{
base.Initialize();
foreach (Message aMessage in this.Messages)
{
if (aMessage.Elements.Count == 0) continue;
if (aMessage.MessageNotificationClass == Message.NotificationClass.LADG) { this._ladgMessage = aMessage; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.SERV) { this._servMessage = aMessage; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.NOA_NOD) { this._noa_nod = aMessage.Elements[0] as NOA_NOD; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.SEC) { this._sec = aMessage.Elements[0] as SEC; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.INFO) { this._info = aMessage.Elements[0] as INFO; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.PRE72H) { this._pre72H = aMessage.Elements[0] as PRE72H; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.AGNT) { this._agnt = aMessage.Elements[0] as AGNT; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.WAS) { this._was = aMessage.Elements[0] as WAS; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.STO) { this._stoMessage = aMessage; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.CREWA) { this._crewMessage = aMessage; this.ControlMessages.Add(aMessage); }
}
// 2.1
this.textBoxDisplayId.Text = this.Core.DisplayId;
this.textBoxTicketNo.DataContext = this.Core;
// 2.2
this.dataGridCallPurposes.Initialize();
this.dataGridCallPurposes.ItemsSource = _noa_nod.CallPurposes;
this.dataGridCallPurposes.EditRequested += DataGridCallPurposes_EditRequested;
this.dataGridCallPurposes.AddingNewItem += DataGridCallPurposes_AddingNewItem;
this.dataGridCallPurposes.CreateRequested += DataGridCallPurposes_CreateRequested;
this.dataGridCallPurposes.DeleteRequested += DataGridCallPurposes_DeleteRequested;
portAreas = LocalizedLookup.getPortAreasForLocode(this.Core.PoC);
this.comboBoxPortArea.ItemsSource = portAreas;
this.textRequestedPostionInPortOfCall.DataContext = this._info;
this.textSpecialRequirements.DataContext = this._info;
this.textConstructionCharacteristics.DataContext = this._info;
this.textBoxPlannedOperations.DataContext = this._pre72H;
this.textBoxPlannedWorks.DataContext = this._pre72H;
// 2.3
this.textBox_AgentCity.DataContext = this._agnt;
this.textBox_AgentCompanyName.DataContext = this._agnt;
this.textBox_AgentCountry.DataContext = this._agnt;
this.textBox_AgentEMail.DataContext = this._agnt;
this.textBox_AgentFax.DataContext = this._agnt;
this.textBox_AgentFirstName.DataContext = this._agnt;
this.textBox_AgentLastName.DataContext = this._agnt;
this.textBox_AgentPhone.DataContext = this._agnt;
this.textBox_AgentPostalCode.DataContext = this._agnt;
this.textBox_AgentStreetAndNumber.DataContext = this._agnt;
if (_agntTemplates == null)
{
_agntTemplates = await DBManagerAsync.GetAGNTTemplatesAsync(); // inital full load
_agntTemplates.Sort();
Trace.WriteLine(string.Format("{0} agent templates loaded", _agntTemplates.Count));
}
this.comboBox_AgentTemplate.ItemsSource = _agntTemplates;
// 2.4
this.dataGridSERV.Initialize();
this.dataGridSERV.ItemsSource = this._servMessage.Elements;
this.dataGridSERV.AddingNewItem += DataGridSERV_AddingNewItem;
this.dataGridSERV.EditRequested += DataGridSERV_EditRequested;
this.dataGridSERV.DeleteRequested += DataGridSERV_DeleteRequested;
this.dataGridSERV.CreateRequested += DataGridSERV_CreateRequested;
// 2.5
this.comboBoxGeneralDescriptionOfCargo.ItemsSource = cargoDescriptions;
this.comboBoxGeneralDescriptionOfCargo.DataContext = _sec;
this.checkBoxFumigatedBulkCargo.DataContext = this._info;
this.comboBoxConditionCargoBallastTanks.ItemsSource = conditionCargoTanks;
this.comboBoxConditionCargoBallastTanks.DataContext = this._pre72H;
this.textBoxNatureOfCargo.DataContext = this._pre72H;
this.doubleUpDownVolumeOfCargo.DataContext = this._pre72H;
// 2.6
this.dataGridLADG.Initialize();
this.dataGridLADG.ItemsSource = this._ladgMessage.Elements;
this.dataGridLADG.AddingNewItem += DataGridLADG_AddingNewItem;
this.dataGridLADG.EditRequested += DataGridLADG_EditRequested;
this.dataGridLADG.DeleteRequested += DataGridLADG_DeleteRequested;
this.dataGridLADG.CreateRequested += DataGridLADG_CreateRequested;
// 2.7
this.dataGridWaste.Initialize();
this.dataGridWaste.ItemsSource = _was.Waste;
this.dataGridWaste.AddingNewItem += DataGridWaste_AddingNewItem;
this.dataGridWaste.EditRequested += DataGridWaste_EditRequested;
this.dataGridWaste.DeleteRequested += DataGridWaste_DeleteRequested;
this.dataGridWaste.CreateRequested += DataGridWaste_CreateRequested;
this.locodeCtrlLastWastePort.DataContext = _was;
this.locodeCtrlNextWastePort.DataContext = _was;
this.datePickerDateLastDisposal.DataContext = _was;
this.textBoxWasteDisposalServiceProviders.DataContext = _was;
await InitTemplates();
this.comboBox_WSDPTemplate.ItemsSource = _wsdpTemplates;
// 2.8
if (_stoMessage != null)
{
this.dataGridSTO.Initialize();
this.dataGridSTO.ItemsSource = _stoMessage.Elements;
}
// 2.9
this.dataGridEffects.Initialize();
this.dataGridEffects.ItemsSource = _crewMessage.Elements;
}
#endregion
private void PortControl_Loaded(object sender, RoutedEventArgs e)
{
// 2.1
this.textBoxTicketNo.TextChanged += CoreTextBox_TextChanged;
this.textBoxDisplayId.TextChanged += CoreTextBox_TextChanged;
// 2.3
this.RegisterComboboxValueChange(this.comboBoxPortArea, Message.NotificationClass.INFO);
this.RegisterTextboxChange(this.textRequestedPostionInPortOfCall, Message.NotificationClass.INFO);
this.RegisterTextboxChange(this.textSpecialRequirements, Message.NotificationClass.INFO);
this.RegisterTextboxChange(this.textConstructionCharacteristics, Message.NotificationClass.INFO);
this.RegisterTextboxChange(this.textBoxPlannedOperations, Message.NotificationClass.PRE72H);
this.RegisterTextboxChange(this.textBoxPlannedWorks, Message.NotificationClass.PRE72H);
// 2.4
this.RegisterTextboxChange(this.textBox_AgentCity, Message.NotificationClass.AGNT);
this.RegisterTextboxChange(this.textBox_AgentCompanyName, Message.NotificationClass.AGNT);
this.RegisterTextboxChange(this.textBox_AgentEMail, Message.NotificationClass.AGNT);
this.RegisterTextboxChange(this.textBox_AgentFax, Message.NotificationClass.AGNT);
this.RegisterTextboxChange(this.textBox_AgentFirstName, Message.NotificationClass.AGNT);
this.RegisterTextboxChange(this.textBox_AgentLastName, Message.NotificationClass.AGNT);
this.RegisterTextboxChange(this.textBox_AgentPhone, Message.NotificationClass.AGNT);
this.RegisterTextboxChange(this.textBox_AgentPostalCode, Message.NotificationClass.AGNT);
this.RegisterTextboxChange(this.textBox_AgentStreetAndNumber, Message.NotificationClass.AGNT);
this.RegisterTextboxChange(this.textBox_AgentCountry, Message.NotificationClass.AGNT);
this.buttonSaveTemplate.IsEnabled = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor;
this.buttonDeleteTemplate.IsEnabled = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor;
// 2.5
this.RegisterComboboxIndexChange(this.comboBoxGeneralDescriptionOfCargo, Message.NotificationClass.SEC);
this.RegisterCheckboxChange(this.checkBoxFumigatedBulkCargo, Message.NotificationClass.INFO);
this.RegisterComboboxIndexChange(this.comboBoxConditionCargoBallastTanks, Message.NotificationClass.PRE72H);
this.RegisterTextboxChange(this.textBoxNatureOfCargo, Message.NotificationClass.PRE72H);
this.RegisterDoubleUpDownChange(this.doubleUpDownVolumeOfCargo, Message.NotificationClass.PRE72H);
// 2.6
this.dataGridLADG.CellEditEnding += (obj, ev) => { this.OnNotificationClassChanged(Message.NotificationClass.LADG); };
// 2.7
this.RegisterLocodeChange(this.locodeCtrlLastWastePort, Message.NotificationClass.WAS);
this.RegisterLocodeChange(this.locodeCtrlNextWastePort, Message.NotificationClass.WAS);
this.RegisterTextboxChange(this.textBoxWasteDisposalServiceProviders, Message.NotificationClass.WAS);
this.RegisterDatePickerChange(this.datePickerDateLastDisposal, Message.NotificationClass.WAS);
}
private void buttonSearchPortArea_Click(object sender, RoutedEventArgs e)
{
if (portAreas != null)
{
SelectPortAreaDialog spad = new SelectPortAreaDialog(this.Core.PoC);
if (spad.ShowDialog() ?? false)
{
if (spad.SelectedArea != null)
{
if (portAreas.ContainsKey(spad.SelectedArea))
{
var pair = portAreas.SingleOrDefault(p => p.Key == spad.SelectedArea);
this.comboBoxPortArea.SelectedItem = pair;
}
}
}
}
}
private void CoreTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
this.OnNotificationClassChanged(null);
}
private void comboBox_AgentTemplate_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Trace.WriteLine("combo selection changed");
if (this.comboBox_AgentTemplate.SelectedItem is AGNT_Template at)
{
this.textBoxTemplateTitle.Text = at.AgentTitle;
this.buttonDeleteTemplate.IsEnabled = true;
this.buttonSetTemplate.IsEnabled = true;
this._currentTemplate = at;
}
}
private void buttonSetTemplate_Click(object sender, RoutedEventArgs e)
{
if (this._currentTemplate == null) return;
this._undoTemplate = createFromCurrentText(null, null);
this.textBox_AgentCity.Text = this._currentTemplate.AgentCity;
this.textBox_AgentCity.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentCompanyName.Text = this._currentTemplate.AgentCompanyName;
this.textBox_AgentCompanyName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentCountry.Text = this._currentTemplate.AgentCountry;
this.textBox_AgentCountry.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentEMail.Text = this._currentTemplate.AgentEMail;
this.textBox_AgentEMail.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentFax.Text = this._currentTemplate.AgentFax;
this.textBox_AgentEMail.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentFirstName.Text = this._currentTemplate.AgentFirstName;
this.textBox_AgentFirstName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentLastName.Text = this._currentTemplate.AgentLastName;
this.textBox_AgentLastName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentPhone.Text = this._currentTemplate.AgentPhone;
this.textBox_AgentPhone.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentPostalCode.Text = this._currentTemplate.AgentPostalCode;
this.textBox_AgentPostalCode.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentStreetAndNumber.Text = this._currentTemplate.AgentStreetAndNumber;
this.textBox_AgentStreetAndNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.buttonUndoTemplate.IsEnabled = true;
this.buttonSetTemplate.IsEnabled = false;
this.comboBox_AgentTemplate.SelectedItem = null;
this.textBoxTemplateTitle.Text = "";
this._currentTemplate = null;
}
private void buttonSaveTemplate_Click(object sender, RoutedEventArgs e)
{
string title = this.textBoxTemplateTitle.Text.Trim();
if (title.IsNullOrEmpty())
{
MessageBox.Show("Title may not be empty", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
AGNT_Template existingTemplate = null;
foreach (AGNT_Template anExistingTemplate in _agntTemplates)
{
if (anExistingTemplate.AgentTitle.Equals(title, StringComparison.OrdinalIgnoreCase))
{
existingTemplate = anExistingTemplate;
break;
}
}
if (existingTemplate != null)
{
if (MessageBox.Show("A template with this name already exists, overwrite?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
return;
}
this._currentTemplate = createFromCurrentText(title, existingTemplate);
DBManager.Instance.Save(this._currentTemplate);
if (existingTemplate == null)
{
comboBox_AgentTemplate.ItemsSource = null;
_agntTemplates.Add(this._currentTemplate);
_agntTemplates.Sort();
comboBox_AgentTemplate.ItemsSource = _agntTemplates;
}
MessageBox.Show("Template saved", "OK", MessageBoxButton.OK, MessageBoxImage.Information);
}
private void buttonDeleteTemplate_Click(object sender, RoutedEventArgs e)
{
if (_currentTemplate != null)
{
if (MessageBox.Show("Delete this template?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
{
this.comboBox_AgentTemplate.SelectedItem = null;
this.comboBox_AgentTemplate.ItemsSource = null;
DBManager.Instance.Delete(_currentTemplate);
_agntTemplates.Remove(_currentTemplate);
this.textBoxTemplateTitle.Text = null;
this.buttonDeleteTemplate.IsEnabled = false;
this.comboBox_AgentTemplate.ItemsSource = _agntTemplates;
this.buttonSetTemplate.IsEnabled = false;
}
}
}
private void buttonUndoTemplate_Click(object sender, RoutedEventArgs e)
{
this.textBox_AgentCity.Text = this._undoTemplate.AgentCity;
this.textBox_AgentCity.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentCompanyName.Text = this._undoTemplate.AgentCompanyName;
this.textBox_AgentCompanyName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentCountry.Text = this._undoTemplate.AgentCountry;
this.textBox_AgentCountry.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentEMail.Text = this._undoTemplate.AgentEMail;
this.textBox_AgentEMail.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentFax.Text = this._undoTemplate.AgentFax;
this.textBox_AgentFax.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentFirstName.Text = this._undoTemplate.AgentFirstName;
this.textBox_AgentFirstName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentLastName.Text = this._undoTemplate.AgentLastName;
this.textBox_AgentLastName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentPhone.Text = this._undoTemplate.AgentPhone;
this.textBox_AgentPhone.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentPostalCode.Text = this._undoTemplate.AgentPostalCode;
this.textBox_AgentPostalCode.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentStreetAndNumber.Text = this._undoTemplate.AgentStreetAndNumber;
this.textBox_AgentStreetAndNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.buttonUndoTemplate.IsEnabled = false; // can't undo after undo
}
private AGNT_Template createFromCurrentText(string title, AGNT_Template existingTemplate)
{
AGNT_Template at = new AGNT_Template();
if (existingTemplate != null)
at = existingTemplate;
at.AgentTitle = title;
at.AgentCity = this.textBox_AgentCity.Text;
at.AgentCompanyName = this.textBox_AgentCompanyName.Text;
at.AgentCountry = this.textBox_AgentCountry.Text;
at.AgentEMail = this.textBox_AgentEMail.Text;
at.AgentFax = this.textBox_AgentFax.Text;
at.AgentFirstName = this.textBox_AgentFirstName.Text;
at.AgentLastName = this.textBox_AgentLastName.Text;
at.AgentPhone = this.textBox_AgentPhone.Text;
at.AgentPostalCode = this.textBox_AgentPostalCode.Text;
at.AgentStreetAndNumber = textBox_AgentStreetAndNumber.Text;
return at;
}
private void buttonAddMissingEntries_Click(object sender, RoutedEventArgs e)
{
this._was.AddMissingWaste();
if (this._was.Waste.Count < 15)
{
Waste newWaste = new Waste
{
Identifier = DatabaseEntity.GetNewIdentifier(this._was.Waste),
WAS = this._was,
WasteAmountGeneratedTillNextPort_MTQ = 0,
WasteAmountRetained_MTQ = 0,
WasteCapacity_MTQ = 0,
WasteDescription = "",
WasteDisposalAmount_MTQ = 0,
WasteDisposalPort = "ZZUKN"
};
this._was.Waste.Add(newWaste);
}
this.SublistElementChanged(Message.NotificationClass.WAS);
this.dataGridWaste.Items.Refresh();
}
private void buttonImportFromExcel_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.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<Waste> importWasteList = new List<Waste>();
try
{
do
{
// skip first three rows
reader.Read();
reader.Read();
reader.Read();
int cnt = 0;
object o = null;
// Diese Funktion kann das "alte" Sheet Format nicht mehr einlesen!
while (reader.Read() && (cnt < 35))
{
if (reader.FieldCount < 9)
{
throw new InvalidDataException("Sheet must have 9 Columns of data");
}
if (!reader.IsDBNull(1)) o = reader.GetValue(1); else o = null;
if ((o != null) && Int32.TryParse(o.ToString(), out int wasteType))
{
Waste waste = _was.GetWasteForType(wasteType);
if (waste == null)
{
waste = new Waste();
waste.WasteType = wasteType;
waste.WAS = this._was;
waste.IsDirty = true;
waste.Identifier = Waste.GetNewIdentifier(this._was.Waste);
this._was.Waste.Add(waste);
}
else
{
waste.IsDirty = true;
}
if (!reader.IsDBNull(4)) waste.WasteDescription = reader.GetString(4);
if (waste.WasteDescription.IsNullOrEmpty())
waste.WasteDescription = "-";
if (!reader.IsDBNull(5)) o = reader.GetValue(5); else o = null;
if (o != null) waste.WasteDisposalAmount_MTQ = Convert.ToDouble(o);
if (!reader.IsDBNull(6)) o = reader.GetValue(6); else o = null;
if (o != null) waste.WasteCapacity_MTQ = Convert.ToDouble(o);
if (!reader.IsDBNull(7)) o = reader.GetValue(7); else o = null;
if (o != null) waste.WasteAmountRetained_MTQ = Convert.ToDouble(o);
if (!reader.IsDBNull(8)) waste.WasteDisposalPort = reader.GetString(8).ToUpper();
if (!reader.IsDBNull(9)) o = reader.GetValue(9); else o = null;
if (o != null) waste.WasteAmountGeneratedTillNextPort_MTQ = Convert.ToDouble(o);
importWasteList.Add(waste);
cnt++;
}
}
} while (reader.NextResult());
}
catch (Exception ex)
{
MessageBox.Show("Error reading Excel: " + ex.Message, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
}
if (importWasteList.Count > 0)
{
this.dataGridWaste.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.WAS);
MessageBox.Show(String.Format(Properties.Resources.textWasteImported, importWasteList.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
}
}
stream.Close();
}
}
private async Task InitTemplates()
{
_wsdpTemplates = await DBManagerAsync.GetWastDisposalServiceProviderTemplatesAsync();
_wsdpTemplates.Sort();
this.comboBox_WSDPTemplate.ItemsSource = null;
this.comboBox_WSDPTemplate.ItemsSource = _wsdpTemplates;
Trace.WriteLine($"{_wsdpTemplates.Count} WSDP templates loaded");
}
private void comboBox_WSDPTemplate_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Trace.WriteLine("WSDP combo selection changed");
if (this.comboBox_WSDPTemplate.SelectedItem is WasteDisposalServiceProvider_Template wdsp_t)
{
this.textBoxTemplateTitle.Text = wdsp_t.Remark;
this.buttonDeleteTemplate.IsEnabled = true;
this._currentWSDPTemplate = wdsp_t;
this._undoWSDPTemplate = this.textBoxWasteDisposalServiceProviders.Text.Trim();
this.buttonUndoTemplate.IsEnabled = this._undoWSDPTemplate.Length > 0;
this.textBoxWasteDisposalServiceProviders.Text = wdsp_t.WasteDisposalServiceProviderName;
}
}
private async void buttonSaveWasteTemplate_Click(object sender, RoutedEventArgs e)
{
string currentWSDPProviderName = this.textBoxWasteDisposalServiceProviders.Text.Trim();
string currentRemark = this.textBoxTemplateTitle.Text.Trim();
if ((currentWSDPProviderName.Length == 0) || (currentRemark.Length == 0)) return;
WasteDisposalServiceProvider_Template existingTemplate = null;
foreach (WasteDisposalServiceProvider_Template wdsp_template in _wsdpTemplates)
{
// bei gefundenem Match wird ggf. der Remark überschrieben
if (wdsp_template.Remark.Equals(currentRemark))
{
existingTemplate = wdsp_template;
break;
}
}
if (existingTemplate != null)
{
if (MessageBox.Show("A template with this name already exists, overwrite?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
return;
existingTemplate.WasteDisposalServiceProviderName = currentWSDPProviderName;
await DBManagerAsync.SaveAsync(existingTemplate);
return;
}
WasteDisposalServiceProvider_Template newTemplate = new WasteDisposalServiceProvider_Template();
newTemplate.WasteDisposalServiceProviderName = currentWSDPProviderName;
newTemplate.Remark = currentRemark;
await DBManagerAsync.SaveAsync(newTemplate);
comboBox_WSDPTemplate.ItemsSource = null;
_wsdpTemplates.Add(newTemplate);
_wsdpTemplates.Sort();
comboBox_WSDPTemplate.ItemsSource = _wsdpTemplates;
MessageBox.Show("Template saved", "OK", MessageBoxButton.OK, MessageBoxImage.Information);
}
private void buttonDeleteWasteTemplate_Click(object sender, RoutedEventArgs e)
{
if (_currentWSDPTemplate != null)
{
if (MessageBox.Show("Delete this template?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
{
this.comboBox_WSDPTemplate.SelectedItem = null;
this.comboBox_WSDPTemplate.ItemsSource = null;
DBManager.Instance.Delete(_currentTemplate);
_wsdpTemplates.Remove(_currentWSDPTemplate);
this.textBoxTemplateTitle.Text = null;
this.buttonDeleteTemplate.IsEnabled = false;
this.comboBox_WSDPTemplate.ItemsSource = _wsdpTemplates;
}
}
}
private void buttonUndoWasteTemplate_Click(object sender, RoutedEventArgs e)
{
if (this._undoWSDPTemplate != null)
{
this.textBoxWasteDisposalServiceProviders.Text = this._undoWSDPTemplate;
this.buttonUndoTemplate.IsEnabled = false;
this._undoWSDPTemplate = null;
this.comboBox_WSDPTemplate.SelectedItem = null;
}
}
#region datagrid call purposes
private void DataGridCallPurposes_DeleteRequested(DatabaseEntity obj)
{
if (obj is CallPurpose cp)
{
// are you sure dialog is in base class
_noa_nod.CallPurposes.Remove(cp);
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(cp);
DatabaseEntity.ResetIdentifiers(new List<DatabaseEntity>(_noa_nod.CallPurposes));
this.SublistElementChanged(Message.NotificationClass.NOA_NOD);
this.dataGridCallPurposes.Items.Refresh();
}
}
private void DataGridCallPurposes_CreateRequested()
{
EditCallPurposeDialog ecpd = new EditCallPurposeDialog();
ecpd.AddClicked += () =>
{
ecpd.CopyValuesToEntity();
if (!_noa_nod.CallPurposes.Contains(ecpd.CallPurpose))
_noa_nod.CallPurposes.Add(ecpd.CallPurpose);
this.dataGridCallPurposes.Items.Refresh();
ecpd.CallPurpose = new CallPurpose();
ecpd.CallPurpose.Identifier = CallPurpose.GetNewIdentifier(_noa_nod.CallPurposes);
ecpd.CallPurpose.NOA_NOD = this._noa_nod;
this.SublistElementChanged(Message.NotificationClass.NOA_NOD);
};
ecpd.CallPurpose = new CallPurpose();
ecpd.CallPurpose.Identifier = CallPurpose.GetNewIdentifier(_noa_nod.CallPurposes);
ecpd.CallPurpose.NOA_NOD = this._noa_nod;
if (ecpd.ShowDialog() ?? false)
{
if (!_noa_nod.CallPurposes.Contains(ecpd.CallPurpose))
_noa_nod.CallPurposes.Add(ecpd.CallPurpose);
this.dataGridCallPurposes.Items.Refresh();
// signal up
this.SublistElementChanged(Message.NotificationClass.NOA_NOD);
}
}
private void DataGridCallPurposes_AddingNewItem(object sender, AddingNewItemEventArgs e)
{
this.DataGridCallPurposes_CreateRequested();
}
private void DataGridCallPurposes_EditRequested(DatabaseEntity obj)
{
EditCallPurposeDialog ecpd = new EditCallPurposeDialog();
ecpd.CallPurpose = obj as CallPurpose;
ecpd.AddClicked += () =>
{
ecpd.CopyValuesToEntity();
if (!_noa_nod.CallPurposes.Contains(ecpd.CallPurpose))
_noa_nod.CallPurposes.Add(ecpd.CallPurpose);
this.dataGridCallPurposes.Items.Refresh();
ecpd.CallPurpose = new CallPurpose();
ecpd.CallPurpose.Identifier = CallPurpose.GetNewIdentifier(_noa_nod.CallPurposes);
ecpd.CallPurpose.NOA_NOD = this._noa_nod;
this.SublistElementChanged(Message.NotificationClass.NOA_NOD);
};
if (ecpd.ShowDialog() ?? false)
{
if (!_noa_nod.CallPurposes.Contains(ecpd.CallPurpose))
_noa_nod.CallPurposes.Add(ecpd.CallPurpose);
this.dataGridCallPurposes.Items.Refresh();
// signal up
this.SublistElementChanged(Message.NotificationClass.NOA_NOD);
}
}
#endregion
#region datagrid SERV
private void DataGridSERV_CreateRequested()
{
EditSERVDialog esd = new EditSERVDialog();
esd.SERV = new SERV();
esd.SERV.Identifier = SERV.GetNewIdentifier(_servMessage.Elements);
esd.SERV.MessageHeader = _servMessage;
esd.AddClicked += () =>
{
esd.CopyValuesToEntity();
if (!_servMessage.Elements.Contains(esd.SERV))
_servMessage.Elements.Add(esd.SERV);
this.dataGridSERV.Items.Refresh();
esd.SERV = new SERV();
esd.SERV.MessageHeader = _servMessage;
esd.SERV.Identifier = SERV.GetNewIdentifier(_servMessage.Elements);
this.SublistElementChanged(Message.NotificationClass.SERV);
};
if (esd.ShowDialog() ?? false)
{
if (!_servMessage.Elements.Contains(esd.SERV))
_servMessage.Elements.Add(esd.SERV);
this.dataGridSERV.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.SERV);
}
}
private void DataGridSERV_DeleteRequested(DatabaseEntity obj)
{
if (obj is SERV serv)
{
// are you sure dialog is in base class
_servMessage.Elements.Remove(serv);
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(serv);
DatabaseEntity.ResetIdentifiers(_servMessage.Elements);
this.SublistElementChanged(Message.NotificationClass.SERV);
this.dataGridSERV.Items.Refresh();
}
}
private void DataGridSERV_EditRequested(DatabaseEntity obj)
{
EditSERVDialog esd = new EditSERVDialog();
esd.SERV = obj as SERV;
esd.AddClicked += () =>
{
esd.CopyValuesToEntity();
if (!_servMessage.Elements.Contains(esd.SERV))
_servMessage.Elements.Add(esd.SERV);
this.dataGridSERV.Items.Refresh();
esd.SERV = new SERV();
esd.SERV.Identifier = SERV.GetNewIdentifier(_servMessage.Elements);
esd.SERV.MessageHeader = _servMessage;
this.SublistElementChanged(Message.NotificationClass.SERV);
};
if (esd.ShowDialog() ?? false)
{
if (!_servMessage.Elements.Contains(esd.SERV))
_servMessage.Elements.Add(esd.SERV);
this.dataGridSERV.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.SERV);
}
}
private void DataGridSERV_AddingNewItem(object sender, AddingNewItemEventArgs e)
{
this.DataGridSERV_CreateRequested();
}
#endregion
#region datagrid LADG
private void DataGridLADG_CreateRequested()
{
this.dataGridLADG.CancelEdit();
this.dataGridLADG.CancelEdit();
EditLADGDialog eld = new EditLADGDialog();
eld.LADG = new LADG();
eld.LADG.MessageHeader = _ladgMessage;
eld.LADG.Identifier = LADG.GetNewIdentifier(_ladgMessage.Elements);
eld.Core = this.Core;
eld.AddClicked += () =>
{
eld.CopyValuesToEntity();
if (!this._ladgMessage.Elements.Contains(eld.LADG))
this._ladgMessage.Elements.Add(eld.LADG);
this.dataGridLADG.Items.Refresh();
eld.LADG = new LADG();
eld.LADG.MessageHeader = _ladgMessage;
eld.LADG.Identifier = LADG.GetNewIdentifier(_ladgMessage.Elements);
this.SublistElementChanged(Message.NotificationClass.LADG);
};
if (eld.ShowDialog() ?? false)
{
if (!_ladgMessage.Elements.Contains(eld.LADG))
_ladgMessage.Elements.Add(eld.LADG);
this.dataGridLADG.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.LADG);
}
}
private void DataGridLADG_DeleteRequested(DatabaseEntity obj)
{
if (obj is LADG ladg)
{
this.dataGridLADG.CancelEdit();
this.dataGridLADG.CancelEdit();
// are you sure dialog is in base class
this._ladgMessage.Elements.Remove(ladg);
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(ladg);
DatabaseEntity.ResetIdentifiers(_ladgMessage.Elements);
this.SublistElementChanged(Message.NotificationClass.LADG);
this.dataGridLADG.Items.Refresh();
}
}
private void DataGridLADG_EditRequested(DatabaseEntity obj)
{
this.dataGridLADG.CancelEdit();
this.dataGridLADG.CancelEdit();
LADG ladg = obj as LADG;
EditLADGDialog eld = new EditLADGDialog();
eld.Core = this.Core;
eld.LADG = ladg;
eld.AddClicked += () =>
{
eld.CopyValuesToEntity();
if (!_ladgMessage.Elements.Contains(eld.LADG))
_ladgMessage.Elements.Add(eld.LADG);
this.dataGridLADG.Items.Refresh();
eld.LADG = new LADG();
eld.LADG.Identifier = LADG.GetNewIdentifier(_ladgMessage.Elements);
eld.LADG.MessageHeader = _ladgMessage;
this.SublistElementChanged(Message.NotificationClass.LADG);
};
if (eld.ShowDialog() ?? false)
{
if (!_ladgMessage.Elements.Contains(eld.LADG))
_ladgMessage.Elements.Add(eld.LADG);
this.dataGridLADG.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.LADG);
}
}
private void DataGridLADG_AddingNewItem(object sender, AddingNewItemEventArgs e)
{
this.DataGridLADG_CreateRequested();
}
#endregion
#region Waste grid event handler
private void DataGridWaste_CreateRequested()
{
EditWasteDialog epd = new EditWasteDialog();
epd.Waste = new Waste();
epd.Waste.Identifier = Waste.GetNewIdentifier(_was.Waste);
epd.Waste.WAS = this._was;
epd.AddClicked += () =>
{
epd.CopyValuesToEntity();
if (!this._was.Waste.Any(w => w.WasteType == epd.Waste.WasteType))
{
this._was.Waste.Add(epd.Waste);
this.dataGridWaste.Items.Refresh();
epd.Waste = new Waste();
epd.Waste.WAS = this._was;
epd.Waste.Identifier = Waste.GetNewIdentifier(_was.Waste);
this.SublistElementChanged(Message.NotificationClass.WAS);
}
};
if (epd.ShowDialog() ?? false)
{
if (!this._was.Waste.Any(w => w.WasteType == epd.Waste.WasteType))
{
_was.Waste.Add(epd.Waste);
this.dataGridWaste.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.WAS);
}
}
}
private void DataGridWaste_DeleteRequested(DatabaseEntity obj)
{
if (obj is Waste waste)
{
// are you sure dialog is in base class
_was.Waste.Remove(waste);
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(waste);
DatabaseEntity.ResetIdentifiers(new List<DatabaseEntity>(_was.Waste));
this.SublistElementChanged(Message.NotificationClass.WAS);
this.dataGridWaste.Items.Refresh();
}
}
private void DataGridWaste_EditRequested(DatabaseEntity obj)
{
EditWasteDialog epd = new EditWasteDialog();
epd.Waste = obj as Waste;
epd.AddClicked += () =>
{
epd.CopyValuesToEntity();
if (!_was.Waste.Any(w => w.WasteType == epd.Waste.WasteType))
{
_was.Waste.Add(epd.Waste);
this.dataGridWaste.Items.Refresh();
epd.Waste = new Waste();
epd.Waste.Identifier = Waste.GetNewIdentifier(_was.Waste);
epd.Waste.WAS = _was;
this.SublistElementChanged(Message.NotificationClass.WAS);
}
};
if (epd.ShowDialog() ?? false)
{
if (!_was.Waste.Contains(epd.Waste))
_was.Waste.Add(epd.Waste);
this.dataGridWaste.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.WAS);
}
}
private void DataGridWaste_AddingNewItem(object sender, AddingNewItemEventArgs e)
{
this.DataGridWaste_CreateRequested();
}
#endregion
#region mouse wheel
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
ScrollViewer scv = (ScrollViewer)sender;
scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
e.Handled = true;
}
#endregion
}
}

View File

@ -12,7 +12,7 @@
mc:Ignorable="d"
d:DesignHeight="2450" d:DesignWidth="800">
<GroupBox Name="arrivalNotificationGroupBox" Header="{x:Static p:Resources.textVoyage}">
<GroupBox Name="voyageGroupBox" Header="{x:Static p:Resources.textVoyage}">
<ScrollViewer PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
<Grid>
<Grid.ColumnDefinitions>

View File

@ -1,14 +1,12 @@
// Copyright (c) 2025 - schick Informatik
// Description:
// Description: Display control of formsheet Tab 1. Voyage
//
using System.Windows;
using bsmd.database;
using ENI2.EditControls;
using System.Windows.Media;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using System;
using ENI2.Util;
using System.Collections.Generic;