///<summary> /// Instance a new container according to Object Class rules. Note: this does not get the properties. /// </summary> public CswNbtObjClassContainer makeContainer(Action <CswNbtNode> After) { CswNbtObjClassContainer ret = null; CswNbtMetaDataNodeType ContainerNt = _ContainerOc.getLatestVersionNodeTypes().FirstOrDefault(); if (null != ContainerNt) { Action <CswNbtNode> After2 = delegate(CswNbtNode NewNode) { CswNbtObjClassContainer RetAsContainer = NewNode; RetAsContainer.Material.RelatedNodeId = _MaterialId; //cases 30647 and 31079 //RetAsContainer.Material.setHidden( value: true, SaveToDb: false ); //RetAsContainer.Size.setHidden( value: true, SaveToDb: false ); if (null != After) { After(NewNode); } }; ret = _CswNbtSdTabsAndProps.getAddNodeAndPostChanges(ContainerNt, After2); if (null == ret) { throw new CswDniException(CswEnumErrorType.Error, "Could not create a new container.", "Failed to create a new Container node."); } } return(ret); } // makeContainer()
/// <summary> /// Instance a new EnterprisePart Request Item /// </summary> public CswNbtObjClassRequestItem makeEnterprisePartRequestItem(CswNbtObjClassEnterprisePart EnterprisePart, CswNbtObjClass.NbtButtonData ButtonData) { checkForCentralInventoryGroups(_CswNbtResources); CswNbtObjClassRequestItem RequestItem = null; CswNbtMetaDataObjectClass RequestItemOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.RequestItemClass); CswNbtMetaDataNodeType RequestItemNT = RequestItemOC.getNodeTypes().FirstOrDefault(); CswNbtSdTabsAndProps PropsAction = new CswNbtSdTabsAndProps(_CswNbtResources); if (null != RequestItemNT) { RequestItem = PropsAction.getAddNodeAndPostChanges(RequestItemNT, delegate(CswNbtNode NewNode) { CswNbtObjClassRequestItem RequestItemNode = NewNode; RequestItemNode.EnterprisePart.RelatedNodeId = EnterprisePart.NodeId; RequestItemNode.Type.Value = CswNbtObjClassRequestItem.Types.EnterprisePart; if (null != _ThisUser.DefaultLocationId) { CswNbtObjClassLocation DefaultAsLocation = _CswNbtResources.Nodes.GetNode(_ThisUser.DefaultLocationId); if (null != DefaultAsLocation) { RequestItemNode.Location.SelectedNodeId = DefaultAsLocation.NodeId; RequestItemNode.Location.CachedNodeName = DefaultAsLocation.Location.CachedNodeName; RequestItemNode.Location.CachedPath = DefaultAsLocation.Location.CachedPath; } } }); } return(RequestItem); }
/// <summary> /// Instance a new Container Request Item based on the selected button option - the type will either be Dispense, Move, or Dispose. /// </summary> public CswNbtObjClassRequestItem makeContainerRequestItem(CswNbtObjClassContainer Container, CswNbtObjClass.NbtButtonData ButtonData) { checkForCentralInventoryGroups(_CswNbtResources); CswNbtObjClassRequestItem RequestItem; CswNbtMetaDataObjectClass RequestItemOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.RequestItemClass); CswNbtMetaDataNodeType RequestItemNT = RequestItemOC.getNodeTypes().FirstOrDefault(); CswNbtSdTabsAndProps PropsAction = new CswNbtSdTabsAndProps(_CswNbtResources); RequestItem = PropsAction.getAddNodeAndPostChanges(RequestItemNT, delegate(CswNbtNode NewNode) { CswNbtObjClassRequestItem RequestItemNode = NewNode; if (null != getCurrentRequestNodeId() && null != Container) { RequestItemNode.Container.RelatedNodeId = Container.NodeId; RequestItemNode.Material.RelatedNodeId = Container.Material.RelatedNodeId; CswPrimaryKey SelectedLocationId = CswTools.IsPrimaryKey(_ThisUser.DefaultLocationId) ? _ThisUser.DefaultLocationId : Container.Location.SelectedNodeId; ButtonData.Action = CswEnumNbtButtonAction.request; switch (ButtonData.SelectedText) { case CswEnumNbtContainerRequestMenu.Dispense: RequestItemNode.Type.Value = CswNbtObjClassRequestItem.Types.ContainerDispense; RequestItemNode.Quantity.UnitId = Container.Quantity.UnitId; RequestItemNode.Size.RelatedNodeId = Container.Size.RelatedNodeId; RequestItemNode.Location.SelectedNodeId = SelectedLocationId; //Scope available units of measure on Quantity based on the Container's Material CswNbtNode MaterialNode = _CswNbtResources.Nodes[Container.Material.RelatedNodeId]; if (null != MaterialNode) { CswNbtUnitViewBuilder Vb = new CswNbtUnitViewBuilder(_CswNbtResources); Vb.setQuantityUnitOfMeasureView(MaterialNode, RequestItemNode.Quantity); } break; case CswEnumNbtContainerRequestMenu.Dispose: RequestItemNode.Type.Value = CswNbtObjClassRequestItem.Types.ContainerDispose; RequestItemNode.Location.SelectedNodeId = Container.Location.SelectedNodeId; break; case CswEnumNbtContainerRequestMenu.Move: RequestItemNode.Type.Value = CswNbtObjClassRequestItem.Types.ContainerMove; RequestItemNode.Location.SelectedNodeId = SelectedLocationId; break; } RequestItemNode.Location.RefreshNodeName(); } }); if (null == RequestItem) { throw new CswDniException(CswEnumErrorType.Error, "Could not generate a new request item.", "Failed to create a new Request Item node."); } return(RequestItem); }
/// <summary> /// Instance a new Material Request Item based on the selected button option - the type will either be By Bulk or By Size. /// </summary> public CswNbtObjClassRequestItem makeMaterialRequestItem(CswNbtPropertySetMaterial Material, CswNbtObjClass.NbtButtonData ButtonData) { checkForCentralInventoryGroups(_CswNbtResources); CswNbtObjClassRequestItem RequestItem = null; CswNbtMetaDataObjectClass RequestItemOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.RequestItemClass); CswNbtMetaDataNodeType RequestItemNT = RequestItemOC.getNodeTypes().FirstOrDefault(); CswNbtSdTabsAndProps PropsAction = new CswNbtSdTabsAndProps(_CswNbtResources); if (null != RequestItemNT) { RequestItem = PropsAction.getAddNodeAndPostChanges(RequestItemNT, delegate(CswNbtNode NewNode) { CswNbtObjClassRequestItem RequestItemNode = NewNode; RequestItemNode.Material.RelatedNodeId = Material.NodeId; if (null != _ThisUser.DefaultLocationId) { CswNbtObjClassLocation DefaultAsLocation = _CswNbtResources.Nodes.GetNode(_ThisUser.DefaultLocationId); if (null != DefaultAsLocation) { RequestItemNode.Location.SelectedNodeId = DefaultAsLocation.NodeId; RequestItemNode.Location.CachedNodeName = DefaultAsLocation.Location.CachedNodeName; RequestItemNode.Location.CachedPath = DefaultAsLocation.Location.CachedPath; } } switch (ButtonData.SelectedText) { case CswNbtPropertySetMaterial.CswEnumRequestOption.Size: RequestItemNode.Type.Value = CswNbtObjClassRequestItem.Types.MaterialSize; break; default: //Request by Bulk RequestItemNode.Type.Value = CswNbtObjClassRequestItem.Types.MaterialBulk; break; } }); } return(RequestItem); }