added button to overwrite WAS_RCPT disposal values from WAS

This commit is contained in:
Daniel Schick 2023-07-18 07:56:26 +02:00
parent 73019a996d
commit 6e8fdb0d35
5 changed files with 58 additions and 2 deletions

View File

@ -182,10 +182,12 @@
</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">

View File

@ -684,5 +684,35 @@ namespace ENI2.DetailViewControls
#endregion
#region Copy WAS to WAS_RCPT handler
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
}
}

View File

@ -1613,6 +1613,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Copy from WAS.
/// </summary>
public static string textCopyFromWAS {
get {
return ResourceManager.GetString("textCopyFromWAS", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Copy IMO to clipboard.
/// </summary>
@ -1658,6 +1667,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Do you want to copy / overwrite disposal amounts using values from WAS?.
/// </summary>
public static string textCopyToWASConfirmation {
get {
return ResourceManager.GetString("textCopyToWASConfirmation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Copy TOWA to TOWD.
/// </summary>

View File

@ -1882,4 +1882,10 @@
<data name="textExcelValueMappings" xml:space="preserve">
<value>Excel import value mappings</value>
</data>
<data name="textCopyFromWAS" xml:space="preserve">
<value>Copy from WAS</value>
</data>
<data name="textCopyToWASConfirmation" xml:space="preserve">
<value>Do you want to copy / overwrite disposal amounts using values from WAS?</value>
</data>
</root>

View File

@ -97,8 +97,8 @@ namespace bsmd.database
public int CompareTo(object obj)
{
if (obj is WasteDisposalServiceProvider_Template)
this.Remark?.CompareTo(((WasteDisposalServiceProvider_Template)obj).Remark ?? "");
if (obj is WasteDisposalServiceProvider_Template template)
this.Remark?.CompareTo(template.Remark ?? "");
return 0;
}