Exemplo n.º 1
0
        public bool Add(ProductMasterItem item, ref double count)
        {
            bool   added    = false;
            double numToAdd = count;

            if (!IsFull())
            {
                // get the number that can be added.
                double hoursAvailable = GetAvailableHours();
                double maxUnitsToMake = hoursAvailable * item.UnitsPerHour;

                // clamp
                numToAdd = numToAdd > maxUnitsToMake ? maxUnitsToMake : numToAdd;

                PressMasterItem pressItem = Produced.FirstOrDefault(p => p.MasterItem == item);

                if (pressItem == null)
                {
                    Produced.Add(new PressMasterItem(item, numToAdd));
                }
                else
                {
                    pressItem.UnitsMade += numToAdd;
                }
                RaisePropertyChangedEvent("Produced");
                count -= numToAdd;
                added  = true;
            }

            return(added);
        }
Exemplo n.º 2
0
        public void Remove(ProductMasterItem item, ref double scheduledCount)
        {
            PressMasterItem pressItem = Produced.FirstOrDefault(p => p.MasterItem.Equals(item));

            if (pressItem != null)
            {
                if (scheduledCount >= pressItem.UnitsMade)
                {
                    Produced.Remove(pressItem);
                }

                scheduledCount -= pressItem.UnitsMade;
                RaisePropertyChangedEvent("Produced");
            }
        }