public ActionResult Adiciona(ClientesPJ cliente) { var dao = new ClientesPjDao(); var funcionou = dao.DbAdd(cliente); return(View()); }
public FormCadastrarCliente(ClientesPJ cliente) { InitializeComponent(); this.clientePj = cliente; PreencherFormulario(clientePj); //radioPessoaFisica.Enabled = false; //radioPessoaJuridica.Enabled = false; btnAtualizar.Show(); }
public ActionResult Deletar(ClientesPJ clientePj) { try { new ClientesPjDao().DeleteRegistro(clientePj); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Atualizar(ClientesPJ cliente) { try { var bd = new ClientesPjDao().DbUpdate(cliente); return(RedirectToAction("Index")); } catch { return(View()); } }
private void CadastrarPj() { bool ativo = true; //if (checkAtivo.Checked) ativo = true; EnderecosBuilder enderecoBuilder = new EnderecosBuilder() .GetCep(maskedCEP.Text) .GetLogradouro(txtLogradouro.Text) .GetNumero(txtNumero.Text) .GetComplemento(txtComplemento.Text) .GetBairro(txtBairro.Text) .GetCidade(txtCidade.Text) .GetUf(txtUF.Text); var endereco = enderecoBuilder.Build(); ClientesPJBuilder PjBuilder = new ClientesPJBuilder() .GetIsAtivo(ativo) .GetRazaoSocial(txtNome.Text) .GetCnpj(maskedCpf.Text) .GetContato(txtProfissao.Text) .GetTelCelular(txtTelCel.Text) .GetEmail(txtEmail.Text) .GetIe(txtRG.Text) .GetTelComercial(txtTelCom.Text) .GetEndereco(endereco); clientePj = PjBuilder.Build(); if (MessageBox.Show($"Favor confirmar os dados:\n" + $"Nome da empresa:{clientePj.RazaoSocial}\n" + $" Cnpj: {clientePj.Cnpj} - IE: {clientePj.Ie}\n " + $"E-Mail: {clientePj.Email} - Contato: {clientePj.Contato} \n" + $"Telefone: {clientePj.TelComercial}\n" + $"Endereço:\n " + $"CEP: {clientePj.Endereco.Cep} \n" + $"{clientePj.Endereco.Logradouro} {clientePj.Endereco.Num} Complemento: {clientePj.Endereco.Complemento} \n" + $"Bairro: {clientePj.Endereco.Bairro} / Cidade: {clientePj.Endereco.Cidade} / UF: {clientePj.Endereco.Uf} \n", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (new ClientesPjDao().DbAdd(clientePj)) { MessageBox.Show("Cadastro Efetuado com sucesso!", "Sucesso!"); ConfirmaSaida(); } else { MessageBox.Show("Erro ao adicionar cliente, tente novamente!"); } } }
private void AtualizarPj(ClientesPJ cliente) { int id = Convert.ToInt32(txtId.Text); cliente.Endereco.Id = id; EnderecosBuilder enderecoBuilder = new EnderecosBuilder() .GetCep(maskedCEP.Text) .GetLogradouro(txtLogradouro.Text) .GetNumero(txtNumero.Text) .GetComplemento(txtComplemento.Text) .GetBairro(txtBairro.Text) .GetCidade(txtCidade.Text) .GetUf(txtUF.Text); Enderecos endereco = enderecoBuilder.Build(); cliente.Endereco = endereco; cliente.RazaoSocial = txtNome.Text; cliente.Cnpj = maskedCpf.Text; cliente.Contato = txtProfissao.Text; cliente.Email = txtEmail.Text; cliente.Ie = txtRG.Text; cliente.TelComercial = txtTelCom.Text; cliente.TelCelular = txtTelCel.Text; if (MessageBox.Show($"Favor confirmar a atualização:\n" + $"Nome da empresa:{cliente.RazaoSocial}\n" + $" Cnpj: {cliente.Cnpj} - IE: {cliente.Ie}\n " + $"E-Mail: {cliente.Email} - Contato: {cliente.Contato} \n" + $"Telefone: {cliente.TelComercial}\n" + $"Endereço:\n " + $"CEP: {cliente.Endereco.Cep} \n" + $"{cliente.Endereco.Logradouro} {cliente.Endereco.Num} Complemento: {cliente.Endereco.Complemento} \n" + $"Bairro: {cliente.Endereco.Bairro} / Cidade: {cliente.Endereco.Cidade} / UF: {cliente.Endereco.Uf} \n", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (new ClientesPjDao().DbUpdate(cliente)) { MessageBox.Show("Cadastro Atualizado com sucesso!", "Sucesso!"); ConfirmaSaida(); } else { MessageBox.Show("Erro na atualização, tente novamente."); } } }
private void PreencherFormulario(ClientesPJ cliente) { //if (cliente is Motoristas cli) //{ // radioPessoaFisica.Checked = true; // radioPessoaJuridica.Checked = false; // if (cli.IsAtivo == false) // { // checkAtivo.Checked = false; // } // else // { // checkAtivo.Checked = true; // } // txtId.Text = cli.Id.ToString(); // txtNome.Text = cli.Nome; // maskedCpf.Text = cli.Cpf; // txtEmail.Text = cli.Email; // txtRG.Text = cli.Rg; // dateNascimento.Value = cli.Nascimento; // dateCnhEmitida.Value = cli.Cnh.Emissao; // dateCnhValidade.Value = cli.Cnh.Validade; // txtTelCom.Text = cli.TelComercial; // txtTelRes.Text = cli.TelResidencial; // txtTelCel.Text = cli.TelCelular; // txtCNH.Text = cli.Cnh.Numero; // txtCategoria.Text = cli.Cnh.Categoria; // this.groupEndereco.Select(); // maskedCEP.Text = cli.Endereco.Cep; // txtLogradouro.Text = cli.Endereco.Logradouro; // txtNumero.Text = cli.Endereco.Num; // txtComplemento.Text = cli.Endereco.Complemento; // txtBairro.Text = cli.Endereco.Bairro; // txtCidade.Text = cli.Endereco.Cidade; // txtUF.Text = cli.Endereco.Uf; //} ClientesPJ c = cliente; //radioPessoaJuridica.Checked = true; //radioPessoaFisica.Checked = false; //if (c.IsAtivo == false) //{ // checkAtivo.Checked = false; //} //else //{ // checkAtivo.Checked = true; //} txtId.Text = c.Id.ToString(); txtNome.Text = c.RazaoSocial; maskedCpf.Text = c.Cnpj; txtProfissao.Text = c.Contato; txtEmail.Text = c.Email; txtRG.Text = c.Ie; txtTelCom.Text = c.TelComercial; txtTelCel.Text = c.TelCelular; maskedCEP.Text = c.Endereco.Cep; txtLogradouro.Text = c.Endereco.Logradouro; txtNumero.Text = c.Endereco.Num; txtComplemento.Text = c.Endereco.Complemento; txtBairro.Text = c.Endereco.Bairro; txtCidade.Text = c.Endereco.Cidade; txtUF.Text = c.Endereco.Uf; }