244 lines
7.3 KiB
C#
244 lines
7.3 KiB
C#
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
|
using Sarand.Net.Standard.Base.Bus;
|
|
using Sarand.Net.Standard.Base.Core;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
|
{
|
|
//=======================================================================
|
|
public abstract class SbmItemBatch : SbmHierarchyItem
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Columns.
|
|
public enum Column
|
|
{
|
|
Hidden,
|
|
Pos,
|
|
Id,
|
|
//ItemBatch.
|
|
AffIdOwner,
|
|
Type,
|
|
TypeDesc,
|
|
Ref,
|
|
DescBrief,
|
|
ProcessType,
|
|
ProcessTypeDesc,
|
|
LinkCount,
|
|
// Common properties.
|
|
Notes,
|
|
Flag,
|
|
Status,
|
|
Status_Desc,
|
|
Status_Ind,
|
|
CreateOn_Date,
|
|
UpdateOn_Date,
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
/// <summary>Properties other than common.</summary>
|
|
public class DataProperties
|
|
{
|
|
public SysId AffiliateIdOwner { get; set; } = new SysId();
|
|
public Sbm.ItemBatchType ItemBatchType { get; set; } = Sbm.ItemBatchType.Unknown;
|
|
public String Ref { get; set; } = "";
|
|
public String DescBrief { get; set; } = "";
|
|
public String ProcessType { get; set; } = "";
|
|
}
|
|
|
|
// Data.
|
|
public new class Data : SacsHierarchyItem.Data
|
|
{
|
|
// Data members.
|
|
private readonly DataProperties data = new DataProperties();
|
|
// Construction.
|
|
public Data()
|
|
{
|
|
Status = DefaultStatus;
|
|
}
|
|
public SysId AffiliateIdOwner
|
|
{
|
|
get { return data.AffiliateIdOwner; }
|
|
set { CheckChanged(data.AffiliateIdOwner, value); data.AffiliateIdOwner = value; }
|
|
}
|
|
public Sbm.ItemBatchType ItemBatchType
|
|
{
|
|
get { return data.ItemBatchType; }
|
|
set { CheckChanged((int)data.ItemBatchType, (int)value); data.ItemBatchType = value; }
|
|
}
|
|
public String Ref
|
|
{
|
|
get { return data.Ref; }
|
|
set { CheckChanged(data.Ref, value); data.Ref = value; }
|
|
}
|
|
public String DescBrief
|
|
{
|
|
get { return data.DescBrief; }
|
|
set { CheckChanged(data.DescBrief, value); data.DescBrief = value; }
|
|
}
|
|
public String ProcessType
|
|
{
|
|
get { return data.ProcessType; }
|
|
set { CheckChanged(data.ProcessType, value); data.ProcessType = value; }
|
|
}
|
|
|
|
internal void PopulateFrom(Data data)
|
|
{
|
|
AffiliateIdOwner = data.AffiliateIdOwner;
|
|
ItemBatchType = data.ItemBatchType;
|
|
Ref = data.Ref;
|
|
DescBrief = data.DescBrief;
|
|
ProcessType = data.ProcessType;
|
|
base.PopulateFrom(data);
|
|
}
|
|
public Data Clone()
|
|
{
|
|
Data data = new Data();
|
|
data.PopulateFrom(this);
|
|
return data;
|
|
}
|
|
}
|
|
|
|
public new class ErrField : SacsHierarchyItem.ErrField
|
|
{
|
|
// Identifies the field that has invalid data.
|
|
|
|
public ValidValue AffiliateIdOwner { get; set; } = ValidValue.Valid;
|
|
public ValidValue ItemBatchType { get; set; } = ValidValue.Valid;
|
|
public ValidValue Ref { get; set; } = ValidValue.Valid;
|
|
public ValidValue DescBrief { get; set; } = ValidValue.Valid;
|
|
public ValidValue ProcessType { get; set; } = ValidValue.Valid;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
private readonly Data data = new Data();
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
protected SbmItemBatch(SbmUserContext userContext, SysId id, SysId affiliateIdOwner, Sbm.ItemBatchType itemBatchType, String refs) : base(userContext, id)
|
|
{
|
|
base.SetData(data);
|
|
AffiliateIdOwner = affiliateIdOwner;
|
|
ItemBatchType = itemBatchType;
|
|
Ref = refs;
|
|
Status = DefaultStatus;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// ItemBatch status.
|
|
private static readonly List<SaStatus> itemBatchStatuses = new List<SaStatus>()
|
|
{
|
|
SaStatus.Current,
|
|
SaStatus.OnHold,
|
|
//SaStatus.Inactive,
|
|
//SaStatus.Cancelled,
|
|
SaStatus.Disabled,
|
|
};
|
|
public static SaStatus DefaultStatus { get { return SaStatus.Current; } }
|
|
public static List<SaStatus> ItemBatchStatuses { get { return new List<SaStatus>(itemBatchStatuses); } }
|
|
public static DataValue.TriStateType GetStatusTriState(SaStatus status)
|
|
{
|
|
switch (status)
|
|
{
|
|
case SaStatus.Active:
|
|
case SaStatus.Current:
|
|
return DataValue.TriStateType.Green;
|
|
case SaStatus.OnHold:
|
|
return DataValue.TriStateType.Amber;
|
|
case SaStatus.Inactive:
|
|
case SaStatus.Cancelled:
|
|
case SaStatus.Disabled:
|
|
return DataValue.TriStateType.Red;
|
|
case SaStatus.Deleted:
|
|
return DataValue.TriStateType.Purple;
|
|
}
|
|
return DataValue.TriStateType.Unknown;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Utilities.
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
public Data GetData() { return data.Clone(); }
|
|
public void SetData(Data data)
|
|
{
|
|
String fn = GetType().Name + ".SetData";
|
|
// Properties that cannot be changed if previously specified.
|
|
if (SysId.IsValid(Id) && SysId.ToInt(Id) != SysId.ToInt(data.Id))
|
|
throw new NotSupportedException(fn + " Id cannot be changed");
|
|
// Populate individual properties to ensure that 'Changed' indicator is kept up to date.
|
|
this.data.PopulateFrom(data);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Attributes.
|
|
public SysId AffiliateIdOwner
|
|
{
|
|
get { return data.AffiliateIdOwner; }
|
|
set { data.AffiliateIdOwner = value; }
|
|
}
|
|
public Sbm.ItemBatchType ItemBatchType
|
|
{
|
|
get { return data.ItemBatchType; }
|
|
set { data.ItemBatchType = value; }
|
|
}
|
|
public String Ref
|
|
{
|
|
get { return data.Ref; }
|
|
set { data.Ref = value; }
|
|
}
|
|
public String DescBrief
|
|
{
|
|
get { return data.DescBrief; }
|
|
set { data.DescBrief = value; }
|
|
}
|
|
public String ProcessType
|
|
{
|
|
get { return data.ProcessType; }
|
|
set { data.ProcessType = value; }
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// A s s o c i a t e d D a t a E l e m e n t s
|
|
//-------------------------------------------------------------------
|
|
|
|
//-------------------------------------------------------------------
|
|
// P a r a m s
|
|
//-------------------------------------------------------------------
|
|
/// <summary>Parameters - used to define the filters that should be applied to a List of Item Batches</summary>
|
|
// List parameters.
|
|
public enum StatusCat
|
|
{
|
|
Any,
|
|
}
|
|
/// <summary>
|
|
/// Item list parameters.
|
|
/// </summary>
|
|
public new class Params : SacsHierarchyItem.Params
|
|
{
|
|
// List filtering.
|
|
public List<SysId> IncludedIds { get; } = new List<SysId>();
|
|
public List<SysId> ExcludedIds { get; } = new List<SysId>();
|
|
// ItemBatch.
|
|
public Sbm.ItemBatchType ItemBatchType { get; set; }
|
|
public String Ref { get; set; }
|
|
public String RefPartial { get; set; }
|
|
public String DescBrief { get; set; }
|
|
public bool NotCompleted { get; set; }
|
|
|
|
public StatusCat StatusCat { get; set; } = StatusCat.Any;
|
|
}
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
// I t e m L i n k D a t a L i s t
|
|
//=======================================================================
|
|
public static class SbmItemBatchList
|
|
{
|
|
/// <summary>Check whether currency exists/locate in list with specified Id.</summary>
|
|
}
|
|
//=======================================================================
|
|
}
|