private void btnRemover_Click(object sender, EventArgs e) { string msg; if (lblId.Text != string.Empty) { msg = "Confirma Remoção do Cliente " + txtNome.Text + "?"; DialogResult resp; resp = MessageBox.Show(msg, "Remover", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (resp == DialogResult.Yes) { int id = Convert.ToInt32(lblId.Text); Camadas.BLL.Cliente bllCliente = new Camadas.BLL.Cliente(); Camadas.Model.Cliente cliente = new Camadas.Model.Cliente(); cliente.Id = id; bllCliente.Delete(cliente); dgvClientes.DataSource = ""; dgvClientes.DataSource = bllCliente.Select(); } } else { msg = "Não há registro para remoção..."; MessageBox.Show(msg, "Remover", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } limparCampos(); Habilitar(false); }
private void btnGrvar_Click(object sender, EventArgs e) { Camadas.BLL.Cliente bllCliente = new Camadas.BLL.Cliente(); Camadas.Model.Cliente cliente = new Camadas.Model.Cliente(); int id = Convert.ToInt32(lblId.Text); string msg = ""; if (id == -1) { msg = "Confirma Inclusão dos Dados?"; } else { msg = "Confirma Atualização dos Dados?"; } DialogResult resp; resp = MessageBox.Show(msg, "Gravar", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (resp == DialogResult.Yes) { cliente.Id = id; cliente.Nome = txtNome.Text; cliente.CPF = txtCpf.Text; cliente.RG = txtRg.Text; cliente.Endereco = txtEndereco.Text; cliente.Bairro = txtBairro.Text; cliente.Cidade = txtCidade.Text; cliente.UF = txtUf.Text.ToUpper(); cliente.Telefone = txtTelefone.Text; cliente.Celular = txtCelular.Text; cliente.Sexo = txtSexo.Text; cliente.Email = txtEmail.Text; if (id == -1) { bllCliente.Insert(cliente); } else { bllCliente.Update(cliente); } } dgvClientes.DataSource = ""; dgvClientes.DataSource = bllCliente.Select(); limparCampos(); Habilitar(false); }