This commit is contained in:
2021-09-09 15:15:16 +00:00
parent bf07bcfbe4
commit 23ffa04ce1

View File

@@ -1,9 +1,11 @@
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using AyaNova.Biz;
using System.Linq;
namespace AyaNova.PickList
{
internal class CustomerPickList : AyaPickList
internal class CustomerPickList : AyaPickList, IAyaPickListVariant
{
public CustomerPickList()
{
@@ -43,14 +45,44 @@ namespace AyaNova.PickList
IsRowId = true
});
ColumnDefinitions.Add(new AyaPickListFieldDefinition
ColumnDefinitions.Add(new AyaPickListFieldDefinition
{
TKey = "Tags",
FieldKey = "customertags",
ColumnDataType = UiFieldDataType.Tags,
SqlValueColumnName = "acustomer.tags"
});
}
public string GetVariantCriteria(string variant)
{
//Currently the only variant is a object type and id to indicate headoffice
//ClientCriteria format for this list is "OBJECTID,AYATYPE"
var crit = (variant ?? "").Split(',').Select(z => z.Trim()).ToArray();
if (crit.Length > 1)
{
int nType = 0;
if (!int.TryParse(crit[1], out nType)) return string.Empty;
AyaType forType = (AyaType)nType;
if (forType != AyaType.HeadOffice) return string.Empty;
long lId = 0;
if (!long.TryParse(crit[0], out lId)) return string.Empty;
if (lId == 0) return string.Empty;
//Have valid type, have an id, so filter away
switch (forType)
{
case AyaType.HeadOffice:
{
return $"aunit.customerid = {lId}";
}
}
}
return string.Empty;
}
}//eoc
}//eons