private void btDel_Click(object sender, EventArgs e) { if (dgRes.SelectedCells.Count > 0) { ClassCliente cc = new ClassCliente(); cc.RetornClie(Convert.ToInt32(dgRes.SelectedRows[0].Cells[0].Value)); if (MessageBox.Show("Você Deseja Realmente Excluir o Cliente '" + cc.NomeCliente + "' ?", "Alerta!", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { int aux = cc.DelClie(); if (aux != 0) { MessageBox.Show("O Cliente '" + cc.NomeCliente + "' 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) { ClassCliente cc = new ClassCliente(); cc.RetornClie(Convert.ToInt32(dgRes.SelectedRows[0].Cells[0].Value)); frmCadastroCliente fc = new frmCadastroCliente(); fc.txtCod.Text = cc.CodCliente.ToString(); fc.dataCad.Text = cc.DataCadCliente.ToString(); fc.txtNome.Text = cc.NomeCliente; fc.txtNomeSoc.Text = cc.NomeSocCliente; fc.txtDataNasc.Text = cc.DataNascClie.ToString("dd-MM-yyyy"); fc.txtTel1.Text = cc.TelCliente1; fc.txtTel2.Text = cc.TelCliente2; fc.txtCpf.Text = cc.CpfCliente; fc.CB_OREMISSOR.Text = cc.OrgEmiClie; fc.txtRg.Text = cc.RgClie; fc.txtEnd.Text = cc.EndRuaCliente; fc.txtCidade.Text = cc.EndCityCliente; fc.CbEst.Text = cc.EndEstadoCliente; fc.txtCep.Text = cc.EndCepCliente; fc.chkAtivo.Enabled = true; if (cc.StatusClieI == 1) { fc.chkAtivo.Checked = true; } else { fc.chkAtivo.Checked = false; } if (cc.SexoCliente == 1) { fc.radFem.Checked = true; } else { fc.radMasc.Checked = true; } fc.btCad.Visible = false; fc.BtAtt.Visible = true; fc.btClear.Visible = false; fc.ShowDialog(); btPesq_Click(this, new EventArgs()); } }