165 lines
6.5 KiB
C#
165 lines
6.5 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Sockeye.Biz;
|
|
using Sockeye.Models;
|
|
|
|
namespace Sockeye.DataList
|
|
{
|
|
internal class PurchaseDataList : DataListProcessingBase, IDataListInternalCriteria
|
|
{
|
|
public PurchaseDataList(long translationId)
|
|
{
|
|
DefaultListAType = SockType.Purchase;
|
|
SQLFrom = @"FROM apurchase LEFT JOIN aproduct on (apurchase.productid = aproduct.id) LEFT JOIN avendor ON (apurchase.vendorid = avendor.id) LEFT JOIN acustomer ON (apurchase.customerid = acustomer.id)";
|
|
|
|
var RoleSet = BizRoles.GetRoleSet(DefaultListAType);
|
|
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
|
DefaultColumns = new List<string>() { "PurchaseDate", "PurchaseSalesOrderNumber", "Customer", "Product", "PurchaseProcessedDate" };
|
|
DefaultSortBy = new Dictionary<string, string>() { { "PurchaseDate", "-" } };
|
|
FieldDefinitions = new List<DataListFieldDefinition>();
|
|
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PurchaseSalesOrderNumber",
|
|
FieldKey = "PurchaseSalesOrderNumber",
|
|
SockType = (int)SockType.Purchase,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "apurchase.id",
|
|
SqlValueColumnName = "apurchase.salesordernumber",
|
|
IsRowId = true
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "Customer",
|
|
FieldKey = "Customer",
|
|
SockType = (int)SockType.Customer,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "apurchase.customerid",
|
|
SqlValueColumnName = "acustomer.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "Vendor",
|
|
FieldKey = "Vendor",
|
|
SockType = (int)SockType.Vendor,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "apurchase.vendorid",
|
|
SqlValueColumnName = "avendor.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "Product",
|
|
FieldKey = "Product",
|
|
SockType = (int)SockType.Product,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "apurchase.productid",
|
|
SqlValueColumnName = "aproduct.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PurchaseDate",
|
|
FieldKey = "PurchaseDate",
|
|
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
|
SqlValueColumnName = "apurchase.purchasedate"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PurchaseExpireDate",
|
|
FieldKey = "PurchaseExpireDate",
|
|
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
|
SqlValueColumnName = "apurchase.expiredate"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PurchaseCancelDate",
|
|
FieldKey = "PurchaseCancelDate",
|
|
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
|
SqlValueColumnName = "apurchase.canceldate"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PurchaseCouponCode",
|
|
FieldKey = "PurchaseCouponCode",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "apurchase.couponcode"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PurchaseNotes",
|
|
FieldKey = "PurchaseNotes",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "apurchase.notes"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PurchaseRenewNoticeSent",
|
|
FieldKey = "PurchaseRenewNoticeSent",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "apurchase.renewnoticesent"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PurchaseQuantity",
|
|
FieldKey = "PurchaseQuantity",
|
|
UiFieldDataType = (int)UiFieldDataType.Integer,
|
|
SqlValueColumnName = "apurchase.quantity"
|
|
});
|
|
|
|
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "PurchaseProcessedDate",
|
|
FieldKey = "PurchaseProcessedDate",
|
|
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
|
SqlValueColumnName = "apurchase.processeddate"
|
|
});
|
|
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "Tags",
|
|
FieldKey = "purchasetags",
|
|
UiFieldDataType = (int)UiFieldDataType.Tags,
|
|
SqlValueColumnName = "apurchase.tags"
|
|
});
|
|
|
|
//META column
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "metacustomer",
|
|
UiFieldDataType = (int)UiFieldDataType.InternalId,
|
|
SqlIdColumnName = "apurchase.customerid",
|
|
SqlValueColumnName = "apurchase.customerid",
|
|
IsMeta = true
|
|
});
|
|
|
|
}
|
|
|
|
public List<DataListFilterOption> DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles, string clientCriteria)
|
|
{
|
|
List<DataListFilterOption> ret = new List<DataListFilterOption>();
|
|
//ClientCriteria MUST be CustomerId
|
|
if (string.IsNullOrWhiteSpace(clientCriteria))
|
|
throw new System.ArgumentNullException("CustomerNoteDataList - ClientCriteria is empty, should be Customer ID");
|
|
|
|
DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metacustomer" };
|
|
FilterOption.Items.Add(new DataListColumnFilter() { value = clientCriteria, op = DataListFilterComparisonOperator.Equality });
|
|
|
|
ret.Add(FilterOption);
|
|
return ret;
|
|
}
|
|
|
|
}//eoc
|
|
}//eons |