Esempio n. 1
0
        }//afterPopulateProps()

        /// <summary>
        ///
        /// </summary>
        public override bool onPropertySetButtonClick(NbtButtonData ButtonData)
        {
            if (null != ButtonData.NodeTypeProp)
            {
                //Remember: Save is an OCP too
                switch (ButtonData.NodeTypeProp.getObjectClassPropName())
                {
                case PropertyName.Fulfill:
                    //If we do this here, we'll override the Actions for other options managed by the Property Set
                    //ButtonData.Action = NbtButtonAction.nothing;
                    switch (ButtonData.SelectedText)
                    {
                    case FulfillMenu.Create:
                        ButtonData.Action = CswEnumNbtButtonAction.nothing;
                        if (PotentialMaterial().existsInDb(ForceRecalc: true))
                        {
                            ButtonData.Message = "The requested Material has already been created: " + PotentialMaterial().existingMaterial().Node.NodeLink;
                        }
                        else
                        {
                            CswNbtPropertySetMaterial NewMaterial = PotentialMaterial().commit();         //See Case 28310. We do not want to upversion this node. The Create Material Wizard will do that for us.
                            bool Success = null != NewMaterial;
                            if (Success)
                            {
                                ButtonData.Action      = CswEnumNbtButtonAction.creatematerial;
                                Material.RelatedNodeId = NewMaterial.NodeId;
                                Fulfill.State          = FulfillMenu.Create;

                                ButtonData.Data["state"] = new JObject();
                                ButtonData.Data["state"]["materialType"]         = new JObject();
                                ButtonData.Data["state"]["materialType"]["name"] = PotentialMaterial().NodeTypeName;
                                ButtonData.Data["state"]["materialType"]["val"]  = PotentialMaterial().NodeTypeId;
                                ButtonData.Data["state"]["materialId"]           = NewMaterial.NodeId.ToString();
                                ButtonData.Data["state"]["tradeName"]            = PotentialMaterial().TradeName;
                                ButtonData.Data["state"]["supplier"]             = new JObject();
                                ButtonData.Data["state"]["supplier"]["val"]      = PotentialMaterial().SupplierId.ToString();
                                ButtonData.Data["state"]["supplier"]["name"]     = PotentialMaterial().SupplierName;
                                ButtonData.Data["state"]["partNo"] = NewMaterialPartNo.Text;
                            }
                            else
                            {
                                ButtonData.Message = "The requested Material cannot not be created.";
                            }
                            ButtonData.Data["success"] = Success;
                        }
                        break;
                    }     //switch( ButtonData.SelectedText )

                    _getNextStatus(ButtonData.SelectedText);
                    ButtonData.Data["requestitem"] = ButtonData.Data["requestitem"] ?? new JObject();
                    ButtonData.Data["requestitem"]["requestitemid"] = NodeId.ToString();
                    ButtonData.Data["requestitem"]["materialid"]    = (Material.RelatedNodeId ?? new CswPrimaryKey()).ToString();
                    break;     //case PropertyName.Fulfill:
                }
            }
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Fetch a Material node by NodeTypeId, TradeName, Supplier and PartNo (Optional). This method will throw if required parameters are null or empty.
        /// </summary>
        public static CswNbtPropertySetMaterial getExistingMaterial( CswNbtResources NbtResources, Int32 MaterialNodeTypeId, CswPrimaryKey SupplierId, string TradeName, string PartNo, bool IsConstituent )
        {
            CswNbtPropertySetMaterial Ret = null;

            CswNbtView MaterialNodeView = getMaterialNodeView( NbtResources, MaterialNodeTypeId, TradeName, SupplierId, PartNo, IsConstituent );
            ICswNbtTree Tree = NbtResources.Trees.getTreeFromView( MaterialNodeView, false, false, false );
            bool MaterialExists = Tree.getChildNodeCount() > 0;

            if( MaterialExists )
            {
                Tree.goToNthChild( 0 );
                Ret = Tree.getNodeForCurrentPosition();
            }
            return Ret;
        }
Esempio n. 3
0
 private void _throwIfMaterialExists()
 {
     if (Status.Value != Statuses.Cancelled &&
         false == CswTools.IsPrimaryKey(Material.RelatedNodeId) &&
         NewMaterialType.SelectedNodeTypeIds.Count == 1 &&
         false == string.IsNullOrEmpty(NewMaterialTradename.Text) &&
         CswTools.IsPrimaryKey(NewMaterialSupplier.RelatedNodeId))
     {
         CswNbtPropertySetMaterial ExistingMaterial = PotentialMaterial().existingMaterial(ForceRecalc: true);
         if (null != ExistingMaterial)
         {
             throw new CswDniException(CswEnumErrorType.Warning, "The requested Material already exists: " + ExistingMaterial.Node.NodeLink, "The requested Material already exists: " + ExistingMaterial.Node.NodeLink);
         }
     }
 }
Esempio n. 4
0
 public static CswNbtView getMaterialNodeView( CswNbtResources NbtResources, CswNbtPropertySetMaterial MaterialNode, string Prepend = "New Material: " )
 {
     CswNbtView Ret = null;
     if( MaterialNode != null )
     {
         Ret = MaterialNode.Node.getViewOfNode( false );
         if( NbtResources.Modules.IsModuleEnabled( CswEnumNbtModuleName.Containers ) && CswEnumTristate.True != MaterialNode.IsConstituent.Checked )
         {
             CswNbtMetaDataObjectClass SizeOc = NbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.SizeClass );
             CswNbtMetaDataObjectClassProp MaterialOcp = SizeOc.getObjectClassProp( CswNbtObjClassSize.PropertyName.Material );
             Ret.AddViewRelationship( Ret.Root.ChildRelationships[0], CswEnumNbtViewPropOwnerType.Second, MaterialOcp, false );
         }
         Ret.ViewName = Prepend + MaterialNode.NodeName;
     }
     return Ret;
 }
        }//afterPopulateProps()

        /// <summary>
        ///
        /// </summary>
        public override bool onPropertySetButtonClick(NbtButtonData ButtonData)
        {
            if (null != ButtonData.NodeTypeProp)
            {
                //Remember: Save is an OCP too
                switch (ButtonData.NodeTypeProp.getObjectClassPropName())
                {
                case PropertyName.Fulfill:
                    switch (ButtonData.SelectedText)
                    {
                    case FulfillMenu.Order:
                        ButtonData.Action         = CswEnumNbtButtonAction.editprop;
                        ButtonData.Data["nodeid"] = NodeId.ToString();
                        CswPropIdAttr OrdIdAttr = new CswPropIdAttr(Node, ExternalOrderNumber.NodeTypeProp);
                        ButtonData.Data["propidattr"] = OrdIdAttr.ToString();
                        ButtonData.Data["title"]      = "Enter the External Order Number";
                        break;

                    case FulfillMenu.Receive:
                        CswNbtPropertySetMaterial NodeAsMaterial = _CswNbtResources.Nodes.GetNode(Material.RelatedNodeId);
                        if (null != NodeAsMaterial)
                        {
                            if (null != NodeAsMaterial.Receive.NodeTypeProp)
                            {
                                NbtButtonData ReceiveData = new NbtButtonData(NodeAsMaterial.Receive.NodeTypeProp);
                                NodeAsMaterial.triggerOnButtonClick(ReceiveData);
                                ButtonData.clone(ReceiveData);
                                if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.SDS))
                                {
                                    CswNbtMetaDataObjectClass SDSDocOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.SDSDocumentClass);
                                    Int32 SDSNodeTypeId = SDSDocOC.FirstNodeType.NodeTypeId;
                                    if (Int32.MinValue != SDSNodeTypeId)
                                    {
                                        ButtonData.Data["documenttypeid"] = SDSNodeTypeId;
                                    }
                                }
                            }
                        }
                        break;

                    case FulfillMenu.Dispense:
                        JObject InitialQuantity = null;
                        if (false == Quantity.Empty)
                        {
                            InitialQuantity = new JObject();
                            Quantity.ToJSON(InitialQuantity);
                        }
                        if (null != InitialQuantity)
                        {
                            ButtonData.Data["initialQuantity"] = InitialQuantity;
                        }
                        string Title = "Fulfill Request for " + Quantity.Gestalt + " of " + Material.Gestalt;
                        if (TotalDispensed.Quantity > 0)
                        {
                            Title += " (" + TotalDispensed.Gestalt + ") dispensed.";
                        }
                        ButtonData.Data["title"] = Title;
                        ButtonData.Action        = CswEnumNbtButtonAction.dispense;
                        break;

                    case FulfillMenu.Move:
                        ButtonData.Data["title"]    = "Fulfill Request for " + Count.Value + " x " + Size.Gestalt + " of " + Material.Gestalt;
                        ButtonData.Data["sizeid"]   = Size.RelatedNodeId.ToString();
                        ButtonData.Data["location"] = Location.Gestalt;
                        ButtonData.Action           = CswEnumNbtButtonAction.move;
                        break;
                    }     //switch( ButtonData.SelectedText )

                    _getNextStatus(ButtonData.SelectedText);
                    ButtonData.Data["requestitem"] = ButtonData.Data["requestitem"] ?? new JObject();
                    ButtonData.Data["requestitem"]["requestMode"]      = Type.Value.ToLower();
                    ButtonData.Data["requestitem"]["requestitemid"]    = NodeId.ToString();
                    ButtonData.Data["requestitem"]["inventorygroupid"] = (InventoryGroup.RelatedNodeId ?? new CswPrimaryKey()).ToString();
                    ButtonData.Data["requestitem"]["materialid"]       = (Material.RelatedNodeId ?? new CswPrimaryKey()).ToString();
                    ButtonData.Data["requestitem"]["locationid"]       = (Location.SelectedNodeId ?? new CswPrimaryKey()).ToString();
                    break;     //case PropertyName.Fulfill:
                }
            }
            return(true);
        }
Esempio n. 6
0
 /// <summary>
 /// Cast a Request Item PropertySet back to an Object Class
 /// </summary>
 public static CswNbtObjClassBiological fromPropertySet( CswNbtPropertySetMaterial PropertySet )
 {
     return PropertySet.Node;
 }