115 lines
3.6 KiB
C#
115 lines
3.6 KiB
C#
//
|
|
// Class: TIEFD
|
|
// Current CLR: 4.0.30319.34209
|
|
// System: Microsoft Visual Studio 10.0
|
|
// Author: dani
|
|
// Created: 4/1/2015 10:00:57 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 TIEFD : DatabaseEntity
|
|
{
|
|
|
|
public TIEFD()
|
|
{
|
|
this.tablename = "[dbo].[TIEFD]";
|
|
}
|
|
|
|
#region Properties
|
|
|
|
[ShowReport]
|
|
[Validation(ValidationCode.NOT_NULL)]
|
|
[LookupName("TIEFD.DraughtUponDeparture_DMT")]
|
|
[ENI2Validation]
|
|
public double? DraughtUponDeparture_DMT { get; set; }
|
|
|
|
public override string Subtitle
|
|
{
|
|
get
|
|
{
|
|
return "Draught at departure notification";
|
|
}
|
|
}
|
|
|
|
#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.DraughtUponDeparture_DMT);
|
|
|
|
if (this.IsNew)
|
|
{
|
|
this.CreateId();
|
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
|
scmd.CommandText = string.Format("INSERT INTO {0} (Id, MessageHeaderId, DraughtUponDeparture_DMT) VALUES ( @ID, @P1, @P2 )",
|
|
this.Tablename);
|
|
}
|
|
else
|
|
{
|
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
|
scmd.CommandText = string.Format("UPDATE {0} SET DraughtUponDeparture_DMT = @P2 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, DraughtUponDeparture_DMT 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())
|
|
{
|
|
TIEFD tiefd = new TIEFD();
|
|
|
|
tiefd.id = reader.GetGuid(0);
|
|
if (!reader.IsDBNull(1)) tiefd.DraughtUponDeparture_DMT = reader.GetDouble(1);
|
|
result.Add(tiefd);
|
|
}
|
|
reader.Close();
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Validation
|
|
|
|
public override void Validate(List<MessageError> errors, List<MessageViolation> violations)
|
|
{
|
|
if (this.DraughtUponDeparture_DMT.HasValue && ((this.DraughtUponDeparture_DMT.Value < 10) || (this.DraughtUponDeparture_DMT.Value > 200)))
|
|
violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Check draught on departure", null, this.Title, null, this.Tablename));
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
} |