From 3735735ef717eb222ae837794629ca8f8487fafc Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Wed, 22 Oct 2025 09:48:29 +0200 Subject: [PATCH] Error correction fixes --- .../PortCallDetailControl.xaml.cs | 17 ++++++++------- ENI2/Excel/ExcelUtil.cs | 12 ++++------- ENI2/SheetDisplayControls/PortControl.xaml.cs | 21 +++++++++---------- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs b/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs index 33cbce41..2a2e9a5e 100644 --- a/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs +++ b/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs @@ -69,6 +69,9 @@ namespace ENI2.DetailViewControls this.RegisterTextboxChange(this.textBox_AgentStreetAndNumber, 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.buttonDeleteTemplate.IsEnabled = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor; } @@ -253,7 +256,7 @@ namespace ENI2.DetailViewControls } } - #endregion + #endregion #region AGNT templates combo @@ -281,7 +284,7 @@ namespace ENI2.DetailViewControls DBManager.Instance.Delete(_currentTemplate); _agntTemplates.Remove(_currentTemplate); this.textBoxTemplateTitle.Text = null; - this.buttonDeleteTemplate.IsEnabled = false; + this.buttonDeleteTemplate.IsEnabled = false; this.comboBox_AgentTemplate.ItemsSource = _agntTemplates; this.buttonSetTemplate.IsEnabled = false; } @@ -352,7 +355,6 @@ namespace ENI2.DetailViewControls this.textBox_AgentStreetAndNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_WasteDisposalServiceProvider.Text = this._undoTemplate.WasteDisposalServiceProviderName; this.textBox_WasteDisposalServiceProvider.GetBindingExpression(TextBox.TextProperty).UpdateSource(); - this.SublistElementChanged(Message.NotificationClass.WAS); 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.GetBindingExpression(TextBox.TextProperty).UpdateSource(); 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.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_AgentLastName.Text = this._currentTemplate.AgentLastName; @@ -390,11 +392,10 @@ namespace ENI2.DetailViewControls this.textBox_AgentPostalCode.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_AgentStreetAndNumber.Text = this._currentTemplate.AgentStreetAndNumber; 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.GetBindingExpression(TextBox.TextProperty).UpdateSource(); - this.SublistElementChanged(Message.NotificationClass.WAS); } this.buttonUndoTemplate.IsEnabled = true; @@ -409,7 +410,7 @@ namespace ENI2.DetailViewControls AGNT_Template at = new AGNT_Template(); if (existingTemplate != null) at = existingTemplate; - + at.AgentTitle = title; at.AgentCity = this.textBox_AgentCity.Text; at.AgentCompanyName = this.textBox_AgentCompanyName.Text; @@ -427,6 +428,6 @@ namespace ENI2.DetailViewControls } #endregion - + } } diff --git a/ENI2/Excel/ExcelUtil.cs b/ENI2/Excel/ExcelUtil.cs index ae7c9913..60966356 100644 --- a/ENI2/Excel/ExcelUtil.cs +++ b/ENI2/Excel/ExcelUtil.cs @@ -15,6 +15,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Reflection; +using System.Text.RegularExpressions; using System.Threading.Tasks; namespace ENI2.Excel @@ -1699,14 +1700,9 @@ namespace ENI2.Excel if (sLevel.Contains('3')) l10fc.PortFacilityShipSecurityLevel = 3; } - l10fc.PortFacilityGISISCode = reader.ReadCellAsText(sheetTitle, string.Format("J{0}", 54 + i), 4); - - if (l10fc.PortFacilityGISISCode.IsNullOrEmpty() || l10fc.PortFacilityGISISCode == "0") - l10fc.PortFacilityGISISCode = "0000"; - if (l10fc.PortFacilityGISISCode?.Length < 4) - { - while (l10fc.PortFacilityGISISCode.Length < 4) l10fc.PortFacilityGISISCode = "0" + l10fc.PortFacilityGISISCode; - } + string s = reader.ReadCellAsText(sheetTitle, string.Format("J{0}", 54 + i), 4); + // All invalid codes become "0000", Oct/25 + l10fc.PortFacilityGISISCode = (s != null) && Regex.IsMatch(s.Trim(), @"^\d{4}$") ? s.Trim() : "0000"; l10fc.PortFacilitySecurityMattersToReport = reader.ReadCellAsText(sheetTitle, string.Format("K{0}", 54 + i), 255); diff --git a/ENI2/SheetDisplayControls/PortControl.xaml.cs b/ENI2/SheetDisplayControls/PortControl.xaml.cs index ddcef7cc..edd2f6e5 100644 --- a/ENI2/SheetDisplayControls/PortControl.xaml.cs +++ b/ENI2/SheetDisplayControls/PortControl.xaml.cs @@ -32,7 +32,7 @@ namespace ENI2.SheetDisplayControls private AGNT _agnt; private SEC _sec; private WAS _was; - private Message _stoMessage; + private Message _stoMessage; private Dictionary portAreas = null; @@ -43,7 +43,7 @@ namespace ENI2.SheetDisplayControls private static List _servTemplates = null; private SERV_Template _currentSERVTemplate; - private static List _wsdpTemplates = null; + private static List _wsdpTemplates = null; private WasteDisposalServiceProvider_Template _currentWSDPTemplate; private string _undoWSDPTemplate; @@ -81,11 +81,11 @@ namespace ENI2.SheetDisplayControls { base.Initialize(); foreach (Message aMessage in this.Messages) - { + { 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.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.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); } @@ -105,7 +105,7 @@ namespace ENI2.SheetDisplayControls this.dataGridCallPurposes.AddingNewItem += DataGridCallPurposes_AddingNewItem; this.dataGridCallPurposes.CreateRequested += DataGridCallPurposes_CreateRequested; this.dataGridCallPurposes.DeleteRequested += DataGridCallPurposes_DeleteRequested; - + portAreas = LocalizedLookup.getPortAreasForLocode(this.Core.PoC); this.comboBoxPortArea.ItemsSource = portAreas; this.comboBoxPortArea.DataContext = this._info; @@ -264,6 +264,7 @@ namespace ENI2.SheetDisplayControls this.RegisterTextboxChange(this.textBox_AgentPostalCode, Message.NotificationClass.AGNT); this.RegisterTextboxChange(this.textBox_AgentStreetAndNumber, 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.buttonDeleteTemplate.IsEnabled = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor; @@ -283,7 +284,7 @@ namespace ENI2.SheetDisplayControls this.RegisterLocodeChange(this.locodeCtrlNextWastePort, Message.NotificationClass.WAS); this.RegisterTextboxChange(this.textBoxWasteDisposalServiceProviders, Message.NotificationClass.WAS); this.RegisterDatePickerChange(this.datePickerDateLastDisposal, Message.NotificationClass.WAS); - + } private void CheckBoxValidExemption_Checked(object sender, RoutedEventArgs e) @@ -367,11 +368,10 @@ namespace ENI2.SheetDisplayControls this.textBox_AgentPostalCode.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_AgentStreetAndNumber.Text = this._currentTemplate.AgentStreetAndNumber; 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.GetBindingExpression(TextBox.TextProperty).UpdateSource(); - this.SublistElementChanged(Message.NotificationClass.WAS); } this.buttonUndoTemplate.IsEnabled = true; @@ -462,7 +462,6 @@ namespace ENI2.SheetDisplayControls this.textBox_AgentStreetAndNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.textBox_WasteDisposalServiceProvider.Text = this._undoTemplate.WasteDisposalServiceProviderName; this.textBox_WasteDisposalServiceProvider.GetBindingExpression(TextBox.TextProperty).UpdateSource(); - this.SublistElementChanged(Message.NotificationClass.WAS); this.buttonUndoTemplate.IsEnabled = false; // can't undo after undo } @@ -613,7 +612,7 @@ namespace ENI2.SheetDisplayControls stream.Close(); } - } + } #endregion @@ -732,7 +731,7 @@ namespace ENI2.SheetDisplayControls this.dataGridSERV.Items.Refresh(); this.SublistElementChanged(Message.NotificationClass.SERV); } - } + } #endregion