public override bool Equals(Object test) { if (test == null || GetType() != test.GetType()) { return(false); } PurchaseSet purchase = (PurchaseSet)test; return(this.part.name == purchase.part.name); }
/// <summary> /// /// AddPart - Adds a single part to the correct list, when given the part object /// /// and a quantity of the item to add. /// /// </summary> /// /// <param name="newPart">The new part to add.</param> /// <param name="quantity">The quantity of that part to add.</param> private void AddPart(Part newPart, decimal quantity) { PurchaseSet purchaseSet = new PurchaseSet { part = newPart, quantity = quantity }; if (purchaseSet.part.type.Equals("Labor") || purchaseSet.part.type.Equals("Service")) { this.laborList.Add(purchaseSet); } else { this.partsList.Add(purchaseSet); } this.PartsDG.Items.Refresh(); this.LaborDG.Items.Refresh(); /** * // Uncomment this code block to condense all items of a single name into one block. otherwise, they will * // be added as separate items to allow for easier comparison to the actual billing chart. * * if (this.PartsDG.Items.Contains(purchaseSet)) { * * //Increase the quantity of this item should it already exist in the list. * int index = this.PartsDG.Items.IndexOf(purchaseSet); * PurchaseSet old = (PurchaseSet)this.PartsDG.Items.GetItemAt(index); * old.quantity += purchaseSet.quantity; * * //Tempting... but that's bad style :'( * //((PurchaseSet)this.PartsDG.Items.GetItemAt(this.PartsDG.Items.IndexOf(purchaseSet))).quantity += purchaseSet.quantity; * * } */ UpdateTotals(); }