diff --git a/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml b/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml
index fe9d1837..f36a0619 100644
--- a/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml
+++ b/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml
@@ -28,6 +28,7 @@
+
diff --git a/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml.cs b/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml.cs
index 1c28b2cb..f20d2c45 100644
--- a/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml.cs
+++ b/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml.cs
@@ -799,5 +799,69 @@ namespace ENI2.DetailViewControls
#endregion
+ #region new sublist item button handler
+
+ private void buttonNewItem_Click(object sender, RoutedEventArgs e)
+ {
+ HAZ haz = this.IsDeparture ? hazd : haza;
+ NewDGItemDialog nd = new NewDGItemDialog();
+ if(nd.ShowDialog() ?? false)
+ {
+ HAZPosTemplate selectedTemplate = nd.SelectedTemplate;
+ if(selectedTemplate != null)
+ {
+ // create new DG position based on template
+ switch(selectedTemplate.TemplateType)
+ {
+ case HAZPosTemplate.SublistType.IBC:
+ this.tabControlPositions.SelectedIndex = 1;
+ IBCPosition ibcPos = new IBCPosition();
+ ibcPos.FlashpointInformation = selectedTemplate.Flashpoint;
+ ibcPos.SpecRef15_19 = selectedTemplate.SpecRef15_19;
+ ibcPos.Identifier = DatabaseEntity.GetNewIdentifier(haz.IBCPositions, "IBC-");
+ ibcPos.PollutionCategory = selectedTemplate.Hazard;
+ ibcPos.HAZ = haz;
+ haz.IBCPositions.Add(ibcPos);
+ this.dataGridIBCItems.Items.Refresh();
+ this.DataGridIBCItems_EditRequested(ibcPos);
+ break;
+ case HAZPosTemplate.SublistType.IGC:
+ this.tabControlPositions.SelectedIndex = 2;
+ IGCPosition igcPos = new IGCPosition();
+
+ igcPos.Identifier = DatabaseEntity.GetNewIdentifier(haz.IGCPositions, "IGC-");
+ igcPos.HAZ = haz;
+ haz.IGCPositions.Add(igcPos);
+ this.dataGridIGCItems.Items.Refresh();
+ this.DataGridIGCItems_EditRequested(igcPos);
+ break;
+ case HAZPosTemplate.SublistType.IMSBC:
+ this.tabControlPositions.SelectedIndex = 3;
+ IMSBCPosition imsbcPos = new IMSBCPosition();
+
+ imsbcPos.Identifier = DatabaseEntity.GetNewIdentifier(haz.IMSBCPositions, "IMSBC-");
+ imsbcPos.HAZ = haz;
+ haz.IMSBCPositions.Add(imsbcPos);
+ this.dataGridIMSBCItems.Items.Refresh();
+ this.DataGridIMSBCItems_EditRequested(imsbcPos);
+ break;
+ case HAZPosTemplate.SublistType.MARPOL:
+ this.tabControlPositions.SelectedIndex = 4;
+ MARPOL_Annex_I_Position marpolPos = new MARPOL_Annex_I_Position();
+ marpolPos.FlashpointInformation = selectedTemplate.Flashpoint;
+ marpolPos.Identifier = DatabaseEntity.GetNewIdentifier(haz.MARPOLPositions, "MARPOL-");
+ marpolPos.HAZ = haz;
+ haz.MARPOLPositions.Add(marpolPos);
+ this.dataGridMARPOLItems.Items.Refresh();
+ this.DataGridMARPOLItems_EditRequested(marpolPos);
+ break;
+
+ }
+ }
+ }
+ }
+
+ #endregion
+
}
}
diff --git a/ENI2/ENI2.csproj b/ENI2/ENI2.csproj
index 94a125b6..50575c85 100644
--- a/ENI2/ENI2.csproj
+++ b/ENI2/ENI2.csproj
@@ -240,6 +240,9 @@
FixImportDialog.xaml
+
+ NewDGItemDialog.xaml
+
@@ -659,6 +662,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/ENI2/EditControls/NewDGItemDialog.xaml b/ENI2/EditControls/NewDGItemDialog.xaml
new file mode 100644
index 00000000..baa72a3e
--- /dev/null
+++ b/ENI2/EditControls/NewDGItemDialog.xaml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ENI2/EditControls/NewDGItemDialog.xaml.cs b/ENI2/EditControls/NewDGItemDialog.xaml.cs
new file mode 100644
index 00000000..5fc626c5
--- /dev/null
+++ b/ENI2/EditControls/NewDGItemDialog.xaml.cs
@@ -0,0 +1,77 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+using ENI2.Controls;
+using bsmd.database;
+
+namespace ENI2.EditControls
+{
+ ///
+ /// Interaction logic for NewDGItemDialog.xaml
+ ///
+ public partial class NewDGItemDialog : EditWindowBase
+ {
+ private List _data = null;
+
+ public NewDGItemDialog()
+ {
+ InitializeComponent();
+ }
+
+ public HAZPosTemplate SelectedTemplate
+ {
+ get
+ {
+ return this.comboBoxDescription.SelectedItem as HAZPosTemplate;
+ }
+ }
+
+ private void EditWindowBase_Loaded(object sender, RoutedEventArgs e)
+ {
+ // load combo boxes
+ _data = LocalizedLookup.LoadHAZTemplates();
+ this.comboBoxDescription.ItemsSource = _data;
+ this.comboBoxType.ItemsSource = Enum.GetValues(typeof(HAZPosTemplate.SublistType));
+ }
+
+ private void comboBoxType_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ // filter description against type
+ List comboData = new List();
+ HAZPosTemplate.SublistType sType = (HAZPosTemplate.SublistType) this.comboBoxType.SelectedItem;
+
+ foreach (HAZPosTemplate ht in this._data)
+ {
+ if (ht.TemplateType == sType)
+ comboData.Add(ht);
+ }
+ this.comboBoxDescription.ItemsSource = comboData;
+ }
+
+ private void comboBoxDescription_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ HAZPosTemplate selectedTemplate = this.comboBoxDescription.SelectedItem as HAZPosTemplate;
+ if (selectedTemplate != null)
+ {
+ this.textBlockDescription.Text = selectedTemplate.Description;
+ this.textBlockRemarks.Text = selectedTemplate.Comment;
+ }
+ else
+ {
+ this.textBlockDescription.Text = "";
+ this.textBlockRemarks.Text = "";
+ }
+ }
+ }
+}
diff --git a/ENI2/Properties/Resources.Designer.cs b/ENI2/Properties/Resources.Designer.cs
index e0f5ccba..344ccf71 100644
--- a/ENI2/Properties/Resources.Designer.cs
+++ b/ENI2/Properties/Resources.Designer.cs
@@ -3309,6 +3309,15 @@ namespace ENI2.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to New dangerous goods item.
+ ///
+ public static string textNewDGItem {
+ get {
+ return ResourceManager.GetString("textNewDGItem", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to New group.
///
diff --git a/ENI2/Properties/Resources.resx b/ENI2/Properties/Resources.resx
index 445b547c..20e2be23 100644
--- a/ENI2/Properties/Resources.resx
+++ b/ENI2/Properties/Resources.resx
@@ -1849,4 +1849,7 @@
..\Resources\import2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ New dangerous goods item
+
\ No newline at end of file
diff --git a/ENI2/Util/EnumHelper.cs b/ENI2/Util/EnumHelper.cs
index 64f3207a..077740d2 100644
--- a/ENI2/Util/EnumHelper.cs
+++ b/ENI2/Util/EnumHelper.cs
@@ -2,8 +2,6 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ENI2.Util
{
@@ -14,7 +12,7 @@ namespace ENI2.Util
var nAttributes = eValue.GetType().GetField(eValue.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false);
if (nAttributes.Any())
return (nAttributes.First() as DescriptionAttribute).Description;
- return eValue.ToString();
+ return eValue.ToString();
}
public static IEnumerable> GetAllValuesAndDescription(Type t)
diff --git a/bsmd.database/HAZPosTemplate.cs b/bsmd.database/HAZPosTemplate.cs
index 36fbff7a..cdb28e83 100644
--- a/bsmd.database/HAZPosTemplate.cs
+++ b/bsmd.database/HAZPosTemplate.cs
@@ -44,9 +44,13 @@ namespace bsmd.database
public byte? PollutionCategory { get; set; }
+ #endregion
+
+ #region static storage helper classes
+
public static string GetQuery()
{
- return "SELECT Beschreibung, HAZARD_ENUM, FP_ENUM, '15.19?', Typ, POLLUTION_CATEGORY_ENUM, GrundKeineAnmeldung, Bemerkung FROM GEFAHRGUTLISTE ORDER BY Beschreibung";
+ return "SELECT Beschreibung, HAZARD_ENUM, FP_ENUM, \"15.19?\", Typ, POLLUTION_CATEGORY_ENUM, GrundKeineAnmeldung, Bemerkung FROM GEFAHRGUTLISTE ORDER BY Beschreibung";
}
public static List LoadList(IDataReader reader)
@@ -59,9 +63,9 @@ namespace bsmd.database
HAZPosTemplate hpt = new HAZPosTemplate();
hpt.Description = reader.GetString(0);
if (!reader.IsDBNull(1))
- hpt.Hazard = reader.GetByte(1);
+ hpt.Hazard = (byte) reader.GetDouble(1);
if (!reader.IsDBNull(2))
- hpt.Flashpoint = reader.GetByte(2);
+ hpt.Flashpoint = (byte) reader.GetDouble(2);
if (!reader.IsDBNull(3))
{
string specRefString = reader.GetString(3);
@@ -81,7 +85,7 @@ namespace bsmd.database
}
if (!reader.IsDBNull(5))
- hpt.PollutionCategory = reader.GetByte(5);
+ hpt.PollutionCategory = (byte) reader.GetDouble(5);
if (!reader.IsDBNull(6))
hpt.NoDeclarationReason = reader.GetString(6);
if (!reader.IsDBNull(7))
@@ -95,5 +99,16 @@ namespace bsmd.database
#endregion
+ #region overrides
+
+ public override string ToString()
+ {
+ if (this.Description.Length > 75)
+ return string.Format("{0}...", this.Description.Substring(0, 75));
+ return Description;
+ }
+
+ #endregion
+
}
}