236 lines
12 KiB
C#
236 lines
12 KiB
C#
//
|
|
// Class: MDH
|
|
// Current CLR: 4.0.30319.34209
|
|
// System: Microsoft Visual Studio 10.0
|
|
// Author: dani
|
|
// Created: 3/21/2015 10:56:30 AM
|
|
//
|
|
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
|
|
|
|
using System;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Collections.Generic;
|
|
|
|
namespace bsmd.database
|
|
{
|
|
public class MDH : DatabaseEntity, ISublistContainer
|
|
{
|
|
|
|
private List<PortOfCallLast30Days> portOfCallLast30Days = new List<PortOfCallLast30Days>();
|
|
|
|
public MDH()
|
|
{
|
|
this.tablename = "[dbo].[MDH]";
|
|
}
|
|
|
|
#region Properties
|
|
|
|
public List<PortOfCallLast30Days> PortOfCallLast30Days { get { return this.portOfCallLast30Days; } }
|
|
[ShowReport]
|
|
public bool? MDHSimplification { get; set; }
|
|
[ShowReport]
|
|
public string PortOfCallWhereCompleteMDHNotified { get; set; }
|
|
[ShowReport]
|
|
public bool? NonAccidentalDeathsDuringVoyage { get; set; }
|
|
[ShowReport]
|
|
public int? NonAccidentalDeathsDuringVoyageCount { get; set; }
|
|
[ShowReport]
|
|
public bool? SuspisionInfectiousNature { get; set; }
|
|
[ShowReport]
|
|
public bool? NumberOfIllPersonsHigherThanExpected { get; set; }
|
|
[ShowReport]
|
|
public int? NumberOfIllPersons { get; set; }
|
|
[ShowReport]
|
|
public bool? SickPersonsOnBoard { get; set; }
|
|
[ShowReport]
|
|
public bool? MedicalConsulted { get; set; }
|
|
[ShowReport]
|
|
public bool? AwareOfFurtherInfections { get; set; }
|
|
[ShowReport]
|
|
public bool? SanitaryMeasuresApplied { get; set; }
|
|
[ShowReport]
|
|
public string SanitaryMeasuresType { get; set; }
|
|
[ShowReport]
|
|
public string SanitaryMeasuresLocation { get; set; }
|
|
[ShowReport]
|
|
public DateTime? SanitaryMeasuresDate { get; set; }
|
|
[ShowReport]
|
|
public bool? StowawaysDetected { get; set; }
|
|
[ShowReport]
|
|
public string StowawaysJoiningLocation { get; set; }
|
|
[ShowReport]
|
|
public bool? SickAnimalOrPetOnBoard { get; set; }
|
|
[ShowReport]
|
|
public bool? ValidSanitaryControlExemptionOrCertificateOnBoard { get; set; }
|
|
[ShowReport]
|
|
public string PlaceOfIssue { get; set; }
|
|
[ShowReport]
|
|
public DateTime? DateOfIssue { get; set; }
|
|
[ShowReport]
|
|
public bool? SanitaryControlReinspectionRequired { get; set; }
|
|
[ShowReport]
|
|
public bool? InfectedAreaVisited { get; set; }
|
|
[ShowReport]
|
|
public string InfectedAreaPort { get; set; }
|
|
[ShowReport]
|
|
public DateTime? InfectedAreaDate { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region abstract method implementation
|
|
|
|
public override void PrepareSave(System.Data.IDbCommand cmd)
|
|
{
|
|
SqlCommand scmd = cmd as SqlCommand;
|
|
|
|
scmd.Parameters.AddWithNullableValue("@P1", this.MessageHeader.Id);
|
|
scmd.Parameters.AddWithNullableValue("@P2", this.MDHSimplification);
|
|
scmd.Parameters.AddWithNullableValue("@P3", this.PortOfCallWhereCompleteMDHNotified);
|
|
scmd.Parameters.AddWithNullableValue("@P4", this.NonAccidentalDeathsDuringVoyage);
|
|
scmd.Parameters.AddWithNullableValue("@P5", this.NonAccidentalDeathsDuringVoyageCount);
|
|
scmd.Parameters.AddWithNullableValue("@P6", this.SuspisionInfectiousNature);
|
|
scmd.Parameters.AddWithNullableValue("@P7", this.NumberOfIllPersonsHigherThanExpected);
|
|
scmd.Parameters.AddWithNullableValue("@P8", this.NumberOfIllPersons);
|
|
scmd.Parameters.AddWithNullableValue("@P9", this.SickPersonsOnBoard);
|
|
scmd.Parameters.AddWithNullableValue("@P10", this.MedicalConsulted);
|
|
scmd.Parameters.AddWithNullableValue("@P11", this.AwareOfFurtherInfections);
|
|
scmd.Parameters.AddWithNullableValue("@P12", this.SanitaryMeasuresApplied);
|
|
scmd.Parameters.AddWithNullableValue("@P13", this.SanitaryMeasuresType);
|
|
scmd.Parameters.AddWithNullableValue("@P14", this.SanitaryMeasuresLocation);
|
|
scmd.Parameters.AddWithNullableValue("@P15", this.SanitaryMeasuresDate);
|
|
scmd.Parameters.AddWithNullableValue("@P16", this.StowawaysDetected);
|
|
scmd.Parameters.AddWithNullableValue("@P17", this.StowawaysJoiningLocation);
|
|
scmd.Parameters.AddWithNullableValue("@P18", this.SickAnimalOrPetOnBoard);
|
|
scmd.Parameters.AddWithNullableValue("@P19", this.ValidSanitaryControlExemptionOrCertificateOnBoard);
|
|
scmd.Parameters.AddWithNullableValue("@P20", this.PlaceOfIssue);
|
|
scmd.Parameters.AddWithNullableValue("@P21", this.DateOfIssue);
|
|
scmd.Parameters.AddWithNullableValue("@P22", this.SanitaryControlReinspectionRequired);
|
|
scmd.Parameters.AddWithNullableValue("@P23", this.InfectedAreaVisited);
|
|
scmd.Parameters.AddWithNullableValue("@P24", this.InfectedAreaPort);
|
|
scmd.Parameters.AddWithNullableValue("@P25", this.InfectedAreaDate);
|
|
|
|
|
|
if (this.IsNew)
|
|
{
|
|
this.CreateId();
|
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
|
scmd.CommandText = string.Format("INSERT INTO {0} (Id, MessageHeaderId, MDHSimplification, PortOfCallWhereCompleteMDHNotified, " +
|
|
"NonAccidentalDeathsDuringVoyage, NonAccidentalDeathsDuringVoyageCount, SuspisionInfectiousNature, NumberOfIllPersonsHigherThanExpected, " +
|
|
"NumberOfIllPersons, SickPersonsOnBoard, MedicalConsulted, AwareOfFurtherInfections, SanitaryMeasuresApplied, SanitaryMeasuresType, " +
|
|
"SanitaryMeasuresLocation, SanitaryMeasuresDate, StowawaysDetected, StowawaysJoiningLocation, SickAnimalOrPetOnBoard, " +
|
|
"ValidSanitaryControlExemptionOrCertificateOnBoard, PlaceOfIssue, DateOfIssue, SanitaryControlReinspectionRequired, " +
|
|
"InfectedAreaVisited, InfectedAreaPort, InfectedAreaDate) VALUES (@ID, @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, " +
|
|
"@P13, @P14, @P15, @P16, @P17, @P18, @P19, @P20, @P21, @P22, @P23, @P24, @P25)", this.Tablename);
|
|
}
|
|
else
|
|
{
|
|
scmd.CommandText = string.Format("UPDATE {0} SET MDHSimplification = @P2, PortOfCallWhereCompleteMDHNotified = @P3, " +
|
|
"NonAccidentalDeathsDuringVoyage = @P4, NonAccidentalDeathsDuringVoyageCount = @P5, SuspisionInfectiousNature = @P6, " +
|
|
"NumberOfIllPersonsHigherThanExpected = @P7, NumberOfIllPersons = @P8, SickPersonsOnBoard = @P9, MedicalConsulted = @P10, " +
|
|
"AwareOfFurtherInfections = @P11, SanitaryMeasuresApplied = @P12, SanitaryMeasuresType = @P13, SanitaryMeasuresLocation = @P14, " +
|
|
"SanitaryMeasuresDate = @P15, StowawaysDetected = @P16, StowawaysJoiningLocation = @P17, SickAnimalOrPetOnBoard = @P18, " +
|
|
"ValidSanitaryControlExemptionOrCertificateOnBoard = @P19, PlaceofIssue = @P20, DateOfIssue = @P21, SanitaryControlReinspectionRequired = @P22, " +
|
|
"InfectedAreaVisited = @P23, InfectedAreaPort = @P24, InfectedAreaDate = @P25", this.Tablename);
|
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
|
}
|
|
}
|
|
|
|
public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
|
{
|
|
string query = string.Format("SELECT Id, MDHSimplification, PortOfCallWhereCompleteMDHNotified, " +
|
|
"NonAccidentalDeathsDuringVoyage, NonAccidentalDeathsDuringVoyageCount, SuspisionInfectiousNature, " +
|
|
"NumberOfIllPersonsHigherThanExpected, NumberOfIllPersons, SickPersonsOnBoard, MedicalConsulted, AwareOfFurtherInfections, " +
|
|
"SanitaryMeasuresApplied, SanitaryMeasuresType, SanitaryMeasuresLocation, SanitaryMeasuresDate, StowawaysDetected, " +
|
|
"StowawaysJoiningLocation, SickAnimalOrPetOnBoard, ValidSanitaryControlExemptionOrCertificateOnBoard, " +
|
|
"PlaceOfIssue, DateOfIssue, SanitaryControlReinspectionRequired, InfectedAreaVisited, InfectedAreaPort, InfectedAreaDate " +
|
|
"FROM {0} ", this.Tablename);
|
|
|
|
switch (filter)
|
|
{
|
|
case Message.LoadFilter.MESSAGEHEADER:
|
|
query += "WHERE MessageHeaderId = @MHID";
|
|
((SqlCommand)cmd).Parameters.AddWithValue("@MHID", criteria[0]);
|
|
break;
|
|
case Message.LoadFilter.ALL:
|
|
default:
|
|
|
|
break;
|
|
}
|
|
cmd.CommandText = query;
|
|
}
|
|
|
|
public override List<DatabaseEntity> LoadList(System.Data.IDataReader reader)
|
|
{
|
|
List<DatabaseEntity> result = new List<DatabaseEntity>();
|
|
|
|
while (reader.Read())
|
|
{
|
|
MDH mdh = new MDH();
|
|
|
|
mdh.id = reader.GetGuid(0);
|
|
if (!reader.IsDBNull(1)) mdh.MDHSimplification = reader.GetBoolean(1);
|
|
if (!reader.IsDBNull(2)) mdh.PortOfCallWhereCompleteMDHNotified = reader.GetString(2);
|
|
if (!reader.IsDBNull(3)) mdh.NonAccidentalDeathsDuringVoyage = reader.GetBoolean(3);
|
|
if (!reader.IsDBNull(4)) mdh.NonAccidentalDeathsDuringVoyageCount = reader.GetInt32(4);
|
|
if (!reader.IsDBNull(5)) mdh.SuspisionInfectiousNature = reader.GetBoolean(5);
|
|
if (!reader.IsDBNull(6)) mdh.NumberOfIllPersonsHigherThanExpected = reader.GetBoolean(6);
|
|
if (!reader.IsDBNull(7)) mdh.NumberOfIllPersons = reader.GetInt32(7);
|
|
if (!reader.IsDBNull(8)) mdh.SickPersonsOnBoard = reader.GetBoolean(8);
|
|
if (!reader.IsDBNull(9)) mdh.MedicalConsulted = reader.GetBoolean(9);
|
|
if (!reader.IsDBNull(10)) mdh.AwareOfFurtherInfections = reader.GetBoolean(10);
|
|
if (!reader.IsDBNull(11)) mdh.SanitaryMeasuresApplied = reader.GetBoolean(11);
|
|
if (!reader.IsDBNull(12)) mdh.SanitaryMeasuresType = reader.GetString(12);
|
|
if (!reader.IsDBNull(13)) mdh.SanitaryMeasuresLocation = reader.GetString(13);
|
|
if (!reader.IsDBNull(14)) mdh.SanitaryMeasuresDate = reader.GetDateTime(14);
|
|
if (!reader.IsDBNull(15)) mdh.StowawaysDetected = reader.GetBoolean(15);
|
|
if (!reader.IsDBNull(16)) mdh.StowawaysJoiningLocation = reader.GetString(16);
|
|
if (!reader.IsDBNull(17)) mdh.SickAnimalOrPetOnBoard = reader.GetBoolean(17);
|
|
if (!reader.IsDBNull(18)) mdh.ValidSanitaryControlExemptionOrCertificateOnBoard = reader.GetBoolean(18);
|
|
if (!reader.IsDBNull(19)) mdh.PlaceOfIssue = reader.GetString(19);
|
|
if (!reader.IsDBNull(20)) mdh.DateOfIssue = reader.GetDateTime(20);
|
|
if (!reader.IsDBNull(21)) mdh.SanitaryControlReinspectionRequired = reader.GetBoolean(21);
|
|
if (!reader.IsDBNull(22)) mdh.InfectedAreaVisited = reader.GetBoolean(22);
|
|
if (!reader.IsDBNull(23)) mdh.InfectedAreaPort = reader.GetString(23);
|
|
if (!reader.IsDBNull(24)) mdh.InfectedAreaDate = reader.GetDateTime(24);
|
|
|
|
result.Add(mdh);
|
|
}
|
|
|
|
reader.Close();
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ISublistElement implementation
|
|
|
|
public ISublistElement GetSublistElementWithIdentifier(string identifier)
|
|
{
|
|
foreach(ISublistElement sElem in this.PortOfCallLast30Days)
|
|
{
|
|
if (sElem.Identifier.Equals(identifier)) return sElem;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IMessageParagraph implementation
|
|
|
|
public override List<IMessageParagraph> ChildParagraphs
|
|
{
|
|
get
|
|
{
|
|
List<IMessageParagraph> result = new List<IMessageParagraph>();
|
|
foreach (IMessageParagraph imp in this.PortOfCallLast30Days)
|
|
result.Add(imp);
|
|
return result;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|