private void btDel_Click(object sender, EventArgs e) { if (dgRes.SelectedCells.Count > 0) { ClassProduto cp = new ClassProduto(); cp.ReturnProd(Convert.ToInt32(dgRes.SelectedRows[0].Cells[0].Value)); if (MessageBox.Show("Você Deseja Realmente Excluir o Produto'" + cp.NomeProd + "'?", "Alerta!", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { int aux = cp.DelProd(); if (aux != 0) { MessageBox.Show("O Produto '" + cp.NomeProd + "' foi Excluido com Sucesso!", "Sucesso!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Erro ao realizar Exclusão.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } btPesq_Click(this, new EventArgs()); } } }
private void btEdit_Click(object sender, EventArgs e) { if (dgRes.SelectedCells.Count > 0) { ClassProduto cp = new ClassProduto(); cp.ReturnProd(Convert.ToInt32(dgRes.SelectedRows[0].Cells[0].Value)); frmCadastroProduto fp = new frmCadastroProduto(); fp.txtNome.Text = cp.NomeProd.ToString(); fp.txtDataCad.Text = cp.DataCadProd.ToString(); fp.txtPreco.Text = cp.PrecoProd.ToString(); fp.txtDescricao.Text = cp.DescProd.ToString(); fp.txtQtde.Text = cp.QtdeProd.ToString(); fp.txtCod.Text = cp.CodProd.ToString(); fp.UpdatePlat = cp.CodPlat; fp.UpdateCat = cp.CatProd; fp.chkAtivo.Enabled = true; if (cp.StatusProd == 1) { fp.chkAtivo.Checked = true; } else { fp.chkAtivo.Checked = false; } fp.btCad.Visible = false; fp.btAtt.Visible = true; fp.ShowDialog(); btPesq_Click(this, new EventArgs()); } }