Пример #1
0
        private void btnProductDelete_Click(object sender, EventArgs e)
        {
            if (lvProduct.SelectedItems.Count == 0)
            {
                return;
            }

            string id     = (lvProduct.SelectedItems[0].Tag as Product).ID;
            bool   result = productBUS.Delete(id);

            if (result)
            {
                MessageBox.Show("Xóa thành công");
                ShowAllProduct();
            }
            else
            {
                MessageBox.Show("Xóa thất bại");
            }
        }
Пример #2
0
        private void dgvProduct_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int col = e.ColumnIndex;

            if (dgvProduct.Columns[col] is DataGridViewButtonColumn && dgvProduct.Columns[col].Name == "Delete")
            {
                // delete product - event CellClick
                int    currentIndex = dgvProduct.CurrentCell.RowIndex;
                string productId    = dgvProduct.Rows[currentIndex].Cells[1].Value.ToString();
                try
                {
                    int number = productBus.Delete(productId);
                    if (number > 0)
                    {
                        dgvProduct.DataSource = productBus.GetProducts();
                    }
                }
                catch (SqlException ex)
                {
                    MessageBox.Show("Loi xoa san pham. \n" + ex.Message, "Delete", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #3
0
 //xóa PRODUCT
 public bool Delete(ProductDTO product)
 {
     return(bus.Delete(product));
 }