149 lines
6.5 KiB
C#
149 lines
6.5 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using AyaNova.Biz;
|
|
using AyaNova.Models;
|
|
|
|
namespace AyaNova.DataList
|
|
{
|
|
internal class PartInventoryDataList : DataListBase, IDataListInternalCriteria
|
|
{
|
|
public PartInventoryDataList()
|
|
{
|
|
|
|
DefaultListObjectType = AyaType.PartInventory;
|
|
SQLFrom = "from vpartinventorynow "
|
|
+ "left join apart on (vpartinventorynow.partid=apart.id) "
|
|
+ "left join apartwarehouse on (vpartinventorynow.partwarehouseid=apartwarehouse.id) ";
|
|
var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType);
|
|
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
|
|
|
// //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############
|
|
// //Default ListView - show all transactions in order
|
|
// dynamic dlistView = new JArray();
|
|
// dynamic cm = null;
|
|
|
|
// cm = new JObject();
|
|
// cm.fld = "PartPartNumber";
|
|
// cm.sort = "+";
|
|
// dlistView.Add(cm);
|
|
|
|
// cm = new JObject();
|
|
// cm.fld = "PartWarehouseName";
|
|
// cm.sort = "+";
|
|
// dlistView.Add(cm);
|
|
|
|
// cm = new JObject();
|
|
// cm.fld = "PartInventoryBalance";
|
|
// dlistView.Add(cm);
|
|
|
|
// // cm = new JObject();
|
|
// // cm.fld = "PartInventoryTransactionDescription";
|
|
// // dlistView.Add(cm);
|
|
|
|
// DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None);
|
|
|
|
DefaultColumns = new List<string>() { "PartPartNumber", "PartWarehouseName", "PartInventoryBalance", "PartInventoryTransactionDescription" };
|
|
DefaultSortBy = new Dictionary<string, string>() { { "PartPartNumber", "+" }, { "PartWarehouseName", "+" } };
|
|
|
|
|
|
FieldDefinitions = new List<DataListFieldDefinition>();
|
|
|
|
// FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
// {
|
|
// TKey = "PartInventoryTransactionSource",
|
|
// FieldKey = "PartInventoryTransactionSource",
|
|
// UiFieldDataType = (int)UiFieldDataType.Text,
|
|
// SqlIdColumnName = "vpartinventorynow.sourceid",
|
|
// SqlValueColumnName = "AYGETNAME(vpartinventorynow.sourceid, vpartinventorynow.sourcetype)",
|
|
// SqlAyTypeColumnName = "vpartinventorynow.sourcetype"
|
|
// });
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartPartNumber",
|
|
FieldKey = "PartPartNumber",
|
|
AyaObjectType = (int)AyaType.Part,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "apart.id",
|
|
SqlValueColumnName = "apart.partnumber"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartWarehouseName",
|
|
FieldKey = "PartWarehouseName",
|
|
AyaObjectType = (int)AyaType.PartWarehouse,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "apartwarehouse.id",
|
|
SqlValueColumnName = "apartwarehouse.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartInventoryTransactionDescription",
|
|
FieldKey = "PartInventoryTransactionDescription",
|
|
AyaObjectType = (int)AyaType.PartInventory,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "vpartinventorynow.id",
|
|
SqlValueColumnName = "vpartinventorynow.description",
|
|
IsMeta = true,//only so it doesn't show in the UI but is required for report
|
|
IsRowId = true
|
|
});
|
|
|
|
// FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
// {
|
|
// TKey = "PartInventoryTransactionEntryDate",
|
|
// FieldKey = "PartInventoryTransactionEntryDate",
|
|
// UiFieldDataType = (int)UiFieldDataType.DateTime,
|
|
// SqlValueColumnName = "vpartinventorynow.entrydate"
|
|
// });
|
|
|
|
// FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
// {
|
|
// TKey = "PartInventoryTransactionQuantity",
|
|
// FieldKey = "PartInventoryTransactionQuantity",
|
|
// UiFieldDataType = (int)UiFieldDataType.Decimal,
|
|
// SqlValueColumnName = "vpartinventorynow.quantity"
|
|
// });
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PartInventoryBalance",
|
|
FieldKey = "PartInventoryBalance",
|
|
UiFieldDataType = (int)UiFieldDataType.Decimal,
|
|
SqlValueColumnName = "vpartinventorynow.balance"
|
|
});
|
|
|
|
}
|
|
|
|
public List<DataListFilterOption> DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles, Models.DataListBase dataListBase)
|
|
{
|
|
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 = (dataListBase.ClientCriteria ?? "").Split(',').Select(z => z.Trim()).ToArray();
|
|
if (crit.Length > 1)
|
|
{
|
|
//Part criteria
|
|
if (crit[0]!="0")
|
|
{
|
|
DataListFilterOption FilterOption = new DataListFilterOption() { Column = "PartPartNumber" };
|
|
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 = "PartWarehouseName" };
|
|
FilterOption.Items.Add(new DataListColumnFilter() { value = crit[1], op = DataListFilterComparisonOperator.Equality });
|
|
ret.Add(FilterOption);
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
}//eoc
|
|
}//eons |