public override void setQuantityOptions() { CswNbtNode MaterialNode = _CswNbtResources.Nodes.GetNode(_RequestItem.Material.RelatedNodeId); if (MaterialNode != null) { CswNbtUnitViewBuilder Vb = new CswNbtUnitViewBuilder(_CswNbtResources); Vb.setQuantityUnitOfMeasureView(MaterialNode, _RequestItem.Quantity); } }
//set available quantity units when rendering the property on the add/edit layout private void _setUnits() { CswNbtNode MaterialNode = _CswNbtResources.Nodes.GetNode(Material.RelatedNodeId); if (MaterialNode != null) { Material.setReadOnly(value: true, SaveToDb: true); CswNbtUnitViewBuilder Vb = new CswNbtUnitViewBuilder(_CswNbtResources); Vb.setQuantityUnitOfMeasureView(MaterialNode, InitialQuantity); } }
/// <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); }
private void onMaterialPropChange(CswNbtNodeProp Prop) { if (CswTools.IsPrimaryKey(Material.RelatedNodeId)) { Material.setReadOnly(value: true, SaveToDb: true); CswNbtNode MaterialNode = _CswNbtResources.Nodes[Material.RelatedNodeId]; CswNbtUnitViewBuilder Vb = new CswNbtUnitViewBuilder(_CswNbtResources); Vb.setQuantityUnitOfMeasureView(MaterialNode, Quantity); Vb.setQuantityUnitOfMeasureView(MaterialNode, TotalDispensed); TotalDispensed.Quantity = 0; } }
private void OnMaterialPropChange( CswNbtNodeProp Prop, bool Creating ) { if( CswTools.IsPrimaryKey( Material.RelatedNodeId ) ) { CswNbtNode MaterialNode = _CswNbtResources.Nodes[Material.RelatedNodeId]; if( null != MaterialNode ) { CswNbtUnitViewBuilder Vb = new CswNbtUnitViewBuilder( _CswNbtResources ); Vb.setQuantityUnitOfMeasureView( MaterialNode, CurrentQuantity ); Vb.setQuantityUnitOfMeasureView( MaterialNode, Level ); } } }
public static JObject getSizeNodeProps(CswNbtResources CswNbtResources, Int32 SizeNodeTypeId, JObject SizeObj, bool WriteNode, out CswNbtNode SizeNode, CswPrimaryKey MaterialId = null) { JObject Ret = new JObject(); SizeNode = CswNbtResources.Nodes.makeNodeFromNodeTypeId(SizeNodeTypeId, OverrideUniqueValidation: true); string UoMId = SizeObj["uom"]["id"].ToString(); // CIS-53182: Preventative measure against the uomid being empty from client if (null != MaterialId && string.IsNullOrEmpty(UoMId) && false == string.IsNullOrEmpty(SizeObj["uom"]["value"].ToString())) { // Try to find the id for the unit of measure CswNbtUnitViewBuilder UnitViewBuilder = new CswNbtUnitViewBuilder(CswNbtResources); CswNbtView UnitsView = UnitViewBuilder.getQuantityUnitOfMeasureView(MaterialId); ICswNbtTree UnitTree = CswNbtResources.Trees.getTreeFromView(UnitsView, false, false, false); for (int i = 0; i < UnitTree.getChildNodeCount(); i++) { UnitTree.goToNthChild(i); if (UnitTree.getNodeNameForCurrentPosition().Equals(SizeObj["uom"]["value"].ToString())) { UoMId = UnitTree.getNodeIdForCurrentPosition().ToString(); } } } CswPrimaryKey UnitIdPK = CswConvert.ToPrimaryKey(UoMId); if (null != UnitIdPK) { SizeNode = CswNbtResources.Nodes.makeNodeFromNodeTypeId(SizeNodeTypeId, delegate(CswNbtNode NewNode) { CswNbtObjClassSize NodeAsSize = (CswNbtObjClassSize)NewNode; NodeAsSize.InitialQuantity.Quantity = CswConvert.ToDouble(SizeObj["quantity"]["value"]); NodeAsSize.InitialQuantity.UnitId = UnitIdPK; NodeAsSize.CatalogNo.Text = SizeObj["catalogNo"]["value"].ToString(); NodeAsSize.QuantityEditable.Checked = CswConvert.ToTristate(SizeObj["quantityEditable"]["value"]); NodeAsSize.Dispensable.Checked = CswConvert.ToTristate(SizeObj["dispensible"]["value"]); NodeAsSize.UnitCount.Value = CswConvert.ToDouble(SizeObj["unitCount"]["value"]); NodeAsSize.Material.RelatedNodeId = MaterialId; }); } else { SizeNode = null; } return(Ret); }
public static JObject getMaterialUnitsOfMeasure(string PhysicalStateValue, CswNbtResources CswNbtResources) { JObject ret = new JObject(); string PhysicalState = "n/a"; foreach (string CurrentPhysicalState in CswNbtPropertySetMaterial.CswEnumPhysicalState.Options) { if (PhysicalStateValue.Equals(CurrentPhysicalState)) { PhysicalState = CurrentPhysicalState; } } if (false == string.IsNullOrEmpty(PhysicalState)) { CswNbtUnitViewBuilder unitViewBuilder = new CswNbtUnitViewBuilder(CswNbtResources); CswNbtView unitsView = unitViewBuilder.getQuantityUnitOfMeasureView(PhysicalState); Collection <CswNbtNode> _UnitNodes = new Collection <CswNbtNode>(); ICswNbtTree UnitsTree = CswNbtResources.Trees.getTreeFromView(CswNbtResources.CurrentNbtUser, unitsView, RequireViewPermissions: true, IncludeSystemNodes: false, IncludeHiddenNodes: false); UnitsTree.goToRoot(); for (int i = 0; i < UnitsTree.getChildNodeCount(); i++) { UnitsTree.goToNthChild(i); _UnitNodes.Add(UnitsTree.getNodeForCurrentPosition()); UnitsTree.goToParentNode(); } foreach (CswNbtNode unitNode in _UnitNodes) { CswNbtObjClassUnitOfMeasure nodeAsUnitOfMeasure = (CswNbtObjClassUnitOfMeasure)unitNode; ret[nodeAsUnitOfMeasure.NodeId.ToString()] = nodeAsUnitOfMeasure.Name.Gestalt; } } return(ret); }
/// <summary> /// Takes the current Quantity value, converts it to the proper kg and Liters values, and stores it in Val_kg and Val_Liters /// </summary> public void SyncConvertedVals(CswPrimaryKey MaterialId = null) { if (null != UnitId) { CswNbtObjClassUnitOfMeasure CurrentUnit = _CswNbtResources.Nodes[UnitId]; if (CurrentUnit.UnitType.Value == CswEnumNbtUnitTypes.Weight.ToString() || CurrentUnit.UnitType.Value == CswEnumNbtUnitTypes.Volume.ToString()) { CswNbtUnitViewBuilder UnitBuilder = new CswNbtUnitViewBuilder(_CswNbtResources); CswNbtObjClassUnitOfMeasure kgUnit = UnitBuilder.getUnit("kg", "Unit_Weight"); CswNbtObjClassUnitOfMeasure LitersUnit = UnitBuilder.getUnit("Liters", "Unit_Volume"); if (null != kgUnit && (CurrentUnit.UnitType.Value == kgUnit.UnitType.Value || MaterialId != null)) { CswNbtUnitConversion Conversion = new CswNbtUnitConversion(_CswNbtResources, UnitId, kgUnit.NodeId, MaterialId); Val_kg = Conversion.convertUnit(Quantity); } if (null != LitersUnit && (CurrentUnit.UnitType.Value == LitersUnit.UnitType.Value || MaterialId != null)) { CswNbtUnitConversion Conversion = new CswNbtUnitConversion(_CswNbtResources, UnitId, LitersUnit.NodeId, MaterialId); Val_Liters = Conversion.convertUnit(Quantity); } } } }
public override void setQuantityOptions() { CswNbtUnitViewBuilder Vb = new CswNbtUnitViewBuilder(_CswNbtResources); Vb.getQuantityUnitOfMeasureView(CswNbtPropertySetMaterial.CswEnumPhysicalState.Liquid, _RequestItem.Quantity); }