Erweiterung Speicherklassen Part I (nur Entities)
This commit is contained in:
parent
5bc00c8dea
commit
6cea222305
@ -140,7 +140,8 @@ namespace bsmd.database
|
||||
DELETED,
|
||||
IMPORTHEADER_ID,
|
||||
BY_CORE_AND_CLASS,
|
||||
BY_AGE
|
||||
BY_AGE,
|
||||
WASRCPT_ID
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
105
bsmd.database/TreatmentFacilityProvider.cs
Normal file
105
bsmd.database/TreatmentFacilityProvider.cs
Normal file
@ -0,0 +1,105 @@
|
||||
// Copyright (c) 2020-present schick Informatik
|
||||
// Description:
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace bsmd.database
|
||||
{
|
||||
public class TreatmentFacilityProvider : DatabaseEntity, ISublistElement
|
||||
{
|
||||
|
||||
public TreatmentFacilityProvider()
|
||||
{
|
||||
this.tablename = "[dbo].[TreatmentFacilityProvider]";
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
[JsonIgnore]
|
||||
public WAS_RCPT WAS_RCPT { get; set; }
|
||||
|
||||
[ShowReport]
|
||||
[MaxLength(70)]
|
||||
[ENI2Validation]
|
||||
[Validation(ValidationCode.STRING_MAXLEN, 70)]
|
||||
public string TreatmentFacilityProviderName { get; set; }
|
||||
|
||||
public string Identifier { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string SublistCollectionKey { get { return "tfp"; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region DatabaseEntity implementation
|
||||
|
||||
public override void PrepareSave(System.Data.IDbCommand cmd)
|
||||
{
|
||||
|
||||
SqlCommand scmd = cmd as SqlCommand;
|
||||
|
||||
scmd.Parameters.AddWithValue("@P1", this.WAS_RCPT.Id);
|
||||
scmd.Parameters.AddWithNullableValue("@P2", this.TreatmentFacilityProviderName);
|
||||
scmd.Parameters.AddWithNullableValue("@P3", this.Identifier);
|
||||
|
||||
if (this.IsNew)
|
||||
{
|
||||
this.CreateId();
|
||||
scmd.Parameters.AddWithValue("@ID", this.Id);
|
||||
scmd.CommandText = string.Format("INSERT INTO {0} (Id, WASId, TreatmentFacilityProviderName, Identifier) " +
|
||||
"VALUES ( @ID, @P1, @P2, @P3 )", this.Tablename);
|
||||
}
|
||||
else
|
||||
{
|
||||
scmd.Parameters.AddWithValue("ID", this.Id);
|
||||
scmd.CommandText = string.Format("UPDATE {0} SET TreatmentFacilityProviderName = @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, TreatmentFacilityProviderName, Identifier FROM {0}", this.Tablename);
|
||||
|
||||
switch (filter)
|
||||
{
|
||||
case Message.LoadFilter.WASRCPT_ID:
|
||||
query += "WHERE WAS_RCPTId = @WASRCPTID";
|
||||
((SqlCommand)cmd).Parameters.AddWithValue("@WASRCPTID", criteria[0]);
|
||||
break;
|
||||
case Message.LoadFilter.ALL:
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
query += " ORDER BY CAST(Identifier AS INT)";
|
||||
|
||||
cmd.CommandText = query;
|
||||
}
|
||||
|
||||
public override List<DatabaseEntity> LoadList(System.Data.IDataReader reader)
|
||||
{
|
||||
List<DatabaseEntity> result = new List<DatabaseEntity>();
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
TreatmentFacilityProvider tfp = new TreatmentFacilityProvider();
|
||||
|
||||
tfp.id = reader.GetGuid(0);
|
||||
if (!reader.IsDBNull(1)) tfp.TreatmentFacilityProviderName = reader.GetString(1);
|
||||
if (!reader.IsDBNull(2)) tfp.Identifier = reader.GetString(2);
|
||||
result.Add(tfp);
|
||||
}
|
||||
reader.Close();
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
243
bsmd.database/WAS_RCPT.cs
Normal file
243
bsmd.database/WAS_RCPT.cs
Normal file
@ -0,0 +1,243 @@
|
||||
// Copyright (c) 2020-present schick Informatik
|
||||
// Description: New class for NSW 7.0 Waste "Empfangsbestätigung"
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Data.SqlClient;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using Newtonsoft.Json;
|
||||
using System.Data;
|
||||
|
||||
namespace bsmd.database
|
||||
{
|
||||
|
||||
[TypeConverter(typeof(MessageClassConverter<WAS>))]
|
||||
[JsonConverter(typeof(NoTypeConverterJsonConverter<WAS>))]
|
||||
public class WAS_RCPT : DatabaseEntity, ISublistContainer
|
||||
{
|
||||
public WAS_RCPT()
|
||||
{
|
||||
this.tablename = "[dbo].[WAS_RCPT]";
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
[MaxLength(20)]
|
||||
public string IdentificationNumber { get; set; }
|
||||
|
||||
[MaxLength(70)]
|
||||
public string PortReceptionFacilityName { get; set; }
|
||||
|
||||
[MaxLength(70)]
|
||||
public string PortReceptionFacilityProviderName { get; set; }
|
||||
|
||||
public ObservableCollection<WasteReceived> WasteReceived { get; private set; } = new ObservableCollection<WasteReceived>();
|
||||
|
||||
[Validation(ValidationCode.NOT_NULL)]
|
||||
public DateTime? WasteDeliveryDateFrom { get; set; }
|
||||
|
||||
[Validation(ValidationCode.NOT_NULL)]
|
||||
public DateTime? WasteDeliveryDateTo { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public ObservableCollection<TreatmentFacilityProvider> TreatmentFacilityProvider { get; private set; } = new ObservableCollection<TreatmentFacilityProvider>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region ISublistContainer implementation
|
||||
|
||||
public ISublistElement GetSublistElementWithIdentifier(string identifier)
|
||||
{
|
||||
foreach (WasteReceived wasteReceived in this.WasteReceived)
|
||||
{
|
||||
if (wasteReceived.Identifier.Equals(identifier))
|
||||
return wasteReceived;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[JsonIgnore]
|
||||
public int NumberOfExcelRows
|
||||
{
|
||||
get { return 15; }
|
||||
}
|
||||
|
||||
public void SaveElements()
|
||||
{
|
||||
foreach (WasteReceived wasteReceived in this.WasteReceived)
|
||||
{
|
||||
DBManager.Instance.Save(wasteReceived);
|
||||
}
|
||||
|
||||
foreach(TreatmentFacilityProvider tfp in this.TreatmentFacilityProvider)
|
||||
{
|
||||
DBManager.Instance.Save(tfp);
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteElements()
|
||||
{
|
||||
foreach (WasteReceived wasteReceived in this.WasteReceived)
|
||||
{
|
||||
DBManager.Instance.Delete(wasteReceived);
|
||||
}
|
||||
this.WasteReceived.Clear();
|
||||
|
||||
foreach(TreatmentFacilityProvider tfp in this.TreatmentFacilityProvider)
|
||||
{
|
||||
DBManager.Instance.Delete(tfp);
|
||||
}
|
||||
this.TreatmentFacilityProvider.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DatabaseEntity implementation
|
||||
|
||||
public override void PrepareSave(IDbCommand cmd)
|
||||
{
|
||||
SqlCommand scmd = cmd as SqlCommand;
|
||||
|
||||
scmd.Parameters.AddWithValue("@P1", this.MessageHeader.Id);
|
||||
scmd.Parameters.AddWithNullableValue("@P2", this.IdentificationNumber);
|
||||
scmd.Parameters.AddWithNullableValue("@P3", this.PortReceptionFacilityName);
|
||||
scmd.Parameters.AddWithNullableValue("@P4", this.PortReceptionFacilityProviderName);
|
||||
scmd.Parameters.AddWithNullableValue("@P5", this.WasteDeliveryDateFrom);
|
||||
scmd.Parameters.AddWithNullableValue("@P6", this.WasteDeliveryDateTo);
|
||||
|
||||
if (this.IsNew)
|
||||
{
|
||||
this.CreateId();
|
||||
scmd.Parameters.AddWithValue("@ID", this.Id);
|
||||
scmd.CommandText = string.Format("INSERT INTO {0} (Id, MessageHeaderId, IdentificationNumber, " +
|
||||
"PortReceptionFacilityName, PortReceptionFacilityProviderName, WasteDeliveryDateFrom, WasteDeliveryDateTo) " +
|
||||
"VALUES ( @ID, @P1, @P2, @P3, @P4, @P5, @P6 )", this.Tablename);
|
||||
}
|
||||
else
|
||||
{
|
||||
scmd.Parameters.AddWithValue("ID", this.Id);
|
||||
scmd.CommandText = string.Format("UPDATE {0} SET IdentificationNumber = @P2, PortReceptionFacilityName = @P3, " +
|
||||
"PortReceptionFacilityProviderName = @P4, WasteDeliveryDateFrom = @P5, WasteDeliveryDateTo = @P6 " +
|
||||
"WHERE Id = @ID", this.Tablename);
|
||||
}
|
||||
}
|
||||
|
||||
public override void PrepareLoadCommand(IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
||||
{
|
||||
string query = string.Format("SELECT Id, IdentificationNumber, PortReceptionFacilityName, PortReceptionFacilityProviderName, " +
|
||||
"WasteDeliveryDateFrom, WasteDeliveryDateTo " +
|
||||
"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(IDataReader reader)
|
||||
{
|
||||
List<DatabaseEntity> result = new List<DatabaseEntity>();
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
WAS_RCPT was_rcpt = new WAS_RCPT
|
||||
{
|
||||
id = reader.GetGuid(0)
|
||||
};
|
||||
|
||||
if (!reader.IsDBNull(1)) was_rcpt.IdentificationNumber = reader.GetString(1);
|
||||
if (!reader.IsDBNull(2)) was_rcpt.PortReceptionFacilityName = reader.GetString(2);
|
||||
if (!reader.IsDBNull(3)) was_rcpt.PortReceptionFacilityProviderName = reader.GetString(3);
|
||||
if (!reader.IsDBNull(4)) was_rcpt.WasteDeliveryDateFrom = reader.GetDateTime(4);
|
||||
if (!reader.IsDBNull(5)) was_rcpt.WasteDeliveryDateTo = reader.GetDateTime(5);
|
||||
|
||||
result.Add(was_rcpt);
|
||||
}
|
||||
reader.Close();
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IMessageParagraph implementation
|
||||
|
||||
[Browsable(false)]
|
||||
[JsonIgnore]
|
||||
public override string Subtitle
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Waste receipt";
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[JsonIgnore]
|
||||
public override List<IMessageParagraph> ChildParagraphs
|
||||
{
|
||||
get
|
||||
{
|
||||
List<IMessageParagraph> result = new List<IMessageParagraph>();
|
||||
foreach (IMessageParagraph imp in this.WasteReceived)
|
||||
result.Add(imp);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Validation
|
||||
|
||||
public override void Validate(List<MessageError> errors, List<MessageViolation> violations)
|
||||
{
|
||||
foreach (WasteReceived wasteReceived in this.WasteReceived)
|
||||
{
|
||||
RuleEngine.ValidateProperties(wasteReceived, errors, violations);
|
||||
wasteReceived.Validate(errors, violations);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ICloneable implementation
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
WAS_RCPT wasRcpt = this.MemberwiseClone() as WAS_RCPT;
|
||||
wasRcpt.id = null;
|
||||
wasRcpt.WasteReceived = new ObservableCollection<WasteReceived>();
|
||||
|
||||
foreach (WasteReceived wasteReceived in this.WasteReceived)
|
||||
{
|
||||
WasteReceived clonedWasteReceived = wasteReceived.Clone() as WasteReceived;
|
||||
clonedWasteReceived.WAS_RCPT = wasRcpt;
|
||||
wasRcpt.WasteReceived.Add(clonedWasteReceived);
|
||||
}
|
||||
|
||||
foreach(TreatmentFacilityProvider tfp in this.TreatmentFacilityProvider)
|
||||
{
|
||||
TreatmentFacilityProvider clonedTfp = tfp.Clone() as TreatmentFacilityProvider;
|
||||
clonedTfp.WAS_RCPT = wasRcpt;
|
||||
wasRcpt.TreatmentFacilityProvider.Add(clonedTfp);
|
||||
}
|
||||
|
||||
return wasRcpt;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@ -95,6 +95,7 @@ namespace bsmd.database
|
||||
}
|
||||
}
|
||||
|
||||
// jetzt der "WasteCode"
|
||||
[Validation(ValidationCode.NOT_NULL)]
|
||||
[ENI2Validation]
|
||||
public int? WasteType { get; set; }
|
||||
@ -119,6 +120,7 @@ namespace bsmd.database
|
||||
[ENI2Validation]
|
||||
public double? WasteAmountRetained_MTQ { get; set; }
|
||||
|
||||
// Jetzt der "RemainingWasteDeliveryPort"
|
||||
[ShowReport]
|
||||
[MaxLength(5)]
|
||||
[ENI2Validation]
|
||||
|
||||
131
bsmd.database/WasteReceived.cs
Normal file
131
bsmd.database/WasteReceived.cs
Normal file
@ -0,0 +1,131 @@
|
||||
// Copyright (c) 2020-present schick Informatik
|
||||
// Description: Element für WAS_RCPT
|
||||
|
||||
using System.Data.SqlClient;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel;
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace bsmd.database
|
||||
{
|
||||
|
||||
[TypeConverter(typeof(MessageClassConverter<WasteReceived>))]
|
||||
[JsonConverter(typeof(NoTypeConverterJsonConverter<WasteReceived>))]
|
||||
public class WasteReceived : DatabaseEntity, ISublistElement
|
||||
{
|
||||
|
||||
#region ISublistElement implementation
|
||||
|
||||
[JsonIgnore]
|
||||
[Browsable(false)]
|
||||
public string SublistCollectionKey { get { return "wasteReceived"; } }
|
||||
|
||||
public string Identifier { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
[JsonIgnore]
|
||||
[Browsable(false)]
|
||||
public WAS_RCPT WAS_RCPT { get; set; }
|
||||
|
||||
[ShowReport]
|
||||
[MaxLength(3)]
|
||||
[ENI2Validation]
|
||||
public string WasteCode { get; set; }
|
||||
|
||||
[ShowReport]
|
||||
[MaxLength(256)]
|
||||
[ENI2Validation]
|
||||
public string WasteDescription { get; set; }
|
||||
|
||||
[ShowReport]
|
||||
[Validation(ValidationCode.NOT_NULL)]
|
||||
[ENI2Validation]
|
||||
public double? AmountWasteReceived_MTQ { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region DatabaseEntity implementation
|
||||
|
||||
public override List<DatabaseEntity> LoadList(IDataReader reader)
|
||||
{
|
||||
List<DatabaseEntity> result = new List<DatabaseEntity>();
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
WasteReceived wasteReceived = new WasteReceived();
|
||||
|
||||
wasteReceived.id = reader.GetGuid(0);
|
||||
if (!reader.IsDBNull(1)) wasteReceived.WasteCode = reader.GetString(1);
|
||||
if (!reader.IsDBNull(2)) wasteReceived.WasteDescription = reader.GetString(2);
|
||||
if (!reader.IsDBNull(3)) wasteReceived.AmountWasteReceived_MTQ = (float)reader.GetDouble(3);
|
||||
if (!reader.IsDBNull(4)) wasteReceived.Identifier = reader.GetString(4);
|
||||
result.Add(wasteReceived);
|
||||
}
|
||||
reader.Close();
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void PrepareLoadCommand(IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
||||
{
|
||||
string query = string.Format("SELECT Id, WasteCode, WasteDescription, AmountWasteReceived_MTQ, Identifier FROM {0} ", this.Tablename);
|
||||
|
||||
switch (filter)
|
||||
{
|
||||
case Message.LoadFilter.WASRCPT_ID:
|
||||
query += " WHERE WAS_RCPTId = @WDID";
|
||||
((SqlCommand)cmd).Parameters.AddWithValue("@WDID", criteria[0]);
|
||||
break;
|
||||
case Message.LoadFilter.ALL:
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
query += " ORDER BY CAST(Identifier AS INT)";
|
||||
|
||||
cmd.CommandText = query;
|
||||
}
|
||||
|
||||
public override void PrepareSave(IDbCommand cmd)
|
||||
{
|
||||
SqlCommand scmd = cmd as SqlCommand;
|
||||
|
||||
scmd.Parameters.AddWithValue("@P1", this.WAS_RCPT.Id);
|
||||
scmd.Parameters.AddWithNullableValue("@P2", this.WasteCode);
|
||||
scmd.Parameters.AddWithNullableValue("@P3", this.WasteDescription);
|
||||
scmd.Parameters.AddWithNullableValue("@P4", this.AmountWasteReceived_MTQ);
|
||||
scmd.Parameters.AddWithNullableValue("@P5", this.Identifier);
|
||||
|
||||
if (this.IsNew)
|
||||
{
|
||||
this.CreateId();
|
||||
scmd.Parameters.AddWithValue("@ID", this.Id);
|
||||
scmd.CommandText = string.Format("INSERT INTO {0} (Id, WAS_RCPTId, WasteCode, WasteDescription, " +
|
||||
"AmountWasteReceived_MTQ, Identifier) " +
|
||||
" VALUES ( @ID, @P1, @P2, @P3, @P4, @P5 )", this.Tablename);
|
||||
}
|
||||
else
|
||||
{
|
||||
scmd.Parameters.AddWithValue("@ID", this.Id);
|
||||
scmd.CommandText = string.Format("UPDATE {0} SET WasteCode = @P2, WasteDescription = @P3, " +
|
||||
"AmountWasteReceived_MTQ = @P4, Identifier = @P5 WHERE Id = @ID", this.Tablename);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Validation
|
||||
|
||||
public override void Validate(List<MessageError> errors, List<MessageViolation> violations)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -173,6 +173,7 @@
|
||||
<Compile Include="TIEFD.cs" />
|
||||
<Compile Include="TOWA.cs" />
|
||||
<Compile Include="TOWD.cs" />
|
||||
<Compile Include="TreatmentFacilityProvider.cs" />
|
||||
<Compile Include="Util.cs" />
|
||||
<Compile Include="ValidationAttribute.cs" />
|
||||
<Compile Include="ValidationCondition.cs" />
|
||||
@ -180,6 +181,8 @@
|
||||
<Compile Include="WAS.cs" />
|
||||
<Compile Include="Waste.cs" />
|
||||
<Compile Include="WasteDisposalServiceProvider.cs" />
|
||||
<Compile Include="WasteReceived.cs" />
|
||||
<Compile Include="WAS_RCPT.cs" />
|
||||
<Compile Include="XtraSendLogic.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user