272 lines
13 KiB
C#
272 lines
13 KiB
C#
using System.Collections.Generic;
|
|
using Newtonsoft.Json.Linq;
|
|
using AyaNova.Biz;
|
|
namespace AyaNova.DataList
|
|
{
|
|
internal class UnitDataList : AyaDataList
|
|
{
|
|
public UnitDataList()
|
|
{
|
|
DefaultListObjectType = AyaType.Unit;
|
|
SQLFrom = "from aunit "
|
|
+ "left outer join acustomer on (aunit.customerid=acustomer.id) "
|
|
+ "left outer join aunit as aparentunit on (aunit.parentunitid=aunit.id) "
|
|
+ "left outer join aunitmodel on (aunit.unitmodelid=aunitmodel.id) "
|
|
+ "left outer join avendor on (aunit.purchasedfromvendorid=avendor.id) "
|
|
+ "left outer join aunit as areplacedbyunit on (aunit.replacedbyunitid=aunit.id) ";
|
|
var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType);
|
|
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
|
|
|
//######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############
|
|
//Default ListView
|
|
dynamic dlistView = new JArray();
|
|
|
|
dynamic cm = new JObject();
|
|
cm.fld = "UnitSerial";
|
|
cm.sort = "+";
|
|
dlistView.Add(cm);
|
|
|
|
cm = new JObject();
|
|
cm.fld = "UnitModel";
|
|
dlistView.Add(cm);
|
|
|
|
cm = new JObject();
|
|
cm.fld = "Customer";
|
|
dlistView.Add(cm);
|
|
|
|
cm = new JObject();
|
|
cm.fld = "Active";
|
|
dlistView.Add(cm);
|
|
|
|
|
|
DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None);
|
|
|
|
|
|
//NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely
|
|
FieldDefinitions = new List<AyaDataListFieldDefinition>();
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "UnitSerial",
|
|
FieldKey = "UnitSerial",
|
|
AyaObjectType = (int)AyaType.Unit,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "aunit.id",
|
|
SqlValueColumnName = "aunit.serial",
|
|
IsRowId = true
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "UnitNotes",
|
|
FieldKey = "unitnotes",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aunit.notes"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "Active",
|
|
FieldKey = "Active",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "aunit.active"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "Tags",
|
|
FieldKey = "unittags",
|
|
UiFieldDataType = (int)UiFieldDataType.Tags,
|
|
SqlValueColumnName = "aunit.tags"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
FieldKey = "Customer",
|
|
TKey = "Customer",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AyaObjectType = (int)AyaType.Customer,
|
|
SqlIdColumnName = "acustomer.id",
|
|
SqlValueColumnName = "acustomer.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
FieldKey = "UnitParentUnitID",
|
|
TKey = "UnitParentUnitID",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AyaObjectType = (int)AyaType.Unit,
|
|
SqlIdColumnName = "aparentunit.id",
|
|
SqlValueColumnName = "aparentunit.serial"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
FieldKey = "UnitReplacedByUnitID",
|
|
TKey = "UnitReplacedByUnitID",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AyaObjectType = (int)AyaType.Unit,
|
|
SqlIdColumnName = "areplacedbyunit.id",
|
|
SqlValueColumnName = "areplacedbyunit.serial"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
FieldKey = "UnitModel",
|
|
TKey = "UnitModel",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AyaObjectType = (int)AyaType.UnitModel,
|
|
SqlIdColumnName = "aunitmodel.id",
|
|
SqlValueColumnName = "aunitmodel.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "UnitUnitHasOwnAddress",
|
|
FieldKey = "UnitUnitHasOwnAddress",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "aunit.unithasownaddress"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "UnitBoughtHere",
|
|
FieldKey = "UnitBoughtHere",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "aunit.boughthere"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
FieldKey = "UnitPurchaseFromID",
|
|
TKey = "UnitPurchaseFromID",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AyaObjectType = (int)AyaType.Vendor,
|
|
SqlIdColumnName = "avendor.id",
|
|
SqlValueColumnName = "avendor.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "UnitReceipt",
|
|
FieldKey = "UnitReceipt",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aunit.receipt"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "UnitPurchasedDate",
|
|
FieldKey = "UnitPurchasedDate",
|
|
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
|
SqlValueColumnName = "aunit.purchaseddate"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "UnitDescription",
|
|
FieldKey = "UnitDescription",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aunit.description"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "UnitOverrideWarranty",
|
|
FieldKey = "UnitOverrideWarranty",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "aunit.overridemodelwarranty"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "UnitOverrideLength",
|
|
FieldKey = "UnitOverrideLength",
|
|
UiFieldDataType = (int)UiFieldDataType.Integer,
|
|
SqlValueColumnName = "aunit.warrantylength"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "UnitOverrideLifeTime",
|
|
FieldKey = "UnitOverrideLifeTime",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "aunit.lifetimewarranty"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "UnitOverrideWarrantyTerms",
|
|
FieldKey = "UnitOverrideWarrantyTerms",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aunit.warrantyterms"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "UsesBanking",
|
|
FieldKey = "UsesBanking",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "aunit.usesbanking"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "UnitMetered",
|
|
FieldKey = "UnitMetered",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "aunit.metered"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "UnitText1",
|
|
FieldKey = "UnitText1",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aunit.text1"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "UnitText2",
|
|
FieldKey = "UnitText2",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aunit.text2"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "UnitText3",
|
|
FieldKey = "UnitText3",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aunit.text3"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "UnitText4",
|
|
FieldKey = "UnitText4",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aunit.text4"
|
|
});
|
|
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "UnitCustom1", FieldKey = "unitcustom1", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aunit.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "UnitCustom2", FieldKey = "unitcustom2", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aunit.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "UnitCustom3", FieldKey = "unitcustom3", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aunit.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "UnitCustom4", FieldKey = "unitcustom4", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aunit.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "UnitCustom5", FieldKey = "unitcustom5", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aunit.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "UnitCustom6", FieldKey = "unitcustom6", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aunit.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "UnitCustom7", FieldKey = "unitcustom7", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aunit.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "UnitCustom8", FieldKey = "unitcustom8", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aunit.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "UnitCustom9", FieldKey = "unitcustom9", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aunit.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "UnitCustom10", FieldKey = "unitcustom10", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aunit.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "UnitCustom11", FieldKey = "unitcustom11", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aunit.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "UnitCustom12", FieldKey = "unitcustom12", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aunit.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "UnitCustom13", FieldKey = "unitcustom13", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aunit.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "UnitCustom14", FieldKey = "unitcustom14", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aunit.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "UnitCustom15", FieldKey = "unitcustom15", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aunit.customfields" });
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "UnitCustom16", FieldKey = "unitcustom16", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aunit.customfields" });
|
|
}
|
|
}//eoc
|
|
}//eons |