protected override bool onButtonClick(NbtButtonData ButtonData) { if (null != ButtonData.NodeTypeProp) { string OCPPropName = ButtonData.NodeTypeProp.getObjectClassPropName(); switch (OCPPropName) { case PropertyName.Request: if (_CswNbtResources.Permit.can(CswEnumNbtActionName.Submit_Request)) { ButtonData.Action = CswEnumNbtButtonAction.request; CswNbtActRequesting RequestAct = new CswNbtActRequesting(_CswNbtResources); CswNbtObjClassRequestItem RequestItem = RequestAct.makeEnterprisePartRequestItem(this, ButtonData); ButtonData.Data["titleText"] = "Add to Cart: " + RequestItem.Type.Value; ButtonData.Data["requestItemProps"] = RequestAct.getRequestItemAddProps(RequestItem.Node); ButtonData.Data["requestItemNodeTypeId"] = RequestItem.NodeTypeId; } else { throw new CswDniException(CswEnumErrorType.Warning, "You do not have permission to the Submit Request action.", "You do not have permission to the Submit Request action."); } break; } } return(true); }
protected override bool onButtonClick( NbtButtonData ButtonData ) { if( null != ButtonData.NodeTypeProp ) { bool HasPermission = false; string OCPPropName = ButtonData.NodeTypeProp.getObjectClassPropName(); switch( OCPPropName ) { case PropertyName.Request: if( _CswNbtResources.Permit.can( CswEnumNbtActionName.Submit_Request ) ) { // Case CIS-52280 if( Obsolete.Checked == CswEnumTristate.True ) { throw new CswDniException( CswEnumErrorType.Warning, "Can't request Material " + TradeName + " because it is obsolete.", "Material is obsolete" ); } HasPermission = true; CswNbtActRequesting RequestAct = new CswNbtActRequesting( _CswNbtResources ); CswNbtObjClassRequestItem RequestItem = RequestAct.makeMaterialRequestItem( this, ButtonData ); ButtonData.Data["requestaction"] = ButtonData.SelectedText; //ButtonData.Data["requestaction"] = OCPPropName; //Case 31298: Default Option Text "Request" != "Request By Bulk" if( ButtonData.SelectedText == "Request" ) { ButtonData.SelectedText = CswEnumRequestOption.Bulk; } ButtonData.Data["titleText"] = ButtonData.SelectedText + " for " + TradeName.Text; ButtonData.Data["requestItemProps"] = RequestAct.getRequestItemAddProps( RequestItem.Node ); ButtonData.Data["requestItemNodeTypeId"] = RequestItem.NodeTypeId; ButtonData.Data["relatednodeid"] = NodeId.ToString(); ButtonData.Action = CswEnumNbtButtonAction.request; } break; case PropertyName.Receive: if( _CswNbtResources.Permit.can( CswEnumNbtActionName.Receiving ) ) { // Case CIS-52280 if( Obsolete.Checked == CswEnumTristate.True ) { throw new CswDniException( CswEnumErrorType.Warning, "Can't receive Material " + TradeName + " because it is obsolete.", "Material is obsolete" ); } HasPermission = true; CswNbtActReceiving Act = new CswNbtActReceiving( _CswNbtResources, NodeId ); _CswNbtResources.setAuditActionContext( CswEnumNbtActionName.Receiving ); Action<CswNbtNode> After = delegate( CswNbtNode NewNode ) { CswNbtObjClassContainer newContainer = NewNode; //Case 29436 if( newContainer.isLocationInAccessibleInventoryGroup( _CswNbtResources.CurrentNbtUser.DefaultLocationId ) ) { newContainer.Location.SelectedNodeId = _CswNbtResources.CurrentNbtUser.DefaultLocationId; } newContainer.Owner.RelatedNodeId = _CswNbtResources.CurrentNbtUser.UserId; DateTime ExpirationDate = getDefaultExpirationDate( DateTime.Now ); if( DateTime.MinValue != ExpirationDate ) { newContainer.ExpirationDate.DateTimeValue = ExpirationDate; } //Container.postChanges( false ); }; CswNbtObjClassContainer Container = Act.makeContainer( After ); ButtonData.Data["state"] = new JObject(); ButtonData.Data["state"]["materialId"] = NodeId.ToString(); ButtonData.Data["state"]["materialNodeTypeId"] = NodeTypeId; ButtonData.Data["state"]["tradeName"] = TradeName.Text; ButtonData.Data["state"]["nodeName"] = NodeName; Int32 ContainerLimit = CswConvert.ToInt32( _CswNbtResources.ConfigVbls.getConfigVariableValue( CswEnumNbtConfigurationVariables.container_receipt_limit.ToString() ) ); ButtonData.Data["state"]["containerlimit"] = ContainerLimit; ButtonData.Data["state"]["containerNodeId"] = Container.NodeId.ToString(); ButtonData.Data["state"]["containerNodeTypeId"] = Container.NodeTypeId; bool customBarcodes = CswConvert.ToBoolean( _CswNbtResources.ConfigVbls.getConfigVariableValue( CswEnumNbtConfigurationVariables.custom_barcodes.ToString() ) ); ButtonData.Data["state"]["customBarcodes"] = customBarcodes; ButtonData.Data["state"]["nodetypename"] = this.NodeType.NodeTypeName; ButtonData.Data["state"]["containerAddLayout"] = Act.getContainerAddProps( Container ); onReceiveButtonClick( ButtonData ); _setCofAData( ButtonData ); ButtonData.Action = CswEnumNbtButtonAction.receive; } break; case CswNbtObjClass.PropertyName.Save: HasPermission = true; break; } HasPermission = HasPermission || onPropertySetButtonClick( ButtonData ); if( false == HasPermission ) { throw new CswDniException( CswEnumErrorType.Warning, "You do not have permission to the " + OCPPropName + " action.", "You do not have permission to the " + OCPPropName + " action." ); } } return true; }