Пример #1
0
        public async Task <IActionResult> Create([Bind("Id,Codigo,Nome,Cpf,Senha,DataNascimento,PlanoDeSaudeId")] PacienteEntity pacienteEntity)
        {
            ViewData["errorMessage"] = "";
            if (ModelState.IsValid)
            {
                //Validando o cadastro de pessoas maiores de idade.
                int idade = DateTime.Now.Year - pacienteEntity.DataNascimento.Year;
                if (idade >= 18)
                {
                    //Utilizando o método para validar o CPF
                    if (ValidaCPF.IsCpf(pacienteEntity.Cpf))
                    {
                        _context.Add(pacienteEntity);
                        await _context.SaveChangesAsync();

                        return(RedirectToAction(nameof(Index)));
                    }
                    else
                    {
                        ViewData["errorMessage"] = "O CPF está inválido.";
                    }
                }
                else
                {
                    ViewData["errorMessage"] = "Não é permitido cadastrar menor de idade.";
                }
            }
            ViewData["PlanoDeSaudeId"] = new SelectList(_context.PlanoSaudes, "Id", "Nome", pacienteEntity.PlanoDeSaudeId);
            return(View(pacienteEntity));
        }
Пример #2
0
        public static void Cadastrar()
        {
            Console.WriteLine("################## Cadastrar Clientes ##################");
            Console.Write("Informe o nome do cliente: ");
            var nome = Convert.ToString(Console.ReadLine());

            Console.Write("Informe o CPF do cliente: ");
            var     cpf     = Convert.ToString(Console.ReadLine());
            Cliente cliente = new Cliente(nome, cpf);

            if (ValidaCPF.ValidarCpf(cliente.CPF))
            {
                if (ClienteDAO.CadastrarCliente(cliente))
                {
                    Console.WriteLine("Cadastro realizado no sistema!");
                }
                else
                {
                    Console.WriteLine("CPF já existe no sistema!");
                }
            }
            else
            {
                Console.WriteLine("CPF inválido");
            }
        }
Пример #3
0
        public static void Cadastrar()
        {
            Console.WriteLine("################## Cadastrar Venddedor ##################");
            Console.Write("Informe o nome do vendedor: ");
            var nome = Convert.ToString(Console.ReadLine());

            Console.Write("Informe o CPF do vendedor: ");
            var      cpf      = Convert.ToString(Console.ReadLine());
            Vendedor vendedor = new Vendedor(nome, cpf);

            if (ValidaCPF.ValidarCpf(vendedor.CPF))
            {
                if (VendedorDAO.CadastrarVendedor(vendedor))
                {
                    Console.WriteLine("Cadastro realizado no sistema!");
                }
                else
                {
                    Console.WriteLine("CPF já existe no sistema!");
                }
            }
            else
            {
                Console.WriteLine("CPF inválido");
            }
        }
Пример #4
0
        public string Validar(tb_Colaborador colaborador)
        {
            if (!string.IsNullOrEmpty(colaborador.cpf) && !ValidaCPF.IsCpf(colaborador.cpf))
            {
                return("CPF informado não é valido!");
            }

            if (colaborador.dtDemissao != null && colaborador.dtDemissao < colaborador.dtAdmissao)
            {
                return("Data de Demissão não pode ser menor que a data de Admissão!");
            }

            if (colaborador.dtAdmissao == null)
            {
                return("Data de Admissão deve ser informada!");
            }

            if (string.IsNullOrEmpty(colaborador.cpf))
            {
                return("CPF deve ser informado!");
            }

            if (this.Tudo().FirstOrDefault(x => x.cpf == colaborador.cpf &&
                                           x.Id_Colaborador != colaborador.Id_Colaborador) != null)
            {
                return("CPF já cadastrado");
            }

            return(string.Empty);
        }
Пример #5
0
        private void EhPFValido(FornecedorViewModel viewModel, string ufEmpresa)
        {
            if (string.IsNullOrEmpty(viewModel.RG))
            {
                ModelState.AddModelError("RG", $"Campo obrigatório para pessoa física");
            }


            if (string.IsNullOrEmpty(viewModel.CPF))
            {
                ModelState.AddModelError("CPF", $"Campo obrigatório para pessoa física");
            }


            if (!viewModel.DataNascimento.HasValue)
            {
                ModelState.AddModelError("DataNascimento", $"Campo obrigatório para pessoa física");
            }


            if ((!string.IsNullOrEmpty(viewModel.CPF)) && !ValidaCPF.EhCpfValido(viewModel.CPF))
            {
                ModelState.AddModelError("CPF", $"CPF inválido");
            }

            ValidaMenorDeIdadeParana(viewModel.DataNascimento, ufEmpresa);
        }
Пример #6
0
        private void txtCNPJCPF_Validating(object sender, CancelEventArgs e)
        {
            string strCPF, strCNPJ = string.Empty;
            bool   exibeMsg = false;

            if (!string.IsNullOrEmpty(txtCNPJCPF.Text))
            {
                txtCNPJCPF.Text = txtCNPJCPF.Text.Trim().Replace(".", "").Replace("-", "").Replace("/", "");

                if (txtCNPJCPF.Text.Where(c => char.IsNumber(c)).Count() == 11)
                {
                    strCPF = Convert.ToInt64(txtCNPJCPF.Text).ToString(@"000\.000\.000\-00");
                    if (!ValidaCPF.IsCpf(strCPF))
                    {
                        exibeMsg = true;
                    }
                    else
                    {
                        txtCNPJCPF.Text = strCPF;
                    }
                }
                else if (txtCNPJCPF.Text.Where(c => char.IsNumber(c)).Count() >= 14)
                {
                    strCNPJ = Convert.ToInt64(txtCNPJCPF.Text).ToString(@"00\.000\.000\/0000\-00");
                    if (!ValidaCNPJ.IsCnpj(strCNPJ))
                    {
                        exibeMsg = true;
                    }
                    else
                    {
                        txtCNPJCPF.Text = strCNPJ;
                    }
                }
                else
                {
                    exibeMsg = true;
                }

                if (exibeMsg)
                {
                    epValidaDados.SetError(txtCNPJCPF, "CNPJ / CPF inválido.");
                    MessageBox.Show("CNPJ / CPF inválido.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    e.Cancel = true;
                }
                else
                {
                    ClienteBLL = new ClienteBLL();
                    List <Cliente> cliList = ClienteBLL.getCliente(p => p.cnpj_cpf.Contains(txtCNPJCPF.Text));
                    if (cliList.Count() > 0)
                    {
                        if (cliList.FirstOrDefault().Id != Id)
                        {
                            epValidaDados.SetError(txtCNPJCPF, "CNPJ / CPF Já está cadastrado.");
                            MessageBox.Show("CNPJ / CPF Já está cadastrado.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            e.Cancel = true;
                        }
                    }
                }
            }
        }
        public async Task <PessoaJwt> LoginPessoa(PessoaLogin pessoa, IToken token)
        {
            if (pessoa.Login.Length >= 11)
            {
                if (!ValidaCPF.ValidarCPF(pessoa.Login))
                {
                    throw new Exception("CPF inválido !");
                }
            }

            var pessoaLogada = await repositorio.BuscarLoginSenha(pessoa.Login, pessoa.Senha);

            if (pessoaLogada == null)
            {
                throw new Exception("Usuario e Login invalidos");
            }

            return(new PessoaJwt()
            {
                Id = pessoaLogada.Id,
                Name = pessoaLogada.Nome,
                Documento = pessoaLogada.Documento,
                Tipo = pessoaLogada.Tipo.ToString(),
                Token = token.GerarToken(pessoaLogada)
            });
        }
Пример #8
0
        public override bool IsValid(object value)
        {
            var cpf = value as string;

            return(ValidaCPF.IsCpf(cpf));

            //return base.IsValid(value);
        }
Пример #9
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                dataGridView1.Rows[i].DataGridView.Columns.Clear();
            }

            try
            {
                string valor = mskCPF.Text;
                if (ValidaCPF.IsCpf(valor))
                {
                    Funcionarios   func   = new Funcionarios();
                    FuncionariosBO funcBO = new FuncionariosBO();

                    func.Nome  = txtNome.Text;
                    func.Senha = txtSenha.Text;


                    if ((func.Nome == "") || (func.Nome == null) || (func.Senha == "") || (func.Senha == null))
                    {
                        MessageBox.Show("Preencha todos os campos");
                    }
                    else
                    {
                        func.Nome     = txtNome.Text.ToUpper();
                        func.Cpf      = Convert.ToInt64(mskCPF.Text);
                        func.Funcao   = cbbFuncao.SelectedItem.ToString();
                        func.Telefone = mskTelefone.Text;
                        func.Celular  = mskCelular.Text;
                        func.Senha    = txtSenha.Text;

                        funcBO.Editar(func);
                        MessageBox.Show("Funcionário editado com sucesso");

                        txtNome.Clear();
                        mskCPF.Clear();
                        mskBuscaCPF.Clear();
                        cbbFuncao.SelectedIndex = -1;
                        mskTelefone.Clear();
                        mskCelular.Clear();
                        txtBusca.Clear();
                        txtSenha.Clear();
                        panel1.Enabled     = false;
                        btnAlterar.Enabled = false;
                    }
                }
                else
                {
                    MessageBox.Show("CPF Inválido !");
                    mskCPF.Clear();
                }
            }
            catch
            {
                MessageBox.Show("Verifique os dados e tente novamente");
            }
        }
Пример #10
0
        public ActionResult Create([Bind(Include = "ID_CLIENTE,NOME_COMPLETO,ENDERECO,BAIRRO,CIDADE,ESTADO,TELEFONE,CELULAR,CPF_CLIENTE")] DADOS_CLIENTE dADOS_CLIENTE)
        {
            if (ModelState.IsValid && (ValidaCPF.IsCpf(dADOS_CLIENTE.CPF_CLIENTE) == true))
            {
                db.DADOS_CLIENTE.Add(dADOS_CLIENTE);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(dADOS_CLIENTE));
        }
Пример #11
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            string CPF = value as string;

            if (ValidaCPF.IsCpf(CPF))
            {
                return(ValidationResult.Success);
            }
            else
            {
                return(new ValidationResult(ErrorMessage));
            }
        }
Пример #12
0
 public bool filtroCPF()
 {
     Cpf = mskBCPF.Text;
     if (ValidaCPF.IsCpf(Cpf))
     {
         return(true);
     }
     else
     {
         MessageBox.Show("CPF inválido!", "Atenção!");
         return(false);
     }
 }
Пример #13
0
        public Cliente PesquisaCliente(string cpf)
        {
            if (string.IsNullOrEmpty(cpf))
            {
                throw new Exception("Cpf não informado");
            }

            if (ValidaCPF.IsCpf(cpf) == false)
            {
                throw new Exception("Cpf inválido");
            }

            return(Banco.Pesquisa(cpf));
        }
Пример #14
0
        public void CadastraCliente(Cliente cliente)
        {
            if (cliente == null)
            {
                throw new Exception("Cliente não informado.");
            }

            if (string.IsNullOrEmpty(cliente.CPF))
            {
                throw new Exception("Cpf não informado");
            }

            if (string.IsNullOrEmpty(cliente.Email))
            {
                throw new Exception("Email não informado");
            }

            if (string.IsNullOrEmpty(cliente.Endereco))
            {
                throw new Exception("Endereco não informado");
            }

            if (cliente.Idade < 18)
            {
                throw new Exception("Idade menor que 18");
            }

            if (string.IsNullOrEmpty(cliente.Telefone))
            {
                throw new Exception("Telefone não informado");
            }

            if (IsValidEmail(cliente.Email) == false)
            {
                throw new Exception("Email inválido");
            }

            if (cliente.Nome.Length > 50)
            {
                throw new Exception("Nome inválido");
            }

            if (ValidaCPF.IsCpf(cliente.CPF) == false)
            {
                throw new Exception("Cpf inválido");
            }

            Banco.Salvar(cliente);
        }
Пример #15
0
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                string valor = mskCPF.Text;
                if (ValidaCPF.IsCpf(valor))
                {
                    Funcionarios   func   = new Funcionarios();
                    FuncionariosBO funcBO = new FuncionariosBO();

                    func.Nome  = txtNome.Text;
                    func.Senha = txtSenha.Text;


                    if ((func.Nome == "") || (func.Nome == null) || (func.Senha == "") || (func.Senha == null))
                    {
                        MessageBox.Show("Preencha todos os campos");
                    }
                    else
                    {
                        func.Nome     = txtNome.Text.ToUpper();
                        func.Cpf      = Convert.ToInt64(mskCPF.Text);
                        func.Funcao   = cbbFuncao.SelectedItem.ToString();
                        func.Telefone = mskTelefone.Text;
                        func.Celular  = mskCelular.Text;
                        func.Senha    = txtSenha.Text;

                        funcBO.Gravar(func);
                        MessageBox.Show("Funcionário cadastrado com sucesso");

                        txtNome.Clear();
                        mskCPF.Clear();
                        cbbFuncao.SelectedIndex = -1;
                        mskTelefone.Clear();
                        mskCelular.Clear();
                        txtSenha.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("CPF Inválido!");
                    mskCPF.Clear();
                }
            }
            catch
            {
                MessageBox.Show("Verifique os dados e tente novamente");
            }
        }
Пример #16
0
 private bool Validation(Client client)
 {
     bool validation = true;
     if (!ValidaCPF.IsCpf(PrepareToCpf(client.CPF)))
     {
         TempData["warning"] = "CPF invalido!";
         validation = false;
     }
     else if (GetByCPF(client) != null)
     {
         TempData["warning"] = "CPF já Registrado!";
         validation = false;
     }
     return validation;
 }
        public void Cadastrar()
        {
            PessoaFisica pf = new PessoaFisica();

            Console.Clear();
            Console.WriteLine("------------------------------");
            Console.WriteLine("CADASTRANDO PESSOA FISICA");
            Console.WriteLine("------------------------------");

            Console.WriteLine("Informe o ID");
            pf.Id = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Informe o nome: ");
            pf.Nome = Console.ReadLine();

            bool isValidCpf = false;

            while (!isValidCpf)
            {
                Console.WriteLine("Informe o CPF: ");
                var cpfDigitado = Console.ReadLine();
                if (ValidaCPF.IsCpf(cpfDigitado))
                {
                    pf.Cpf     = cpfDigitado;
                    isValidCpf = true;
                }
                else
                {
                    Console.WriteLine("CNPJ Invalido! \n Por favor digite um CNPJ valido");
                }
            }

            Console.WriteLine("Informe a data de nascimento: \n");
            pf.DtNascimento = Convert.ToDateTime(Console.ReadLine());

            Console.WriteLine("Informe o logradouro: ");
            pf.Logradouro = Console.ReadLine();

            Console.WriteLine("Informe o numero do logradouro: ");
            pf.NumeroLogradouro = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Informe o nome da cidade: ");
            pf.Cidade = Console.ReadLine();

            Console.WriteLine("Informe a UF: ");
            pf.Uf = Console.ReadLine();
            _pessoaFisicaDAO.CadastroPFisica(pf);
        }
Пример #18
0
 private bool Validar(Aluno aluno)
 {
     if (aluno.GetMatricula() <= 0)
     {
         throw new ExcecaoSAG("A Matrícula dave ser válida.");
     }
     if (aluno.GetNomeCompleto() == null || aluno.GetNomeCompleto().Trim().Equals(""))
     {
         throw new ExcecaoSAG("Nome completo deve ser preenchido");
     }
     if (aluno.GetNascimento() <= 0 || !FormatarData.DataNascimentoValida(aluno.GetNascimento()))
     {
         throw new ExcecaoSAG("Data de nascimento deve ser válida");
     }
     if (aluno.GetCpf() == null || aluno.GetCpf().Trim().Equals("") || !ValidaCPF.Valida(aluno.GetCpf()))
     {
         throw new ExcecaoSAG("CPF deve ser válido");
     }
     if (aluno.GetTelefone() <= 0)
     {
         throw new ExcecaoSAG("O Telefone deve ser preenchido com um número válido.");
     }
     if (aluno.GetCelular() <= 0)
     {
         throw new ExcecaoSAG("O Celular deve ser preenchido com um número válido.");
     }
     if (aluno.GetTelefone().ToString().Length <= 7)
     {
         throw new ExcecaoSAG("O Telefone deve ser preenchido com no mínimo 8 dígitos.");
     }
     if (aluno.GetCelular().ToString().Length <= 8)
     {
         throw new ExcecaoSAG("O Celular deve ser preenchido com no mínimo 9 dígitos.");
     }
     if (aluno.GetUsuario() == null || aluno.GetUsuario().Trim().Equals(""))
     {
         throw new ExcecaoSAG("Usuario deve ser preenchido");
     }
     if (aluno.GetSenha() == null || aluno.GetSenha().Trim().Equals(""))
     {
         throw new ExcecaoSAG("Senha deve ser preenchida");
     }
     if (aluno.GetEmail() == null || aluno.GetEmail().Trim().Equals(""))
     {
         throw new ExcecaoSAG("Email deve ser preenchido");
     }
     return(true);
 }
Пример #19
0
        private void maskValor_Leave_1(object sender, EventArgs e)
        {
            string valor = maskValor.Text;

            if (ValidaCPF.IsCpf(maskValor.Text))
            {
                maskValor.BackColor = Color.White;
                mensagem            = "O número é um CPF Válido !";
            }
            else
            {
                maskValor.BackColor = Color.Red;
                mensagem            = "O número é um CPF Inválido !";
            }
            MessageBox.Show(mensagem, "Validação");
        }
Пример #20
0
        protected override bool PreCondicional()
        {
            aEmpresa.cnpj = Utility.removerCaracteresEspeciais(aEmpresa.cnpj);
            aEmpresa.cep  = Utility.removerCaracteresEspeciais(aEmpresa.cep);

            if (aEmpresa.cnpj.Length == 11)
            {
                if (!ValidaCPF.IsCpf(aEmpresa.cnpj))
                {
                    addErro("CPF Inválido");
                    return(withoutError());
                }
            }

            if (aEmpresa.cnpj.Length == 14)
            {
                if (!ValidaCNPJ.IsCnpj(aEmpresa.cnpj))
                {
                    addErro("CNPJ Inválido");
                    return(withoutError());
                }
            }

            UserEmpresa associacao = aEmpresaUserRepository.Value.getUser(aUserId);

            if (associacao != null)
            {
                addErro("Já associado a uma empresa");
            }

            Empresa lEmpresaDup = aEmpresaRepository.Value.getCNPJ(aEmpresa.cnpj);

            if (lEmpresaDup != null)
            {
                addErro("Já existe uma empresa cadastrada com este documento");
            }

            User lUser = new UsersRepository().getId(aUserId);

            if (lUser != null && lUser.usermasterid.HasValue)
            {
                addErro("Usuário associado não pode criar empresa.");
            }

            return(withoutError());
        }
Пример #21
0
        public ClienteValidator()
        {
            RuleFor(c => c)
            .NotNull()
            .OnAnyFailure((x) => throw new ArgumentException("Cliente inválido"));

            var InformeNome = "Informe o nome";

            RuleFor(c => c.Nome)
            .NotNull().WithMessage(InformeNome)
            .NotEmpty().WithMessage(InformeNome);

            var InformeEmail = "Informe o e-mail";

            RuleFor(c => c.Email)
            .NotNull().WithMessage(InformeEmail)
            .NotEmpty().WithMessage(InformeEmail);

            var InformeEndereco = "Informe o endereço";

            RuleFor(c => c.Enderecos)
            .NotNull().WithMessage(InformeEndereco)
            .Must(x => x.Count() > 0).WithMessage(InformeEndereco)
            .ForEach(x => x.SetValidator(new EnderecoValidator()));

            var InformeTelefone = "Informe um telefone";

            RuleFor(c => c.Telefones)
            .NotNull().WithMessage(InformeTelefone)
            .Must(x => x.Count() > 0).WithMessage(InformeTelefone)
            .ForEach(x => x.SetValidator(new TelefoneValidator()));

            When(c => c.Tipo == TipoPessoa.Fisica, () =>
            {
                RuleFor(c => c.CGC)
                .Must(c => ValidaCPF.IsCpf(c))
                .WithMessage("Informe um CPF válido");
            });

            When(c => c.Tipo == TipoPessoa.Juridica, () =>
            {
                RuleFor(c => c.CGC)
                .Must(c => ValidaCNPJ.IsCnpj(c))
                .WithMessage("Informe um CNPJ válido");
            });
        }
Пример #22
0
        public static async Task <string> ValidaFornecedor(FornecedorEntity fornecedor, EmpresaEntity empresa)
        {
            if (fornecedor.TipoFornecedor == TipoFornecedor.Fisico)
            {
                if (!ValidaCPF.IsCpf(fornecedor.CPFCNPJ))
                {
                    return("CPF Inválido");
                }

                if (empresa.UF == UnidadeFederacaoSigla.PR && fornecedor.DataNascimento.Value.AddYears(18) >= DateTime.Now)
                {
                    return("Fornecedor não pode ser cadastrado por ser menor de idade");
                }

                return("");
            }
            return(EmpresaValidation.ValidarCNPJEmpresa(empresa.CNPJ));
        }
Пример #23
0
        private void btSalvar_Click(object sender, EventArgs e)
        {
            FuncionarioDAO funcionarioDAO = new FuncionarioDAO();
            Funcionario    funcionario    = getDTO();


            if (txtCpf.Text != "" || txtNome.Text != "")
            {
                if (ValidaCPF.IsCpf(txtCpf.Text))
                {
                    Fill();
                    if (btSalvar.Text == "Salvar")
                    {
                        funcionarioDAO.Salvar(funcionario);
                        MessageBox.Show("Cadastrado com Sucesso!");
                    }
                    else
                    {
                        funcionarioDAO.atualizar(funcionario);
                        MessageBox.Show("Atualizado com Sucesso!");
                        btSalvar.Text = "Salvar";
                    }
                    try
                    {
                        Fill();
                        ControlaBotoes(true);
                        limparCampos();
                    }

                    catch (Exception)
                    {
                        MessageBox.Show("CPF Já cadastrado! ");
                    }
                }
                else
                {
                    MessageBox.Show(this, "campo CPF invalido", "ATENÇÃO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show(this, "Favor preencher: CPF/Nome ", "ATENÇÃO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Пример #24
0
        protected async void btnAlterar_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (!ValidaCPF.IsCpf(txtCPF.Text))
                {
                    MessageBox.Show(this.Page, "CPF inválido");
                    return;
                }

                try
                {
                    Cliente cliente = new Cliente();
                    cliente.ClienteId    = int.Parse(Session["ClienteIdAlterar"].ToString());
                    cliente.Nome         = txtNome.Text;
                    cliente.CPF          = txtCPF.Text.Replace(".", "").Replace("-", "");
                    cliente.mSituacao    = lstSituacao.SelectedIndex;
                    cliente.mTipoCliente = lstTipoCliente.SelectedIndex;
                    if (rdbFeminino.Checked == true)
                    {
                        cliente.Sexo = "F";
                    }
                    else if (rdbMasculino.Checked == true)
                    {
                        cliente.Sexo = "M";
                    }


                    var message  = JsonConvert.SerializeObject(cliente);
                    var response = await CallApi.InsertAlterInfo(message, HttpMethod.Put, ApiEndPoint.ApiCliente + ApiEndPoint.Atualizar);

                    MessageBox.Show(this.Page, response.ReasonPhrase);
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        Response.Redirect("Listar.aspx", false);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this.Page, "Erro ao alterar: " + ex.Message);
                }
            }
        }
Пример #25
0
        public void cSalvar(object sender, EventArgs args)
        {
            if (ValidaCPF.IsCpf(cpf1))
            {
                Consultas consulta = new Consultas();
                consulta.Telefone     = tel.Text;
                consulta.Cpf          = cpf1;
                consulta.NomePaciente = NomePac.Text;
                consulta.Cidade       = cit.Text;
                consulta.situacao     = "Em espera";

                if (consulta.NomePaciente != null)
                {
                    if (consulta.Telefone != null)
                    {
                        if (consulta.Cidade != null)
                        {
                            DisplayAlert("Sucesso!", "Cadastrado!", "OK");
                            AcessoBanco acessobanco = new AcessoBanco();
                            acessobanco.Cadastro(consulta);

                            Navigation.PushAsync(new Perfil(cpf1));
                        }
                        else
                        {
                            DisplayAlert("ERRO", "A Cidade está em branco!", "Tentar Novamente");
                        }
                    }
                    else
                    {
                        DisplayAlert("ERRO", "O Telefone está em branco!", "Tentar Novamente");
                    }
                }
                else
                {
                    DisplayAlert("ERRO", "O Nome está em branco!", "Tentar Novamente");
                }
            }
            else
            {
                DisplayAlert("ERRO", "CPF Inválido!", "OK");
            }
        }
Пример #26
0
        protected override bool PreCondicional()
        {
            if (aCliente == null)
            {
                addErro("Houve um erro ao obter as informações digitadas.");
            }
            else
            {
                if (string.IsNullOrWhiteSpace(aCliente.documento))
                {
                    addErro("Documento não pode estar em branco");
                }
                else
                if (!ValidaCPF.IsCpf(aCliente.documento))
                {
                    addErro("CPF inválido");
                }
            }

            return(withoutError());
        }
Пример #27
0
        public ForncecedorValidation()
        {
            RuleFor(f => f.Nome).NotEmpty().WithMessage("O campo {PropertyName} precisa ser fornecido")
            .Length(2, 100).WithMessage("O Campo {PropertyName} precisa ter entre {MinLength} e {MaxLength} caracteres");

            When(f => f.TipoFornecedor == TipoFornecedor.PessoFisica, () =>
            {
                RuleFor(f => f.Documento.Length).Equal(11)
                .WithMessage("O campo Documento precisa ter {ComparisonValue} caracteres e foi fornecido {PropertyValue}.");
                RuleFor(f => ValidaCPF.IsCpf(f.Documento)).Equal(true)
                .WithMessage("O documento fornecido é inválido.");
            });

            When(f => f.TipoFornecedor == TipoFornecedor.PessoaJuridica, () =>
            {
                RuleFor(f => f.Documento.Length).Equal(14)
                .WithMessage("O campo Documento precisa ter {ComparisonValue} caracteres e foi fornecido {PropertyValue}.");
                RuleFor(f => ValidaCNPJ.IsCnpj(f.Documento)).Equal(true)
                .WithMessage("O documento fornecido é inválido.");
            });
        }
Пример #28
0
        public void DeletaCliente(string cpf)
        {
            if (string.IsNullOrEmpty(cpf))
            {
                throw new Exception("Cpf não informado");
            }

            if (ValidaCPF.IsCpf(cpf) == false)
            {
                throw new Exception("Cpf inválido");
            }

            var cliente = Banco.Pesquisa(cpf);

            if (cliente == null)
            {
                throw new Exception("Cliente não encontrado");
            }

            Banco.Deleta(cpf);
        }
Пример #29
0
        public void Cbusca(object sender, EventArgs args)
        {
            if (CPF1 != null)
            {
                AcessoBanco      acessoBanco = new AcessoBanco();
                List <Consultas> consultas   = acessoBanco.Pesquisar(CPF1);

                if (consultas.Any())
                {
                    AcessoBanco banco = new AcessoBanco();
                    ListaVagas.ItemsSource = banco.Pesquisar(CPF1);
                }
                else
                {
                    DisplayAlert("Não Cadastrado!", "Sem consultas.", "Tentar novamente");
                }
            }
            else if (ValidaCPF.IsCpf(CPF.Text))
            {
                string cpf;
                cpf = Regex.Replace(CPF.Text, @"[^\d]", "");

                AcessoBanco      acessoBanco = new AcessoBanco();
                List <Consultas> consultas   = acessoBanco.Pesquisar(cpf);

                if (consultas.Any())
                {
                    AcessoBanco banco = new AcessoBanco();
                    ListaVagas.ItemsSource = banco.Pesquisar(cpf);
                }
                else
                {
                    DisplayAlert("Não Cadastrado!", "Entrada mal sucedida!", "Tentar novamente");
                }
            }
            else
            {
                DisplayAlert("ERRO", "CPF Inválido!", "OK");
            }
        }
Пример #30
0
        public void Entrar(object sender, EventArgs args)
        {
            if (ValidaCPF.IsCpf(Cpf.Text))
            {
                string cpf;
                cpf = Regex.Replace(Cpf.Text, @"[^\d]", "");
                AcessoBanco      acessoBanco = new AcessoBanco();
                List <Consultas> consultas   = acessoBanco.Pesquisar(cpf);

                if (consultas.Any())
                {
                    Navigation.PushAsync(new Perfil(cpf));
                }
                else
                {
                    Navigation.PushAsync(new Cadastro(cpf));
                }
            }
            else
            {
                DisplayAlert("ERRO", "CPF Inválido!", "OK");
            }
        }