コード例 #1
0
 /// <summary>
 /// Checks permission and disposes a container (does not post changes!)
 /// </summary>
 public void Dispose(bool OverridePermissions = false)
 {
     if (OverridePermissions || CswNbtObjClassContainer.canContainer(_CswNbtResources, _CswNbtResources.Actions[CswEnumNbtActionName.DisposeContainer], _Container.getPermissionGroupId()))
     {
         _ContainerDispenseTransactionBuilder.create(CswEnumNbtContainerDispenseType.Dispose, -_Container.Quantity.Quantity, _Container.Quantity.UnitId, SrcContainer: _Container);
         _Container.Quantity.Quantity = 0;
         _Container.Disposed.Checked  = CswEnumTristate.True;
         _Container.CreateContainerLocationNode(CswEnumNbtContainerLocationTypeOptions.Dispose);
         _Container.Node.IconFileNameOverride = "x.png";
         _Container.Node.Searchable           = false;
     }
 }
コード例 #2
0
        /// <summary>
        /// Dispense out of this container.
        /// </summary>
        /// <param name="DispenseType"></param>
        /// <param name="QuantityToDeduct">Positive quantity to subtract</param>
        /// <param name="UnitId"></param>
        /// <param name="RequestItemId"></param>
        /// <param name="DestinationContainer"></param>
        public void DispenseOut(CswEnumNbtContainerDispenseType DispenseType, double QuantityToDeduct, CswPrimaryKey UnitId,
                                CswPrimaryKey RequestItemId = null, CswNbtObjClassContainer DestinationContainer = null, bool RecordTransaction = true)
        {
            double RealQuantityToDeduct = _getDispenseAmountInProperUnits(QuantityToDeduct, UnitId, _Container.Quantity.UnitId);
            double CurrentQuantity      = 0;

            if (CswTools.IsDouble(_Container.Quantity.Quantity))
            {
                CurrentQuantity = _Container.Quantity.Quantity;
            }
            _Container.Quantity.Quantity = CurrentQuantity - RealQuantityToDeduct;

            if (DestinationContainer != null)
            {
                DestinationContainer.DispenseIn(DispenseType, QuantityToDeduct, UnitId, RequestItemId, _Container, false);    // false, because we do not want another duplicate transaction record
            }
            if (RecordTransaction)
            {
                _ContainerDispenseTransactionBuilder.create(DispenseType, -RealQuantityToDeduct, _Container.Quantity.UnitId, RequestItemId, _Container, DestinationContainer);
            }
            _Container.CreateContainerLocationNode(CswEnumNbtContainerLocationTypeOptions.Dispense);
        } // DispenseOut()