Beispiel #1
0
 public void DefinirLogradouro(string logradouro)
 {
     if (this.DefinirLogradouroScopeEhValido(logradouro))
     {
         Logradouro = TextoHelper.ToTitleCase(logradouro);
     }
 }
Beispiel #2
0
        public static bool ValidarCelular(string numero)
        {
            var semmascara      = TextoHelper.GetNumeros(numero);
            var fromatarcelular = new Regex(@"^[1-9]{2}[9]{1}[4-9]{1}[0-9]{3}[0-9]{4}$");

            return(fromatarcelular.IsMatch(semmascara));
        }
Beispiel #3
0
 public void DefinirBairro(string bairro)
 {
     if (this.DefinirBairroScopeEhValido(bairro))
     {
         Bairro = TextoHelper.ToTitleCase(bairro);
     }
 }
Beispiel #4
0
 public void DefinirComplemento(string complemento)
 {
     if (string.IsNullOrEmpty(complemento))
     {
         complemento = "";
     }
     Complemento = TextoHelper.RemoverAcentos(complemento);
 }
Beispiel #5
0
 public void SetComplemento(string complemento)
 {
     if (string.IsNullOrEmpty(complemento))
     {
         complemento = "";
     }
     Complemento = TextoHelper.ToTitleCase(complemento);
 }
Beispiel #6
0
 public void DefinirDescricao(string descricao)
 {
     if (string.IsNullOrEmpty(descricao))
     {
         descricao = "";
     }
     Descricao = TextoHelper.RemoverAcentos(descricao);
 }
 public string SetComplemento(string complemento)
 {
     if (string.IsNullOrEmpty(complemento))
     {
         complemento = "";
     }
     return(TextoHelper.ToTitleCase(complemento));
 }
Beispiel #8
0
 public Agencia(Guid agenciaid, string nomefantasia, string razaosocial, string cnpj, string fixo)
 {
     AgenciaId = agenciaid;
     DefinirNomeFantasia(nomefantasia);
     DefinirRazaoSocial(razaosocial);
     DefinirCnpj(cnpj);
     TelefoneFixo = TextoHelper.GetNumeros(fixo);
     Enderecos    = new List <Endereco>();
 }
Beispiel #9
0
        public void DefinirCep(string cep)
        {
            var tempCep = TextoHelper.GetNumeros(cep);

            if (this.DefinirCEPScopeEhValido(tempCep))
            {
                Cep = new CEP(tempCep);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Inclui um novo cliente
        /// </summary>
        /// <param name="cliente">Objeto de cliente</param>
        internal long Incluir(DML.Cliente cliente)
        {
            long ret = 0;

            using (System.Data.SqlClient.SqlConnection conexao = Connection())
            {
                conexao.Open();

                System.Data.SqlClient.SqlCommand     comando   = conexao.CreateCommand();
                System.Data.SqlClient.SqlTransaction transacao = conexao.BeginTransaction("IncluirCliente");

                comando.Connection  = conexao;
                comando.Transaction = transacao;

                try
                {
                    comando.CommandType = CommandType.StoredProcedure;
                    comando.CommandText = "[FI_SP_IncClienteV2]";

                    comando.Parameters.AddWithValue("@Nome", cliente.Nome);
                    comando.Parameters.AddWithValue("@Sobrenome", cliente.Sobrenome);
                    comando.Parameters.AddWithValue("@CPF", TextoHelper.RemoveNaoNumericos(cliente.CPF));
                    comando.Parameters.AddWithValue("@Nacionalidade", cliente.Nacionalidade);
                    comando.Parameters.AddWithValue("@CEP", cliente.CEP);
                    comando.Parameters.AddWithValue("@Estado", cliente.Estado);
                    comando.Parameters.AddWithValue("@Cidade", cliente.Cidade);
                    comando.Parameters.AddWithValue("@Logradouro", cliente.Logradouro);
                    comando.Parameters.AddWithValue("@Email", cliente.Email ?? string.Empty);
                    comando.Parameters.AddWithValue("@Telefone", cliente.Telefone ?? string.Empty);

                    var idCliente = comando.ExecuteScalar();

                    cliente.Id = Convert.ToInt64(idCliente);

                    foreach (Beneficiario beneficiario in cliente.Beneficiarios)
                    {
                        comando.Parameters.Clear();
                        comando.CommandText = "[FI_SP_IncBeneficiario]";
                        comando.Parameters.AddWithValue("@CPF", TextoHelper.RemoveNaoNumericos(beneficiario.CPF));
                        comando.Parameters.AddWithValue("@NOME", beneficiario.Nome);
                        comando.Parameters.AddWithValue("@IDCLIENTE", cliente.Id);

                        comando.ExecuteNonQuery();
                    }

                    ret = cliente.Id;

                    transacao.Commit();
                }
                catch (Exception ex)
                {
                    transacao.Rollback();
                }
            }

            return(ret);
        }
Beispiel #11
0
        public void DefinirValorDoMeioDeComunicacao(string valor, TipoDeMeioDeComunicacao tipoDeMeioDeComunicacao)
        {
            switch (tipoDeMeioDeComunicacao.Descricao)
            {
            case "TELEFONE":
                var tempTelefone = new Telefone(valor);

                if (!this.DefinirTelefoneMeioDeComunicacaoScopeEhValido(tempTelefone))
                {
                    return;
                }

                Valor = TextoHelper.GetNumeros(tempTelefone.Numero);
                break;

            case "CELULAR":
                var tempCelular = new Telefone(valor);

                if (!this.DefinirTelefoneMeioDeComunicacaoScopeEhValido(tempCelular))
                {
                    return;
                }

                Valor = TextoHelper.GetNumeros(tempCelular.Numero);
                break;

            case "E-MAIL":
                var tempEmail = new Email(valor);

                if (!this.DefinirEmailMeioDeComunicacaoScopeEhValido(tempEmail))
                {
                    return;
                }

                Valor = tempEmail.Endereco;
                break;

            case "REDE SOCIAL":
                if (!this.DefinirRedeSocialMeioDeComunicacaoScopeEhValido(valor))
                {
                    return;
                }

                Valor = valor;
                break;

            case "SITE":
                if (!this.DefinirSiteMeioDeComunicacaoScopeEhValido(valor))
                {
                    return;
                }

                Valor = valor;
                break;
            }
        }
        public TransportadoraViewModel Atualizar(TransportadoraViewModel transportadora)
        {
            var atualizaTransportadora = Mapper.Map <Transportadora>(transportadora);

            atualizaTransportadora.Ativo = true;
            atualizaTransportadora.CNPJ  = TextoHelper.GetNumeros(atualizaTransportadora.CNPJ);
            _transportadoraService.Atualizar(atualizaTransportadora);
            Commit();
            return(transportadora);
        }
Beispiel #13
0
 private void SetDDD(string ddd)
 {
     Guard.ForNullOrEmptyDefaultMessage("DDD", ddd);
     ddd = TextoHelper.GetNumeros(ddd);
     Guard.StringLength("DDD", ddd, DDDMaxLength);
     try {
         DDD = Convert.ToInt32(ddd);
     } catch (Exception) {
         throw new Exception("DDD inválido: " + ddd);
     }
 }
Beispiel #14
0
 public void DefinirCidade(string cidade)
 {
     if (this.DefinirCidadeScopeEhValido(cidade))
     {
         if (string.IsNullOrEmpty(cidade))
         {
             cidade = "";
         }
     }
     Cidade = TextoHelper.RemoverAcentos(cidade);;
 }
Beispiel #15
0
 public ViaCep ConsultarCEP(string cep)
 {
     using (var WebClient = new WebClient())
     {
         string urlViacep   = ConfigurationManager.AppSettings["urlViaCep"];
         string rawJson     = WebClient.DownloadString(urlViacep + TextoHelper.GetNumeros(cep.Trim()) + "/json/");
         string unicodeJson = Encoding.UTF8.GetString(Encoding.GetEncoding("iso-8859-1").GetBytes(rawJson));
         var    viaCep      = JsonConvert.DeserializeObject <ViaCep>(unicodeJson);
         return(viaCep);
     }
 }
Beispiel #16
0
        internal bool VerificarExistencia(string cpf, long idCliente)
        {
            List <System.Data.SqlClient.SqlParameter> parametros = new List <System.Data.SqlClient.SqlParameter>();

            parametros.Add(new System.Data.SqlClient.SqlParameter("CPF", TextoHelper.RemoveNaoNumericos(cpf)));
            parametros.Add(new System.Data.SqlClient.SqlParameter("ID", idCliente));

            DataSet ds = base.Consultar("FI_SP_VerificaCliente", parametros);

            return(ds.Tables[0].Rows.Count > 0);
        }
Beispiel #17
0
        public static string Clear(string cnpj)
        {
            cnpj = TextoHelper.ObterNumeros(cnpj);

            if (string.IsNullOrEmpty(cnpj))
            {
                return("");
            }

            return(cnpj);
        }
Beispiel #18
0
 public void DefinirLogradouro(string logradouro)
 {
     if (this.DefinirLogradouroScopeEhValido(logradouro))
     {
         if (string.IsNullOrEmpty(logradouro))
         {
             logradouro = "";
         }
     }
     Logradouro = TextoHelper.RemoverAcentos(logradouro);
 }
Beispiel #19
0
 private void SetTelefone(string numero)
 {
     Guard.ForNullOrEmptyDefaultMessage("TELEFONE", numero);
     numero = TextoHelper.GetNumeros(numero);
     Guard.StringLength("TELEFONE", numero, NumeroTelefoneMaxLength);
     try {
         NumeroTelefone = Convert.ToInt64(numero);
     } catch (Exception) {
         throw new Exception("Telefone inválido: " + numero);
     }
 }
Beispiel #20
0
        public static string Clear(string text)
        {
            text = TextoHelper.ObterNumeros(text);

            if (string.IsNullOrEmpty(text))
            {
                return("");
            }

            return(text);
        }
Beispiel #21
0
 public void SetCep(string cep)
 {
     Guard.ForNullOrEmptyDefaultMessage("CEP", cep);
     cep = TextoHelper.GetNumeros(cep);
     Guard.StringLength("CEP", cep, CepMaxLength);
     try {
         CepCod = Convert.ToInt64(cep);
     } catch (Exception) {
         throw new Exception("Cep inválido: " + cep);
     }
 }
Beispiel #22
0
        public void DefinirCPF(string cpf)
        {
            var tempCpf = new CPF(TextoHelper.GetNumeros(cpf));

            if (!this.DefinirCPFPessoaFisicaScopeEhValido(tempCpf))
            {
                return;
            }

            CPF = tempCpf;
        }
Beispiel #23
0
        public void DefinirCelular(string celular)
        {
            var tempCelular = new Telefone(celular);

            if (!this.DefinirCelularScopeEhValido(tempCelular))
            {
                return;
            }

            tempCelular = new Telefone(TextoHelper.GetNumeros(tempCelular.Numero));

            Celular = tempCelular;
        }
Beispiel #24
0
 private void SetSUS(string sus)
 {
     Guard.ForNullOrEmptyDefaultMessage("SUS", sus);
     sus = TextoHelper.GetNumeros(sus);
     Guard.StringLength("SUS", sus, SUSMaxLength);
     try {
         //validador de sus
         //lacar excesao se n e sus
         Sus = Convert.ToInt32(sus);
     } catch (Exception) {
         throw new Exception("SUS inválido: " + sus);
     }
 }
 public static string CnpjLimpo(string cnpj)
 {
     cnpj = TextoHelper.GetNumeros(cnpj);
     if (string.IsNullOrEmpty(cnpj))
     {
         return("");
     }
     while (cnpj.StartsWith("0"))
     {
         cnpj = cnpj.Substring(1);
     }
     return(cnpj);
 }
Beispiel #26
0
        public static string RetornarCelular(string numero)
        {
            var semmascara = TextoHelper.GetNumeros(numero);

            if (ValidarCelular(semmascara) == true)
            {
                return(semmascara);
            }
            else
            {
                return("");
            }
        }
Beispiel #27
0
        public void DefinirCNPJ(string cnpj)
        {
            var tempCNPJ = new CNPJ(TextoHelper.GetNumeros(cnpj));

            //Verificar se vai ser necessario limpar o cnpj dos caractes especiais

            if (!this.DefinirCNPJPessoaJuridicaScopeEhValido(tempCNPJ))
            {
                return;
            }

            CNPJ = tempCNPJ;
        }
Beispiel #28
0
        public bool ValidarTelefone(string telefone)
        {
            var tel = TextoHelper.GetNumeros(telefone);

            if (tel.Length < 10 || tel.Length > 11)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Beispiel #29
0
        public void DefinirTelefone(string telefone)
        {
            var tempTelefone = new Telefone(telefone);

            if (!this.DefinirTelefonePessoaJuridicaScopeEhValido(tempTelefone))
            {
                return;
            }

            tempTelefone = new Telefone(TextoHelper.GetNumeros(tempTelefone.Numero));

            Telefone = tempTelefone;
        }
Beispiel #30
0
        public static string CpfLimpo(string cpf)
        {
            cpf = TextoHelper.GetNumeros(cpf);
            if (string.IsNullOrEmpty(cpf))
            {
                return(string.Empty);
            }

            while (cpf.StartsWith("0"))
            {
                cpf = cpf.Substring(1);
            }
            return(cpf);
        }