105 lines
3.5 KiB
C#
105 lines
3.5 KiB
C#
//
|
|
// Class: LADG
|
|
// Current CLR: 4.0.30319.34209
|
|
// System: Microsoft Visual Studio 10.0
|
|
// Author: dani
|
|
// Created: 4/2/2015 6:48:58 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 LADG : DatabaseEntity
|
|
{
|
|
|
|
public LADG()
|
|
{
|
|
this.tablename = "[dbo].[LADG]";
|
|
}
|
|
|
|
#region Properties
|
|
|
|
public byte? CargoHandlingType { get; set; }
|
|
|
|
public string CargoCodeNST { get; set; }
|
|
|
|
public int? CargoNumberOfItems { get; set; }
|
|
|
|
public float? CargoGrossQuantity_TNE { get; set; }
|
|
|
|
#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.CargoHandlingType);
|
|
scmd.Parameters.AddWithNullableValue("@P3", this.CargoCodeNST);
|
|
scmd.Parameters.AddWithNullableValue("@P4", this.CargoNumberOfItems);
|
|
scmd.Parameters.AddWithNullableValue("@P5", this.CargoGrossQuantity_TNE);
|
|
|
|
if (this.IsNew)
|
|
{
|
|
scmd.CommandText = string.Format("INSERT INTO {0} (MessageHeaderId, CargoHandlingType, CargoCodeNST, " +
|
|
"CargoNumberOfItems, CargoGrossQuantity_TNE) VALUES ( @P1, @P2, @P3, @P4, @P5 )", this.Tablename);
|
|
}
|
|
else
|
|
{
|
|
scmd.Parameters.AddWithValue(@"ID", this.Id);
|
|
scmd.CommandText = string.Format("UPDATE {0} SET CargoHandlingType = @P2, CargoCodeNST = @P3, CargoNumberOfItems = @P4, " +
|
|
"CargoGrossQuantity_TNE = @P5 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, CargoHandlingType, CargoCodeNST, CargoNumberOfItems, CargoGrossQuantity_TNE 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())
|
|
{
|
|
LADG ladg = new LADG();
|
|
|
|
ladg.id = reader.GetGuid(0);
|
|
if (!reader.IsDBNull(1)) ladg.CargoHandlingType = reader.GetByte(1);
|
|
if (!reader.IsDBNull(2)) ladg.CargoCodeNST = reader.GetString(2);
|
|
if (!reader.IsDBNull(3)) ladg.CargoNumberOfItems = reader.GetInt32(3);
|
|
if (!reader.IsDBNull(4)) ladg.CargoGrossQuantity_TNE = reader.GetFloat(4);
|
|
result.Add(ladg);
|
|
}
|
|
reader.Close();
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
} |