protected virtual void INItemClass_ItemType_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e) { if (e.Row == null) { return; } INItemClass itemClassRow = (INItemClass)e.Row; FSxServiceClass fsxServiceClassRow = cache.GetExtension <FSxServiceClass>(itemClassRow); if (itemClassRow.ItemType != INItemTypes.ServiceItem) { fsxServiceClassRow.RequireRoute = false; } }
protected virtual void _(Events.FieldUpdated <INItemClass, INItemClass.itemType> e) { if (e.Row == null) { return; } INItemClass itemClassRow = (INItemClass)e.Row; FSxServiceClass fsxServiceClassRow = e.Cache.GetExtension <FSxServiceClass>(itemClassRow); if (itemClassRow.ItemType != INItemTypes.ServiceItem) { fsxServiceClassRow.RequireRoute = false; } }
/// <summary> /// Assign the default Billing Rule set in the ItemClass. /// </summary> public virtual void SetDefaultBillingRule(PXCache cache, InventoryItem nonStockItemRow) { if (nonStockItemRow == null || nonStockItemRow.ItemClassID == null) { return; } if (nonStockItemRow.ItemType == INItemTypes.ServiceItem) { INItemClass inItemClassRow = PXSelect <INItemClass, Where < INItemClass.itemClassID, Equal <Required <InventoryItem.itemClassID> > > > .Select(Base, nonStockItemRow.ItemClassID); FSxServiceClass fsxServiceClassRow = PXCache <INItemClass> .GetExtension <FSxServiceClass>(inItemClassRow); FSxService service = cache.GetExtension <FSxService>(nonStockItemRow); service.BillingRule = fsxServiceClassRow.DfltBillingRule; } }
/// <summary> /// Enables or disables fields. /// </summary> private void EnableDisable(PXCache cache, INItemClass itemClassRow) { bool isEnabledAsModelTemplate = false; bool isStkItem = itemClassRow.StkItem == true; FSxServiceClass fsxServiceClassRow = cache.GetExtension <FSxServiceClass>(itemClassRow); PXUIFieldAttribute.SetEnabled <FSxServiceClass.dfltBillingRule>(cache, itemClassRow, itemClassRow.ItemType == INItemTypes.ServiceItem); EnableDisable_ItemType(cache, itemClassRow, fsxServiceClassRow); ModelTemplateComponentRecords.AllowSelect = false; if (PXAccess.FeatureInstalled <FeaturesSet.equipmentManagementModule>()) { FSxEquipmentModelTemplate fsxEquipmentModelTemplateRow = cache.GetExtension <FSxEquipmentModelTemplate>(itemClassRow); isEnabledAsModelTemplate = fsxEquipmentModelTemplateRow.EQEnabled == true && fsxEquipmentModelTemplateRow.EquipmentItemClass == ID.Equipment_Item_Class.MODEL_EQUIPMENT; fsxEquipmentModelTemplateRow.Mem_ShowComponent = isEnabledAsModelTemplate; PXUIFieldAttribute.SetEnabled <FSxEquipmentModelTemplate.equipmentItemClass>(cache, itemClassRow, isStkItem); PXUIFieldAttribute.SetEnabled <FSxEquipmentModelTemplate.eQEnabled>(cache, itemClassRow, isStkItem); PXUIFieldAttribute.SetEnabled <FSxEquipmentModelTemplate.dfltModelType>(cache, itemClassRow, isEnabledAsModelTemplate); PXDefaultAttribute.SetPersistingCheck <FSxEquipmentModelTemplate.dfltModelType>( cache, itemClassRow, isEnabledAsModelTemplate == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing); ModelTemplateComponentRecords.AllowSelect = fsxEquipmentModelTemplateRow.Mem_ShowComponent == true; } ModelTemplateComponentRecords.Cache.AllowInsert = isEnabledAsModelTemplate; ModelTemplateComponentRecords.Cache.AllowUpdate = isEnabledAsModelTemplate; ModelTemplateComponentRecords.Cache.AllowDelete = isEnabledAsModelTemplate; if (isEnabledAsModelTemplate == false) { ModelTemplateComponentRecords.Cache.Clear(); } }
/// <summary> /// Enables/Disables the Item Type field depending of there is at least one service related to. /// </summary> /// <param name="cache">PXCache instance.</param> /// <param name="itemClassRow">The current INItemClass object row.</param> /// <param name="fsxServiceClassRow">The current <c>FSxServiceClass</c> object row.</param> private void EnableDisable_ItemType(PXCache cache, INItemClass itemClassRow, FSxServiceClass fsxServiceClassRow) { bool enableItemType = true; PXSetPropertyException exception = null; if (itemClassRow.ItemType == INItemTypes.ServiceItem && cache.GetStatus(itemClassRow) != PXEntryStatus.Inserted) { int rowCount = PXSelectJoin <InventoryItem, InnerJoin <INItemClass, On <INItemClass.itemClassID, Equal <InventoryItem.itemClassID> > >, Where < InventoryItem.itemClassID, Equal <Required <InventoryItem.itemClassID> >, And <InventoryItem.itemType, Equal <INItemTypes.serviceItem> > > > .SelectWindowed(cache.Graph, 0, 1, itemClassRow.ItemClassID).Count; enableItemType = rowCount == 0; } if (enableItemType == false) { exception = new PXSetPropertyException( PXMessages.LocalizeFormat(TX.Warning.CANNOT_MODIFY_FIELD, "Services", "Item Class"), PXErrorLevel.Warning); } cache.RaiseExceptionHandling <INItemClass.itemType>( itemClassRow, itemClassRow.ItemType, exception ); cache.RaiseExceptionHandling <FSxServiceClass.requireRoute>( itemClassRow, fsxServiceClassRow.RequireRoute, exception ); PXUIFieldAttribute.SetEnabled <INItemClass.itemType>(cache, itemClassRow, enableItemType); PXUIFieldAttribute.SetEnabled <FSxServiceClass.requireRoute>(cache, itemClassRow, enableItemType); }
protected virtual void INItemClass_RowPersisting(PXCache cache, PXRowPersistingEventArgs e) { if (e.Row == null) { return; } INItemClass itemClassRow = (INItemClass)e.Row; FSxServiceClass fsxServiceClassRow = cache.GetExtension <FSxServiceClass>(itemClassRow); if (string.IsNullOrEmpty(fsxServiceClassRow.DfltBillingRule)) { cache.RaiseExceptionHandling <FSxServiceClass.dfltBillingRule>(e.Row, fsxServiceClassRow.DfltBillingRule, new PXException(PX.Objects.FS.TX.Error.FIELD_EMPTY)); e.Cancel = true; } if (PXAccess.FeatureInstalled <FeaturesSet.equipmentManagementModule>()) { FSxEquipmentModelTemplate fsxEquipmentModelTemplateRow = cache.GetExtension <FSxEquipmentModelTemplate>(itemClassRow); CheckComponentsClassID(fsxEquipmentModelTemplateRow); } }