106 lines
3.1 KiB
C#
106 lines
3.1 KiB
C#
// Copyright (c) 2026 schick Informatik
|
|
// Description: DB entity for LADG NST2007 lookup
|
|
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace bsmd.database
|
|
{
|
|
public class LADG_NST2007 : DatabaseEntity
|
|
{
|
|
public LADG_NST2007()
|
|
{
|
|
this.tablename = "[dbo].[LADG_NST2007]";
|
|
}
|
|
|
|
#region Properties
|
|
|
|
[MaxLength(100)]
|
|
[ENI2Validation]
|
|
public string Description { get; set; }
|
|
|
|
[MaxLength(3)]
|
|
[ENI2Validation]
|
|
public string NST2007 { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region public static methods
|
|
|
|
public static List<KeyValuePair<string, string>> GetNST2007List()
|
|
{
|
|
List<KeyValuePair<string, string>> result = new List<KeyValuePair<string, string>>();
|
|
foreach (LADG_NST2007 item in DBManagerAsync.GetLADGNST2007Dict().Values)
|
|
{
|
|
result.Add(new KeyValuePair<string, string>(item.Description, item.NST2007));
|
|
}
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region abstract method implementation
|
|
|
|
public override List<DatabaseEntity> LoadList(IDataReader reader)
|
|
{
|
|
List<DatabaseEntity> result = new List<DatabaseEntity>();
|
|
while (reader.Read())
|
|
{
|
|
LADG_NST2007 item = new LADG_NST2007();
|
|
item.id = reader.GetGuid(0);
|
|
if (!reader.IsDBNull(1)) item.Description = reader.GetString(1);
|
|
if (!reader.IsDBNull(2)) item.NST2007 = reader.GetString(2);
|
|
result.Add(item);
|
|
}
|
|
reader.Close();
|
|
return result;
|
|
}
|
|
|
|
public override void PrepareLoadCommand(IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
|
{
|
|
string query = string.Format("SELECT Id, Description, NST2007 FROM {0} ", this.Tablename);
|
|
|
|
switch (filter)
|
|
{
|
|
case Message.LoadFilter.ALL:
|
|
default:
|
|
break;
|
|
}
|
|
|
|
cmd.CommandText = query;
|
|
}
|
|
|
|
public override void PrepareSave(IDbCommand cmd)
|
|
{
|
|
SqlCommand scmd = cmd as SqlCommand;
|
|
|
|
scmd.Parameters.AddWithNullableValue("@DESCRIPTION", this.Description);
|
|
scmd.Parameters.AddWithNullableValue("@NST2007", this.NST2007);
|
|
|
|
if (this.IsNew)
|
|
{
|
|
this.CreateId();
|
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
|
scmd.CommandText = string.Format("INSERT INTO {0} (Id, Description, NST2007) VALUES (@ID, @DESCRIPTION, @NST2007)", this.Tablename);
|
|
}
|
|
else
|
|
{
|
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
|
scmd.CommandText = string.Format("UPDATE {0} SET Description = @DESCRIPTION, NST2007 = @NST2007 WHERE Id = @ID", this.Tablename);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region override
|
|
|
|
public override string ToString()
|
|
{
|
|
return string.Format("{0} {1}", this.NST2007, this.Description);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|