Compare commits

...

2 Commits

6 changed files with 156 additions and 33 deletions

View File

@ -51,7 +51,7 @@
(yyyy-MM-ddTHH:mm:ss)" TextAlignment="Right" VerticalAlignment="Center" Margin="0,0,4,0"/> (yyyy-MM-ddTHH:mm:ss)" TextAlignment="Right" VerticalAlignment="Center" Margin="0,0,4,0"/>
<TextBox Text="{Binding ProofInformationT2LT2LF.DeclarationDate, StringFormat={}{0:yyyy-MM-ddTHH:mm:ss}, UpdateSourceTrigger=PropertyChanged}" Margin="2" VerticalContentAlignment="Center" /> <TextBox Text="{Binding ProofInformationT2LT2LF.DeclarationDate, StringFormat={}{0:yyyy-MM-ddTHH:mm:ss}, UpdateSourceTrigger=PropertyChanged}" Margin="2" VerticalContentAlignment="Center" />
<TextBlock Text="Gesamtrohmasse (kg)" TextAlignment="Right" VerticalAlignment="Center" Margin="0,0,4,0"/> <TextBlock Text="Gesamtrohmasse (kg)" TextAlignment="Right" VerticalAlignment="Center" Margin="0,0,4,0"/>
<TextBox Text="{Binding ProofInformationT2LT2LF.TotalGrossMassKg, UpdateSourceTrigger=PropertyChanged}" Margin="2" VerticalContentAlignment="Center"/> <TextBox x:Name="textBoxTotalGrossMass" Text="{Binding ProofInformationT2LT2LF.TotalGrossMassKg, UpdateSourceTrigger=PropertyChanged}" Margin="2" VerticalContentAlignment="Center"/>
<TextBlock TextWrapping="Wrap" Text="Antrag auf Gültigkeitsdauer des Nachweises (in Tagen)" TextAlignment="Right" VerticalAlignment="Center" Margin="0,0,4,0"/> <TextBlock TextWrapping="Wrap" Text="Antrag auf Gültigkeitsdauer des Nachweises (in Tagen)" TextAlignment="Right" VerticalAlignment="Center" Margin="0,0,4,0"/>
<TextBox Text="{Binding ProofInformationT2LT2LF.RequestedValidityOfTheProof.NumberOfDays, UpdateSourceTrigger=PropertyChanged}" Margin="2" VerticalContentAlignment="Center"/> <TextBox Text="{Binding ProofInformationT2LT2LF.RequestedValidityOfTheProof.NumberOfDays, UpdateSourceTrigger=PropertyChanged}" Margin="2" VerticalContentAlignment="Center"/>
@ -77,7 +77,7 @@
<TextBlock Text="Warenpositionen (Paste tab/CSV with columns: HS, Item#, Description, Gross, Net, Pkgs, Type, Marks)" Margin="4,12,0,4"/> <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}" <DataGrid ItemsSource="{Binding ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF}"
AutoGenerateColumns="False" SelectionMode="Extended" x:Name="dataGridGoodsItems" CanUserAddRows="False" AutoGenerateColumns="False" SelectionMode="Extended" x:Name="dataGridGoodsItems" CanUserAddRows="False"
PreviewKeyDown="DataGrid_PreviewKeyDown"> PreviewKeyDown="DataGrid_PreviewKeyDown" Focusable="True" MinHeight="80" IsTabStop="True" MaxHeight="320">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="HS Code" Binding="{Binding Commodity.HarmonizedSystemSubHeadingCode}"/> <DataGridTextColumn Header="HS Code" Binding="{Binding Commodity.HarmonizedSystemSubHeadingCode}"/>
<DataGridTextColumn Header="Item #" Binding="{Binding GoodsItemNumber}"/> <DataGridTextColumn Header="Item #" Binding="{Binding GoodsItemNumber}"/>

View File

@ -7,12 +7,15 @@ using ENI2.Util;
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Xml; using System.Xml;
@ -28,6 +31,8 @@ namespace ENI2.Controls
private ProofRequest _vm; private ProofRequest _vm;
#region Construction
public EasyPeasyControl() public EasyPeasyControl()
{ {
InitializeComponent(); InitializeComponent();
@ -46,7 +51,23 @@ namespace ENI2.Controls
deleteItem.Click += DeleteItem_Click; deleteItem.Click += DeleteItem_Click;
this.dataGridGoodsItems.ContextMenu.Items.Add(deleteItem); this.dataGridGoodsItems.ContextMenu.Items.Add(deleteItem);
} // Add separator and paste option
this.dataGridGoodsItems.ContextMenu.Items.Add(new Separator());
MenuItem pasteItem = new MenuItem();
pasteItem.Header = "Paste";
pasteItem.Click += (s, e) => HandlePasteOperation();
this.dataGridGoodsItems.ContextMenu.Items.Add(pasteItem);
// Add command bindings for proper keyboard handling
this.dataGridGoodsItems.CommandBindings.Add(new CommandBinding(
ApplicationCommands.Paste,
(s, e) => HandlePasteOperation(),
(s, e) => e.CanExecute = Clipboard.ContainsText()));
}
#endregion
public void SaveState() public void SaveState()
{ {
@ -87,11 +108,17 @@ namespace ENI2.Controls
private void buttonClear_Click(object sender, RoutedEventArgs e) private void buttonClear_Click(object sender, RoutedEventArgs e)
{ {
CleanupAutoCalculation();
this._vm = EasyPeasyState.CreateDefault(); this._vm = EasyPeasyState.CreateDefault();
if (_vm.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF?.GoodsItemsForT2LT2LF == null) if (_vm.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF?.GoodsItemsForT2LT2LF == null)
_vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF = new ObservableCollection<GoodsItemForT2LT2LF>(); _vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF = new ObservableCollection<GoodsItemForT2LT2LF>();
_vm.ProofInformationT2LT2LF.DeclarationDate = DateTime.Now; // reset to today
_vm.ProofInformationT2LT2LF.RequestedValidityOfTheProof.NumberOfDays = 90; // default 90 days
this.DataContext = this._vm; this.DataContext = this._vm;
SetupAutoCalculation();
} }
private void buttonExport_Click(object sender, RoutedEventArgs e) private void buttonExport_Click(object sender, RoutedEventArgs e)
@ -145,6 +172,7 @@ namespace ENI2.Controls
{ {
using (var fs = File.OpenRead(ofd.FileName)) using (var fs = File.OpenRead(ofd.FileName))
{ {
CleanupAutoCalculation();
var ser = new XmlSerializer(typeof(ProofRequest)); var ser = new XmlSerializer(typeof(ProofRequest));
_vm = (ProofRequest)ser.Deserialize(fs); _vm = (ProofRequest)ser.Deserialize(fs);
// after loading/creating _vm // after loading/creating _vm
@ -152,8 +180,11 @@ namespace ENI2.Controls
_vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF = new ObservableCollection<GoodsItemForT2LT2LF>(); _vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF = new ObservableCollection<GoodsItemForT2LT2LF>();
_vm.ProofInformationT2LT2LF.DeclarationDate = DateTime.Now; // reset to today _vm.ProofInformationT2LT2LF.DeclarationDate = DateTime.Now; // reset to today
if(_vm.ProofInformationT2LT2LF.RequestedValidityOfTheProof.NumberOfDays == 9)
_vm.ProofInformationT2LT2LF.RequestedValidityOfTheProof.NumberOfDays = 90; // default 90 days
this.DataContext = _vm; this.DataContext = _vm;
SetupAutoCalculation();
} }
} }
} }
@ -175,10 +206,14 @@ namespace ENI2.Controls
}; };
_vm.ProofInformationT2LT2LF.DeclarationDate = DateTime.Now; // reset to today _vm.ProofInformationT2LT2LF.DeclarationDate = DateTime.Now; // reset to today
this.DataContext = _vm; this.DataContext = _vm;
SetupAutoCalculation();
} }
private void UserControl_Unloaded(object sender, RoutedEventArgs e) private void UserControl_Unloaded(object sender, RoutedEventArgs e)
{ {
CleanupAutoCalculation();
try try
{ {
EasyPeasyState.Save(_vm); EasyPeasyState.Save(_vm);
@ -188,8 +223,95 @@ namespace ENI2.Controls
#endregion #endregion
#region auto calculation total gross mass
private void SetupAutoCalculation()
{
if (_vm?.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF?.GoodsItemsForT2LT2LF != null)
{
// Subscribe to collection changes (add/remove items)
_vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF.CollectionChanged += GoodsItems_CollectionChanged;
// Subscribe to DataGrid cell changes
dataGridGoodsItems.CellEditEnding += DataGridGoodsItems_CellEditEnding;
// Calculate initial total
CalculateTotalGrossMass();
}
}
private void CleanupAutoCalculation()
{
if (_vm?.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF?.GoodsItemsForT2LT2LF != null)
{
// Unsubscribe from collection changes
_vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF.CollectionChanged -= GoodsItems_CollectionChanged;
dataGridGoodsItems.CellEditEnding -= DataGridGoodsItems_CellEditEnding;
}
}
private void DataGridGoodsItems_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
// Check if the edited column is GrossMass
if (e.Column.Header.ToString() == "Gross")
{
// Delay calculation to allow the binding to update
Dispatcher.BeginInvoke(new Action(() => {
CalculateTotalGrossMass();
}), System.Windows.Threading.DispatcherPriority.Background);
}
}
private void GoodsItems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
// Recalculate total after any collection change
CalculateTotalGrossMass();
}
private void CalculateTotalGrossMass()
{
if (_vm?.ProofInformationT2LT2LF?.GoodsShipmentForT2LT2LF?.GoodsItemsForT2LT2LF != null)
{
var total = _vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF
.Sum(item => item.GoodsMeasure?.GrossMass ?? 0m);
_vm.ProofInformationT2LT2LF.TotalGrossMassKg = total;
// Force UI update by refreshing the binding
var binding = BindingOperations.GetBindingExpression(
FindTotalGrossMassTextBox(), TextBox.TextProperty);
binding?.UpdateTarget();
}
}
// Simple property changed notification helper
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private TextBox FindTotalGrossMassTextBox()
{
// Find the TextBox that displays TotalGrossMassKg
return this.FindName("textBoxTotalGrossMass") as TextBox ??
this.GetTemplateChild("textBoxTotalGrossMass") as TextBox;
}
#endregion
#region cut & paste logic #region cut & paste logic
private void HandlePasteOperation()
{
if (Clipboard.ContainsText())
{
var text = Clipboard.GetText();
if (!TryPaste_EspHsPkgsGross(text))
PasteGoodsItems(text);
}
}
private void DataGrid_PreviewKeyDown(object sender, KeyEventArgs e) private void DataGrid_PreviewKeyDown(object sender, KeyEventArgs e)
{ {
if (e.Key == Key.V && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) if (e.Key == Key.V && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
@ -228,7 +350,7 @@ namespace ENI2.Controls
if (cells.Length > 4 && decimal.TryParse(cells[4], out var net)) item.GoodsMeasure.NetMass = net; if (cells.Length > 4 && decimal.TryParse(cells[4], out var net)) item.GoodsMeasure.NetMass = net;
if (cells.Length > 5 && int.TryParse(cells[5], out var pkgs)) item.Packaging.NumberOfPackages = pkgs; if (cells.Length > 5 && int.TryParse(cells[5], out var pkgs)) item.Packaging.NumberOfPackages = pkgs;
if (cells.Length > 6) item.Packaging.TypeOfPackages = cells[6].Trim(); if (cells.Length > 6) item.Packaging.TypeOfPackages = cells[6].Trim();
if (cells.Length > 7) item.Packaging.ShippingMarks = cells[7].Trim(); if (cells.Length > 7) item.Packaging.ShippingMarks = cells[7].Trim();
_vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF.Add(item); _vm.ProofInformationT2LT2LF.GoodsShipmentForT2LT2LF.GoodsItemsForT2LT2LF.Add(item);
} }
@ -333,7 +455,7 @@ namespace ENI2.Controls
item.DescriptionOfGoods = "Brand New Vehicles"; // per spec item.DescriptionOfGoods = "Brand New Vehicles"; // per spec
item.Packaging.TypeOfPackages = "UN"; // per spec item.Packaging.TypeOfPackages = "UN"; // per spec
item.Packaging.ShippingMarks = "-"; // per spec item.Packaging.ShippingMarks = "-"; // per spec
list.Add(item); list.Add(item);
anyAdded = true; anyAdded = true;

View File

@ -527,9 +527,14 @@ namespace ENI2
{ {
if ((message.Status == Message.MessageStatus.ACCEPTED) && if ((message.Status == Message.MessageStatus.ACCEPTED) &&
((message.InternalStatus == Message.BSMDStatus.CONFIRMED) || (message.InternalStatus == Message.BSMDStatus.VIOLATION))) ((message.InternalStatus == Message.BSMDStatus.CONFIRMED) || (message.InternalStatus == Message.BSMDStatus.VIOLATION)))
{
message.InternalStatus = Message.BSMDStatus.UPDATED; message.InternalStatus = Message.BSMDStatus.UPDATED;
message.Status = null; // reset send status
}
else else
{
message.InternalStatus = Message.BSMDStatus.SAVED; message.InternalStatus = Message.BSMDStatus.SAVED;
}
string userName = "?"; string userName = "?";
if(App.UserId.HasValue && DBManager.Instance.GetReportingPartyDict().ContainsKey(App.UserId.Value)) if(App.UserId.HasValue && DBManager.Instance.GetReportingPartyDict().ContainsKey(App.UserId.Value))

View File

@ -69,6 +69,9 @@ namespace ENI2.DetailViewControls
this.RegisterTextboxChange(this.textBox_AgentStreetAndNumber, Message.NotificationClass.AGNT); this.RegisterTextboxChange(this.textBox_AgentStreetAndNumber, Message.NotificationClass.AGNT);
this.RegisterTextboxChange(this.textBox_AgentCountry, Message.NotificationClass.AGNT); this.RegisterTextboxChange(this.textBox_AgentCountry, Message.NotificationClass.AGNT);
// WAS
this.RegisterTextboxChange(this.textBox_WasteDisposalServiceProvider, Message.NotificationClass.WAS);
this.buttonSaveTemplate.IsEnabled = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor; this.buttonSaveTemplate.IsEnabled = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor;
this.buttonDeleteTemplate.IsEnabled = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor; this.buttonDeleteTemplate.IsEnabled = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor;
} }
@ -253,7 +256,7 @@ namespace ENI2.DetailViewControls
} }
} }
#endregion #endregion
#region AGNT templates combo #region AGNT templates combo
@ -281,7 +284,7 @@ namespace ENI2.DetailViewControls
DBManager.Instance.Delete(_currentTemplate); DBManager.Instance.Delete(_currentTemplate);
_agntTemplates.Remove(_currentTemplate); _agntTemplates.Remove(_currentTemplate);
this.textBoxTemplateTitle.Text = null; this.textBoxTemplateTitle.Text = null;
this.buttonDeleteTemplate.IsEnabled = false; this.buttonDeleteTemplate.IsEnabled = false;
this.comboBox_AgentTemplate.ItemsSource = _agntTemplates; this.comboBox_AgentTemplate.ItemsSource = _agntTemplates;
this.buttonSetTemplate.IsEnabled = false; this.buttonSetTemplate.IsEnabled = false;
} }
@ -352,7 +355,6 @@ namespace ENI2.DetailViewControls
this.textBox_AgentStreetAndNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_AgentStreetAndNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_WasteDisposalServiceProvider.Text = this._undoTemplate.WasteDisposalServiceProviderName; this.textBox_WasteDisposalServiceProvider.Text = this._undoTemplate.WasteDisposalServiceProviderName;
this.textBox_WasteDisposalServiceProvider.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_WasteDisposalServiceProvider.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.SublistElementChanged(Message.NotificationClass.WAS);
this.buttonUndoTemplate.IsEnabled = false; // can't undo after undo this.buttonUndoTemplate.IsEnabled = false; // can't undo after undo
} }
@ -379,7 +381,7 @@ namespace ENI2.DetailViewControls
this.textBox_AgentEMail.Text = this._currentTemplate.AgentEMail; this.textBox_AgentEMail.Text = this._currentTemplate.AgentEMail;
this.textBox_AgentEMail.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_AgentEMail.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentFax.Text = this._currentTemplate.AgentFax; this.textBox_AgentFax.Text = this._currentTemplate.AgentFax;
this.textBox_AgentFax.GetBindingExpression (TextBox.TextProperty).UpdateSource(); this.textBox_AgentFax.GetBindingExpression (TextBox.TextProperty).UpdateSource();
this.textBox_AgentFirstName.Text = this._currentTemplate.AgentFirstName; this.textBox_AgentFirstName.Text = this._currentTemplate.AgentFirstName;
this.textBox_AgentFirstName.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_AgentFirstName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentLastName.Text = this._currentTemplate.AgentLastName; this.textBox_AgentLastName.Text = this._currentTemplate.AgentLastName;
@ -390,11 +392,10 @@ namespace ENI2.DetailViewControls
this.textBox_AgentPostalCode.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_AgentPostalCode.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentStreetAndNumber.Text = this._currentTemplate.AgentStreetAndNumber; this.textBox_AgentStreetAndNumber.Text = this._currentTemplate.AgentStreetAndNumber;
this.textBox_AgentStreetAndNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_AgentStreetAndNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if ((this._currentTemplate.WasteDisposalServiceProviderName ?? "") != this.textBox_WasteDisposalServiceProvider.Text) if ((this._currentTemplate.WasteDisposalServiceProviderName ?? "").Trim() != (this.textBox_WasteDisposalServiceProvider.Text ?? "").Trim())
{ {
this.textBox_WasteDisposalServiceProvider.Text = this._currentTemplate.WasteDisposalServiceProviderName; this.textBox_WasteDisposalServiceProvider.Text = this._currentTemplate.WasteDisposalServiceProviderName;
this.textBox_WasteDisposalServiceProvider.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_WasteDisposalServiceProvider.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.SublistElementChanged(Message.NotificationClass.WAS);
} }
this.buttonUndoTemplate.IsEnabled = true; this.buttonUndoTemplate.IsEnabled = true;
@ -409,7 +410,7 @@ namespace ENI2.DetailViewControls
AGNT_Template at = new AGNT_Template(); AGNT_Template at = new AGNT_Template();
if (existingTemplate != null) if (existingTemplate != null)
at = existingTemplate; at = existingTemplate;
at.AgentTitle = title; at.AgentTitle = title;
at.AgentCity = this.textBox_AgentCity.Text; at.AgentCity = this.textBox_AgentCity.Text;
at.AgentCompanyName = this.textBox_AgentCompanyName.Text; at.AgentCompanyName = this.textBox_AgentCompanyName.Text;
@ -427,6 +428,6 @@ namespace ENI2.DetailViewControls
} }
#endregion #endregion
} }
} }

View File

@ -15,6 +15,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ENI2.Excel namespace ENI2.Excel
@ -1699,14 +1700,9 @@ namespace ENI2.Excel
if (sLevel.Contains('3')) l10fc.PortFacilityShipSecurityLevel = 3; if (sLevel.Contains('3')) l10fc.PortFacilityShipSecurityLevel = 3;
} }
l10fc.PortFacilityGISISCode = reader.ReadCellAsText(sheetTitle, string.Format("J{0}", 54 + i), 4); string s = reader.ReadCellAsText(sheetTitle, string.Format("J{0}", 54 + i), 4);
// All invalid codes become "0000", Oct/25
if (l10fc.PortFacilityGISISCode.IsNullOrEmpty() || l10fc.PortFacilityGISISCode == "0") l10fc.PortFacilityGISISCode = (s != null) && Regex.IsMatch(s.Trim(), @"^\d{4}$") ? s.Trim() : "0000";
l10fc.PortFacilityGISISCode = "0000";
if (l10fc.PortFacilityGISISCode?.Length < 4)
{
while (l10fc.PortFacilityGISISCode.Length < 4) l10fc.PortFacilityGISISCode = "0" + l10fc.PortFacilityGISISCode;
}
l10fc.PortFacilitySecurityMattersToReport = reader.ReadCellAsText(sheetTitle, string.Format("K{0}", 54 + i), 255); l10fc.PortFacilitySecurityMattersToReport = reader.ReadCellAsText(sheetTitle, string.Format("K{0}", 54 + i), 255);

View File

@ -32,7 +32,7 @@ namespace ENI2.SheetDisplayControls
private AGNT _agnt; private AGNT _agnt;
private SEC _sec; private SEC _sec;
private WAS _was; private WAS _was;
private Message _stoMessage; private Message _stoMessage;
private Dictionary<string, string> portAreas = null; private Dictionary<string, string> portAreas = null;
@ -43,7 +43,7 @@ namespace ENI2.SheetDisplayControls
private static List<SERV_Template> _servTemplates = null; private static List<SERV_Template> _servTemplates = null;
private SERV_Template _currentSERVTemplate; private SERV_Template _currentSERVTemplate;
private static List<WasteDisposalServiceProvider_Template> _wsdpTemplates = null; private static List<WasteDisposalServiceProvider_Template> _wsdpTemplates = null;
private WasteDisposalServiceProvider_Template _currentWSDPTemplate; private WasteDisposalServiceProvider_Template _currentWSDPTemplate;
private string _undoWSDPTemplate; private string _undoWSDPTemplate;
@ -81,11 +81,11 @@ namespace ENI2.SheetDisplayControls
{ {
base.Initialize(); base.Initialize();
foreach (Message aMessage in this.Messages) foreach (Message aMessage in this.Messages)
{ {
if (aMessage.MessageNotificationClass == Message.NotificationClass.LADG) { this._ladgMessage = aMessage; this.ControlMessages.Add(aMessage); } 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.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.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.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.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.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.AGNT) { this._agnt = aMessage.Elements[0] as AGNT; this.ControlMessages.Add(aMessage); }
@ -105,7 +105,7 @@ namespace ENI2.SheetDisplayControls
this.dataGridCallPurposes.AddingNewItem += DataGridCallPurposes_AddingNewItem; this.dataGridCallPurposes.AddingNewItem += DataGridCallPurposes_AddingNewItem;
this.dataGridCallPurposes.CreateRequested += DataGridCallPurposes_CreateRequested; this.dataGridCallPurposes.CreateRequested += DataGridCallPurposes_CreateRequested;
this.dataGridCallPurposes.DeleteRequested += DataGridCallPurposes_DeleteRequested; this.dataGridCallPurposes.DeleteRequested += DataGridCallPurposes_DeleteRequested;
portAreas = LocalizedLookup.getPortAreasForLocode(this.Core.PoC); portAreas = LocalizedLookup.getPortAreasForLocode(this.Core.PoC);
this.comboBoxPortArea.ItemsSource = portAreas; this.comboBoxPortArea.ItemsSource = portAreas;
this.comboBoxPortArea.DataContext = this._info; this.comboBoxPortArea.DataContext = this._info;
@ -264,6 +264,7 @@ namespace ENI2.SheetDisplayControls
this.RegisterTextboxChange(this.textBox_AgentPostalCode, Message.NotificationClass.AGNT); this.RegisterTextboxChange(this.textBox_AgentPostalCode, Message.NotificationClass.AGNT);
this.RegisterTextboxChange(this.textBox_AgentStreetAndNumber, Message.NotificationClass.AGNT); this.RegisterTextboxChange(this.textBox_AgentStreetAndNumber, Message.NotificationClass.AGNT);
this.RegisterTextboxChange(this.textBox_AgentCountry, Message.NotificationClass.AGNT); this.RegisterTextboxChange(this.textBox_AgentCountry, Message.NotificationClass.AGNT);
this.RegisterTextboxChange(this.textBox_WasteDisposalServiceProvider, Message.NotificationClass.WAS);
this.buttonSaveTemplate.IsEnabled = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor; this.buttonSaveTemplate.IsEnabled = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor;
this.buttonDeleteTemplate.IsEnabled = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor; this.buttonDeleteTemplate.IsEnabled = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor;
@ -283,7 +284,7 @@ namespace ENI2.SheetDisplayControls
this.RegisterLocodeChange(this.locodeCtrlNextWastePort, Message.NotificationClass.WAS); this.RegisterLocodeChange(this.locodeCtrlNextWastePort, Message.NotificationClass.WAS);
this.RegisterTextboxChange(this.textBoxWasteDisposalServiceProviders, Message.NotificationClass.WAS); this.RegisterTextboxChange(this.textBoxWasteDisposalServiceProviders, Message.NotificationClass.WAS);
this.RegisterDatePickerChange(this.datePickerDateLastDisposal, Message.NotificationClass.WAS); this.RegisterDatePickerChange(this.datePickerDateLastDisposal, Message.NotificationClass.WAS);
} }
private void CheckBoxValidExemption_Checked(object sender, RoutedEventArgs e) private void CheckBoxValidExemption_Checked(object sender, RoutedEventArgs e)
@ -367,11 +368,10 @@ namespace ENI2.SheetDisplayControls
this.textBox_AgentPostalCode.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_AgentPostalCode.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_AgentStreetAndNumber.Text = this._currentTemplate.AgentStreetAndNumber; this.textBox_AgentStreetAndNumber.Text = this._currentTemplate.AgentStreetAndNumber;
this.textBox_AgentStreetAndNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_AgentStreetAndNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if (this._currentTemplate.WasteDisposalServiceProviderName != this.textBox_WasteDisposalServiceProvider.Text) if ((this._currentTemplate.WasteDisposalServiceProviderName ?? "").Trim() != (this.textBox_WasteDisposalServiceProvider.Text ?? "").Trim())
{ {
this.textBox_WasteDisposalServiceProvider.Text = this._currentTemplate.WasteDisposalServiceProviderName; this.textBox_WasteDisposalServiceProvider.Text = this._currentTemplate.WasteDisposalServiceProviderName;
this.textBox_WasteDisposalServiceProvider.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_WasteDisposalServiceProvider.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.SublistElementChanged(Message.NotificationClass.WAS);
} }
this.buttonUndoTemplate.IsEnabled = true; this.buttonUndoTemplate.IsEnabled = true;
@ -462,7 +462,6 @@ namespace ENI2.SheetDisplayControls
this.textBox_AgentStreetAndNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_AgentStreetAndNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.textBox_WasteDisposalServiceProvider.Text = this._undoTemplate.WasteDisposalServiceProviderName; this.textBox_WasteDisposalServiceProvider.Text = this._undoTemplate.WasteDisposalServiceProviderName;
this.textBox_WasteDisposalServiceProvider.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_WasteDisposalServiceProvider.GetBindingExpression(TextBox.TextProperty).UpdateSource();
this.SublistElementChanged(Message.NotificationClass.WAS);
this.buttonUndoTemplate.IsEnabled = false; // can't undo after undo this.buttonUndoTemplate.IsEnabled = false; // can't undo after undo
} }
@ -613,7 +612,7 @@ namespace ENI2.SheetDisplayControls
stream.Close(); stream.Close();
} }
} }
#endregion #endregion
@ -732,7 +731,7 @@ namespace ENI2.SheetDisplayControls
this.dataGridSERV.Items.Refresh(); this.dataGridSERV.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.SERV); this.SublistElementChanged(Message.NotificationClass.SERV);
} }
} }
#endregion #endregion