275 lines
13 KiB
C#
275 lines
13 KiB
C#
using System.Collections.Generic;
|
|
using AyaNova.Biz;
|
|
namespace AyaNova.DataList
|
|
{
|
|
internal class UnitDataList : DataListProcessingBase
|
|
{
|
|
public UnitDataList()
|
|
{
|
|
DefaultListObjectType = AyaType.Unit;
|
|
//Self join prototype
|
|
//Be sure to alias *all* the tables to avoid issues
|
|
SQLFrom = "from aunit as amainunit "
|
|
+ "left join acustomer on (amainunit.customerid=acustomer.id) "
|
|
+ "left join aunit as aparentunit on (amainunit.parentunitid=aparentunit.id) "
|
|
+ "left join aunitmodel on (amainunit.unitmodelid=aunitmodel.id) "
|
|
+ "left join avendor on (amainunit.purchasedfromvendorid=avendor.id) "
|
|
+ "left join aunit as areplacedbyunit on (amainunit.replacedbyunitid=areplacedbyunit.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);
|
|
|
|
|
|
DefaultColumns = new List<string>() { "UnitSerial", "UnitModel", "Customer", "Active" };
|
|
DefaultSortBy = new Dictionary<string, string>() { { "UnitSerial", "+" } };
|
|
|
|
FieldDefinitions = new List<DataListFieldDefinition>();
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UnitSerial",
|
|
FieldKey = "UnitSerial",
|
|
AyaObjectType = (int)AyaType.Unit,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "amainunit.id",
|
|
SqlValueColumnName = "amainunit.serial",
|
|
IsRowId = true
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UnitNotes",
|
|
FieldKey = "unitnotes",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "amainunit.notes"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "Active",
|
|
FieldKey = "Active",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "amainunit.active"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "Tags",
|
|
FieldKey = "unittags",
|
|
UiFieldDataType = (int)UiFieldDataType.Tags,
|
|
SqlValueColumnName = "amainunit.tags"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "Customer",
|
|
TKey = "Customer",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AyaObjectType = (int)AyaType.Customer,
|
|
SqlIdColumnName = "acustomer.id",
|
|
SqlValueColumnName = "acustomer.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "UnitParentUnitID",
|
|
TKey = "UnitParentUnitID",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AyaObjectType = (int)AyaType.Unit,
|
|
SqlIdColumnName = "aparentunit.id",
|
|
SqlValueColumnName = "aparentunit.serial"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "UnitReplacedByUnitID",
|
|
TKey = "UnitReplacedByUnitID",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AyaObjectType = (int)AyaType.Unit,
|
|
SqlIdColumnName = "areplacedbyunit.id",
|
|
SqlValueColumnName = "areplacedbyunit.serial"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "UnitModel",
|
|
TKey = "UnitModel",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AyaObjectType = (int)AyaType.UnitModel,
|
|
SqlIdColumnName = "aunitmodel.id",
|
|
SqlValueColumnName = "aunitmodel.number"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UnitUnitHasOwnAddress",
|
|
FieldKey = "UnitUnitHasOwnAddress",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "amainunit.unithasownaddress"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UnitBoughtHere",
|
|
FieldKey = "UnitBoughtHere",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "amainunit.boughthere"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "UnitPurchaseFromID",
|
|
TKey = "UnitPurchaseFromID",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AyaObjectType = (int)AyaType.Vendor,
|
|
SqlIdColumnName = "avendor.id",
|
|
SqlValueColumnName = "avendor.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UnitReceipt",
|
|
FieldKey = "UnitReceipt",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "amainunit.receipt"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UnitPurchasedDate",
|
|
FieldKey = "UnitPurchasedDate",
|
|
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
|
SqlValueColumnName = "amainunit.purchaseddate"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UnitDescription",
|
|
FieldKey = "UnitDescription",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "amainunit.description"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UnitOverrideWarranty",
|
|
FieldKey = "UnitOverrideWarranty",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "amainunit.overridemodelwarranty"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UnitOverrideLength",
|
|
FieldKey = "UnitOverrideLength",
|
|
UiFieldDataType = (int)UiFieldDataType.Integer,
|
|
SqlValueColumnName = "amainunit.warrantylength"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UnitOverrideLifeTime",
|
|
FieldKey = "UnitOverrideLifeTime",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "amainunit.lifetimewarranty"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UnitOverrideWarrantyTerms",
|
|
FieldKey = "UnitOverrideWarrantyTerms",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "amainunit.warrantyterms"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UsesBanking",
|
|
FieldKey = "UsesBanking",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "amainunit.usesbanking"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UnitMetered",
|
|
FieldKey = "UnitMetered",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "amainunit.metered"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UnitText1",
|
|
FieldKey = "UnitText1",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "amainunit.text1"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UnitText2",
|
|
FieldKey = "UnitText2",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "amainunit.text2"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UnitText3",
|
|
FieldKey = "UnitText3",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "amainunit.text3"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "UnitText4",
|
|
FieldKey = "UnitText4",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "amainunit.text4"
|
|
});
|
|
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "UnitCustom1", FieldKey = "unitcustom1", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amainunit.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "UnitCustom2", FieldKey = "unitcustom2", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amainunit.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "UnitCustom3", FieldKey = "unitcustom3", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amainunit.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "UnitCustom4", FieldKey = "unitcustom4", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amainunit.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "UnitCustom5", FieldKey = "unitcustom5", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amainunit.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "UnitCustom6", FieldKey = "unitcustom6", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amainunit.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "UnitCustom7", FieldKey = "unitcustom7", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amainunit.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "UnitCustom8", FieldKey = "unitcustom8", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amainunit.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "UnitCustom9", FieldKey = "unitcustom9", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amainunit.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "UnitCustom10", FieldKey = "unitcustom10", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amainunit.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "UnitCustom11", FieldKey = "unitcustom11", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amainunit.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "UnitCustom12", FieldKey = "unitcustom12", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amainunit.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "UnitCustom13", FieldKey = "unitcustom13", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amainunit.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "UnitCustom14", FieldKey = "unitcustom14", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amainunit.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "UnitCustom15", FieldKey = "unitcustom15", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amainunit.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "UnitCustom16", FieldKey = "unitcustom16", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "amainunit.customfields" });
|
|
}
|
|
}//eoc
|
|
}//eons |