100 lines
3.3 KiB
C#
100 lines
3.3 KiB
C#
// Copyright (c) 2020-present schick Informatik
|
|
// Description: Container for HAZA subclass templates
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace bsmd.database
|
|
{
|
|
/// <summary>
|
|
/// Container for a dangerous goods template description which is imported from SQLite / Excel DB
|
|
/// Instances of this class will be offered to users as templates and respective DG entries created on them:
|
|
/// IGC, IMSBC, IBC and MARPOL (not! IMDG)
|
|
/// </summary>
|
|
public class HAZPosTemplate
|
|
{
|
|
|
|
public enum SublistType
|
|
{
|
|
IBC,
|
|
IGC,
|
|
IMSBC,
|
|
MARPOL
|
|
}
|
|
|
|
#region Properties
|
|
|
|
public string Description { get; set; }
|
|
|
|
public byte? Hazard { get; set; }
|
|
|
|
public byte? Flashpoint { get; set; }
|
|
|
|
public bool? SpecRef15_19 { get; set; }
|
|
|
|
public string NoDeclarationReason { get; set; }
|
|
|
|
public string Comment { get; set; }
|
|
|
|
public SublistType TemplateType { get; set; }
|
|
|
|
public byte? PollutionCategory { get; set; }
|
|
|
|
public static string GetQuery()
|
|
{
|
|
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)
|
|
{
|
|
List<HAZPosTemplate> result = new List<HAZPosTemplate>();
|
|
|
|
while(reader.Read())
|
|
{
|
|
if (reader.IsDBNull(4)) continue; // this row has no type -> ignore
|
|
HAZPosTemplate hpt = new HAZPosTemplate();
|
|
hpt.Description = reader.GetString(0);
|
|
if (!reader.IsDBNull(1))
|
|
hpt.Hazard = reader.GetByte(1);
|
|
if (!reader.IsDBNull(2))
|
|
hpt.Flashpoint = reader.GetByte(2);
|
|
if (!reader.IsDBNull(3))
|
|
{
|
|
string specRefString = reader.GetString(3);
|
|
if (specRefString.Equals("JA", StringComparison.OrdinalIgnoreCase) || specRefString.Equals("Yes", StringComparison.OrdinalIgnoreCase)) hpt.SpecRef15_19 = true;
|
|
if (specRefString.Equals("NEIN", StringComparison.OrdinalIgnoreCase) || specRefString.Equals("No", StringComparison.OrdinalIgnoreCase)) hpt.SpecRef15_19 = false;
|
|
}
|
|
|
|
string type = reader.GetString(4);
|
|
switch(type)
|
|
{
|
|
case "IBC": hpt.TemplateType = SublistType.IBC; break;
|
|
case "IGC": hpt.TemplateType = SublistType.IGC; break;
|
|
case "IMSBC": hpt.TemplateType = SublistType.IMSBC ; break;
|
|
case "MARPOL": hpt.TemplateType = SublistType.MARPOL; break;
|
|
default:
|
|
continue; // ignore this thing
|
|
}
|
|
|
|
if (!reader.IsDBNull(5))
|
|
hpt.PollutionCategory = reader.GetByte(5);
|
|
if (!reader.IsDBNull(6))
|
|
hpt.NoDeclarationReason = reader.GetString(6);
|
|
if (!reader.IsDBNull(7))
|
|
hpt.Comment = reader.GetString(7);
|
|
|
|
result.Add(hpt);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|