diff --git a/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs b/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs
index 28adf8ea..7f827aeb 100644
--- a/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs
+++ b/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs
@@ -381,7 +381,7 @@ namespace ENI2.DetailViewControls
#endregion
- #region Spezialbalkon für die Gruppenauswahl im Core (Maersk BHV / Seago usw.)
+ #region SERV template event handler
private void comboBoxGroup_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
@@ -472,6 +472,10 @@ namespace ENI2.DetailViewControls
}
}
+ #endregion
+
+ #region other event handler
+
private void buttonSearchPortArea_Click(object sender, RoutedEventArgs e)
{
if (portAreas != null)
diff --git a/ENI2/SheetDisplayControls/PortControl.xaml b/ENI2/SheetDisplayControls/PortControl.xaml
index 387783a2..44a96aea 100644
--- a/ENI2/SheetDisplayControls/PortControl.xaml
+++ b/ENI2/SheetDisplayControls/PortControl.xaml
@@ -178,8 +178,40 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ENI2/SheetDisplayControls/PortControl.xaml.cs b/ENI2/SheetDisplayControls/PortControl.xaml.cs
index 13491d60..99d6cabc 100644
--- a/ENI2/SheetDisplayControls/PortControl.xaml.cs
+++ b/ENI2/SheetDisplayControls/PortControl.xaml.cs
@@ -34,7 +34,7 @@ namespace ENI2.SheetDisplayControls
private SEC _sec;
private WAS _was;
private Message _stoMessage;
- private Message _crewMessage;
+ // private Message _crewMessage;
private Dictionary portAreas = null;
@@ -42,6 +42,9 @@ namespace ENI2.SheetDisplayControls
private AGNT_Template _currentTemplate;
private AGNT_Template _undoTemplate;
+ private static List _servTemplates = null;
+ private SERV_Template _currentSERVTemplate;
+
private static List _wsdpTemplates = null;
private WasteDisposalServiceProvider_Template _currentWSDPTemplate;
private string _undoWSDPTemplate;
@@ -90,7 +93,7 @@ namespace ENI2.SheetDisplayControls
if (aMessage.MessageNotificationClass == Message.NotificationClass.AGNT) { this._agnt = aMessage.Elements[0] as AGNT; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.WAS) { this._was = aMessage.Elements[0] as WAS; this.ControlMessages.Add(aMessage); }
if (aMessage.MessageNotificationClass == Message.NotificationClass.STO) { this._stoMessage = aMessage; this.ControlMessages.Add(aMessage); }
- if (aMessage.MessageNotificationClass == Message.NotificationClass.CREWA) { this._crewMessage = aMessage; this.ControlMessages.Add(aMessage); }
+ // if (aMessage.MessageNotificationClass == Message.NotificationClass.CREWA) { this._crewMessage = aMessage; this.ControlMessages.Add(aMessage); }
}
// 2.1
@@ -202,6 +205,23 @@ namespace ENI2.SheetDisplayControls
// this.dataGridEffects.Initialize();
// this.dataGridEffects.ItemsSource = _crewMessage.Elements;
+ #region init SERV templates
+
+ if (_servTemplates == null)
+ {
+ _servTemplates = await DBManagerAsync.GetSERVTemplatesAsync(); // initial load
+ _servTemplates.Sort();
+ Trace.WriteLine($"{_servTemplates.Count} SERV templates loaded");
+ }
+
+ this.comboBoxGroup.ItemsSource = _servTemplates;
+
+ this.buttonDeleteSERVTemplate.Visibility = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor ? Visibility.Visible : Visibility.Hidden;
+ this.buttonEditSERVTemplate.Visibility = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor ? Visibility.Visible : Visibility.Hidden;
+ this.buttonNewSERVTemplate.Visibility = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsEditor ? Visibility.Visible : Visibility.Hidden;
+
+ #endregion
+
}
public override int SelectedTabIndex
@@ -576,38 +596,7 @@ namespace ENI2.SheetDisplayControls
stream.Close();
}
- }
-
- private void comboBoxGroup_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- // clear all
- this.Core.SetFlag(false, MessageCore.CoreFlags.MAERSK_BHV);
- this.Core.SetFlag(false, MessageCore.CoreFlags.SEAGO_BHV);
- this.Core.SetFlag(false, MessageCore.CoreFlags.SEAGO_WHV);
- this.Core.SetFlag(false, MessageCore.CoreFlags.HOEGH);
- this.Core.SetFlag(false, MessageCore.CoreFlags.ELBE_BULK);
- this.Core.SetFlag(false, MessageCore.CoreFlags.FCT_JUNGE);
-
- if (this.comboBoxGroup.SelectedItem == null)
- {
- this.comboBoxGroup.SelectedIndex = 0;
- DBManager.Instance.Save(this.Core);
- }
- else
- {
- DictionaryEntry selectedItem = (DictionaryEntry)this.comboBoxGroup.SelectedItem;
- if (Int32.TryParse((string)selectedItem.Value, out int selectedValue))
- {
- if (selectedValue == (int)MessageCore.CoreFlags.MAERSK_BHV) CheckServiceEntryMaerskBHV();
- if (selectedValue == (int)MessageCore.CoreFlags.SEAGO_BHV) CheckServiceEntrySeaGoBHV();
- if (selectedValue == (int)MessageCore.CoreFlags.HOEGH) CheckServiceEntryHoegh();
- if (selectedValue == (int)MessageCore.CoreFlags.ELBE_BULK) CheckServiceEntryElbeBulk();
- if (selectedValue == (int)MessageCore.CoreFlags.FCT_JUNGE) CheckServiceEntryFctJunge();
- this.Core.SetFlag(true, (MessageCore.CoreFlags)selectedValue);
- DBManager.Instance.Save(this.Core);
- }
- }
- }
+ }
#endregion
@@ -1148,6 +1137,99 @@ namespace ENI2.SheetDisplayControls
}
#endregion
-
+
+ #region SERV template button event handler
+
+ private void comboBoxGroup_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (this.comboBoxGroup.SelectedItem is SERV_Template st)
+ {
+ this.buttonDeleteSERVTemplate.IsEnabled = true;
+ this.buttonSetSERVTemplate.IsEnabled = true;
+ this._currentSERVTemplate = st;
+ }
+ }
+
+ private void buttonSetSERVTemplate_Click(object sender, RoutedEventArgs e)
+ {
+ if (this.comboBoxGroup.SelectedItem is SERV_Template st)
+ {
+ bool found = false;
+ foreach (SERV serv in _servMessage.Elements.Cast())
+ {
+ if (serv.ServiceName.Equals(st.ServiceName))
+ {
+ found = true; break;
+ }
+ }
+
+ if (!found)
+ {
+ SERV newServ = new SERV();
+ newServ.ServiceName = st.ServiceName;
+ newServ.ServiceBeneficiary = st.ServiceBeneficiary;
+ newServ.ServiceInvoiceRecipient = st.ServiceInvoiceRecipient;
+
+ newServ.MessageHeader = this._servMessage;
+ newServ.Identifier = SERV.GetNewIdentifier(_servMessage.Elements);
+ this._servMessage.Elements.Add(newServ);
+ this.dataGridSERV.Items.Refresh();
+ this.SublistElementChanged(Message.NotificationClass.SERV);
+ }
+ }
+ }
+
+ private void buttonEditSERVTemplate_Click(object sender, RoutedEventArgs e)
+ {
+ if (this.comboBoxGroup.SelectedItem is SERV_Template st)
+ {
+ EditSERVDialog editSERVDialog = new EditSERVDialog();
+ editSERVDialog.AddVisible = false;
+ editSERVDialog.SERV_Template = st;
+ if (editSERVDialog.ShowDialog() ?? false)
+ {
+ _ = DBManagerAsync.SaveAsync(st);
+ this.comboBoxGroup.ItemsSource = null;
+ _servTemplates.Sort();
+ this.comboBoxGroup.ItemsSource = _servTemplates;
+ }
+ }
+ }
+
+ private void buttonNewSERVTemplate_Click(object sender, RoutedEventArgs e)
+ {
+ SERV_Template newTemplate = new SERV_Template();
+ EditSERVDialog esd = new EditSERVDialog();
+ esd.AddVisible = false;
+ esd.SERV_Template = newTemplate;
+ if (esd.ShowDialog() ?? false)
+ {
+ _ = DBManagerAsync.SaveAsync(esd.SERV_Template);
+ this.comboBoxGroup.ItemsSource = null;
+ _servTemplates.Add(newTemplate);
+ _servTemplates.Sort();
+ this.comboBoxGroup.ItemsSource = _servTemplates;
+ }
+ }
+
+ private void buttonDeleteSERVTemplate_Click(object sender, RoutedEventArgs e)
+ {
+ if (_currentSERVTemplate != null)
+ {
+ if (MessageBox.Show("Delete this template?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
+ {
+ this.comboBoxGroup.SelectedItem = null;
+ this.comboBoxGroup.ItemsSource = null;
+ _ = DBManagerAsync.DeleteAsync(_currentTemplate);
+ _servTemplates.Remove(_currentSERVTemplate);
+ this.buttonDeleteSERVTemplate.IsEnabled = false;
+ this.comboBoxGroup.ItemsSource = _servTemplates;
+ this.buttonSetSERVTemplate.IsEnabled = false;
+ }
+ }
+ }
+
+ #endregion
+
}
}