diff --git a/ENI2/DetailViewControls/WasteDetailControl.xaml b/ENI2/DetailViewControls/WasteDetailControl.xaml
index 2abe2483..c8ede25e 100644
--- a/ENI2/DetailViewControls/WasteDetailControl.xaml
+++ b/ENI2/DetailViewControls/WasteDetailControl.xaml
@@ -56,7 +56,35 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ENI2/DetailViewControls/WasteDetailControl.xaml.cs b/ENI2/DetailViewControls/WasteDetailControl.xaml.cs
index 00b5f493..e4c5cbec 100644
--- a/ENI2/DetailViewControls/WasteDetailControl.xaml.cs
+++ b/ENI2/DetailViewControls/WasteDetailControl.xaml.cs
@@ -13,6 +13,7 @@ using ExcelDataReader;
using System.IO;
using System;
using Microsoft.Win32;
+using System.Diagnostics;
namespace ENI2.DetailViewControls
{
@@ -29,7 +30,7 @@ namespace ENI2.DetailViewControls
private static List _wsdpTemplates = null;
private WasteDisposalServiceProvider_Template _currentTemplate;
- private WasteDisposalServiceProvider_Template _undoTemplate;
+ private string _undoTemplate;
private static readonly string[] _wasteDeliveryList =
{
@@ -101,7 +102,7 @@ namespace ENI2.DetailViewControls
}
}
- public override void Initialize()
+ public async override void Initialize()
{
base.Initialize();
@@ -182,6 +183,18 @@ namespace ENI2.DetailViewControls
#endregion
+ #region init WSDP provider
+
+ if(_wsdpTemplates == null)
+ {
+ _wsdpTemplates = await DBManagerAsync.GetWastDisposalServiceProviderTemplatesAsync();
+ _wsdpTemplates.Sort();
+ Trace.WriteLine($"{_wsdpTemplates.Count} WSDP templates loaded");
+ }
+ this.comboBox_WSDPTemplate.ItemsSource = _wsdpTemplates;
+
+ #endregion
+
}
#region Waste receipt grid event handler
@@ -585,9 +598,91 @@ namespace ENI2.DetailViewControls
#endregion
+ #region Waste disposal Service Provider templates event handler
+
private void comboBox_WSDPTemplate_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
-
+ Trace.WriteLine("WSDP combo selection changed");
+ if(this.comboBox_WSDPTemplate.SelectedItem is WasteDisposalServiceProvider_Template wdsp_t)
+ {
+ this.textBoxTemplateTitle.Text = wdsp_t.Remark;
+ this.buttonDeleteTemplate.IsEnabled = true;
+ this._currentTemplate = wdsp_t;
+ this._undoTemplate = this.textBoxWasteDisposalServiceProviders.Text.Trim();
+ this.buttonUndoTemplate.IsEnabled = this._undoTemplate.Length > 0;
+ this.textBoxWasteDisposalServiceProviders.Text = wdsp_t.WasteDisposalServiceProviderName;
+ }
}
+
+ private async void buttonSaveTemplate_Click(object sender, RoutedEventArgs e)
+ {
+ string currentWSDPProviderName = this.textBoxWasteDisposalServiceProviders.Text.Trim();
+ string currentRemark = this.textBoxTemplateTitle.Text.Trim();
+
+ if ((currentWSDPProviderName.Length == 0) || (currentRemark.Length == 0)) return;
+
+ WasteDisposalServiceProvider_Template existingTemplate = null;
+ foreach(WasteDisposalServiceProvider_Template wdsp_template in _wsdpTemplates)
+ {
+ // bei gefundenem Match wird ggf. der Remark überschrieben
+ if (wdsp_template.Remark.Equals(currentRemark))
+ {
+ existingTemplate = wdsp_template;
+ break;
+ }
+ }
+
+ if(existingTemplate != null)
+ {
+ if (MessageBox.Show("A template with this name already exists, overwrite?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
+ return;
+
+ existingTemplate.WasteDisposalServiceProviderName = currentWSDPProviderName;
+ await DBManagerAsync.SaveAsync(existingTemplate);
+ return;
+ }
+
+ WasteDisposalServiceProvider_Template newTemplate = new WasteDisposalServiceProvider_Template();
+ newTemplate.WasteDisposalServiceProviderName = currentWSDPProviderName;
+ newTemplate.Remark = currentRemark;
+ await DBManagerAsync.SaveAsync(newTemplate);
+
+ comboBox_WSDPTemplate.ItemsSource = null;
+ _wsdpTemplates.Add(newTemplate);
+ _wsdpTemplates.Sort();
+ comboBox_WSDPTemplate.ItemsSource = _wsdpTemplates;
+ MessageBox.Show("Template saved", "OK", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+
+ private void buttonDeleteTemplate_Click(object sender, RoutedEventArgs e)
+ {
+ if(_currentTemplate != null)
+ {
+ if (MessageBox.Show("Delete this template?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
+ {
+ this.comboBox_WSDPTemplate.SelectedItem = null;
+ this.comboBox_WSDPTemplate.ItemsSource = null;
+ DBManager.Instance.Delete(_currentTemplate);
+ _wsdpTemplates.Remove(_currentTemplate);
+ this.textBoxTemplateTitle.Text = null;
+ this.buttonDeleteTemplate.IsEnabled = false;
+ this.comboBox_WSDPTemplate.ItemsSource = _wsdpTemplates;
+ }
+ }
+ }
+
+ private void buttonUndoTemplate_Click(object sender, RoutedEventArgs e)
+ {
+ if(this._undoTemplate != null)
+ {
+ this.textBoxWasteDisposalServiceProviders.Text = this._undoTemplate;
+ this.buttonUndoTemplate.IsEnabled = false;
+ this._undoTemplate = null;
+ this.comboBox_WSDPTemplate.SelectedItem = null;
+ }
+ }
+
+ #endregion
+
}
}
diff --git a/ENI2/ENI2.csproj b/ENI2/ENI2.csproj
index 2b9c1bf2..7090ff11 100644
--- a/ENI2/ENI2.csproj
+++ b/ENI2/ENI2.csproj
@@ -18,7 +18,7 @@
- eni2.publish\
+ eni_test\
true
Web
true
@@ -28,16 +28,16 @@
false
false
true
- http://192.168.2.24/eni2.publish/
+ http://192.168.2.24/eni_test/
http://www.textbausteine.net/
- ENI
+ ENI Testversion
Informatikbüro Daniel Schick
NSW
5.4.0.0
true
publish.html
- 5
- 7.12.0.%2a
+ 0
+ 7.13.0.%2a
false
true
true