145 lines
6.3 KiB
C#
145 lines
6.3 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using AyaNova.Biz;
|
|
using AyaNova.Models;
|
|
|
|
namespace AyaNova.DataList
|
|
{
|
|
internal class PartInventoryTransactionsDataList : DataListProcessingBase, IDataListInternalCriteria
|
|
{
|
|
public PartInventoryTransactionsDataList()
|
|
{
|
|
DefaultListAType = AyaType.PartInventory;
|
|
SQLFrom = "from apartinventory "
|
|
+ "left join apart on (apartinventory.partid=apart.id) "
|
|
+ "left join apartwarehouse on (apartinventory.partwarehouseid=apartwarehouse.id) ";
|
|
var RoleSet = BizRoles.GetRoleSet(DefaultListAType);
|
|
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
|
DefaultColumns = new List<string>() {
|
|
"PartInventoryTransactionEntryDate", "PartPartNumber", "PartWarehouseName", "PartInventoryTransactionQuantity",
|
|
"PartInventoryTransactionDescription", "PartInventoryTransactionSource", "PartInventoryBalance"
|
|
};
|
|
DefaultSortBy = new Dictionary<string, string>() { { "PartInventoryTransactionEntryDate", "-" } };
|
|
FieldDefinitions = new List<DataListFieldDefinition>();
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartInventoryTransactionSource",
|
|
FieldKey = "PartInventoryTransactionSource",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "apartinventory.sourceid",
|
|
SqlValueColumnName = "AYGETNAME(apartinventory.sourceid, apartinventory.sourcetype)",
|
|
SqlATypeColumnName = "apartinventory.sourcetype",
|
|
Translate=true
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartPartNumber",
|
|
FieldKey = "PartPartNumber",
|
|
AType = (int)AyaType.Part,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "apart.id",
|
|
SqlValueColumnName = "apart.partnumber"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartWarehouseName",
|
|
FieldKey = "PartWarehouseName",
|
|
AType = (int)AyaType.PartWarehouse,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "apartwarehouse.id",
|
|
SqlValueColumnName = "apartwarehouse.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartInventoryTransactionDescription",
|
|
FieldKey = "PartInventoryTransactionDescription",
|
|
AType = (int)AyaType.PartInventory,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "apartinventory.id",
|
|
SqlValueColumnName = "apartinventory.description",
|
|
IsRowId = true//should open to eventlog since no edit
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartInventoryTransactionEntryDate",
|
|
FieldKey = "PartInventoryTransactionEntryDate",
|
|
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
|
SqlValueColumnName = "apartinventory.entrydate"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartInventoryTransactionQuantity",
|
|
FieldKey = "PartInventoryTransactionQuantity",
|
|
UiFieldDataType = (int)UiFieldDataType.Decimal,
|
|
SqlValueColumnName = "apartinventory.quantity"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartInventoryBalance",
|
|
FieldKey = "PartInventoryBalance",
|
|
UiFieldDataType = (int)UiFieldDataType.Decimal,
|
|
SqlValueColumnName = "apartinventory.balance"
|
|
});
|
|
|
|
//META
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
|
|
FieldKey = "metapartnumber",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "apart.id",
|
|
SqlValueColumnName = "apart.partnumber",
|
|
IsMeta = true
|
|
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "metawarehouse",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "apartwarehouse.id",
|
|
SqlValueColumnName = "apartwarehouse.name",
|
|
IsMeta = true
|
|
});
|
|
}
|
|
|
|
|
|
public List<DataListFilterOption> DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles, string clientCriteria)
|
|
{
|
|
List<DataListFilterOption> ret = new List<DataListFilterOption>();
|
|
|
|
//ClientCriteria is optional for this list
|
|
//Format for this list is "PARTID,WAREHOUSENAME" where the id is 0 if not filtered or the id to filter
|
|
//and bizarrely the warehousename is text or empty if not filtered
|
|
var crit = (clientCriteria ?? "").Split(',').Select(z => z.Trim()).ToArray();
|
|
if (crit.Length > 1)
|
|
{
|
|
//Part criteria
|
|
if (crit[0] != "0")
|
|
{
|
|
DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metapartnumber" };
|
|
FilterOption.Items.Add(new DataListColumnFilter() { value = crit[0], op = DataListFilterComparisonOperator.Equality });
|
|
ret.Add(FilterOption);
|
|
}
|
|
|
|
//Warehouse criteria
|
|
if (!string.IsNullOrWhiteSpace(crit[1]))
|
|
{
|
|
DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metawarehouse" };
|
|
FilterOption.Items.Add(new DataListColumnFilter() { value = crit[1], op = DataListFilterComparisonOperator.Equality });
|
|
ret.Add(FilterOption);
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
|
|
}//eoc
|
|
}//eons |