Beispiel #1
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Tem certeza que deseja excluir?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (Convert.ToInt32(lblid.Text) != -1)
                {
                    Camadas.Model.cliente cliente    = new Camadas.Model.cliente();
                    Camadas.BLL.cliente   bllCliente = new Camadas.BLL.cliente();
                    cliente.idCliente = Convert.ToInt32(lblid.Text);

                    bllCliente.Delete(cliente);
                    dgvCliente.DataSource = (from p in bllCliente.Select()
                                             select new
                    {
                        Cliente = p.idCliente,
                        Nome = p.nome,
                        Email = p.email,
                        Endereço = p.endereco,
                        CEP = p.cep,
                        Número = p.nr,
                        CPF = p.cpf,
                        RG = p.rg,
                        Telefone = p.telefone,
                        Cidade = p.cidade,
                        Estado = p.estado
                    }).ToList();
                }
                else
                {
                    MessageBox.Show("Não há nenhum cadastro para ser excluído!", "Confirmação", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
            }
            LimpaCampos();
        }
Beispiel #2
0
        private void btnGravar_Click(object sender, EventArgs e)
        {
            if (Valida())
            {
                Camadas.Model.cliente cliente    = new Camadas.Model.cliente();
                Camadas.BLL.cliente   bllCliente = new Camadas.BLL.cliente();
                cliente.idCliente = Convert.ToInt32(lblid.Text);
                cliente.nome      = textNome.Text;
                cliente.email     = textEmail.Text;
                cliente.endereco  = textEndereco.Text;
                cliente.cep       = maskCEP.Text;
                cliente.nr        = textNr.Text;
                cliente.cpf       = maskCPF.Text;
                cliente.rg        = maskRG.Text;
                cliente.telefone  = maskTelefone.Text;
                cliente.cidade    = textCidade.Text;
                cliente.estado    = textEstado.Text;
                if (cliente.idCliente == -1)
                {
                    bllCliente.Insert(cliente);
                }
                else
                {
                    bllCliente.Update(cliente);
                }

                if (MessageBox.Show("Deseja incluir o cliente?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    MessageBox.Show("Cliente incluido com sucesso!", "Confirmação", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LimpaCampos();
                    Habilita(false);
                }
                else
                {
                    LimpaCampos();
                }
            }
        }