Helper Interface für Gefahrgutpositionen. Bin gespannt was Christin dazu sagt, daher noch WIP

This commit is contained in:
Daniel Schick 2022-09-28 16:13:04 +02:00
parent 2713db9937
commit 3845313bb3
9 changed files with 222 additions and 7 deletions

View File

@ -28,6 +28,7 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Name="textBlockMessageClass" FontWeight="DemiBold" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" />
<Button Content="{x:Static p:Resources.textNewDGItem}" Name="buttonNewItem" Margin="2" Click="buttonNewItem_Click" Grid.Row="0" Grid.Column="1" />
<Label Content="{x:Static p:Resources.textDangerousGoodsOnBoard}" Grid.Column="0" Grid.Row="1" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<Label Content="{x:Static p:Resources.textVesselClass}" Grid.Column="0" Grid.Row="2" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>
<Label Content="{x:Static p:Resources.textDGManifestOnBoard}" Grid.Column="2" Grid.Row="1" HorizontalContentAlignment="Right" Margin="0,0,10,0"/>

View File

@ -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
}
}

View File

@ -240,6 +240,9 @@
<Compile Include="EditControls\FixImportDialog.xaml.cs">
<DependentUpon>FixImportDialog.xaml</DependentUpon>
</Compile>
<Compile Include="EditControls\NewDGItemDialog.xaml.cs">
<DependentUpon>NewDGItemDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Excel\DakosyUtil.cs" />
<Compile Include="Excel\ExcelBase.cs" />
<Compile Include="Excel\ExcelComparer.cs" />
@ -659,6 +662,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="EditControls\NewDGItemDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="EditControls\NewWithIdDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -0,0 +1,41 @@
<enictrl:EditWindowBase x:Class="ENI2.EditControls.NewDGItemDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ENI2.EditControls"
xmlns:enictrl="clr-namespace:ENI2.Controls"
xmlns:p="clr-namespace:ENI2.Properties"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
Title="{x:Static p:Resources.textNewDGItem}" Height="260" Width="600" WindowStyle="SingleBorderWindow" Background="AliceBlue" ResizeMode="CanResize"
Icon="/ENI2;component/Resources/bullet_ball_yellow.ico" Loaded="EditWindowBase_Loaded">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Label Content="{x:Static p:Resources.textType}" Grid.Row="0" Grid.Column="0" />
<ComboBox Name="comboBoxType" Grid.Column="1" Grid.Row="0" Margin="2" SelectionChanged="comboBoxType_SelectionChanged" />
<Label Content="{x:Static p:Resources.textDescription}" Grid.Row="1" Grid.Column="0" />
<ComboBox Name="comboBoxDescription" Grid.Column="1" Grid.Row="1" Margin="2" SelectionChanged="comboBoxDescription_SelectionChanged"/>
<Label Content="{x:Static p:Resources.textRemarks}" Grid.Row="4" Grid.Column="0" />
<Border BorderThickness="1" Grid.Column="1" Grid.Row="2" Grid.RowSpan="2" BorderBrush="Black" Margin="2">
<TextBlock Name="textBlockDescription" Margin="2" Background="LightGray" TextWrapping="Wrap"/>
</Border>
<Border BorderThickness="1" Grid.Column="1" Grid.Row="4" Grid.RowSpan="2" BorderBrush="Black" Margin="2">
<TextBlock Name="textBlockRemarks" Margin="2" Background="LightGray" TextWrapping="Wrap" />
</Border>
</Grid>
</enictrl:EditWindowBase>

View File

@ -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
{
/// <summary>
/// Interaction logic for NewDGItemDialog.xaml
/// </summary>
public partial class NewDGItemDialog : EditWindowBase
{
private List<HAZPosTemplate> _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<HAZPosTemplate> comboData = new List<HAZPosTemplate>();
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 = "";
}
}
}
}

View File

@ -3309,6 +3309,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to New dangerous goods item.
/// </summary>
public static string textNewDGItem {
get {
return ResourceManager.GetString("textNewDGItem", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to New group.
/// </summary>

View File

@ -1849,4 +1849,7 @@
<data name="import2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\import2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="textNewDGItem" xml:space="preserve">
<value>New dangerous goods item</value>
</data>
</root>

View File

@ -2,8 +2,6 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ENI2.Util
{

View File

@ -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<HAZPosTemplate> 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
}
}