Refined the Easy Peasy Control with feedback from Christin

This commit is contained in:
Daniel Schick 2025-10-10 09:57:49 +02:00
parent 1d44b156f4
commit 46ca051331
3 changed files with 54 additions and 8 deletions

View File

@ -76,7 +76,7 @@
<!-- Goods Items grid (paste target) -->
<TextBlock Text="Warenpositionen (Paste tab/CSV with columns: HS, Item#, Description, Gross, Net, Pkgs, Type, Marks)" Margin="4,12,0,4"/>
<DataGrid ItemsSource="{Binding ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF}"
AutoGenerateColumns="False" CanUserAddRows="True"
AutoGenerateColumns="False" SelectionMode="Extended" x:Name="dataGridGoodsItems" CanUserAddRows="False"
PreviewKeyDown="DataGrid_PreviewKeyDown">
<DataGrid.Columns>
<DataGridTextColumn Header="HS Code" Binding="{Binding Commodity.HarmonizedSystemSubHeadingCode}"/>

View File

@ -14,6 +14,7 @@ using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using System.Xml;
using System.Xml.Serialization;
@ -30,6 +31,21 @@ namespace ENI2.Controls
public EasyPeasyControl()
{
InitializeComponent();
this.dataGridGoodsItems.ContextMenu = new ContextMenu();
MenuItem addItem = new MenuItem();
addItem.Header = Properties.Resources.textAdd;
addItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/add.png")) };
addItem.Click += AddItem_Click;
this.dataGridGoodsItems.ContextMenu.Items.Add(addItem);
MenuItem deleteItem = new MenuItem();
deleteItem.Header = Properties.Resources.textDelete;
deleteItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/delete.png")) };
deleteItem.Click += DeleteItem_Click;
this.dataGridGoodsItems.ContextMenu.Items.Add(deleteItem);
}
public void SaveState()
@ -41,6 +57,32 @@ namespace ENI2.Controls
catch { }
}
#region context menu event handler
private void AddItem_Click(object sender, RoutedEventArgs e)
{
if (_vm?.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF?.GoodsItemsForT2LT2LF == null) return;
var list = _vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF;
int nextItemNo = list.Any() ? list.Max(x => x.GoodsItemNumber) + 1 : 1;
var item = new GoodsItemForT2LT2LF
{
GoodsItemNumber = nextItemNo
};
list.Add(item);
}
private void DeleteItem_Click(object sender, RoutedEventArgs e)
{
foreach(GoodsItemForT2LT2LF item in this.dataGridGoodsItems.SelectedItems.Cast<GoodsItemForT2LT2LF>().ToArray())
{
if (_vm?.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF?.GoodsItemsForT2LT2LF == null) return;
var list = _vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF;
list.Remove(item);
}
}
#endregion
#region button event handler
private void buttonClear_Click(object sender, RoutedEventArgs e)
@ -109,6 +151,7 @@ namespace ENI2.Controls
if (_vm.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF?.GoodsItemsForT2LT2LF == null)
_vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF = new ObservableCollection<GoodsItemForT2LT2LF>();
_vm.ProofInformationT2LT2LF.DeclarationDate = DateTime.Now; // reset to today
this.DataContext = _vm;
}
@ -130,6 +173,7 @@ namespace ENI2.Controls
LocationOfGoods = new LocationOfGoods(),
TransportDocuments = new TransportDocuments()
};
_vm.ProofInformationT2LT2LF.DeclarationDate = DateTime.Now; // reset to today
this.DataContext = _vm;
}
@ -287,6 +331,10 @@ namespace ENI2.Controls
item.GoodsMeasure.NetMass = net;
}
item.DescriptionOfGoods = "Brand New Vehicles"; // per spec
item.Packaging.TypeOfPackages = "UN"; // per spec
item.Packaging.ShippingMarks = "-"; // per spec
list.Add(item);
anyAdded = true;
}

View File

@ -7,7 +7,6 @@ using ENI2.EditControls;
using ExcelDataReader;
using Microsoft.Win32;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@ -34,7 +33,6 @@ namespace ENI2.SheetDisplayControls
private SEC _sec;
private WAS _was;
private Message _stoMessage;
// private Message _crewMessage;
private Dictionary<string, string> portAreas = null;