Added sheet / logic part 12,13 ATA and WAS_RCPT

This commit is contained in:
Daniel Schick 2025-01-30 09:25:42 +01:00
parent 40b9fff121
commit 7c8eed08bd
10 changed files with 669 additions and 3 deletions

View File

@ -187,7 +187,8 @@ namespace ENI2
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text9PassengerDeparture, MessageGroupControlType = typeof(PassengerDepartureControl), ImagePath = "Resources/departure_user.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text10DangerousCargoArrival, MessageGroupControlType = typeof(DangerousCargoControl), ImagePath = "Resources/sign_warning_radiation.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text11DangerousCargoDeparture, MessageGroupControlType = typeof(DangerousCargoControl), ImagePath = "Resources/sign_warning_radiation.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text12ATAATD, MessageGroupControlType = typeof(ATAControl), ImagePath = "Resources/clock.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.text13WasteReceipts, MessageGroupControlType = typeof(WasteReceiptsControl), ImagePath = "Resources/garbage.png" });
}
this.listBoxMessages.ItemsSource = this._listBoxList;

View File

@ -585,8 +585,7 @@ namespace ENI2.DetailViewControls
}
#endregion
#endregion
#region Waste disposal Service Provider templates event handler

View File

@ -493,6 +493,9 @@
<DesignTime>True</DesignTime>
<DependentUpon>Reference.svcmap</DependentUpon>
</Compile>
<Compile Include="SheetDisplayControls\ATAControl.xaml.cs">
<DependentUpon>ATAControl.xaml</DependentUpon>
</Compile>
<Compile Include="SheetDisplayControls\CrewDepartureControl.xaml.cs">
<DependentUpon>CrewDepartureControl.xaml</DependentUpon>
</Compile>
@ -523,6 +526,9 @@
<Compile Include="SheetDisplayControls\VoyageControl.xaml.cs">
<DependentUpon>VoyageControl.xaml</DependentUpon>
</Compile>
<Compile Include="SheetDisplayControls\WasteReceiptsControl.xaml.cs">
<DependentUpon>WasteReceiptsControl.xaml</DependentUpon>
</Compile>
<Compile Include="SplashScreenWindow.xaml.cs">
<DependentUpon>SplashScreenWindow.xaml</DependentUpon>
</Compile>
@ -833,6 +839,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="SheetDisplayControls\ATAControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SheetDisplayControls\CrewDepartureControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -873,6 +883,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SheetDisplayControls\WasteReceiptsControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SplashScreenWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -1009,6 +1023,7 @@
<Resource Include="Resources\arrival_worker.png" />
<Resource Include="Resources\departure_user.png" />
<Resource Include="Resources\departure_worker.png" />
<Resource Include="Resources\clock.png" />
<Content Include="x64\SQLite.Interop.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

View File

@ -230,6 +230,16 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap clock {
get {
object obj = ResourceManager.GetObject("clock", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@ -992,6 +1002,24 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to 12.1 Actual time of arrival.
/// </summary>
public static string text121ATA {
get {
return ResourceManager.GetString("text121ATA", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 12.2 Actual time of departure.
/// </summary>
public static string text122ATD {
get {
return ResourceManager.GetString("text122ATD", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 12. Actual time of arrival / departure.
/// </summary>
@ -1010,6 +1038,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to 13.1 Waste receipt.
/// </summary>
public static string text131WasteReceipt {
get {
return ResourceManager.GetString("text131WasteReceipt", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 1.3 Relevant Portcall (port of call) / Kiel-Canal-Transit.
/// </summary>

View File

@ -2158,4 +2158,16 @@
<data name="text116IMDGData" xml:space="preserve">
<value>11.6 IMDG data (on departure), if applicable</value>
</data>
<data name="text121ATA" xml:space="preserve">
<value>12.1 Actual time of arrival</value>
</data>
<data name="text122ATD" xml:space="preserve">
<value>12.2 Actual time of departure</value>
</data>
<data name="text131WasteReceipt" xml:space="preserve">
<value>13.1 Waste receipt</value>
</data>
<data name="clock" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\clock.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

BIN
ENI2/Resources/clock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,45 @@
<src:DetailBaseControl xmlns:src="clr-namespace:ENI2"
x:Class="ENI2.SheetDisplayControls.ATAControl"
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="600" d:DesignWidth="800">
<GroupBox Name="portCallGroupBox" Header="{x:Static p:Resources.text12ATAATD}">
<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="36" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text121ATA}" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"/>
<Label Content="ATA" Grid.Column="0" Grid.Row="1" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<xctk:DateTimePicker Grid.Column="1" Grid.Row="1" Value="{Binding ATAPortOfCall, Mode=TwoWay, Converter={util:UtcToLocalDateTimeConverter}}" Name="dateTimePickerATA" Format="Custom"
FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="True" ContextMenu="{DynamicResource ClearContextMenu}"
TextAlignment="Left" Minimum="1899.12.31 00:00" Maximum="2100.12.31 00:00" PreviewKeyUp="DateTimePicker_PreviewKeyUp" ValueChanged="dateTimePickerATA_ValueChanged" />
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text122ATD}" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2"/>
<Label Content="ATD" Grid.Column="0" Grid.Row="3" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<xctk:DateTimePicker Grid.Column="1" Grid.Row="3" Value="{Binding ATDPortOfCall, Mode=TwoWay, Converter={util:UtcToLocalDateTimeConverter}}" Name="dateTimePickerATD" Format="Custom"
FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2" AllowTextInput="True" ContextMenu="{DynamicResource ClearContextMenu}"
TextAlignment="Left" Minimum="1899.12.31 00:00" Maximum="2100.12.31 00:00" PreviewKeyUp="DateTimePicker_PreviewKeyUp" ValueChanged="dateTimePickerATD_ValueChanged"/>
</Grid>
</ScrollViewer>
</GroupBox>
</src:DetailBaseControl>

View File

@ -0,0 +1,113 @@
// Copyright (c) 2025- schick Informatik
// Description: Display control of formsheet Tab 12. ATA ATD
//
using bsmd.database;
using System;
using System.Windows;
namespace ENI2.SheetDisplayControls
{
/// <summary>
/// Interaction logic for ATAControl.xaml
/// </summary>
public partial class ATAControl : DetailBaseControl
{
#region Fields
ATA _ata;
ATD _atd;
bool startupComplete = false;
#endregion
#region Fields
public ATAControl()
{
InitializeComponent();
Loaded += ATAControl_Loaded;
}
#endregion
#region public overrides
public override void Initialize()
{
base.Initialize();
foreach (Message aMessage in this.Messages)
{
if (aMessage.MessageNotificationClass == Message.NotificationClass.ATA)
{
this.ControlMessages.Add(aMessage);
if (aMessage.Elements.Count > 0)
_ata = aMessage.Elements[0] as ATA;
if (_ata == null)
{
_ata = new ATA();
_ata.MessageCore = this.Core;
_ata.MessageHeader = aMessage;
aMessage.Elements.Add(_ata);
}
this.dateTimePickerATA.DataContext = _ata;
}
if (aMessage.MessageNotificationClass == Message.NotificationClass.ATD)
{
this.ControlMessages.Add(aMessage);
if (aMessage.Elements.Count > 0)
_atd = aMessage.Elements[0] as ATD;
if (_atd == null)
{
_atd = new ATD();
_atd.MessageCore = this.Core;
_atd.MessageHeader = aMessage;
aMessage.Elements.Add(_atd);
}
this.dateTimePickerATD.DataContext = _atd;
}
}
}
public override void SetEnabled(bool enabled)
{
base.SetEnabled(enabled);
}
#endregion
#region event handler
private void ATAControl_Loaded(object sender, RoutedEventArgs e)
{
this.RegisterDateTimePickerChange(this.dateTimePickerATA, Message.NotificationClass.ATA);
this.RegisterDateTimePickerChange(this.dateTimePickerATD, Message.NotificationClass.ATD);
startupComplete = true;
}
private void dateTimePickerATD_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
if (startupComplete && this.dateTimePickerATD.Value.HasValue)
{
DateTime setTime = this.dateTimePickerATD.Value.Value;
if ((setTime > DateTime.Now.AddDays(14)) || (setTime < DateTime.Now.AddDays(-14)))
MessageBox.Show("ATD value may be invalid", "Date implausible", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
private void dateTimePickerATA_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
if (startupComplete && this.dateTimePickerATA.Value.HasValue)
{
DateTime setTime = this.dateTimePickerATA.Value.Value;
if ((setTime > DateTime.Now.AddDays(14)) || (setTime < DateTime.Now.AddDays(-14)))
MessageBox.Show("ATA value may be invalid", "Date implausible", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
#endregion
}
}

View File

@ -0,0 +1,90 @@
<src:DetailBaseControl xmlns:src="clr-namespace:ENI2"
x:Class="ENI2.SheetDisplayControls.WasteReceiptsControl"
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="600" d:DesignWidth="800">
<GroupBox Name="portCallGroupBox" Header="{x:Static p:Resources.text13WasteReceipts}">
<ScrollViewer PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".35*"/>
<ColumnDefinition Width=".65*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="36" />
<RowDefinition Height="640" />
</Grid.RowDefinitions>
<TextBlock FontSize="18" VerticalAlignment="Bottom" Text="{x:Static p:Resources.text131WasteReceipt}" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"/>
<GroupBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Name="was_rcptGroupBox" Header="{x:Static p:Resources.textWasteReceipt}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="120" />
<RowDefinition Height="28" />
<RowDefinition Height="330*" />
</Grid.RowDefinitions>
<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" />
<DataGridTextColumn Header="{x:Static p:Resources.textPortReceptionFacilityName}" Binding="{Binding PortReceptionFacilityName}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textPortReceptionFacilityProviderName}" Binding="{Binding PortReceptionFacilityProviderName}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textTreatmentFacilityProviderName}" Binding="{Binding TreatmentFacilityProviderText}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textWasteDeliveryDateFrom}" Binding="{Binding WasteDeliveryDateFrom, Converter={util:UtcToLocalDateTimeConverter}}" IsReadOnly="True" Width="Auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textWasteDeliveryDateTo}" Binding="{Binding WasteDeliveryDateTo, Converter={util:UtcToLocalDateTimeConverter}}" IsReadOnly="True" Width="Auto" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120" />
<ColumnDefinition Width="120" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Grid.Row="0" Grid.Column="0" Name="buttonWasteReceivedAddMissingEntries" Content="{x:Static p:Resources.textAddMissingEntries}" Margin="2" Click="buttonWasteReceivedAddMissingEntries_Click"/>
<Button Grid.Row="0" Grid.Column="1" Name="buttonCopyFromWAS" Content="{x:Static p:Resources.textCopyFromWAS}" Margin="2" Click="buttonCopyFromWAS_Click"/>
</Grid>
<enictrl:ENIDataGrid x:Name="dataGridWasteReceived" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
AutoGenerateColumns="False" Margin="0,5,0,0" Grid.Row="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.3*" />
<!--DataGridTemplateColumn IsReadOnly="True" Width="0.15*">
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{x:Static p:Resources.textAmountWasteReceived_MTQ}" FontSize="10"/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextAlignment="Center" Text="{Binding AmountWasteReceived_MTQ, StringFormat={}{0:N3}}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn-->
<DataGridTextColumn Header="{x:Static p:Resources.textAmountWasteReceived_MTQ}" IsReadOnly="False" Width="0.15*">
<DataGridTextColumn.Binding>
<Binding Path="AmountWasteReceived_MTQ" Mode="TwoWay" StringFormat="N3" >
<Binding.ValidationRules>
<util:NumberValidationRule MaxValue="10000" MinValue="0" />
</Binding.ValidationRules>
</Binding>
</DataGridTextColumn.Binding>
</DataGridTextColumn>
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>
</GroupBox>
</Grid>
</ScrollViewer>
</GroupBox>
</src:DetailBaseControl>

View File

@ -0,0 +1,354 @@
// Copyright (c) 2025- schick Informatik
// Description: Display control of formsheet Tab 13. Waste receipts
//
using bsmd.database;
using ENI2.EditControls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ENI2.SheetDisplayControls
{
/// <summary>
/// Interaction logic for WasteReceiptsControl.xaml
/// </summary>
public partial class WasteReceiptsControl : DetailBaseControl
{
#region fields
private Message _wasMessage;
private WAS _was;
private Message _wasRcptMessage;
private WAS_RCPT _selectedWAS_RCPT;
#endregion
#region Construction
public WasteReceiptsControl()
{
InitializeComponent();
Loaded += WasteReceiptsControl_Loaded;
}
#endregion
#region public override
public override void Initialize()
{
base.Initialize();
foreach (Message aMessage in this.Messages)
{
if (aMessage.MessageNotificationClass == Message.NotificationClass.WAS) { this._wasMessage = aMessage; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.WAS_RCPT) { this._wasRcptMessage = aMessage; this.ControlMessages.Add(aMessage); }
}
#region init WAS
WAS was = null;
if (this._wasMessage.Elements.Count > 0)
was = this._wasMessage.Elements[0] as WAS;
if (was == null)
{
was = new WAS();
was.MessageCore = this.Core;
was.MessageHeader = this._wasMessage;
_wasMessage.Elements.Add(was);
}
this._was = was;
#endregion
#region init WAS_RCPT
if (this._wasRcptMessage == null)
{
this._wasRcptMessage = this.Core.CreateMessage(Message.NotificationClass.WAS_RCPT);
this.Messages.Add(this._wasRcptMessage);
}
this.dataGridWasteReceipt.Initialize();
this.dataGridWasteReceipt.ItemsSource = this._wasRcptMessage.Elements;
this.dataGridWasteReceipt.AddingNewItem += DataGridWasteReceipt_AddingNewItem;
this.dataGridWasteReceipt.EditRequested += DataGridWasteReceipt_EditRequested;
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;
if (this._wasRcptMessage.Elements.Count > 0)
{
this.dataGridWasteReceipt.SelectedItem = this._wasRcptMessage.Elements[0];
this.dataGridWasteReceipt_SelectionChanged(null, null);
}
#endregion
}
public override void SetEnabled(bool enabled)
{
base.SetEnabled(enabled);
}
#endregion
#region event handler
private void WasteReceiptsControl_Loaded(object sender, RoutedEventArgs e)
{
this.dataGridWasteReceived.CellEditEnding += (obj, ev) => { this.SublistElementChanged(Message.NotificationClass.WAS_RCPT); };
}
private void buttonWasteReceivedAddMissingEntries_Click(object sender, RoutedEventArgs e)
{
if (this._selectedWAS_RCPT != null)
{
this._selectedWAS_RCPT.AddMissingWasteReceived();
this.SublistElementChanged(Message.NotificationClass.WAS_RCPT);
this.dataGridWasteReceived.Items.Refresh();
}
}
private void buttonCopyFromWAS_Click(object sender, RoutedEventArgs e)
{
if (_selectedWAS_RCPT == null) return;
if (MessageBox.Show(Properties.Resources.textCopyToWASConfirmation, Properties.Resources.textConfirmation,
MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
{
foreach (Waste waste in _was.Waste)
{
if (waste.WasteDisposalAmount_MTQ.HasValue && waste.WasteDisposalAmount_MTQ > 0)
{
// find matching WAS_RCPT entry
foreach (WasteReceived wasteReceived in _selectedWAS_RCPT.WasteReceived)
{
if (wasteReceived.WasteCode.Equals(waste.WasteType.ToString()))
{
wasteReceived.AmountWasteReceived_MTQ = waste.WasteDisposalAmount_MTQ;
break;
}
}
}
}
this.dataGridWasteReceived.Items.Refresh();
}
}
#endregion
#region Waste receipt grid event handler
private void DataGridWasteReceipt_CreateRequested()
{
EditWasteReceiptDialog epd = new EditWasteReceiptDialog();
epd.WAS_RCPT = new WAS_RCPT();
epd.WAS_RCPT.MessageHeader = _wasRcptMessage;
epd.WAS_RCPT.Identifier = WAS_RCPT.GetNewIdentifier(_wasRcptMessage.Elements);
epd.WAS_RCPT.AddMissingWasteReceived();
epd.AddClicked += () =>
{
epd.CopyValuesToEntity();
if (!this._wasRcptMessage.Elements.Contains(epd.WAS_RCPT))
this._wasRcptMessage.Elements.Add(epd.WAS_RCPT);
this.dataGridWasteReceipt.Items.Refresh();
epd.WAS_RCPT = new WAS_RCPT();
epd.WAS_RCPT.MessageHeader = _wasRcptMessage;
epd.WAS_RCPT.Identifier = WAS_RCPT.GetNewIdentifier(_wasRcptMessage.Elements);
epd.WAS_RCPT.AddMissingWasteReceived();
this.SublistElementChanged(Message.NotificationClass.WAS_RCPT);
};
if (epd.ShowDialog() ?? false)
{
if (!this._wasRcptMessage.Elements.Contains(epd.WAS_RCPT))
_wasRcptMessage.Elements.Add(epd.WAS_RCPT);
this.dataGridWasteReceipt.Items.Refresh();
this.dataGridWasteReceipt.SelectedItem = epd.WAS_RCPT;
this.SublistElementChanged(Message.NotificationClass.WAS_RCPT);
this.dataGridWasteReceived.ItemsSource = null;
dataGridWasteReceipt_SelectionChanged(this, null);
}
// await InitTemplates(); // templates might have changed in the dialog
}
private void DataGridWasteReceipt_DeleteRequested(DatabaseEntity obj)
{
if (obj is WAS_RCPT wasRCPT)
{
// are you sure dialog is in base class
_wasRcptMessage.Elements.Remove(wasRCPT);
wasRCPT.DeleteElements();
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(wasRCPT);
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;
}
}
private void DataGridWasteReceipt_EditRequested(DatabaseEntity obj)
{
EditWasteReceiptDialog epd = new EditWasteReceiptDialog();
epd.WAS_RCPT = obj as WAS_RCPT;
epd.AddClicked += () =>
{
epd.CopyValuesToEntity();
if (!_wasRcptMessage.Elements.Contains(epd.WAS_RCPT))
_wasRcptMessage.Elements.Add(epd.WAS_RCPT);
this.dataGridWasteReceipt.Items.Refresh();
epd.WAS_RCPT = new WAS_RCPT();
epd.WAS_RCPT.Identifier = WAS_RCPT.GetNewIdentifier(_wasRcptMessage.Elements);
epd.WAS_RCPT.MessageHeader = _wasRcptMessage;
epd.WAS_RCPT.AddMissingWasteReceived();
this.SublistElementChanged(Message.NotificationClass.WAS_RCPT);
};
if (epd.ShowDialog() ?? false)
{
if (!_wasRcptMessage.Elements.Contains(epd.WAS_RCPT))
_wasRcptMessage.Elements.Add(epd.WAS_RCPT);
}
this.dataGridWasteReceipt.SelectedItem = epd.WAS_RCPT;
this.dataGridWasteReceipt.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.WAS_RCPT);
dataGridWasteReceipt_SelectionChanged(this, null);
// await InitTemplates(); // templates might have changed in the dialog
}
private void DataGridWasteReceipt_AddingNewItem(object sender, AddingNewItemEventArgs e)
{
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)
{
this.dataGridWasteReceived.CancelEdit();
this.dataGridWasteReceived.CancelEdit();
// 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>(_selectedWAS_RCPT.WasteReceived));
this.SublistElementChanged(Message.NotificationClass.WAS_RCPT);
this.dataGridWasteReceived.Items.Refresh();
}
}
private void DataGridWasteReceived_CreateRequested()
{
if (_selectedWAS_RCPT == null) return;
this.dataGridWasteReceived.CancelEdit();
this.dataGridWasteReceived.CancelEdit();
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 ((ewrd.WasteReceived.WasteCode != null) && !this._selectedWAS_RCPT.WasteReceived.Any(wr => wr.WasteCode == ewrd.WasteReceived.WasteCode))
{
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 ((ewrd.WasteReceived.WasteCode != null) && !this._selectedWAS_RCPT.WasteReceived.Any(wr => wr.WasteCode == ewrd.WasteReceived.WasteCode))
{
this._selectedWAS_RCPT.WasteReceived.Add(ewrd.WasteReceived);
this.dataGridWasteReceived.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.WAS_RCPT);
}
}
}
private void DataGridWasteReceived_EditRequested(DatabaseEntity obj)
{
this.dataGridWasteReceived.CancelEdit();
this.dataGridWasteReceived.CancelEdit();
EditWasteReceivedDialog ewrd = new EditWasteReceivedDialog();
ewrd.WasteReceived = obj as WasteReceived;
ewrd.AddClicked += () =>
{
ewrd.CopyValuesToEntity();
if ((ewrd.WasteReceived.WasteCode != null) && !this._selectedWAS_RCPT.WasteReceived.Any(wr => wr.WasteCode == ewrd.WasteReceived.WasteCode))
{
_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 ((ewrd.WasteReceived.WasteCode != null) && !_selectedWAS_RCPT.WasteReceived.Any(wr => wr.WasteCode == ewrd.WasteReceived.WasteCode))
{
_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
}
}