// Delete a selected item for both the products and suppliers tab private void btnDelete_Click(object sender, EventArgs e) { if (tabModifyProductSupplier.SelectedTab == tabProduct) // Delete objects for the product tab { string selectedProd = lstProductList.GetItemText(lstProductList.SelectedItem); var deleteList = string.Join("\n", ProductDB.GetDeleteList(selectedProd)); DialogResult delProd = MessageBox.Show("Are you sure you want to delete '" + selectedProd + "'?\n\n" + "You will also be deleting the following links to this product:\n" + deleteList, "Confirm Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (delProd == DialogResult.OK) // Delete if dialog result is OK { ProductDB.DeleteProductName(selectedProd); // Delete the product this.frmModifyProductSupplier_Load(this, null); // Refresh the page } } else if (tabModifyProductSupplier.SelectedTab == tabSupplier) // Delete objects for the supplier tab { string selectedSup = lstSupplierList.GetItemText(lstSupplierList.SelectedItem); var deleteList = string.Join("\n", SupplierDB.GetDeleteList(selectedSup)); DialogResult delProd = MessageBox.Show("Are you sure you want to delete '" + selectedSup + "'?\n\n" + "You will also be deleting the following links to this supplier:\n" + deleteList, "Confirm Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (delProd == DialogResult.OK) // Delete if dialog result is OK { SupplierDB.DeleteSupplierName(selectedSup); // Delete the selected supplier this.frmModifyProductSupplier_Load(this, null); // Refresh the page } } }