Files
BeWoPlaner/Dakota/Models/Daten/DatenelementAuftragsdatei.cs

82 lines
2.3 KiB
C#

using Dakota.Logic;
using Dakota.Models.Schlüssels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dakota.Models.Daten
{
public class DatenelementAuftragsdatei : Dateneinheit
{
private protected string _Value;
public int Stellen { get; private set; }
public FeldartAuftragsdatei Feldart { get; private set; }
public FeldtypAuftragsdatei Feldtyp { get; private set; }
public DatenelementAuftragsdatei(string title, int count, FeldtypAuftragsdatei typ, FeldartAuftragsdatei art)
{
Title = title;
Stellen = count;
Feldart = art;
Feldtyp = typ;
}
public override string GetValue()
{
if (_Value.Length < Stellen || _Value.Length > Stellen)
{
throw new NotImplementedException("Error Code: 3483091097897.2");
}
return _Value;
}
public override bool HasValue()
{
return !string.IsNullOrEmpty(_Value);
}
public void SetValue(int value)
{
SetValue(value.ToString());
}
public void SetValue(Schlüssel schlussel)
{
if (schlussel is null)
return;
SetValue(schlussel.Value);
}
public void SetValue(string value)
{
// Berücksichtige jedes Update
if (value is null)
value = string.Empty;
if (value.Length > Stellen)
throw new NotImplementedException("#43442353313451");
switch (Feldtyp)
{
case FeldtypAuftragsdatei.Numerisch:
value = DakotaUtils.FillFromLeft(value, Stellen, '0');
break;
case FeldtypAuftragsdatei.Alpha:
value = DakotaUtils.FillFromRight(value, Stellen, ' ');
break;
case FeldtypAuftragsdatei.Alphanumerisch:
value = DakotaUtils.FillFromRight(value, Stellen, ' ');
break;
default:
throw new NotImplementedException("#434423533131324");
}
//DakotaValidator.ClearTextString(value);
_Value = value;
}
}
}