/// <summary> /// Button to remove an item from the restock onventory /// </summary> private void btnRemoveItem_Click(object sender, System.EventArgs e) { // If the user has not selected an item yet... if (lvItemList.SelectedIndices == null || lvItemList.SelectedIndices.Count == 0) { // Let the user know they need to select an item from the restock list to remove MessageBox.Show(this, "You must select an item before you can do that."); return; } // Get the SKU number long.TryParse(lvItemList.SelectedItems[0].SubItems[1].ToString().Substring( 18, lvItemList.SelectedItems[0].SubItems[1].ToString().Length - 19), out long sku); // If the SKU is 0 if (sku == 0) { // Let the user know to check selection MessageBox.Show(this, "SKU number is not right, please recheck selection and try again."); return; } // iterate through the restock inventory foreach (Item item in _restockInventory) { // If an item number matches a SKU... if (item.sku == sku) { // Remove that specific item _restockInventory.RemoveItem(_restockInventory.IndexOf(sku)); // Clear the listview lvRestockList.Items.Clear(); // Refresh the listview FillRestockList(_restockInventory); return; } } }