protected override void RemoveItem(int index) { ActiveInventoryObject item = this[index]; UPCDictionary.Remove(item.UPC.ToUpperInvariant()); SKUDictionary.Remove(item.SKU.ToUpperInvariant()); ProductIDDictionary.Remove(item.ProductID); item.UnSubscribeToChangeEvents(item_UPCChanged, item_SKUChanged); base.RemoveItem(index); TotalInvested -= (item.WholeSalePrice + item.AdditionalOverhead) * item.Quantity; }
void item_UPCChanged(object sender, ItemChangedEventArgs e) { string key = e.OldValue as string; if (!string.IsNullOrEmpty(key)) { key = key.ToUpperInvariant(); int index = UPCDictionary[key]; UPCDictionary.Remove(key); key = e.NewValue as string; AddUPCItem(key, index); } }