Exemple #1
0
        public bool DeletePart(OutGoingPen ogPen, PenList mlPen)
        {
            bool bReturn = false;

            //string match = mlPen.Pens[1].Name;
            //for (int i = 0; i < mlPen.Pens.Count(); i++)
            foreach (var pen in mlPen.Pens)
            {
                if (pen.Name == ogPen.Name)
                {
                    //for (int j = 0; j < pen.Parts.Parts.Count(); j++)
                    foreach (var penPart in pen.Parts.Parts)
                    {
                        if (InvParts.ContainsKey(penPart.Name))
                        {
                            var invPart = InvParts[penPart.Name];
                            switch (penPart.Type)
                            {
                            case PartTypeEnum.ptWeight:
                                ((PartWithWeight)invPart).Weight -= (((PartWithWeight)penPart).Weight * ogPen.Count);
                                break;

                            case PartTypeEnum.ptCount:
                                ((PartWithCount)invPart).Count -= (((PartWithCount)penPart).Count * ogPen.Count);
                                break;

                            default:
                                return(false);
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }

                    bReturn = true;
                }
            }

            return(bReturn);
        }
 public bool Add(OutGoingPen pen)
 {
     Pens.Add(pen);
     return(true);
 }