diff --git a/ENI2/Controls/ENIDataGrid.cs b/ENI2/Controls/ENIDataGrid.cs index feeab8c1..fde19681 100644 --- a/ENI2/Controls/ENIDataGrid.cs +++ b/ENI2/Controls/ENIDataGrid.cs @@ -119,7 +119,7 @@ namespace ENI2.Controls { var grid = sender as ENIDataGrid; if (Key.Delete == e.Key) - this.deleteItem(null, null); + this.deleteItem(null, null); } } diff --git a/ENI2/Controls/EditWindowBase.cs b/ENI2/Controls/EditWindowBase.cs index 0f287dcb..29790786 100644 --- a/ENI2/Controls/EditWindowBase.cs +++ b/ENI2/Controls/EditWindowBase.cs @@ -109,6 +109,7 @@ namespace ENI2.Controls thePicker.Value = new DateTime(year, month, day, hour, minute, 0); } catch (FormatException) { } + catch (ArgumentOutOfRangeException) { thePicker.Value = null; } } } @@ -121,10 +122,11 @@ namespace ENI2.Controls string timevalText = rd.Match(thePicker.Text).Captures[0].Value; int day = Int32.Parse(timevalText.Substring(0, 2)); int month = Int32.Parse(timevalText.Substring(2, 2)); - int year = Int32.Parse(timevalText.Substring(4, 4)); + int year = Int32.Parse(timevalText.Substring(4, 4)); thePicker.SelectedDate = new DateTime(year, month, day, 0, 0, 0); } catch (FormatException) { } + catch (ArgumentOutOfRangeException) { thePicker.SelectedDate = null; } } } diff --git a/ENI2/Controls/ReportingPartyControl.xaml b/ENI2/Controls/ReportingPartyControl.xaml index 2058f9a3..24a75514 100644 --- a/ENI2/Controls/ReportingPartyControl.xaml +++ b/ENI2/Controls/ReportingPartyControl.xaml @@ -20,6 +20,7 @@ + diff --git a/ENI2/Controls/ReportingPartyControl.xaml.cs b/ENI2/Controls/ReportingPartyControl.xaml.cs index 368ac39b..f916d83a 100644 --- a/ENI2/Controls/ReportingPartyControl.xaml.cs +++ b/ENI2/Controls/ReportingPartyControl.xaml.cs @@ -59,7 +59,7 @@ namespace ENI2.Controls DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(selectedParty); } } - } + } } #region grid event handler @@ -98,13 +98,13 @@ namespace ENI2.Controls { ReportingParty rp = new ReportingParty(); EditReportingPartyDialog ebd = new EditReportingPartyDialog(); - ebd.ReportingParty = rp; + ebd.ReportingParty = rp; if (ebd.ShowDialog() ?? false) { DBManager.Instance.GetReportingPartyDict().Add(Guid.NewGuid(), rp); this.ReportingParties.Add(rp); - this.dataGridReportingParties.Items.Refresh(); + this.dataGridReportingParties.Items.Refresh(); } } diff --git a/ENI2/DetailBaseControl.cs b/ENI2/DetailBaseControl.cs index 70ecc986..1414ff28 100644 --- a/ENI2/DetailBaseControl.cs +++ b/ENI2/DetailBaseControl.cs @@ -298,7 +298,9 @@ namespace ENI2 int year = Int32.Parse(timevalText.Substring(4, 4)); thePicker.SelectedDate = new DateTime(year, month, day, 0, 0, 0); } - catch (FormatException) { } + catch (Exception) { + thePicker.SelectedDate = null; + } } } diff --git a/ENI2/DetailRootControl.xaml.cs b/ENI2/DetailRootControl.xaml.cs index ecb7c037..c73543d5 100644 --- a/ENI2/DetailRootControl.xaml.cs +++ b/ENI2/DetailRootControl.xaml.cs @@ -106,6 +106,26 @@ namespace ENI2 } } + public bool HasCriticalInfoMissing(out string messageText) + { + messageText = ""; + // Hier haben wir Logik für Spezialfälle, z.B. dass für BRE und BRV bestimmte Meldeklassen gesendet werden *müssen* + + if(this.Core.PoC.Equals("DEBRV") || this.Core.PoC.Equals("DEBRE")) + { + foreach(Message aMessage in _messages) + { + if((aMessage.MessageNotificationClass == Message.NotificationClass.NOA_NOD) && (aMessage.InternalStatus != Message.BSMDStatus.CONFIRMED)) { messageText = "NOA_NOD"; return true; } + if ((aMessage.MessageNotificationClass == Message.NotificationClass.AGNT) && (aMessage.InternalStatus != Message.BSMDStatus.CONFIRMED)) { messageText = "AGNT"; return true; } + if ((aMessage.MessageNotificationClass == Message.NotificationClass.INFO) && (aMessage.InternalStatus != Message.BSMDStatus.CONFIRMED)) { messageText = "INFO"; return true; } + if ((aMessage.MessageNotificationClass == Message.NotificationClass.SEC) && (aMessage.InternalStatus != Message.BSMDStatus.CONFIRMED)) { messageText = "SEC"; return true; } + if ((aMessage.MessageNotificationClass == Message.NotificationClass.TIEFA) && (aMessage.InternalStatus != Message.BSMDStatus.CONFIRMED)) { messageText = "TIEFA"; return true; } + } + } + + return false; + } + #endregion #region Construction diff --git a/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs b/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs index 69190627..4acb71fd 100644 --- a/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs +++ b/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs @@ -67,6 +67,9 @@ namespace ENI2.DetailViewControls 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.buttonSaveTemplate.IsEnabled = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor; + this.buttonDeleteTemplate.IsEnabled = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor; } public override void Initialize() @@ -108,7 +111,7 @@ namespace ENI2.DetailViewControls this.dataGridCallPurposes.EditRequested += DataGridCallPurposes_EditRequested; this.dataGridCallPurposes.AddingNewItem += DataGridCallPurposes_AddingNewItem; this.dataGridCallPurposes.CreateRequested += DataGridCallPurposes_CreateRequested; - this.dataGridCallPurposes.DeleteRequested += DataGridCallPurposes_DeleteRequested; + this.dataGridCallPurposes.DeleteRequested += DataGridCallPurposes_DeleteRequested; this.agentGroupBox.DataContext = _agnt; @@ -138,8 +141,7 @@ namespace ENI2.DetailViewControls private void DataGridCallPurposes_DeleteRequested(DatabaseEntity obj) { - CallPurpose cp = obj as CallPurpose; - if (cp != null) + if (obj is CallPurpose cp) { // are you sure dialog is in base class _noa_nod.CallPurposes.Remove(cp); @@ -151,7 +153,7 @@ namespace ENI2.DetailViewControls } private void DataGridCallPurposes_CreateRequested() - { + { EditCallPurposeDialog ecpd = new EditCallPurposeDialog(); ecpd.AddClicked += () => { @@ -256,16 +258,15 @@ namespace ENI2.DetailViewControls private void comboBox_AgentTemplate_SelectionChanged(object sender, SelectionChangedEventArgs e) { Trace.WriteLine("combo selection changed"); - AGNT_Template at = this.comboBox_AgentTemplate.SelectedItem as AGNT_Template; - if(at != null) + if (this.comboBox_AgentTemplate.SelectedItem is AGNT_Template at) { this.textBoxTemplateTitle.Text = at.AgentTitle; - this.buttonDeleteTemplate.IsEnabled = true; + this.buttonDeleteTemplate.IsEnabled = true; this.buttonSetTemplate.IsEnabled = true; this._currentTemplate = at; } - } + } private void buttonDeleteTemplate_Click(object sender, RoutedEventArgs e) { @@ -308,21 +309,21 @@ namespace ENI2.DetailViewControls { if (MessageBox.Show("A template with this name already exists, overwrite?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No) return; - } - + } + this._currentTemplate = createFromCurrentText(title, existingTemplate); - DBManager.Instance.Save(this._currentTemplate); - + DBManager.Instance.Save(this._currentTemplate); + if(existingTemplate == null) { comboBox_AgentTemplate.ItemsSource = null; _agntTemplates.Add(this._currentTemplate); _agntTemplates.Sort(); comboBox_AgentTemplate.ItemsSource = _agntTemplates; - } + } MessageBox.Show("Template saved", "OK", MessageBoxButton.OK, MessageBoxImage.Information); - } + } private void buttonUndoTemplate_Click(object sender, RoutedEventArgs e) { @@ -349,7 +350,7 @@ namespace ENI2.DetailViewControls this.textBox_AgentStreetAndNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource(); this.buttonUndoTemplate.IsEnabled = false; // can't undo after undo - } + } private void buttonSetTemplate_Click(object sender, RoutedEventArgs e) { diff --git a/ENI2/ENI2.csproj b/ENI2/ENI2.csproj index b8a4ae5e..c3c1f0c3 100644 --- a/ENI2/ENI2.csproj +++ b/ENI2/ENI2.csproj @@ -36,8 +36,8 @@ 5.4.0.0 true publish.html - 4 - 7.6.0.%2a + 8 + 7.7.0.%2a false true true @@ -996,7 +996,7 @@ - + + + diff --git a/ENI2/EditControls/EditLADGDialog.xaml.cs b/ENI2/EditControls/EditLADGDialog.xaml.cs index dab46828..0431da55 100644 --- a/ENI2/EditControls/EditLADGDialog.xaml.cs +++ b/ENI2/EditControls/EditLADGDialog.xaml.cs @@ -2,13 +2,14 @@ // Description: LADG Bearbeitungsdialog // +using System; +using System.Linq; using System.Windows; using System.Collections.Generic; using bsmd.database; using ENI2.Controls; -using System.Collections.ObjectModel; -using System.Windows.Data; + namespace ENI2.EditControls { @@ -30,13 +31,17 @@ namespace ENI2.EditControls Properties.Resources.textDischarge }; + private static List> _nstList = null; + public EditLADGDialog() { InitializeComponent(); Loaded += EditLADGDialog_Loaded; + if (_nstList == null) + _nstList = LocalizedLookup.GetNST2007List(); } - public LADG LADG { get; set; } + public LADG LADG { get; set; } public MessageCore Core { get; set; } @@ -55,16 +60,16 @@ namespace ENI2.EditControls if (this.LADG.CargoHandlingType.HasValue) this.comboBoxHandlingType.SelectedIndex = this.LADG.CargoHandlingType.Value; - this.comboBoxLACodes.ItemsSource = LADG.LACodes; + this.comboBoxLACodes.ItemsSource = LADG.LACodes; this.comboBoxLACodes.SelectedValue = this.LADG.CargoLACode; this.integerUpDownNumberOfItems.Value = this.LADG.CargoNumberOfItems; this.doubleUpDownGrossQuantity.Value = this.LADG.CargoGrossQuantity_TNE; this.locodeControl_PortOfLoading.LocodeValue = this.LADG.PortOfLoading; this.locodeControl_PortOfDischarge.LocodeValue = this.LADG.PortOfDischarge; - this.comboBoxLACodes.SelectedValue = this.LADG.CargoLACode; + this.comboBoxLACodes.SelectedValue = this.LADG.CargoLACode; - this.comboBoxNSTCode.ItemsSource = LADG.CargoCodesNST; + this.comboBoxNSTCode.ItemsSource = LADG.CargoCodesNST; this.comboBoxNSTCode.SelectedValue = this.LADG.CargoCodeNST; this.comboBoxNSTCode.SelectionChanged += ComboBoxNSTCode_SelectionChanged; this.comboBoxNST3Code.ItemsSource = LADG.CargoCodesNST3; @@ -93,7 +98,7 @@ namespace ENI2.EditControls { if (this.comboBoxNSTCode.SelectedItem == null) return; // filter ItemsSource von NST3 - KeyValuePair selectedItem = (KeyValuePair < string, string> ) this.comboBoxNSTCode.SelectedItem; + KeyValuePair selectedItem = (KeyValuePair < string, string> ) this.comboBoxNSTCode.SelectedItem; string key = selectedItem.Key; if (key.Length == 1) key = "0" + key; List> filteredItemsSource = new List>(); @@ -102,7 +107,7 @@ namespace ENI2.EditControls if (aPair.Value.StartsWith(key)) filteredItemsSource.Add(aPair); } - this.comboBoxNST3Code.ItemsSource = filteredItemsSource; + this.comboBoxNST3Code.ItemsSource = filteredItemsSource; } private void EditLADGDialog_OKClicked() @@ -110,7 +115,44 @@ namespace ENI2.EditControls this.CopyValuesToEntity(); } - #endregion + #endregion + + #region NST2007 list search/select event handler + + private void textBoxSearchNSTList_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) + { + if (textBoxSearchNSTList.Text.IsNullOrEmpty() || (textBoxSearchNSTList.Text.Length == 1)) + { + this.listBoxNST2007.ItemsSource = null; + // this.comboBoxSelectNST2007ListItem.ItemsSource = null; + } + else + { + var result = _nstList.Where(kvp => kvp.Key.Contains(textBoxSearchNSTList.Text, StringComparison.OrdinalIgnoreCase)); + this.listBoxNST2007.ItemsSource = result; + //this.comboBoxSelectNST2007ListItem.ItemsSource = result; + } + } + + private void buttonSetTemplate_Click(object sender, RoutedEventArgs e) + { + if(this.listBoxNST2007.SelectedItem != null) + { + KeyValuePair selectedTemplate = (KeyValuePair) this.listBoxNST2007.SelectedItem; + if(selectedTemplate.Value.Length == 3) + { + this.comboBoxNSTCode.SelectedValue = selectedTemplate.Value.Substring(0, 2); + this.comboBoxNST3Code.SelectedValue = selectedTemplate.Value.Substring(2, 1); + } + } + } + + private void listBoxNST2007_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) + { + this.buttonSetTemplate_Click(null, null); + } + + #endregion } } diff --git a/ENI2/EditControls/EditReportingPartyDialog.xaml b/ENI2/EditControls/EditReportingPartyDialog.xaml index 8944d277..2867e0b2 100644 --- a/ENI2/EditControls/EditReportingPartyDialog.xaml +++ b/ENI2/EditControls/EditReportingPartyDialog.xaml @@ -48,6 +48,7 @@