203 lines
8.1 KiB
C#
203 lines
8.1 KiB
C#
//
|
|
// Class: PRE72H
|
|
// Current CLR: 4.0.30319.34209
|
|
// System: Microsoft Visual Studio 10.0
|
|
// Author: dani
|
|
// Created: 4/2/2015 7:17:11 PM
|
|
//
|
|
// 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 PRE72H : DatabaseEntity
|
|
{
|
|
|
|
public PRE72H()
|
|
{
|
|
this.tablename = "[dbo].[PRE72H]";
|
|
}
|
|
|
|
#region Properties
|
|
|
|
[ShowReport]
|
|
[Validation(ValidationCode.NOT_NULL)]
|
|
[LookupName("PRE72H.Tanker")]
|
|
[ENI2Validation]
|
|
public bool? Tanker { get; set; }
|
|
|
|
[ShowReport]
|
|
[ENI2Validation]
|
|
public byte? TankerHullConfiguration { get; set; }
|
|
|
|
[ShowReport]
|
|
[ENI2Validation]
|
|
public byte? ConditionCargoBallastTanks { get; set; }
|
|
|
|
[ShowReport]
|
|
[LookupName("PRE72H.NaturOfCargo")]
|
|
[MaxLength(99)]
|
|
[ENI2Validation]
|
|
public string NatureOfCargo { get; set; }
|
|
|
|
[ShowReport]
|
|
[LookupName("PRE72H.VolumeOfCargo_TNE")]
|
|
[ENI2Validation]
|
|
public double? VolumeOfCargo { get; set; }
|
|
|
|
[ShowReport]
|
|
[Validation(ValidationCode.NOT_NULL)]
|
|
[LookupName("PRE72H.PlannedOperations")]
|
|
[MaxLength(99)]
|
|
[ENI2Validation]
|
|
public string PlannedOperations { get; set; }
|
|
|
|
[ShowReport]
|
|
[Validation(ValidationCode.NOT_NULL)]
|
|
// nach Util verschoben
|
|
[MaxLength(255)]
|
|
[ENI2Validation]
|
|
public string PlannedWorks { get; set; }
|
|
|
|
[ShowReport]
|
|
[LookupName("PRE72H.DateOfLastExpandedInspection")]
|
|
[ENI2Validation]
|
|
[DateOnly]
|
|
public DateTime? DateOfLastExpandedInspection { get; set; }
|
|
|
|
[ShowReport]
|
|
[Validation(ValidationCode.DOUBLE_GT_ZERO)]
|
|
[LookupName("PRE72H.PlannedPeriodOfStay_HUR")]
|
|
[ENI2Validation]
|
|
public double? PlannedPeriodOfStay_HUR { get; set; }
|
|
|
|
[LookupName("PRE72H.IsDueToInspection")]
|
|
[ENI2Validation]
|
|
public bool? IsDueToInspection { get; set; }
|
|
|
|
[LookupName("PRE72H.PossibleAnchorage")]
|
|
[ENI2Validation]
|
|
public bool? PossibleAnchorage { get; set; }
|
|
|
|
public override string Subtitle
|
|
{
|
|
get
|
|
{
|
|
return "72h appointment";
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region DatabaseEntity implementation
|
|
|
|
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.Tanker);
|
|
scmd.Parameters.AddWithNullableValue("@P3", this.TankerHullConfiguration);
|
|
scmd.Parameters.AddWithNullableValue("@P4", this.ConditionCargoBallastTanks);
|
|
scmd.Parameters.AddWithNullableValue("@P5", this.NatureOfCargo);
|
|
scmd.Parameters.AddWithNullableValue("@P6", this.VolumeOfCargo);
|
|
scmd.Parameters.AddWithNullableValue("@P7", this.PlannedOperations);
|
|
scmd.Parameters.AddWithNullableValue("@P8", this.PlannedWorks);
|
|
scmd.Parameters.AddWithNullableValue("@P9", this.DateOfLastExpandedInspection);
|
|
scmd.Parameters.AddWithNullableValue("@P10", this.PlannedPeriodOfStay_HUR);
|
|
scmd.Parameters.AddWithNullableValue("@P11", this.IsDueToInspection);
|
|
scmd.Parameters.AddWithNullableValue("@P12", this.PossibleAnchorage);
|
|
|
|
if (this.IsNew)
|
|
{
|
|
this.CreateId();
|
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
|
scmd.CommandText = string.Format("INSERT INTO {0} (Id, MessageHeaderId, Tanker, TankerHullConfiguration, " +
|
|
"ConditionCargoBallastTanks, NatureOfCargo, VolumeOfCargo, PlannedOperations, PlannedWorks, DateOfLastExpandedInspection, " +
|
|
"PlannedPeriodOfStay_HUR, IsDueToInspection, PossibleAnchorage) VALUES ( @ID, @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12 )",
|
|
this.Tablename);
|
|
}
|
|
else
|
|
{
|
|
scmd.Parameters.AddWithValue(@"ID", this.Id);
|
|
scmd.CommandText = string.Format("UPDATE {0} SET Tanker = @P2, TankerHullConfiguration = @P3, " +
|
|
"ConditionCargoBallastTanks = @P4, NatureOfCargo = @P5, VolumeOfCargo = @P6," +
|
|
"PlannedOperations = @P7, PlannedWorks = @P8, DateOfLastExpandedInspection = @P9, " +
|
|
"PlannedPeriodOfStay_HUR = @P10, IsDueToInspection = @P11, PossibleAnchorage = @P12 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, Tanker, TankerHullConfiguration, ConditionCargoBallastTanks, " +
|
|
"NatureOfCargo, VolumeOfCargo, PlannedOperations, PlannedWorks, DateOfLastExpandedInspection, " +
|
|
"PlannedPeriodOfStay_HUR, IsDueToInspection, PossibleAnchorage 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())
|
|
{
|
|
PRE72H pre72h = new PRE72H();
|
|
|
|
pre72h.id = reader.GetGuid(0);
|
|
if (!reader.IsDBNull(1)) pre72h.Tanker = reader.GetBoolean(1);
|
|
if (!reader.IsDBNull(2)) pre72h.TankerHullConfiguration = reader.GetByte(2);
|
|
if (!reader.IsDBNull(3)) pre72h.ConditionCargoBallastTanks = reader.GetByte(3);
|
|
if (!reader.IsDBNull(4)) pre72h.NatureOfCargo = reader.GetString(4);
|
|
if (!reader.IsDBNull(5)) pre72h.VolumeOfCargo = (float) reader.GetDouble(5);
|
|
if (!reader.IsDBNull(6)) pre72h.PlannedOperations = reader.GetString(6);
|
|
if (!reader.IsDBNull(7)) pre72h.PlannedWorks = reader.GetString(7);
|
|
if (!reader.IsDBNull(8)) pre72h.DateOfLastExpandedInspection = reader.GetDateTime(8);
|
|
if (!reader.IsDBNull(9)) pre72h.PlannedPeriodOfStay_HUR = (float) reader.GetDouble(9);
|
|
if (!reader.IsDBNull(10)) pre72h.IsDueToInspection = reader.GetBoolean(10);
|
|
if (!reader.IsDBNull(11)) pre72h.PossibleAnchorage = reader.GetBoolean(11);
|
|
result.Add(pre72h);
|
|
}
|
|
reader.Close();
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Validation
|
|
|
|
public override void Validate(List<MessageError> errors, List<MessageViolation> violations)
|
|
{
|
|
if (this.Tanker ?? false)
|
|
{
|
|
if (!this.TankerHullConfiguration.HasValue)
|
|
violations.Add(RuleEngine.CreateViolation(ValidationCode.V741, "TankerHullConfiguration", null, this.Title, null, this.Tablename));
|
|
if (!this.ConditionCargoBallastTanks.HasValue)
|
|
violations.Add(RuleEngine.CreateViolation(ValidationCode.V741, "ConditionCargoBallastTanks", null, this.Title, null, this.Tablename));
|
|
if (this.VolumeOfCargo.HasValue && this.VolumeOfCargo.Value == 0)
|
|
violations.Add(RuleEngine.CreateViolation(ValidationCode.DOUBLE_GT_ZERO, "VolumeOfCargo must be > 0", null, this.Title, null, this.Tablename));
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|