157 lines
6.4 KiB
C#
157 lines
6.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using AyaNova.Biz;
|
|
using AyaNova.Models;
|
|
|
|
namespace AyaNova.DataList
|
|
{
|
|
internal class CustomerWorkOrderDataList : DataListProcessingBase, IDataListInternalCriteria
|
|
{
|
|
//CUSTOMER VERSION
|
|
public CustomerWorkOrderDataList(long translationId)
|
|
{
|
|
DefaultListAType = AyaType.CustomerServiceRequest;
|
|
SQLFrom = "from aworkorder " +
|
|
"left join acustomer on (aworkorder.customerid=acustomer.id) " +
|
|
"left join aheadoffice on (acustomer.headofficeid=aheadoffice.id) ";
|
|
var RoleSet = BizRoles.GetRoleSet(DefaultListAType);
|
|
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
|
DefaultColumns = new List<string>() { "WorkOrderSerialNumber", "WorkOrderServiceDate", "Customer", "WorkOrderCustomerReferenceNumber", "WorkOrderInvoiceNumber", "WorkOrderCustomerContactName" };
|
|
DefaultSortBy = new Dictionary<string, string>() { { "WorkOrderSerialNumber", "-" } };
|
|
|
|
FieldDefinitions = new List<DataListFieldDefinition>();
|
|
|
|
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "WorkOrderSerialNumber",
|
|
FieldKey = "WorkOrderSerialNumber",
|
|
AType = (int)AyaType.WorkOrder,
|
|
UiFieldDataType = (int)UiFieldDataType.Integer,
|
|
SqlIdColumnName = "aworkorder.id",
|
|
SqlValueColumnName = "aworkorder.serial",
|
|
IsRowId = true
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "Customer",
|
|
TKey = "Customer",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
// AType = (int)AyaType.Customer,
|
|
// SqlIdColumnName = "acustomer.id",
|
|
SqlValueColumnName = "acustomer.name"
|
|
});
|
|
|
|
//Not really useful either you know it because you are it or you don't need it
|
|
// FieldDefinitions.Add(new DataListFieldDefinition
|
|
// {
|
|
// TKey = "HeadOffice",
|
|
// FieldKey = "workorderheadoffice",
|
|
// UiFieldDataType = (int)UiFieldDataType.Text,
|
|
// // AType = (int)AyaType.HeadOffice,
|
|
// // SqlIdColumnName = "aheadoffice.id",
|
|
// SqlValueColumnName = "aheadoffice.name"
|
|
// });
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "WorkOrderCustomerReferenceNumber",
|
|
FieldKey = "WorkOrderCustomerReferenceNumber",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aworkorder.customerreferencenumber"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "WorkOrderCustomerContactName",
|
|
FieldKey = "WorkOrderCustomerContactName",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aworkorder.customercontactname"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "WorkOrderServiceDate",
|
|
FieldKey = "WorkOrderServiceDate",
|
|
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
|
SqlValueColumnName = "aworkorder.servicedate"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "WorkOrderInvoiceNumber",
|
|
FieldKey = "WorkOrderInvoiceNumber",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aworkorder.invoicenumber"
|
|
});
|
|
|
|
|
|
//-----------
|
|
|
|
|
|
//META COLUMNS
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "metacustomer",
|
|
UiFieldDataType = (int)UiFieldDataType.InternalId,
|
|
SqlIdColumnName = "acustomer.id",
|
|
SqlValueColumnName = "acustomer.id",
|
|
IsMeta = true
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "metaheadoffice",
|
|
UiFieldDataType = (int)UiFieldDataType.InternalId,
|
|
SqlIdColumnName = "aheadoffice.id",
|
|
SqlValueColumnName = "aheadoffice.id",
|
|
IsMeta = true
|
|
});
|
|
|
|
|
|
}
|
|
|
|
public List<DataListFilterOption> DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles, string clientCriteria)
|
|
{
|
|
List<DataListFilterOption> ret = new List<DataListFilterOption>();
|
|
|
|
//ClientCriteria format for this list is "OBJECTID,AYATYPE"
|
|
var crit = (clientCriteria ?? "").Split(',').Select(z => z.Trim()).ToArray();
|
|
if (crit.Length > 1)
|
|
{
|
|
|
|
int nType = 0;
|
|
if (!int.TryParse(crit[1], out nType)) return ret;
|
|
AyaType forType = (AyaType)nType;
|
|
if (forType != AyaType.Customer && forType != AyaType.HeadOffice) return ret;
|
|
|
|
long lId = 0;
|
|
if (!long.TryParse(crit[0], out lId)) return ret;
|
|
if (lId == 0) return ret;
|
|
|
|
//Have valid type, have an id, so filter away
|
|
switch (forType)
|
|
{
|
|
case AyaType.Customer:
|
|
{
|
|
DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metacustomer" };
|
|
FilterOption.Items.Add(new DataListColumnFilter() { value = crit[0], op = DataListFilterComparisonOperator.Equality });
|
|
ret.Add(FilterOption);
|
|
}
|
|
break;
|
|
case AyaType.HeadOffice:
|
|
{
|
|
DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metaheadoffice" };
|
|
FilterOption.Items.Add(new DataListColumnFilter() { value = crit[0], op = DataListFilterComparisonOperator.Equality });
|
|
ret.Add(FilterOption);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
}//eoc
|
|
}//eons |