private void btnExcluirTodos_Click(object sender, EventArgs e) { if (dtgProdutosPorRevista.Rows.Count > 0) { int i; if (MessageBox.Show("Deseja realmente excluir esses " + dtgProdutosPorRevista.Rows.Count.ToString() + " produtos?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { for (i = 0; i < dtgRevistas.Rows.Count; i++) { dtgProdutosPorRevista.Rows[i].Cells["PATIVO"].Value = "N"; produtos = new clProdutos(); produtos.excluirProdutos(Convert.ToInt32(dtgProdutosPorRevista.Rows[i].Cells["ID_PRO"].Value)); } MessageBox.Show(i + " produtos excluídos com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Não há registro para excluir.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void pvExcluirProdutos() { produtos = new clProdutos(); produtos.excluirProdutos(Convert.ToInt32(dtgProdutos.CurrentRow.Cells["ID_PRO"].Value)); }