BusinessMgr
This commit is contained in:
@@ -53,7 +53,7 @@ namespace Sacs.Web.Components
|
||||
//-------------------------------------------------------------------
|
||||
// Culture.
|
||||
private CultureInfo sessionCulture;
|
||||
private CultureInfo RequestCulture { get { return Request.HttpContext.Features.Get<IRequestCultureFeature>().RequestCulture.Culture ?? CultureInfo.InvariantCulture; } }
|
||||
private CultureInfo RequestCulture { get { return Request.HttpContext.Features.Get<IRequestCultureFeature>()?.RequestCulture?.Culture ?? CultureInfo.InvariantCulture; } }
|
||||
public CultureInfo SessionCulture
|
||||
{
|
||||
get
|
||||
@@ -258,7 +258,7 @@ namespace Sacs.Web.Components
|
||||
// Common item properties.
|
||||
public String Id { get; set; } = null;
|
||||
private String notes;
|
||||
public String Notes { get { return StringUtil.OnBlank(notes, null); } set { notes = StringUtil.EmptyOnNull(value).Trim(); } }
|
||||
public String Notes { get { return StringUtil.IsBlank(notes) ? null : notes; } set { notes = StringUtil.EmptyOnNull(value).Trim(); } }
|
||||
public String StatusCode { get; set; } = null;
|
||||
public String StatusDesc { get; set; } = null;
|
||||
// Flags for common status values.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System;
|
||||
@@ -11,7 +12,7 @@ using static Sarand.Net.Standard.Base.Bus.SaErrorStateItem;
|
||||
namespace Sacs.Web.Components
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaModel
|
||||
public class SaModel : SacsDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
@@ -27,6 +28,13 @@ namespace Sacs.Web.Components
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Properties.
|
||||
public bool DebugMode { get; } = SacsSystem.DebugMode;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
// Code type properties.
|
||||
CodeTypeId,
|
||||
CodeType_Code,
|
||||
CodeType_Desc,
|
||||
CodeType_Name,
|
||||
// Code properties.
|
||||
Id,
|
||||
Code,
|
||||
@@ -205,16 +205,20 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
Any,
|
||||
ActiveOnly,
|
||||
InactiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
public List<SysId> IncludedIds { get; } = new List<SysId>();
|
||||
public List<SysId> ExcludedIds { get; } = new List<SysId>();
|
||||
public List<SysId> CodeTypeIds { get; } = new List<SysId>();
|
||||
public List<String> CodeTypeCodes { get; } = new List<string>();
|
||||
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> CodeTypeIds { get; } = new HashSet<SysId>();
|
||||
public HashSet<String> CodeTypeCodes { get; } = new HashSet<string>();
|
||||
/// <summary>Generic search - code, description etc.</summary>
|
||||
public string Search{ get; set; }
|
||||
public string Code { get; set; }
|
||||
public string CodePartial { get; set; }
|
||||
public string Desc { get; set; }
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
// Code type properties.
|
||||
Id,
|
||||
Code,
|
||||
Description,
|
||||
Name,
|
||||
MaxCodeLen,
|
||||
CodeFormat,
|
||||
NextCode,
|
||||
@@ -39,7 +39,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
public class DataProperties
|
||||
{
|
||||
public String Code { get; set; } = String.Empty;
|
||||
public String Description { get; set; } = String.Empty;
|
||||
public String Name { get; set; } = String.Empty;
|
||||
public byte MaxCodeLen { get; set; } = 0;
|
||||
public String CodeFormat { get; set; } = String.Empty;
|
||||
public String NextCode { get; set; } = String.Empty;
|
||||
@@ -62,10 +62,10 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
get { return data.Code; }
|
||||
set { CheckChanged(data.Code, value); data.Code = value; }
|
||||
}
|
||||
public String Description
|
||||
public String Name
|
||||
{
|
||||
get { return data.Description; }
|
||||
set { CheckChanged(data.Description, value); data.Description = value; }
|
||||
get { return data.Name; }
|
||||
set { CheckChanged(data.Name, value); data.Name = value; }
|
||||
}
|
||||
public byte MaxCodeLen
|
||||
{
|
||||
@@ -86,7 +86,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
internal void PopulateFrom(Data data)
|
||||
{
|
||||
Code = data.Code;
|
||||
Description = data.Description;
|
||||
Name = data.Name;
|
||||
MaxCodeLen = data.MaxCodeLen;
|
||||
CodeFormat = data.CodeFormat;
|
||||
NextCode = data.NextCode;
|
||||
@@ -106,7 +106,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
{
|
||||
// Identifies the field that has invalid data.
|
||||
public ValidValue Code { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Description { get; set; } = ValidValue.Valid;
|
||||
public ValidValue Name { get; set; } = ValidValue.Valid;
|
||||
public ValidValue MaxCodeLen { get; set; } = ValidValue.Valid;
|
||||
public ValidValue CodeFormat { get; set; } = ValidValue.Valid;
|
||||
public ValidValue NextCode { get; set; } = ValidValue.Valid;
|
||||
@@ -167,10 +167,10 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
get { return data.Code; }
|
||||
set { data.Code = value; }
|
||||
}
|
||||
public String Description
|
||||
public String Name
|
||||
{
|
||||
get { return data.Description; }
|
||||
set { data.Description = value; }
|
||||
get { return data.Name; }
|
||||
set { data.Name = value; }
|
||||
}
|
||||
public byte MaxCodeLen
|
||||
{
|
||||
@@ -201,19 +201,23 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
{
|
||||
Any,
|
||||
ActiveOnly,
|
||||
NotDeleted,
|
||||
DeletedOnly,
|
||||
}
|
||||
/// <summary>
|
||||
/// Item list parameters.
|
||||
/// </summary>
|
||||
public new class Params : SacsHierarchyItem.Params
|
||||
{
|
||||
public List<SysId> IncludedIds { get; } = new List<SysId>();
|
||||
public List<SysId> ExcludedIds { get; } = new List<SysId>();
|
||||
public HashSet<SysId> IdsIncluded { get; } = new HashSet<SysId>();
|
||||
public HashSet<SysId> IdsExcluded { get; } = new HashSet<SysId>();
|
||||
/// <summary>Generic search - code or name etc.</summary>
|
||||
public String Search { get; set; }
|
||||
public String Code { get; set; }
|
||||
public String CodePartial { get; set; }
|
||||
public String Desc { get; set; }
|
||||
public String DescPartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.ActiveOnly;
|
||||
public String Name { get; set; }
|
||||
public String NamePartial { get; set; }
|
||||
public StatusCat StatusCat { get; set; } = StatusCat.NotDeleted;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
return null;
|
||||
}
|
||||
public abstract SaCodeTypeDfn GetCodeTypeDefinition (SysId codeTypeId);
|
||||
public virtual String GetDescForCodeType (String codeTypeCode)
|
||||
public virtual String GetNameForCodeType (String codeTypeCode)
|
||||
{
|
||||
ClearErrorState();
|
||||
SaCodeTypeDfn codeTypeDfn = GetCodeTypeDefinition(codeTypeCode);
|
||||
@@ -85,8 +85,12 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
//*******************************************************************
|
||||
// C o d e T y p e s
|
||||
//*******************************************************************
|
||||
public abstract bool CodeTypeExists (String codeTypeCode);
|
||||
public abstract SaCodeType CreateCodeType(String code);
|
||||
public abstract bool CodeTypeExistsById(SysId codeTypeId);
|
||||
public abstract bool CodeTypeExistsByCode(String codeTypeCode);
|
||||
public abstract int GetCodeTypeCount (SaCodeType.Params prmCodeType);
|
||||
public abstract SaCodeType GetCodeTypeById(SysId codeTypeId);
|
||||
public abstract SaCodeType GetCodeTypeByCode(String codeTypeCode);
|
||||
public abstract SaCodeType GetCodeType(SaCodeType.Params prmCodeType);
|
||||
public abstract List<SaCodeType> GetCodeTypeList (SaCodeType.Params prmCodeType);
|
||||
// Code type list.
|
||||
@@ -99,21 +103,29 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
public abstract DataValue GetCodeTypeDataValue (ColumnDfn column, NamedValue.Map values);
|
||||
// Population.
|
||||
public abstract bool PopulateCodeType (String codeTypeCode, DbUpdateInfo dbUpdateInfo);
|
||||
// Code Type updates.
|
||||
public abstract bool InsertCodeType(SaCodeType codeType, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateCodeType(SaCodeType codeType, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool DeleteCodeType(SaCodeType codeType, DbUpdateInfo dbUpdateInfo);
|
||||
// Maintain code types - returns true if changes made.
|
||||
// NB Only relevant to desktop application.
|
||||
public abstract bool MaintainCodeTypes(bool userCanManageCodeTypes, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool MaintainCodeType(String codeTypeCode, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//*******************************************************************
|
||||
// C o d e s
|
||||
//*******************************************************************
|
||||
// Create code.
|
||||
public abstract SaCode CreateCode(SysId codeTypeId, String code);
|
||||
// Check whether code exists.
|
||||
public abstract bool CodeExistsForCodeType (String codeTypeCode, String code, bool activeOnly = true);
|
||||
// Codes for code type.
|
||||
public abstract bool CodeTypeHasCodes (String codeTypeCode, bool activeOnly = true);
|
||||
public abstract int GetCodeCountForCodeType (String codeTypeCode, bool activeOnly = true);
|
||||
public abstract SaCode GetCodeById (SysId codeId);
|
||||
public abstract SaCode GetCodeForCodeType(String codeTypeCode, String code, bool activeOnly = true);
|
||||
public abstract List<CodeDesc> GetCodeDescsForCodeType (String codeTypeCode, bool activeOnly = true);
|
||||
public abstract List<SaCode> GetCodeListForCodeType (String codeTypeCode, bool activeOnly = true);
|
||||
public abstract List<SaCode> GetCodesForCodeType (String codeTypeCode, bool activeOnly = true);
|
||||
// Code list.
|
||||
public abstract ColumnDfn GetCodeColumnDfn (SaCode.Column columnId, String caption = "", int width = 0);
|
||||
public abstract List<SaCode> GetCodeList (SaCode.Params prmCode);
|
||||
@@ -126,11 +138,15 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
// Codes by filter.
|
||||
public abstract int GetCodeCount (SaCode.Params prmCode);
|
||||
public abstract SaCode GetCode (SaCode.Params prmCode);
|
||||
/// <summary>Get filtered codes, indexed by Code Type code.</summary>
|
||||
/// <summary>Get filtered code type codes, indexed by Code Type code.</summary>
|
||||
public abstract Dictionary<String, List<SaCode>> GetCodesByCodeType(SaCode.Params prmCode);
|
||||
public abstract Task<Dictionary<String, List<SaCode>>> GetCodesByCodeTypeAsync (SaCode.Params prmCode);
|
||||
/// <summary>Get filtered codes and descriptions, indexed by Code Type code.</summary>
|
||||
public abstract Dictionary<String, List<CodeDesc>> GetCodeDescsByCodeType (SaCode.Params prmCode);
|
||||
// Code updates.
|
||||
public abstract bool InsertCode(SaCode code, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool UpdateCode(SaCode code, DbUpdateInfo dbUpdateInfo);
|
||||
public abstract bool DeleteCode(SaCode code, DbUpdateInfo dbUpdateInfo);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create codes.
|
||||
|
||||
@@ -65,9 +65,9 @@ namespace Sarand.Net.Standard.Base.CodeTypes
|
||||
errField.Code = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!IsValidValue(codeTypeData.Description, "description", (long)SaCodeTypeDbDfn.GetColTextLen(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Name), true))
|
||||
if (!IsValidValue(codeTypeData.Name, "description", (long)SaCodeTypeDbDfn.GetColTextLen(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Name), true))
|
||||
{
|
||||
errField.Description = SacsHierarchyItem.ValidValue.Invalid;
|
||||
errField.Name = SacsHierarchyItem.ValidValue.Invalid;
|
||||
return false;
|
||||
}
|
||||
if (!IsValidValue(codeTypeData.CodeFormat, "code format", (long)SaCodeTypeDbDfn.GetColTextLen(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_CodeFormat)))
|
||||
|
||||
@@ -332,7 +332,7 @@ namespace Sarand.Net.Standard.Base.Dbas
|
||||
/// <para>- Format as: ('Value1','Value2','Value3') if string data, else (Value1,Value2,Value3) etc.</para>
|
||||
/// <para>- Returns empty string if list is empty.</para>
|
||||
/// </summary>
|
||||
public static String FormatForIn(List<String> rawValues, bool stringData = true, bool ignoreBlanks = true)
|
||||
public static String FormatForIn(IEnumerable<String> rawValues, bool stringData = true, bool ignoreBlanks = true)
|
||||
{
|
||||
String result = String.Empty;
|
||||
List<String> values = new List<String>();
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
|
||||
struct _IMAGE_FILE_HEADER
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
public ushort Machine;
|
||||
public ushort NumberOfSections;
|
||||
public uint TimeDateStamp;
|
||||
@@ -23,6 +24,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
public uint NumberOfSymbols;
|
||||
public ushort SizeOfOptionalHeader;
|
||||
public ushort Characteristics;
|
||||
#pragma warning restore CS0649
|
||||
};
|
||||
|
||||
public static DateTime GetBuildDateTime (this Assembly assembly)
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
catch (Exception) { }
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Get Name for enum value.
|
||||
@@ -40,6 +41,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
{
|
||||
return Enum.GetName(typeof(TEnum), value);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// <para>Get enum values.</para>
|
||||
@@ -51,6 +53,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
{
|
||||
return Enum.GetValues(typeof(TEnum)).Cast<TEnum>();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// <para>Convert String to enum.</para>
|
||||
@@ -72,6 +75,22 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
catch (Exception exc) { SaLogger.Debug("EnumUtil.ParseEnum " + ExceptionUtil.GetErrorStateMessage(exc) + " [Enum: " + typeof(TEnum).Name + ". Value: " + value + "]"); }
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public static HashSet<TEnum> ParseEnums<TEnum>(IEnumerable<String> values) where TEnum : struct, IConvertible
|
||||
{
|
||||
HashSet<TEnum> enums = new HashSet<TEnum>();
|
||||
foreach (String value in values)
|
||||
{
|
||||
try
|
||||
{
|
||||
enums.Add((TEnum)Enum.Parse(typeof(TEnum), value, true));
|
||||
}
|
||||
catch (Exception exc) { SaLogger.Debug("EnumUtil.ParseEnums " + ExceptionUtil.GetErrorStateMessage(exc) + " [Enum: " + typeof(TEnum).Name + ". Value: " + value + "]"); }
|
||||
}
|
||||
return enums;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Retrieve the first enum value whose name starts with the specified value.
|
||||
@@ -89,6 +108,7 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
|
||||
@@ -55,53 +55,122 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
//*******************************************************************
|
||||
// C o d e T y p e s
|
||||
//*******************************************************************
|
||||
public override bool CodeTypeExists (String codeTypeCode)
|
||||
|
||||
// Create Code Type.
|
||||
public override SaCodeType CreateCodeType(String code)
|
||||
{
|
||||
ClearErrorState();
|
||||
SaCodeType.Params prmCodeType = new SaCodeType.Params();
|
||||
prmCodeType.Code = codeTypeCode;
|
||||
prmCodeType.StatusCat = SaCodeType.StatusCat.Any;
|
||||
return (codeTypeMgr.GetCodeTypeCount(prmCodeType) > 0);
|
||||
return codeTypeMgr.CreateCodeType(code);
|
||||
}
|
||||
public override String GetDescForCodeType (String codeTypeCode)
|
||||
|
||||
// Code Type exists.
|
||||
public override bool CodeTypeExistsById(SysId codeTypeId)
|
||||
{
|
||||
ClearErrorState();
|
||||
SaCodeType codeTypeData = codeTypeMgr.GetCodeTypeByCode(codeTypeCode);
|
||||
if (codeTypeData != null)
|
||||
return codeTypeData.Description;
|
||||
return base.GetDescForCodeType(codeTypeCode);
|
||||
bool exists = codeTypeMgr.CodeTypeExistsById(codeTypeId);
|
||||
SetErrorState(codeTypeMgr.ErrorStateMessage);
|
||||
return exists;
|
||||
}
|
||||
public override bool CodeTypeExistsByCode(String codeTypeCode)
|
||||
{
|
||||
ClearErrorState();
|
||||
bool exists = codeTypeMgr.CodeTypeExistsByCode(codeTypeCode);
|
||||
SetErrorState(codeTypeMgr.ErrorStateMessage);
|
||||
return exists;
|
||||
}
|
||||
|
||||
// Code Type count.
|
||||
public override int GetCodeTypeCount(SaCodeType.Params prmCodeType)
|
||||
{
|
||||
ClearErrorState();
|
||||
return (int)codeTypeMgr.GetCodeTypeCount(prmCodeType);
|
||||
}
|
||||
|
||||
// Get Code Type.
|
||||
public override SaCodeType GetCodeTypeById(SysId codeTypeId)
|
||||
{
|
||||
ClearErrorState();
|
||||
SaCodeType codeType = codeTypeMgr.GetCodeTypeById(codeTypeId);
|
||||
SetErrorState(codeTypeMgr.ErrorStateMessage);
|
||||
return codeType;
|
||||
}
|
||||
public override SaCodeType GetCodeTypeByCode(String codeTypeCode)
|
||||
{
|
||||
ClearErrorState();
|
||||
SaCodeType codeType = codeTypeMgr.GetCodeTypeByCode(codeTypeCode);
|
||||
SetErrorState(codeTypeMgr.ErrorStateMessage);
|
||||
return codeType;
|
||||
}
|
||||
public override SaCodeType GetCodeType(SaCodeType.Params prmCodeType)
|
||||
{
|
||||
ClearErrorState();
|
||||
return codeTypeMgr.GetCodeType(prmCodeType);
|
||||
SaCodeType codeType = codeTypeMgr.GetCodeType(prmCodeType);
|
||||
SetErrorState(codeTypeMgr.ErrorStateMessage);
|
||||
return codeType;
|
||||
}
|
||||
|
||||
// Get name for Code Type.
|
||||
public override String GetNameForCodeType(String codeTypeCode)
|
||||
{
|
||||
ClearErrorState();
|
||||
SaCodeType codeTypeData = codeTypeMgr.GetCodeTypeByCode(codeTypeCode);
|
||||
if (codeTypeData != null)
|
||||
return codeTypeData.Name;
|
||||
return base.GetNameForCodeType(codeTypeCode);
|
||||
}
|
||||
|
||||
// Get Code Types.
|
||||
public override List<SaCodeType> GetCodeTypeList(SaCodeType.Params prmCodeType)
|
||||
{
|
||||
ClearErrorState();
|
||||
return codeTypeMgr.GetCodeTypeList(prmCodeType);
|
||||
}
|
||||
|
||||
// Code Type columns.
|
||||
public override ColumnDfn GetCodeTypeColumnDfn(SaCodeType.Column columnId, String caption = "", int width = 0)
|
||||
{
|
||||
ClearErrorState();
|
||||
return codeTypeMgr.GetCodeTypeColumnDfn(columnId, caption, width);
|
||||
}
|
||||
|
||||
// Execute Code Type query.
|
||||
public override DbResultSet ExecuteCodeTypeQuery(List<ColumnDfn> columns, SaCodeType.Params prm)
|
||||
{
|
||||
ClearErrorState();
|
||||
return codeTypeMgr.ExecuteCodeTypeQuery(columns, prm);
|
||||
}
|
||||
|
||||
// Get Code Type data value.
|
||||
public override DataValue GetCodeTypeDataValue(ColumnDfn column, NamedValue.Map values)
|
||||
{
|
||||
ClearErrorState();
|
||||
return codeTypeMgr.GetCodeTypeDataValue(column, values);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Code Type updates.
|
||||
public override bool InsertCodeType(SaCodeType codeType, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
bool result = codeTypeMgr.InsertCodeType(codeType, dbUpdateInfo);
|
||||
SetErrorState(codeTypeMgr.ErrorStateMessage);
|
||||
return result;
|
||||
}
|
||||
public override bool UpdateCodeType(SaCodeType codeType, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
bool result = codeTypeMgr.UpdateCodeType(codeType, dbUpdateInfo);
|
||||
SetErrorState(codeTypeMgr.ErrorStateMessage);
|
||||
return result;
|
||||
}
|
||||
public override bool DeleteCodeType(SaCodeType codeType, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
bool result = codeTypeMgr.DeleteCodeType(codeType, dbUpdateInfo);
|
||||
SetErrorState(codeTypeMgr.ErrorStateMessage);
|
||||
return result;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Maintain code types - returns true if changes made.
|
||||
public override bool MaintainCodeTypes(bool userCanManageCodeTypes, DbUpdateInfo dbUpdateInfo)
|
||||
@@ -125,7 +194,20 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
//*******************************************************************
|
||||
// C o d e s
|
||||
//*******************************************************************
|
||||
|
||||
// Create code.
|
||||
public override SaCode CreateCode(SysId codeTypeId, String code)
|
||||
{
|
||||
return codeTypeMgr.CreateCode(codeTypeId, code);
|
||||
}
|
||||
|
||||
// Check whether code exists.
|
||||
|
||||
public override bool CodeTypeHasCodes(String codeTypeCode, bool activeOnly = true)
|
||||
{
|
||||
return GetCodeCountForCodeType(codeTypeCode, activeOnly) > 0;
|
||||
}
|
||||
|
||||
public override bool CodeExistsForCodeType(String codeTypeCode, String code, bool activeOnly)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -138,12 +220,6 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
return (codeTypeMgr.GetCodeCount(prmCode) == 1);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Codes exist for code type.
|
||||
public override bool CodeTypeHasCodes (String codeTypeCode, bool activeOnly = true)
|
||||
{
|
||||
return GetCodeCountForCodeType(codeTypeCode, activeOnly) > 0;
|
||||
}
|
||||
public override int GetCodeCountForCodeType(String codeTypeCode, bool activeOnly = true)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -155,7 +231,16 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get code for code type.
|
||||
// Get code.
|
||||
|
||||
public override SaCode GetCodeById(SysId codeId)
|
||||
{
|
||||
ClearErrorState();
|
||||
SaCode code = codeTypeMgr.GetCodeById(codeId);
|
||||
SetErrorState(codeTypeMgr.ErrorStateMessage);
|
||||
return code;
|
||||
}
|
||||
|
||||
public override SaCode GetCodeForCodeType(String codeTypeCode, String code, bool activeOnly = true)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -164,14 +249,12 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
prmCode.CodeTypeCodes.Add(codeTypeCode);
|
||||
prmCode.Code = code;
|
||||
prmCode.StatusCat = (activeOnly ? SaCode.StatusCat.ActiveOnly : SaCode.StatusCat.Any);
|
||||
List<SaCode> codes = codeTypeMgr.GetCodeList(prmCode);
|
||||
if (codes.Count > 0)
|
||||
return codes[0];
|
||||
return null;
|
||||
return codeTypeMgr.GetCode(prmCode);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get codes for code type.
|
||||
|
||||
public override List<CodeDesc> GetCodeDescsForCodeType(String codeTypeCode, bool activeOnly = true)
|
||||
{
|
||||
ClearErrorState();
|
||||
@@ -202,7 +285,8 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
}
|
||||
return codes;
|
||||
}
|
||||
public override List<SaCode> GetCodeListForCodeType (String codeTypeCode, bool activeOnly = true)
|
||||
|
||||
public override List<SaCode> GetCodesForCodeType(String codeTypeCode, bool activeOnly = true)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (StringUtil.IsEmpty(codeTypeCode)) return new List<SaCode>();
|
||||
@@ -265,7 +349,7 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
|
||||
// Retrieve code type codes.
|
||||
SaCodeType.Params prmCodeType = new SaCodeType.Params();
|
||||
prmCodeType.IncludedIds.AddRange(codesByCodeTypeId.Keys);
|
||||
prmCodeType.IdsIncluded.UnionWith(codesByCodeTypeId.Keys);
|
||||
prmCodeType.StatusCat = SaCodeType.StatusCat.Any;
|
||||
List<SaCodeType> codeTypes = codeTypeMgr.GetCodeTypeList(prmCodeType);
|
||||
|
||||
@@ -281,7 +365,7 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
|
||||
// Retrieve code type codes.
|
||||
SaCodeType.Params prmCodeType = new SaCodeType.Params();
|
||||
prmCodeType.IncludedIds.AddRange(codesByCodeTypeId.Keys);
|
||||
prmCodeType.IdsIncluded.UnionWith(codesByCodeTypeId.Keys);
|
||||
prmCodeType.StatusCat = SaCodeType.StatusCat.Any;
|
||||
List<SaCodeType> codeTypes = await codeTypeMgr.GetCodeTypeListAsync(prmCodeType);
|
||||
|
||||
@@ -381,6 +465,30 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
return codes;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Code updates.
|
||||
public override bool InsertCode(SaCode code, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
bool result = codeTypeMgr.InsertCode(code, dbUpdateInfo);
|
||||
SetErrorState(codeTypeMgr.ErrorStateMessage);
|
||||
return result;
|
||||
}
|
||||
public override bool UpdateCode(SaCode code, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
bool result = codeTypeMgr.UpdateCode(code, dbUpdateInfo);
|
||||
SetErrorState(codeTypeMgr.ErrorStateMessage);
|
||||
return result;
|
||||
}
|
||||
public override bool DeleteCode(SaCode code, DbUpdateInfo dbUpdateInfo)
|
||||
{
|
||||
ClearErrorState();
|
||||
bool result = codeTypeMgr.DeleteCode(code, dbUpdateInfo);
|
||||
SetErrorState(codeTypeMgr.ErrorStateMessage);
|
||||
return result;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Create codes.
|
||||
public override bool CreateCodeOfType(SysId codeTypeId, String code, String desc, DbUpdateInfo dbUpdateInfo)
|
||||
@@ -419,7 +527,7 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
{
|
||||
// Create code type.
|
||||
codeType = codeTypeMgr.CreateCodeType(codeTypeCode);
|
||||
codeType.Description = codeTypeDfn.Description;
|
||||
codeType.Name = codeTypeDfn.Description;
|
||||
codeType.Notes = codeTypeDfn.Notes;
|
||||
codeType.Status = SaCodeType.DefaultStatus;
|
||||
if (!codeTypeMgr.InsertCodeType(codeType, dbUpdateInfo))
|
||||
@@ -428,7 +536,7 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
else
|
||||
{
|
||||
// Code type exists - refresh properties.
|
||||
codeType.Description = codeTypeDfn.Description;
|
||||
codeType.Name = codeTypeDfn.Description;
|
||||
if (StringUtil.IsEmpty(codeType.Notes))
|
||||
codeType.Notes = codeTypeDfn.Notes;
|
||||
codeType.Status = SaCodeType.DefaultStatus;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Sarand.Net.Standard.Dbas.CodeType
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private static String className = nameof(SaCodeTypeDbDfnGenerator);
|
||||
//private static String className = nameof(SaCodeTypeDbDfnGenerator);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
|
||||
@@ -12,6 +12,7 @@ using Sarand.Net.Standard.Dbas.Base;
|
||||
using Sarand.Net.Standard.Dbas.CodeTypes.Internal;
|
||||
using Sarand.Net.Standard.Dbas.Data;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
{
|
||||
@@ -82,13 +83,13 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
{
|
||||
ClearErrorState();
|
||||
if (!SysId.IsValid(id)) return false;
|
||||
return GetCodeTypeCount(SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Id, aliasCodeType) + "=" + SysId.ToString(id)) == 1;
|
||||
return GetCodeTypeCount($"{SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Id, aliasCodeType)}={SysId.ToLong(id)}") == 1;
|
||||
}
|
||||
public override bool CodeTypeExistsByCode(string code)
|
||||
{
|
||||
ClearErrorState();
|
||||
if (StringUtil.IsEmpty(code)) return false;
|
||||
return GetCodeTypeCount(SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Code, aliasCodeType) + "='" + DbQuery.FormatForCondition(code) + "'") == 1;
|
||||
return GetCodeTypeCount($"{SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Code, aliasCodeType)}='{DbQuery.FormatForCondition(code)}'") == 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -234,7 +235,7 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
{
|
||||
dbCodeType._Id = codeType.Id.ToInt();
|
||||
dbCodeType._Code = codeType.Code;
|
||||
dbCodeType._Name = codeType.Description;
|
||||
dbCodeType._Name = codeType.Name;
|
||||
dbCodeType._MaxCodeLen = codeType.MaxCodeLen;
|
||||
dbCodeType._CodeFormat = codeType.CodeFormat;
|
||||
dbCodeType._NextCode = codeType.NextCode;
|
||||
@@ -256,7 +257,7 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
{
|
||||
//codeType.Id = new SysId(dbCodeType._Id);
|
||||
codeType.Code = dbCodeType._Code;
|
||||
codeType.Description = dbCodeType._Name;
|
||||
codeType.Name = dbCodeType._Name;
|
||||
codeType.MaxCodeLen = dbCodeType._MaxCodeLen;
|
||||
codeType.CodeFormat = dbCodeType._CodeFormat;
|
||||
codeType.NextCode = dbCodeType._NextCode;
|
||||
@@ -300,8 +301,8 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
case SaCodeType.Column.Code:
|
||||
SetCodeTypeColDfn(columnDfn, "Code", 90, SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Code);
|
||||
break;
|
||||
case SaCodeType.Column.Description:
|
||||
SetCodeTypeColDfn(columnDfn, "Description", 160, SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Name);
|
||||
case SaCodeType.Column.Name:
|
||||
SetCodeTypeColDfn(columnDfn, "Name", 160, SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Name);
|
||||
break;
|
||||
case SaCodeType.Column.MaxCodeLen:
|
||||
SetCodeTypeColDfn(columnDfn, "Max code len", 90, SaCodeTypeDbDfn.ColumnIdx.SaCodeType_MaxCodeLen, ColumnAlignment.Center, DataValue.DataType.Long);
|
||||
@@ -359,38 +360,58 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
{
|
||||
List<String> filter = new List<String>();
|
||||
|
||||
// Code Type Id.
|
||||
String colId = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Id, aliasCodeType);
|
||||
String includedIds = prm.IncludedIds.Concat(",");
|
||||
if (!includedIds.IsEmpty())
|
||||
filter.Add(colId + " IN (" + includedIds + ")");
|
||||
String excludedIds = prm.ExcludedIds.Concat(",");
|
||||
if (!excludedIds.IsEmpty())
|
||||
filter.Add(colId + " NOT IN (" + excludedIds + ")");
|
||||
String colCode = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Code, aliasCodeType);
|
||||
String colName = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Name, aliasCodeType);
|
||||
String colNotes = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Notes, aliasCodeType);
|
||||
String colStatus = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Status, aliasCodeType);
|
||||
|
||||
// Item Id.
|
||||
if (prm.IdsIncluded.HasValidIds())
|
||||
filter.Add($"{colId} IN ({prm.IdsIncluded.Concat(",")})");
|
||||
if (prm.IdsExcluded.HasValidIds())
|
||||
filter.Add($"{colId} NOT IN ({prm.IdsExcluded.Concat(",")})");
|
||||
|
||||
// Generic search.
|
||||
if (!StringUtil.IsBlank(prm.Search))
|
||||
{
|
||||
foreach (String search in Regex.Split(prm.Search, "[\\s,;\\-+]+"))
|
||||
{
|
||||
if (StringUtil.IsBlank(search)) continue;
|
||||
String searchForLike = DbQuery.FormatForLike(search, true);
|
||||
List<String> searchFilter = new List<string>();
|
||||
searchFilter.Add($"{colCode} LIKE '%{searchForLike}%'");
|
||||
searchFilter.Add($"{colName} LIKE '%{searchForLike}%'");
|
||||
searchFilter.Add($"{colNotes} LIKE '%{searchForLike}%'");
|
||||
filter.Add(searchFilter.Concat(" OR ", "(", ")"));
|
||||
}
|
||||
}
|
||||
|
||||
// Code.
|
||||
String colCode = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Code, aliasCodeType);
|
||||
if (!StringUtil.IsEmpty(prm.Code))
|
||||
filter.Add(colCode + "='" + DbQuery.FormatForCondition(prm.Code) + "'");
|
||||
else if (!StringUtil.IsEmpty(prm.CodePartial))
|
||||
filter.Add(colCode + " LIKE '%" + DbQuery.FormatForLike(prm.CodePartial) + "%'");
|
||||
if (!StringUtil.IsBlank(prm.Code))
|
||||
filter.Add($"{colCode}='{DbQuery.FormatForCondition(prm.Code)}'");
|
||||
else if (!StringUtil.IsBlank(prm.CodePartial))
|
||||
filter.Add($"{colCode} LIKE '%{DbQuery.FormatForLike(prm.CodePartial)}%'");
|
||||
|
||||
// Description.
|
||||
String colName = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Name, aliasCodeType);
|
||||
if (!StringUtil.IsEmpty(prm.Desc))
|
||||
filter.Add(colName + "='" + DbQuery.FormatForCondition(prm.Desc) + "'");
|
||||
else if (!StringUtil.IsEmpty(prm.DescPartial))
|
||||
filter.Add(colName + " LIKE '%" + DbQuery.FormatForLike(prm.DescPartial) + "%'");
|
||||
// Name.
|
||||
if (!StringUtil.IsBlank(prm.Name))
|
||||
filter.Add($"{colName}='{DbQuery.FormatForCondition(prm.Name)}'");
|
||||
else if (!StringUtil.IsBlank(prm.NamePartial))
|
||||
filter.Add($"{colName} LIKE '%" + DbQuery.FormatForLike(prm.NamePartial) + "%'");
|
||||
|
||||
// Status.
|
||||
String colStatus = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Status, aliasCodeType);
|
||||
if (prm.StatusCat == SaCodeType.StatusCat.ActiveOnly)
|
||||
filter.Add(colStatus + " In ('" + SacsSystem.GetStatusCode(SaCodeType.CurrentStatus) + "')");
|
||||
filter.Add($"{colStatus} In ('{SacsSystem.GetStatusCode(SaCodeType.CurrentStatus)}')");
|
||||
else if (prm.StatusCat == SaCodeType.StatusCat.NotDeleted)
|
||||
filter.Add($"{colStatus} Not In ('{SacsSystem.GetStatusCode(SaStatus.Deleted)}')");
|
||||
else if (prm.StatusCat == SaCodeType.StatusCat.DeletedOnly)
|
||||
filter.Add($"{colStatus} In ('{SacsSystem.GetStatusCode(SaStatus.Deleted)}')");
|
||||
|
||||
if (filter.Count < 1 && prm.IncludeDefaultFilter) filter.Add("1=1");
|
||||
return filter;
|
||||
}
|
||||
// CodeType sort columns.
|
||||
|
||||
// Item sort columns.
|
||||
public List<String> GetCodeTypeSortColumns(SaCodeType.Params prm)
|
||||
{
|
||||
// Sort sequence:
|
||||
@@ -529,7 +550,7 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
query.Columns.Add(SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Id, aliasCodeType));
|
||||
if (columns.HasId((int)SaCodeType.Column.Code))
|
||||
query.Columns.Add(SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Code, aliasCodeType));
|
||||
if (columns.HasId((int)SaCodeType.Column.Description))
|
||||
if (columns.HasId((int)SaCodeType.Column.Name))
|
||||
query.Columns.Add(SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Name, aliasCodeType));
|
||||
if (columns.HasId((int)SaCodeType.Column.MaxCodeLen))
|
||||
query.Columns.Add(SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_MaxCodeLen, aliasCodeType));
|
||||
@@ -566,7 +587,7 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
// Filter and sort sequence.
|
||||
query.Filters.AddRange(GetCodeTypeQueryFilter(prm));
|
||||
|
||||
if (prm.IncludedIds.Count != 1)
|
||||
if (prm.IdsIncluded.Count != 1)
|
||||
{
|
||||
// Configure sort sequence.
|
||||
foreach (String sortColumn in GetCodeTypeSortColumns(prm))
|
||||
@@ -818,7 +839,7 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
case SaCode.Column.CodeType_Code:
|
||||
SetCodeColDfn(columnDfn, "Code type", 80, SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Code, ColumnAlignment.Center, DataValue.DataType.String, aliasCode_CodeType, colPrefixCode_CodeType);
|
||||
break;
|
||||
case SaCode.Column.CodeType_Desc:
|
||||
case SaCode.Column.CodeType_Name:
|
||||
SetCodeColDfn(columnDfn, "Code type desc", 100, SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Name, ColumnAlignment.Left, DataValue.DataType.String, aliasCode_CodeType, colPrefixCode_CodeType);
|
||||
break;
|
||||
// Properties.
|
||||
@@ -890,45 +911,64 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
{
|
||||
List<String> filter = new List<String>();
|
||||
|
||||
String colId = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCode_Id, aliasCode);
|
||||
String colCodeTypeId = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCode_CodeTypeId, aliasCode);
|
||||
String colCode = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCode_Code, aliasCode);
|
||||
String colDescription = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCode_Description, aliasCode);
|
||||
String colStatus = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCode_Status, aliasCode);
|
||||
String colNotes = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCode_Notes, aliasCode);
|
||||
|
||||
// Force DBMS type.
|
||||
DbQuery qry = new DbQuery(Database.DbmsType);
|
||||
|
||||
// Code Id.
|
||||
String colId = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCode_Id, aliasCode);
|
||||
String includedIds = prm.IncludedIds.Concat(",");
|
||||
if (!includedIds.IsEmpty())
|
||||
filter.Add(colId + " IN (" + includedIds + ")");
|
||||
String excludedIds = prm.ExcludedIds.Concat(",");
|
||||
if (!excludedIds.IsEmpty())
|
||||
filter.Add(colId + " NOT IN (" + excludedIds + ")");
|
||||
if (prm.IdsIncluded.HasValidIds())
|
||||
filter.Add($"{colId} IN ({prm.IdsIncluded.Concat(",")})");
|
||||
if (prm.IdsExcluded.HasValidIds())
|
||||
filter.Add($"{colId} NOT IN ({prm.IdsExcluded.Concat(",")})");
|
||||
|
||||
// Generic search.
|
||||
if (!StringUtil.IsBlank(prm.Search))
|
||||
{
|
||||
foreach (String search in Regex.Split(prm.Search, "[\\s,;\\-+]+"))
|
||||
{
|
||||
if (StringUtil.IsBlank(search)) continue;
|
||||
String searchForLike = DbQuery.FormatForLike(search, true);
|
||||
List<String> searchFilter = new List<string>();
|
||||
searchFilter.Add($"{colCode} LIKE '%{searchForLike}%'");
|
||||
searchFilter.Add($"{colDescription} LIKE '%{searchForLike}%'");
|
||||
searchFilter.Add($"{colNotes} LIKE '%{searchForLike}%'");
|
||||
filter.Add(searchFilter.Concat(" OR ", "(", ")"));
|
||||
}
|
||||
}
|
||||
|
||||
// Code Type.
|
||||
String colCodeTypeId = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCode_CodeTypeId, aliasCode);
|
||||
if (prm.CodeTypeIds.Count > 0)
|
||||
filter.Add(colCodeTypeId + " In (" + prm.CodeTypeIds.Concat(",") + ")");
|
||||
if (prm.CodeTypeCodes.Count > 0)
|
||||
filter.Add(colCodeTypeId + " In (Select " + SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Id) + " From " + TableName_CodeType + " Where " + SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Code) + " In " + DbQuery.FormatForIn(prm.CodeTypeCodes, true, false) + ")");
|
||||
if (prm.CodeTypeIds.HasValidIds())
|
||||
filter.Add($"{colCodeTypeId} In ({prm.CodeTypeIds.Concat(",")})");
|
||||
if (prm.CodeTypeCodes.Any())
|
||||
filter.Add($"{colCodeTypeId} In (Select {SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Id) + " From " + TableName_CodeType + " Where " + SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCodeType_Code)} In {DbQuery.FormatForIn(prm.CodeTypeCodes, true, false)})");
|
||||
|
||||
// Code.
|
||||
String colCode = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCode_Code, aliasCode);
|
||||
if (!StringUtil.IsEmpty(prm.Code))
|
||||
filter.Add(colCode + "='" + DbQuery.FormatForCondition(prm.Code) + "'");
|
||||
else if (!StringUtil.IsEmpty(prm.CodePartial))
|
||||
filter.Add(colCode + " LIKE '%" + DbQuery.FormatForLike(prm.CodePartial) + "%'");
|
||||
if (!StringUtil.IsBlank(prm.Code))
|
||||
filter.Add($"{colCode}='{DbQuery.FormatForCondition(prm.Code)}'");
|
||||
else if (!StringUtil.IsBlank(prm.CodePartial))
|
||||
filter.Add($"{colCode} LIKE '%{DbQuery.FormatForLike(prm.CodePartial)}%'");
|
||||
|
||||
// Description.
|
||||
String colDescription = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCode_Description, aliasCode);
|
||||
if (!StringUtil.IsEmpty(prm.Desc))
|
||||
filter.Add(colDescription + "='" + DbQuery.FormatForCondition(prm.Desc) + "'");
|
||||
else if (!StringUtil.IsEmpty(prm.DescPartial))
|
||||
filter.Add(colDescription + " LIKE '%" + DbQuery.FormatForLike(prm.DescPartial) + "%'");
|
||||
if (!StringUtil.IsBlank(prm.Desc))
|
||||
filter.Add($"{colDescription}='{DbQuery.FormatForCondition(prm.Desc)}'");
|
||||
else if (!StringUtil.IsBlank(prm.DescPartial))
|
||||
filter.Add($"{colDescription} LIKE '%{DbQuery.FormatForLike(prm.DescPartial)}%'");
|
||||
|
||||
// Status.
|
||||
String colStatus = SaCodeTypeDbDfn.GetColumnNameQual(SaCodeTypeDbDfn.ColumnIdx.SaCode_Status, aliasCode);
|
||||
if (prm.StatusCat == SaCode.StatusCat.ActiveOnly)
|
||||
filter.Add(colStatus + " In ('" + SacsSystem.GetStatusCode(SaCode.ActiveStatus) + "')");
|
||||
filter.Add($"{colStatus} In ('{SacsSystem.GetStatusCode(SaCode.ActiveStatus)}')");
|
||||
else if (prm.StatusCat == SaCode.StatusCat.InactiveOnly)
|
||||
filter.Add(colStatus + " Not In ('" + SacsSystem.GetStatusCode(SaCode.ActiveStatus) + "')");
|
||||
filter.Add($"{colStatus} Not In ('{SacsSystem.GetStatusCode(SaCode.ActiveStatus)}')");
|
||||
else if (prm.StatusCat == SaCode.StatusCat.NotDeleted)
|
||||
filter.Add($"{colStatus} Not In ('{SacsSystem.GetStatusCode(SaStatus.Deleted)}')");
|
||||
else if (prm.StatusCat == SaCode.StatusCat.DeletedOnly)
|
||||
filter.Add($"{colStatus} In ('{SacsSystem.GetStatusCode(SaStatus.Deleted)}')");
|
||||
|
||||
if (filter.Count < 1 && prm.IncludeDefaultFilter) filter.Add("1=1");
|
||||
return filter;
|
||||
@@ -1096,7 +1136,7 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Owner item.
|
||||
if (columns.HasId((int)SaCode.Column.CodeType_Code) || columns.HasId((int)SaCode.Column.CodeType_Desc))
|
||||
if (columns.HasId((int)SaCode.Column.CodeType_Code) || columns.HasId((int)SaCode.Column.CodeType_Name))
|
||||
{
|
||||
DbQueryJoin joinItmOwn = new DbQueryJoin(DbJoinType.LeftOuter);
|
||||
joinItmOwn.Table = new StringPair(TableName_CodeType, aliasCode_CodeType);
|
||||
@@ -1109,7 +1149,7 @@ namespace Sarand.Net.Standard.Dbas.CodeTypes
|
||||
//---------------------------------------------------------------------
|
||||
// Filter and sort sequence.
|
||||
query.Filters.AddRange(GetCodeQueryFilter(prm));
|
||||
if (prm.IncludedIds.Count != 1)
|
||||
if (prm.IdsIncluded.Count != 1)
|
||||
{
|
||||
// Configure sort sequence.
|
||||
foreach (String sortColumn in GetCodeSortColumns(prm))
|
||||
|
||||
Reference in New Issue
Block a user