//delete product supplier item from database
        private void btnProdSupplierDelete_Click(object sender, EventArgs e)
        {
            ListView.SelectedListViewItemCollection psSelectedItems =
                this.lvProdSuppliers.SelectedItems;

            //confirm that only one item is selected
            if (psSelectedItems.Count != 0)
            {
                //get selected product-supplier id

                int selectedProductSupplier = Convert.ToInt32(psSelectedItems[0].SubItems[0].Text);

                ProductSupplier ps = ProductSupplierDB.getProductSupplierById(selectedProductSupplier);

                if (ps != null)  //Product-Supplier exists
                {
                    try
                    {
                        if (ProductSupplierDB.DeleteProductSupplier(ps))
                        {
                            MessageBox.Show("Supplier removed from this product.");
                        }
                        else
                        {
                            MessageBox.Show("A problem occurred with removing this supplier.");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Supplier-product item is part of a Package-Product-Supplier item and cannot be deleted.");
                    }
                }
                else
                {
                    //ProductSupplier item does not exist in database - concurrency issue
                    MessageBox.Show("Supplier has already been removed from this product");
                }

                LoadProductSuppliers(currentProduct.ProductId);
                SetUpFrmControls();
            }
            else
            {
                MessageBox.Show("Please select a supplier to delete.");
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            //ProductSupplierDB.CheckDependency((int)dgvProdSup.CurrentRow.Cells[1].ToString());
            if (dgvProdSup.SelectedCells.Count > 0)
            {
                int selectedrowindex = dgvProdSup.SelectedCells[0].RowIndex;

                DataGridViewRow selectedRow = dgvProdSup.Rows[selectedrowindex];

                int          id     = Convert.ToInt32(selectedRow.Cells["ID"].Value);
                DialogResult result = MessageBox.Show("Are you sure you want to delete this record?" + "\n\nProductSupplier: " + Convert.ToString(selectedRow.Cells["FullName"].Value), "Confirmation", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    string message = ProductSupplierDB.DeleteProductSupplier(id);
                    MessageBox.Show(message);
                    refreshDataSource();
                    dgvProdSup.Focus();
                }
            }
        }