WasteReceived hinzugefügt, neue Waste Codes,..

This commit is contained in:
Daniel Schick 2022-01-20 08:39:41 +01:00
parent 3fb2c519fc
commit 20f1abe7c1
10 changed files with 278 additions and 19 deletions

View File

@ -203,8 +203,7 @@ namespace ENI2.Controls
{
if((this.SelectedItems != null) && (this.SelectedItems.Count == 1) && !this.IsReadOnly)
{
DatabaseEntity selectedEntity = this.SelectedItems[0] as DatabaseEntity;
if (selectedEntity != null)
if (this.SelectedItems[0] is DatabaseEntity selectedEntity)
this.EditRequested?.Invoke(selectedEntity);
}
}
@ -213,8 +212,7 @@ namespace ENI2.Controls
{
if ((this.SelectedItems != null) && (this.SelectedItems.Count == 1) )
{
DatabaseEntity selectedEntity = this.SelectedItems[0] as DatabaseEntity;
if (selectedEntity != null)
if (this.SelectedItems[0] is DatabaseEntity selectedEntity)
this.PrintRequested?.Invoke(selectedEntity);
}
}
@ -223,8 +221,7 @@ namespace ENI2.Controls
{
if ((this.SelectedItems != null) && (this.SelectedItems.Count == 1))
{
DatabaseEntity selectedEntity = this.SelectedItems[0] as DatabaseEntity;
if (selectedEntity != null)
if (this.SelectedItems[0] is DatabaseEntity selectedEntity)
this.ExportRequested?.Invoke(selectedEntity);
}
}
@ -233,8 +230,7 @@ namespace ENI2.Controls
{
if ((this.SelectedItems != null) && (this.SelectedItems.Count == 1))
{
DatabaseEntity selectedEntity = this.SelectedItems[0] as DatabaseEntity;
if (selectedEntity != null)
if (this.SelectedItems[0] is DatabaseEntity selectedEntity)
this.ShowTextRequested?.Invoke(selectedEntity);
}
}
@ -247,12 +243,10 @@ namespace ENI2.Controls
{
if (sender != null)
{
DataGrid grid = sender as DataGrid;
if ((grid != null) && (grid.SelectedItems != null) && (grid.SelectedItems.Count == 1) && !this.IsReadOnly)
if ((sender is DataGrid grid) && (grid.SelectedItems != null) && (grid.SelectedItems.Count == 1) && !this.IsReadOnly)
{
DataGridRow dgr = grid.ItemContainerGenerator.ContainerFromItem(grid.SelectedItem) as DataGridRow;
DatabaseEntity selectedEntity = grid.SelectedItem as DatabaseEntity;
if (selectedEntity != null)
if (grid.SelectedItem is DatabaseEntity selectedEntity)
this.EditRequested?.Invoke(selectedEntity);
}
}
@ -264,7 +258,7 @@ namespace ENI2.Controls
private static T GetVisualChild<T>(Visual parent) where T : Visual
{
T child = default(T);
T child = default;
int numVisuals = VisualTreeHelper.GetChildrenCount(parent);
for (int i = 0; i < numVisuals; i++)
{

View File

@ -148,8 +148,8 @@
<RowDefinition Height="120" />
<RowDefinition Height="330*" />
</Grid.RowDefinitions>
<enictrl:ENIDataGrid x:Name="dataGridWasteReceipt" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
AutoGenerateColumns="False" Margin="0,5,0,0" Grid.Row="0">
<enictrl:ENIDataGrid x:Name="dataGridWasteReceipt" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" SelectionMode="Single"
AutoGenerateColumns="False" Margin="0,5,0,0" Grid.Row="0" SelectionChanged="dataGridWasteReceipt_SelectionChanged">
<DataGrid.Columns>
<DataGridTextColumn Header="" Binding="{Binding Identifier}" IsReadOnly="True" />
<DataGridTextColumn Header="{x:Static p:Resources.textIdentificationNumber}" Binding="{Binding IdentificationNumber}" IsReadOnly="True" Width="Auto" />

View File

@ -24,6 +24,7 @@ namespace ENI2.DetailViewControls
private Message _wasMessage;
private WAS _was;
private Message _wasRcptMessage;
private WAS_RCPT _selectedWAS_RCPT;
private static readonly string[] _wasteDeliveryList =
{
@ -144,6 +145,12 @@ namespace ENI2.DetailViewControls
this.dataGridWasteReceipt.DeleteRequested += DataGridWasteReceipt_DeleteRequested;
this.dataGridWasteReceipt.CreateRequested += DataGridWasteReceipt_CreateRequested;
this.dataGridWasteReceived.Initialize();
this.dataGridWasteReceived.AddingNewItem += DataGridWasteReceived_AddingNewItem;
this.dataGridWasteReceived.EditRequested += DataGridWasteReceived_EditRequested;
this.dataGridWasteReceived.DeleteRequested += DataGridWasteReceived_DeleteRequested;
this.dataGridWasteReceived.CreateRequested += DataGridWasteReceived_CreateRequested;
#endregion
}
@ -175,6 +182,8 @@ namespace ENI2.DetailViewControls
_wasRcptMessage.Elements.Add(epd.WAS_RCPT);
this.dataGridWasteReceipt.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.WAS_RCPT);
this.dataGridWasteReceived.ItemsSource = null;
this._selectedWAS_RCPT = null;
}
}
@ -188,6 +197,8 @@ namespace ENI2.DetailViewControls
DatabaseEntity.ResetIdentifiers(new List<DatabaseEntity>(_wasRcptMessage.Elements));
this.SublistElementChanged(Message.NotificationClass.WAS_RCPT);
this.dataGridWasteReceipt.Items.Refresh();
this.dataGridWasteReceived.ItemsSource = null;
this._selectedWAS_RCPT = null;
}
}
@ -222,6 +233,94 @@ namespace ENI2.DetailViewControls
this.DataGridWasteReceipt_CreateRequested();
}
private void dataGridWasteReceipt_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (this.dataGridWasteReceipt.SelectedItem is WAS_RCPT was_rcpt)
{
this.dataGridWasteReceived.ItemsSource = was_rcpt.WasteReceived;
this._selectedWAS_RCPT = was_rcpt;
}
}
#endregion
#region Waste received grid event handler
private void DataGridWasteReceived_DeleteRequested(DatabaseEntity obj)
{
if (obj is WasteReceived wasteReceived)
{
// are you sure dialog is in base class
_selectedWAS_RCPT.WasteReceived.Remove(wasteReceived);
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(wasteReceived);
DatabaseEntity.ResetIdentifiers(new List<DatabaseEntity>(_wasRcptMessage.Elements));
this.SublistElementChanged(Message.NotificationClass.WAS_RCPT);
this.dataGridWasteReceived.Items.Refresh();
}
}
private void DataGridWasteReceived_CreateRequested()
{
EditWasteReceivedDialog ewrd = new EditWasteReceivedDialog();
ewrd.WasteReceived = new WasteReceived();
ewrd.WasteReceived.WAS_RCPT = _selectedWAS_RCPT;
ewrd.WasteReceived.Identifier = WasteReceived.GetNewIdentifier(_selectedWAS_RCPT.WasteReceived);
ewrd.AddClicked += () =>
{
ewrd.CopyValuesToEntity();
if (!this._selectedWAS_RCPT.WasteReceived.Contains(ewrd.WasteReceived))
this._selectedWAS_RCPT.WasteReceived.Add(ewrd.WasteReceived);
this.dataGridWasteReceived.Items.Refresh();
ewrd.WasteReceived = new WasteReceived();
ewrd.WasteReceived.WAS_RCPT = _selectedWAS_RCPT;
ewrd.WasteReceived.Identifier = WasteReceived.GetNewIdentifier(_selectedWAS_RCPT.WasteReceived);
this.SublistElementChanged(Message.NotificationClass.WAS_RCPT);
};
if (ewrd.ShowDialog() ?? false)
{
if (!this._selectedWAS_RCPT.WasteReceived.Contains(ewrd.WasteReceived))
this._selectedWAS_RCPT.WasteReceived.Add(ewrd.WasteReceived);
this.dataGridWasteReceived.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.WAS_RCPT);
}
}
private void DataGridWasteReceived_EditRequested(DatabaseEntity obj)
{
EditWasteReceivedDialog ewrd = new EditWasteReceivedDialog();
ewrd.WasteReceived = obj as WasteReceived;
ewrd.AddClicked += () =>
{
ewrd.CopyValuesToEntity();
if (!this._selectedWAS_RCPT.WasteReceived.Contains(ewrd.WasteReceived))
_selectedWAS_RCPT.WasteReceived.Add(ewrd.WasteReceived);
this.dataGridWasteReceived.Items.Refresh();
ewrd.WasteReceived = new WasteReceived();
ewrd.WasteReceived.Identifier = WasteReceived.GetNewIdentifier(_selectedWAS_RCPT.WasteReceived);
ewrd.WasteReceived.WAS_RCPT = _selectedWAS_RCPT;
this.SublistElementChanged(Message.NotificationClass.WAS_RCPT);
};
if (ewrd.ShowDialog() ?? false)
{
if (!_selectedWAS_RCPT.WasteReceived.Contains(ewrd.WasteReceived))
_selectedWAS_RCPT.WasteReceived.Add(ewrd.WasteReceived);
this.dataGridWasteReceived.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.WAS_RCPT);
}
}
private void DataGridWasteReceived_AddingNewItem(object sender, AddingNewItemEventArgs e)
{
DataGridWasteReceived_CreateRequested();
}
#endregion
#region Waste grid event handler

View File

@ -233,6 +233,9 @@
<Compile Include="EditControls\EditWasteReceiptDialog.xaml.cs">
<DependentUpon>EditWasteReceiptDialog.xaml</DependentUpon>
</Compile>
<Compile Include="EditControls\EditWasteReceivedDialog.xaml.cs">
<DependentUpon>EditWasteReceivedDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Excel\ExcelBase.cs" />
<Compile Include="Excel\ExcelManager.cs" />
<Compile Include="Excel\ExcelReader.cs" />
@ -625,6 +628,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="EditControls\EditWasteReceivedDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="EditControls\ErrorListDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -36,7 +36,7 @@
<Label Name="labelAmountWasteDischarged" Grid.Row="7" Grid.Column="0" Content="{x:Static p:Resources.textWasteAmountDischargedLastPort}" />
<ComboBox Name="comboBoxWasteCode" Grid.Row="0" Grid.Column="1" Margin="2" SelectedValuePath="Key" DisplayMemberPath="Value" />
<Label Name="labelWasteCodeText" Grid.Row="0" Grid.Column="2" />
<TextBox Name="textBoxDescription" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Width="auto" MaxLength="99" TextWrapping="Wrap" />
<TextBox Name="textBoxDescription" Grid.Row="1" Grid.Column="1" Margin="2" Grid.ColumnSpan="2" Width="auto" MaxLength="99" TextWrapping="Wrap" />
<xctk:DoubleUpDown Grid.Row="2" Grid.Column="1" Name="doubleUpDownAmountDisposed" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2" FormatString="N3" TextAlignment="Left"/>
<xctk:DoubleUpDown Grid.Row="3" Grid.Column="1" Name="doubleUpDownMaxCapacity" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2" FormatString="N3" TextAlignment="Left"/>

View File

@ -0,0 +1,32 @@
<enictrl:EditWindowBase x:Class="ENI2.EditControls.EditWasteReceivedDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ENI2.EditControls"
xmlns:enictrl="clr-namespace:ENI2.Controls"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:p="clr-namespace:ENI2.Properties"
mc:Ignorable="d"
Title="{x:Static p:Resources.textWasteReceived}" Height="200" Width="600" WindowStyle="SingleBorderWindow" Background="AliceBlue">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="56" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<Label Name="labelCode" Grid.Row="0" Grid.Column="0" Content="{x:Static p:Resources.textCode}" />
<Label Name="labelDescription" Grid.Row="1" Grid.Column="0" Content="{x:Static p:Resources.textDescription}" />
<Label Name="labelAmountDisposed" Grid.Row="2" Grid.Column="0" Content="{x:Static p:Resources.textWasteAmountReceived}" />
<ComboBox Name="comboBoxWasteCode" Grid.Row="0" Grid.Column="1" Margin="2" SelectedValuePath="Key" DisplayMemberPath="Value" />
<TextBox Name="textBoxDescription" Grid.Row="1" Margin="2" Grid.Column="1" Width="auto" MaxLength="99" TextWrapping="Wrap" />
<xctk:DoubleUpDown Grid.Row="2" Grid.Column="1" Name="doubleUpDownAmountReceived" ShowButtonSpinner="False" ParsingNumberStyle="Any" Margin="2" FormatString="N3" TextAlignment="Left"/>
</Grid>
</enictrl:EditWindowBase>

View File

@ -0,0 +1,62 @@
// Copyright (c) 2017- schick Informatik
// Description: Wasre received bearbeiten..
//
using System;
using System.Collections.Generic;
using System.Windows;
using bsmd.database;
using ENI2.Controls;
namespace ENI2.EditControls
{
/// <summary>
/// Interaction logic for EditWasteReceivedDialog.xaml
/// </summary>
public partial class EditWasteReceivedDialog : EditWindowBase
{
public EditWasteReceivedDialog()
{
InitializeComponent();
Loaded += EditWasteReceivedDialog_Loaded;
AddClicked += () => { this.comboBoxWasteCode.Focus(); };
}
public WasteReceived WasteReceived { get; set; }
public void CopyValuesToEntity()
{
// copy back
if (this.comboBoxWasteCode.SelectedValue != null)
this.WasteReceived.WasteCode = (string) this.comboBoxWasteCode.SelectedValue;
else
this.WasteReceived.WasteCode = null;
this.WasteReceived.WasteDescription = this.textBoxDescription.Text.Trim();
this.WasteReceived.AmountWasteReceived_MTQ = this.doubleUpDownAmountReceived.Value;
}
private void EditWasteReceivedDialog_Loaded(object sender, RoutedEventArgs e)
{
Dictionary<string, string> codeDict = new Dictionary<string, string>();
for (int i = 0; i < WAS.WasteCodes.Length; i++)
{
codeDict[WAS.WasteCodes[i]] = string.Format("{0} - {1}", WAS.WasteCodes[i], WAS.WasteCodeDescriptions[i]);
}
this.comboBoxWasteCode.ItemsSource = codeDict;
this.comboBoxWasteCode.SelectedValue = this.WasteReceived.WasteCode;
this.textBoxDescription.Text = this.WasteReceived.WasteDescription;
this.doubleUpDownAmountReceived.Value = this.WasteReceived.AmountWasteReceived_MTQ;
OKClicked += EditWasteReceiptDialog_OKClicked;
this.AddVisible = true;
}
private void EditWasteReceiptDialog_OKClicked()
{
this.CopyValuesToEntity();
}
}
}

View File

@ -4963,6 +4963,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Waste amount received (cbm).
/// </summary>
public static string textWasteAmountReceived {
get {
return ResourceManager.GetString("textWasteAmountReceived", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Amount to be disposed.
/// </summary>
@ -5053,6 +5062,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Waste received.
/// </summary>
public static string textWasteReceived {
get {
return ResourceManager.GetString("textWasteReceived", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Waste amount retained on board.
/// </summary>

View File

@ -1786,4 +1786,10 @@
<data name="textTreatmentFacilityProviderDisplay" xml:space="preserve">
<value>Treatment facility provider (comma separated)</value>
</data>
<data name="textWasteAmountReceived" xml:space="preserve">
<value>Waste amount received (cbm)</value>
</data>
<data name="textWasteReceived" xml:space="preserve">
<value>Waste received</value>
</data>
</root>

View File

@ -37,11 +37,52 @@ namespace bsmd.database
public static string[] DKWasteTypes { get; } = { "Waste oils - Sludge", "Waste oils - Bilge water", "Waste oils - Other", "Garbage - Food waste", "Garbage - Plastic", "Garbage - Other", "Garbage - Other - Cooking oil", "Garbage - Other - Incinerator ashes and clinkers", "Operational wastes", "Garbage - Other", "Garbage - Other - Animal carcasses", "Sewage", "Cargo residues - Marpol Annex I - Other", "Cargo residues - Marpol Annex II - Other", "Cargo residues - Marpol Annex V - Other", "Garbage - Other" };
[JsonIgnore]
[Obsolete]
public static int[] RequiredCodes { get; } = { 1100, 1200, 1300, 2100, 2200, 2300, 2311, 2308, 2600, 2309, 3000, 5100, 5200, 5300 };
[JsonIgnore]
[Obsolete]
public static string[] RequiredTypes { get; } = { "Oily Residues (sludge)", "Oily Bilge Water", "Waste oil - others (specify)", "Food waste", "Plastics", "Domestic wastes", "Cooking oil", "Incinerator ashes", "Operational wastes", "Animal carcass(es)", "Sewage", "Cargo residues - Marpol Annex I", "Cargo residues - Marpol Annex II", "Cargo residues - Marpol Annex V" };
/// <summary>
/// NSW 7.0 Waste codes
/// </summary>
public static string[] WasteCodes { get; } = {
"101", "102", "103", "104", "105", "999", "201", "202", "203", "204", "401", "501", "502", "503", "504", "505", "506", "507", "508", "509", "510", "511", "601", "602", "991"
};
/// <summary>
/// NSW 7.0 Waste descriptions
/// </summary>
public static string[] WasteCodeDescriptions { get; } =
{
"Oily bilge water",
"Oily residues (sludge)",
"Oily tank washings (slops)",
"Dirty ballast water",
"Scale and sludge from tank cleaning",
"Other (please specify)",
"Category X substance",
"Category Y substance",
"Category Z substance",
"OS - other substances",
"Sewage",
"A. Plastic",
"B. Food waste",
"C. Domestic waste",
"D. Cooking oil",
"E. Incinerator ashes",
"F. Operational waste",
"G. Animal carcasses",
"H. Fishing gear",
"I. E-waste",
"J. Cargo residues (non-HME)",
"K. Cargo residues (HME)",
"Ozone-depleting substances and equipment containing such substances",
"Exhaust gas-cleaning residues",
"Passively fished waste"
};
[ShowReport]
[ENI2Validation]
public bool? WasteDisposalValidExemption { get; set; }