196 lines
7.6 KiB
C#
196 lines
7.6 KiB
C#
//
|
|
// Class: INFO
|
|
// Current CLR: 4.0.30319.34209
|
|
// System: Microsoft Visual Studio 10.0
|
|
// Author: dani
|
|
// Created: 4/2/2015 6:59:19 PM
|
|
//
|
|
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
|
|
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using log4net;
|
|
|
|
namespace bsmd.database
|
|
{
|
|
public class INFO : DatabaseEntity
|
|
{
|
|
private static ILog _log = LogManager.GetLogger(typeof(INFO));
|
|
public INFO()
|
|
{
|
|
this.tablename = "[dbo].[INFO]";
|
|
}
|
|
|
|
#region Properties
|
|
|
|
[ShowReport]
|
|
[Validation(ValidationCode.NOT_NULL)]
|
|
[ENI2Validation]
|
|
public byte? ShippingArea { get; set; }
|
|
|
|
[ShowReport]
|
|
[Validation(ValidationCode.NOT_NULL)]
|
|
[LookupName("INFO.RequestedPositionInPortOfCall")]
|
|
[MaxLength(100)]
|
|
[ENI2Validation]
|
|
public string RequestedPositionInPortOfCall { get; set; }
|
|
|
|
[ShowReport]
|
|
[LookupName("INFO.SpecialRequirementsOfShipAtBerth")]
|
|
[MaxLength(255)]
|
|
[ENI2Validation]
|
|
public string SpecialRequirementsOfShipAtBerth { get; set; }
|
|
|
|
[ShowReport]
|
|
[LookupName("INFO.ConstructionCharacteristicsOfShip")]
|
|
[MaxLength(100)]
|
|
[ENI2Validation]
|
|
public string ConstructionCharacteristicsOfShip { get; set; }
|
|
|
|
[ShowReport]
|
|
[Validation(ValidationCode.NOT_NULL)]
|
|
[ENI2Validation]
|
|
public byte? FumigatedBulkCargo { get; set; }
|
|
|
|
/// <summary>
|
|
/// ENI-2 Edit Value für Checkbox (OMG!)
|
|
/// </summary>
|
|
public bool? FumigatedBulkCargoBool
|
|
{
|
|
get
|
|
{
|
|
if (this.FumigatedBulkCargo.HasValue) return (this.FumigatedBulkCargo.Value != 0);
|
|
return null;
|
|
}
|
|
set
|
|
{
|
|
if (value.HasValue)
|
|
this.FumigatedBulkCargo = value.Value ? (byte)1 : (byte)0;
|
|
else
|
|
this.FumigatedBulkCargo = null;
|
|
}
|
|
}
|
|
|
|
[ShowReport]
|
|
[LookupName("INFO.DeadWeightSummer_TNE")]
|
|
[ENI2Validation]
|
|
public double? DeplacementSummerDraught_TNE { get; set; }
|
|
|
|
[ShowReport]
|
|
[LookupName("INFO.PortArea")]
|
|
[Validation(ValidationCode.NOT_NULL)] // ist bei NOK Transit leer
|
|
[MaxLength(50)]
|
|
[ENI2Validation]
|
|
public string PortArea { get; set; }
|
|
|
|
[MaxLength(50)]
|
|
[ENI2Validation]
|
|
public string BowThrusterPower { get; set; }
|
|
|
|
[MaxLength(50)]
|
|
[ENI2Validation]
|
|
public string SternThrusterPower { get; set; }
|
|
|
|
[MaxLength(4)]
|
|
[LookupName("INFO.PortFacility")]
|
|
[ENI2Validation]
|
|
public string PortFacility { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region DatabaseEntity implementation
|
|
|
|
public override string Subtitle
|
|
{
|
|
get
|
|
{
|
|
return "General information";
|
|
}
|
|
}
|
|
|
|
public override void PrepareSave(System.Data.IDbCommand cmd)
|
|
{
|
|
|
|
SqlCommand scmd = cmd as SqlCommand;
|
|
|
|
scmd.Parameters.AddWithValue("@P1", this.MessageHeader.Id);
|
|
scmd.Parameters.AddWithNullableValue("@P2", this.ShippingArea);
|
|
scmd.Parameters.AddWithNullableValue("@P3", this.RequestedPositionInPortOfCall);
|
|
scmd.Parameters.AddWithNullableValue("@P4", this.SpecialRequirementsOfShipAtBerth);
|
|
scmd.Parameters.AddWithNullableValue("@P5", this.ConstructionCharacteristicsOfShip);
|
|
scmd.Parameters.AddWithNullableValue("@P6", this.FumigatedBulkCargo);
|
|
scmd.Parameters.AddWithNullableValue("@P7", this.DeplacementSummerDraught_TNE);
|
|
scmd.Parameters.AddWithNullableValue("@P8", this.PortArea);
|
|
scmd.Parameters.AddWithNullableValue("@P9", this.BowThrusterPower);
|
|
scmd.Parameters.AddWithNullableValue("@P10", this.SternThrusterPower);
|
|
scmd.Parameters.AddWithNullableValue("@P11", this.PortFacility);
|
|
|
|
if (this.IsNew)
|
|
{
|
|
this.CreateId();
|
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
|
scmd.CommandText = string.Format("INSERT INTO {0} (Id, MessageHeaderId, ShippingArea, RequestedPositionInPortOfCall, " +
|
|
"SpecialRequirementsOfShipAtBerth, ConstructionCharacteristicsOfShip, FumigatedBulkCargo, DeplacementSummerDraught_TNE, " +
|
|
"PortArea, BowThrusterPower, SternThrusterPower, PortFacility) VALUES ( @ID, @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11 )", this.Tablename);
|
|
}
|
|
else
|
|
{
|
|
scmd.Parameters.AddWithValue(@"ID", this.Id);
|
|
scmd.CommandText = string.Format("UPDATE {0} SET ShippingArea = @P2, RequestedPositionInPortOfCall = @P3, " +
|
|
"SpecialRequirementsOfShipAtBerth = @P4, ConstructionCharacteristicsOfShip = @P5, FumigatedBulkCargo = @P6," +
|
|
"DeplacementSummerDraught_TNE = @P7, PortArea = @P8, BowThrusterPower = @P9, SternThrusterPower = @P10, " +
|
|
"PortFacility = @P11 WHERE Id = @ID", this.Tablename);
|
|
}
|
|
}
|
|
|
|
public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
|
{
|
|
string query = string.Format("SELECT Id, ShippingArea, RequestedPositionInPortOfCall, SpecialRequirementsOfShipAtBerth, " +
|
|
"ConstructionCharacteristicsOfShip, FumigatedBulkCargo, DeplacementSummerDraught_TNE, PortArea, BowThrusterPower, " +
|
|
"SternThrusterPower, PortFacility 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())
|
|
{
|
|
INFO info = new INFO();
|
|
|
|
info.id = reader.GetGuid(0);
|
|
if (!reader.IsDBNull(1)) info.ShippingArea = reader.GetByte(1);
|
|
if (!reader.IsDBNull(2)) info.RequestedPositionInPortOfCall = reader.GetString(2);
|
|
if (!reader.IsDBNull(3)) info.SpecialRequirementsOfShipAtBerth = reader.GetString(3);
|
|
if (!reader.IsDBNull(4)) info.ConstructionCharacteristicsOfShip = reader.GetString(4);
|
|
if (!reader.IsDBNull(5)) info.FumigatedBulkCargo = reader.GetByte(5);
|
|
if (!reader.IsDBNull(6)) info.DeplacementSummerDraught_TNE = (float)reader.GetDouble(6);
|
|
if (!reader.IsDBNull(7)) info.PortArea = reader.GetString(7);
|
|
if (!reader.IsDBNull(8)) info.BowThrusterPower = reader.GetString(8);
|
|
if (!reader.IsDBNull(9)) info.SternThrusterPower = reader.GetString(9);
|
|
if(!reader.IsDBNull(10)) info.PortFacility = reader.GetString(10);
|
|
result.Add(info);
|
|
}
|
|
reader.Close();
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
} |