206 lines
8.3 KiB
C#
206 lines
8.3 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using AyaNova.Biz;
|
|
using AyaNova.Models;
|
|
|
|
namespace AyaNova.DataList
|
|
{
|
|
internal class PartInventoryDataList : DataListProcessingBase, IDataListInternalCriteria
|
|
{
|
|
public PartInventoryDataList()
|
|
{
|
|
DefaultListAType = AyaType.PartInventoryDataList;
|
|
|
|
SQLFrom = "from viewpartinventorylist ";
|
|
|
|
|
|
var RoleSet = BizRoles.GetRoleSet(DefaultListAType);
|
|
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
|
DefaultColumns = new List<string>() { "PartPartNumber", "PartWarehouseName", "PartInventoryBalance", "PartByWarehouseInventoryMinStockLevel","PartByWarehouseInventoryReorderQuantity","PartByWarehouseInventoryQuantityOnOrder", "PartByWarehouseInventoryQtyOnOrderCommitted", "Active" };
|
|
DefaultSortBy = new Dictionary<string, string>() { { "PartPartNumber", "+" }, { "PartWarehouseName", "+" } };
|
|
FieldDefinitions = new List<DataListFieldDefinition>();
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartPartNumber",
|
|
FieldKey = "PartPartNumber",
|
|
AType = (int)AyaType.Part,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "partid",
|
|
SqlValueColumnName = "partnumber"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartName",
|
|
FieldKey = "PartName",
|
|
AType = (int)AyaType.Part,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "partid",
|
|
SqlValueColumnName = "partname"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "Active",
|
|
FieldKey = "Active",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "partactive"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartCost",
|
|
FieldKey = "PartCost",
|
|
UiFieldDataType = (int)UiFieldDataType.Currency,
|
|
SqlValueColumnName = "partcost"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartRetail",
|
|
FieldKey = "PartRetail",
|
|
UiFieldDataType = (int)UiFieldDataType.Currency,
|
|
SqlValueColumnName = "partretail"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "PartWholesalerID",
|
|
TKey = "PartWholesalerID",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AType = (int)AyaType.Vendor,
|
|
SqlIdColumnName = "wholesalerid",
|
|
SqlValueColumnName = "wholesalername"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "PartAlternativeWholesalerID",
|
|
TKey = "PartAlternativeWholesalerID",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AType = (int)AyaType.Vendor,
|
|
SqlIdColumnName = "altwholesalerid",
|
|
SqlValueColumnName = "altwholesalername"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartWarehouseName",
|
|
FieldKey = "PartWarehouseName",
|
|
AType = (int)AyaType.PartWarehouse,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "partwarehouseid",
|
|
SqlValueColumnName = "partwarehousename"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartInventoryTransactionDescription",
|
|
FieldKey = "PartInventoryTransactionDescription",
|
|
AType = (int)AyaType.PartInventory,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "partinventoryid",
|
|
SqlValueColumnName = "partinventorydescription",
|
|
IsMeta = true,//only so it doesn't show in the UI but is required for report
|
|
IsRowId = true
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartInventoryBalance",
|
|
FieldKey = "PartInventoryBalance",
|
|
UiFieldDataType = (int)UiFieldDataType.Decimal,
|
|
SqlValueColumnName = "onhandqty"
|
|
});
|
|
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartByWarehouseInventoryQuantityOnOrder",
|
|
FieldKey = "PartByWarehouseInventoryQuantityOnOrder",
|
|
UiFieldDataType = (int)UiFieldDataType.Decimal,
|
|
SqlValueColumnName = "onorderqty"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartByWarehouseInventoryQtyOnOrderCommitted",
|
|
FieldKey = "PartByWarehouseInventoryQtyOnOrderCommitted",
|
|
UiFieldDataType = (int)UiFieldDataType.Decimal,
|
|
SqlValueColumnName = "onordercommittedqty"
|
|
});
|
|
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartByWarehouseInventoryMinStockLevel",
|
|
FieldKey = "PartByWarehouseInventoryMinStockLevel",
|
|
UiFieldDataType = (int)UiFieldDataType.Decimal,
|
|
SqlValueColumnName = "restockminqty"
|
|
});
|
|
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartByWarehouseInventoryReorderQuantity",
|
|
FieldKey = "PartByWarehouseInventoryReorderQuantity",
|
|
UiFieldDataType = (int)UiFieldDataType.Decimal,
|
|
SqlValueColumnName = "reorderqty"
|
|
});
|
|
|
|
|
|
//META
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
|
|
FieldKey = "metapartnumber",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "partid",
|
|
SqlValueColumnName = "partnumber",
|
|
IsMeta = true
|
|
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "metawarehouse",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "partwarehouseid",
|
|
SqlValueColumnName = "partwarehousename",
|
|
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 |