public ActionResult Prosseguir(DadosViajante dadosViajante)
        {
            if (dadosViajante.CPF != null)
            {
                if (!ValidacaoCPF.Validar(dadosViajante.CPF))
                {
                    ModelState.AddModelError("InvalidCPF", "CPF Inválido ");
                }
            }
            if (dadosViajante.CPF == null)
            {
                ModelState.AddModelError("InvalidCPF", "Campo Obrigatório");
            }


            dadosViajante.Profissao = "nulo";
            if (ModelState.IsValid)
            {
                var dao = new DadosViajanteDAO();
                dao.Adicionar(dadosViajante);

                return(Json(new { formValido = true, viajanteId = dadosViajante.ViajanteId }));
            }
            return(PartialView("Viajante", dadosViajante));
        }
Esempio n. 2
0
        private void ValidacaoCpfForm(string cpf)
        {
            ValidacaoCPF validaCpf = new ValidacaoCPF();

            if (cpf == "")
            {
                MessageBox.Show("CPF não informado!", "Mensagem de Validação", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                if (cpf.Length != 11)
                {
                    MessageBox.Show("O CPF deve conter 11 dígitos!", "Mensagem de Validação", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (MessageBox.Show("Deseja realmente validar o CPF?", "Mensagem de Validação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        if (validaCpf.ValidarCPF(cpf))
                        {
                            MessageBox.Show("CPF Válido!", "Mensagem de Validação", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("CPF Inválido!", "Mensagem de Validação", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public void ValidaInformacoes()
        {
            ValidacaoCPF cpf       = new ValidacaoCPF();
            bool         validaCpf = cpf.ValidarCPF(this.CPF);

            if (!validaCpf)
            {
                throw new Exception("CPF inválido!");
            }
        }
Esempio n. 4
0
        public static bool Cadastrar(Cliente c)
        {
            if (ValidacaoCPF.ValidarCpf(c.Cpf))
            {
                c.Cpf = c.Cpf.Replace(".", "").Replace("-", "");
                if (BuscarPorCpf(c.Cpf) == null)
                {
                    _context.Clientes.Add(c);
                    _context.SaveChanges();

                    return(true);
                }
            }
            return(false);
        }
Esempio n. 5
0
        public static bool Cadastrar(Funcionario f, Endereco e)
        {
            if (ValidacaoCPF.ValidarCpf(f.Cpf))
            {
                f.Cpf = f.Cpf.Replace(".", "").Replace("-", "");
                if (BuscarPorCpf(f.Cpf) == null)
                {
                    _context.Funcionarios.Add(f);
                    _context.Enderecos.Add(e);
                    _context.SaveChanges();

                    return(true);
                }
            }
            return(false);
        }
        public PacienteValidation()
        {
            RuleFor(p => p.Nome)
            .NotEmpty().WithMessage("O {PropertyName} precisa ser fornecido");

            RuleFor(p => p.Telefone)
            .NotEmpty().WithMessage("O {PropertyName} precisa ser fornecido")
            .Length(10, 11).WithMessage("O { PropertyName} deve ter 10 ou 11 números, incluindo o DDD");

            RuleFor(p => p.Cpf.Length).Equal(ValidacaoCPF.TamanhoCPF)
            .WithMessage("O CPF deve ter {ComparisonValue} dígitos");

            RuleFor(p => ValidacaoCPF.Validar(p.Cpf)).Equal(true)
            .WithMessage("O documento fornecido é inválido");

            RuleFor(p => ValidacaoData.ValidarDataNascimento(p.DataNascimento)).Equal(true)
            .WithMessage("Anos menores que 1900 e maiores que " + DateTime.Now.Year + "não são válidos para data de nascimento!");
        }
Esempio n. 7
0
        public static bool Editar(Cliente c)
        {
            try
            {
                if (ValidacaoCPF.ValidarCpf(c.Cpf))
                {
                    _context.Clientes.Update(c);
                    _context.SaveChanges();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                return(false);

                throw new Exception("Erro ao editar");
            }
        }
Esempio n. 8
0
        protected void btnRegistrar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtNome.Text))
            {
                ModelState.AddModelError(string.Empty, "O campo Nome é obrigatório");
            }

            if (string.IsNullOrEmpty(this.txtEmail.Text))
            {
                ModelState.AddModelError(string.Empty, "O campo Email é obrigatório");
            }

            if (string.IsNullOrEmpty(this.txtCPF.Text))
            {
                ModelState.AddModelError(string.Empty, "O campo CPF é obrigatório");
            }

            if (string.IsNullOrEmpty(this.txtLogin.Text))
            {
                ModelState.AddModelError(string.Empty, "O campo Login é obrigatório");
            }

            if (string.IsNullOrEmpty(this.txtSenha.Text))
            {
                ModelState.AddModelError(string.Empty, "O campo Senha é obrigatório");
            }

            if (this.txtSenha.Text != this.txtSenhaConfirmada.Text)
            {
                ModelState.AddModelError(string.Empty, "As senhas não conferem.");
            }

            if (!ValidacaoCPF.Validar(this.txtCPF.Text))
            {
                ModelState.AddModelError(string.Empty, "O CPF informado é inválido.");
            }

            if (!ValidacaoEmail.Validar(this.txtEmail.Text))
            {
                ModelState.AddModelError(string.Empty, "O Email informado é inválido.");
            }

            var usuarioJaRegistrado = _usuarioDAO.ObterUsuarioPorCpfOuLogin(this.txtCPF.Text, this.txtLogin.Text);

            if (usuarioJaRegistrado != null)
            {
                ModelState.AddModelError(string.Empty, "Já existe um usuário com o mesmo CPF/Login");
            }

            if (!ModelState.IsValid)
            {
                return;
            }

            var usuario = new Usuario(
                this.txtNome.Text,
                this.txtCPF.Text,
                this.txtLogin.Text,
                this.txtEmail.Text,
                this.txtSenha.Text);

            _usuarioDAO.Registrar(usuario);

            Response.Redirect("Login.aspx");
        }
Esempio n. 9
0
        private string GerarXMLDUESiscomexComNotaFiscal(int dueId)
        {
            var parametros = _parametrosDAO.ObterParametros();

            var due = documentoUnicoExportacaoDAO.ObterDUEPorId(dueId);

            var itens = documentoUnicoExportacaoDAO.ObterItensDUE(dueId);

            due.AdicionarItens(itens);

            var recintoDespachoId = string.IsNullOrEmpty(due.UnidadeDespacho.RecintoAduaneiroId)
                ? due.UnidadeDespacho.DocumentoResponsavel
                : due.UnidadeDespacho.RecintoAduaneiroId;

            var xml = $@"
                    <Declaration
                        xsi:schemaLocation='urn:wco:datamodel:WCO:GoodsDeclaration:1 GoodsDeclaration_1p0_DUE.xsd'
                        xmlns:ds='urn:wco:datamodel:WCO:GoodsDeclaration_DS:1'
                        xmlns='urn:wco:datamodel:WCO:GoodsDeclaration:1'
                        xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
                            <DeclarationNFe>
                            <ID>{due.DUE}</ID>
                            <DeclarationOffice>
                                <ID listID='token'>{due.UnidadeDespacho.Id.ToString()}</ID>
                                <Warehouse>
                                    <ID>{recintoDespachoId}</ID>
                                    <TypeCode>{due.UnidadeDespacho.TipoRecinto}</TypeCode>";

            if (!string.IsNullOrEmpty(due.UnidadeDespacho.Latitude))
            {
                xml = xml + $@"<LatitudeMeasure>{due.UnidadeDespacho.Latitude}</LatitudeMeasure>";
            }

            if (!string.IsNullOrEmpty(due.UnidadeDespacho.Longitude))
            {
                xml = xml + $@"<LongitudeMeasure>{due.UnidadeDespacho.Longitude}</LongitudeMeasure>";
            }

            if (!string.IsNullOrEmpty(due.UnidadeDespacho.Endereco))
            {
                xml = xml + $@"<Address><Line>{due.UnidadeDespacho.Endereco}</Line></Address>";
            }

            xml = xml + $@"
                                </Warehouse>
                            </DeclarationOffice>
                            <AdditionalInformation>
                                <StatementCode>{due.FormaExportacao.ToString()}</StatementCode>
                                <StatementTypeCode>CUS</StatementTypeCode>
                            </AdditionalInformation>";

            if (!string.IsNullOrEmpty(due.DUE))
            {
                xml = xml + $@"<AdditionalInformation>
                                <StatementTypeCode>DEF</StatementTypeCode>
                                <StatementDescription>Vinculo de notas fiscais</StatementDescription>
                            </AdditionalInformation>";
            }

            if (due.SituacaoEspecial != 0)
            {
                xml = xml + $@"
                            <AdditionalInformation>
                                <StatementCode>{due.SituacaoEspecial.ToString()}</StatementCode>
                                <StatementTypeCode>AHZ</StatementTypeCode>
                            </AdditionalInformation>";
            }

            if (due.ViaEspecialTransporte != 0)
            {
                xml = xml + $@"
                            <AdditionalInformation>
                                <StatementCode>{due.ViaEspecialTransporte.ToString()}</StatementCode>
                                <StatementTypeCode>TRA</StatementTypeCode>
                            </AdditionalInformation>";
            }

            xml = xml + $@"<AdditionalInformation>
                                <StatementDescription languageID=''>{due.InformacoesComplementares.ToString().RemoverCaracteresEspeciais().QuebraDeLinhaXML()}</StatementDescription>
                                <LimitDateTime>10</LimitDateTime>
                                <StatementTypeCode>AAI</StatementTypeCode>
                            </AdditionalInformation>
                            <CurrencyExchange>
                                <CurrencyTypeCode>{due.MoedaNegociacao}</CurrencyTypeCode>
                            </CurrencyExchange>
                            <Declarant>
                                <ID schemeID='token'>{due.DocumentoDeclarante}</ID>
                            </Declarant>
                            <ExitOffice>
                                <ID>{due.UnidadeEmbarque.Id}</ID>
                                    <Warehouse>
                                        <ID>{due.UnidadeEmbarque.RecintoAduaneiroId}</ID>
                                        <TypeCode>{due.UnidadeEmbarque.TipoRecinto}</TypeCode>
                                    </Warehouse>
                            </ExitOffice>";

            var sequenciaItem = 1;

            foreach (var item in due.Itens)
            {
                xml = xml + $@"<GoodsShipment>";

                if (!string.IsNullOrEmpty(item.Exportador?.Descricao))
                {
                    xml = xml + $@"<Exporter>
                            <Name languageID=''>{item.Exportador?.Descricao}</Name>
                            <ID schemeID='token'>{item.Exportador?.Documento}</ID>
                            <Address>
                                <CountryCode>{item.Exportador?.Pais}</CountryCode>
                                <CountrySubDivisionCode>{string.Concat(item.Exportador?.Pais, "-", item.Exportador?.UF.ToUpper())}</CountrySubDivisionCode>
                                <Line languageID=''>{item.Exportador?.Endereco}</Line>
                            </Address>
                        </Exporter>";
                }

                var subItens = documentoUnicoExportacaoDAO.ObterDetalhesItem(item.Id);

                foreach (var subItem in subItens)
                {
                    xml = xml + $@"
	                            <GovernmentAgencyGoodsItem>
	                                <CustomsValueAmount languageID=''>{subItem.ValorMercadoriaLocalEmbarque.ToString().PPonto()}</CustomsValueAmount>
	                                <SequenceNumeric>{sequenciaItem}</SequenceNumeric>
	                                    <Destination>
		                                    <CountryCode>{subItem.PaisDestino}</CountryCode>
		                                    <GoodsMeasure>
		                                    <TariffQuantity>{subItem.QuantidadeEstatistica.ToString().PPonto()}</TariffQuantity>
		                                    </GoodsMeasure>
	                                    </Destination>"    ;

                    if (subItem.PrioridadeCarga != 0)
                    {
                        xml = xml + $@"
                            <AdditionalInformation>
                                <StatementCode>{subItem.PrioridadeCarga.ToString()}</StatementCode>
                                <StatementDescription languageID=''></StatementDescription>
                                <LimitDateTime>{subItem.Limite.ToString()}</LimitDateTime>
                                <StatementTypeCode>PRI</StatementTypeCode>
                            </AdditionalInformation>";
                    }

                    xml = xml + $@"
	                            <Commodity>
		                            <Description>{subItem.DescricaoComplementar}</Description>
		                            <ValueAmount schemeID='token'>{subItem.ValorMercadoriaCondicaoVenda.ToString().PPonto()}</ValueAmount>
                                    <CommercialDescription languageID=''>{subItem.DescricaoMercadoria}</CommercialDescription>
                                    <Classification>
                                        <ID schemeID='token'>{subItem.NCM.ToString()}</ID>
                                        <IdentificationTypeCode>HS</IdentificationTypeCode>
                                    </Classification>";

                    if (parametros.ValidarAtributosCafe > 0)
                    {
                        if (!string.IsNullOrEmpty(subItem.Attr_Padrao_Qualidade))
                        {
                            if (subItem.Attr_Padrao_Qualidade.ToInt() > 0)
                            {
                                var atributoPadraoQualidade = atributosDAO.ObterAtributo(
                                    "PadraoQualidade",
                                    subItem.NCM.ToString(),
                                    subItem.Attr_Padrao_Qualidade.ToString());

                                xml = xml + $@"
                                    <ProductCharacteristics>
                                        <TypeCode>{atributoPadraoQualidade?.Atributo}</TypeCode>
                                        <Description>{atributoPadraoQualidade?.Codigo}</Description>
                                    </ProductCharacteristics>";
                            }
                        }

                        if (!string.IsNullOrEmpty(subItem.Attr_Embarque_Em))
                        {
                            if (subItem.Attr_Embarque_Em.ToInt() > 0)
                            {
                                var atributoEmbarcadoEm = atributosDAO.ObterAtributo(
                                    "EmbarcadoEm",
                                    subItem.NCM.ToString(),
                                    subItem.Attr_Embarque_Em.ToString());

                                xml = xml + $@"
                                    <ProductCharacteristics>
                                        <TypeCode>{atributoEmbarcadoEm?.Atributo}</TypeCode>
                                        <Description>{atributoEmbarcadoEm?.Codigo}</Description>
                                    </ProductCharacteristics>";
                            }
                        }

                        if (!string.IsNullOrEmpty(subItem.Attr_Tipo))
                        {
                            if (subItem.Attr_Tipo.ToInt() > 0)
                            {
                                var atributoTipo = atributosDAO.ObterAtributo(
                                    "Tipo",
                                    subItem.NCM.ToString(),
                                    subItem.Attr_Tipo.ToString());

                                xml = xml + $@"
                                    <ProductCharacteristics>
                                        <TypeCode>{atributoTipo?.Atributo}</TypeCode>
                                        <Description>{atributoTipo?.Codigo}</Description>
                                    </ProductCharacteristics>";
                            }
                        }

                        if (!string.IsNullOrEmpty(subItem.Attr_Metodo_Processamento))
                        {
                            if (subItem.Attr_Metodo_Processamento.ToInt() > 0)
                            {
                                var atributoMetodoProcessamento = atributosDAO.ObterAtributo(
                                    "MetodoProcessamento",
                                    subItem.NCM.ToString(),
                                    subItem.Attr_Metodo_Processamento.ToString());

                                xml = xml + $@"
                                    <ProductCharacteristics>
                                        <TypeCode>{atributoMetodoProcessamento?.Atributo}</TypeCode>
                                        <Description>{atributoMetodoProcessamento?.Codigo}</Description>
                                    </ProductCharacteristics>";
                            }
                        }

                        if (!string.IsNullOrEmpty(subItem.Attr_Caracteristica_Especial))
                        {
                            var atributoCaracteristicaEspecial = atributosDAO.ObterAtributo(
                                "CaracteristicaEspecial",
                                subItem.NCM.ToString(),
                                subItem.Attr_Caracteristica_Especial);

                            xml = xml + $@"
                                <ProductCharacteristics>
                                    <TypeCode>{atributoCaracteristicaEspecial?.Atributo}</TypeCode>
                                    <Description>{atributoCaracteristicaEspecial?.Codigo}</Description>
                                </ProductCharacteristics>";
                        }

                        if (!string.IsNullOrEmpty(subItem.Attr_Outra_Caracteristica_Especial))
                        {
                            var atributoOutraCaracteristicaEspecial = atributosDAO.ObterAtributo("OutraCaracteristicaEspecial", subItem.NCM.ToString());

                            xml = xml + $@"
                                <ProductCharacteristics>
                                    <TypeCode>{atributoOutraCaracteristicaEspecial?.Atributo}</TypeCode>
                                    <Description>{subItem?.Attr_Outra_Caracteristica_Especial}</Description>
                                </ProductCharacteristics>";
                        }
                    }

                    xml = xml + $@"<Product>
                                        <ID schemeID='token'>{subItem.CodigoProduto.ToString()}</ID>
                                        <IdentifierTypeCode>VN</IdentifierTypeCode>
                                    </Product>";

                    xml = xml + $@"<InvoiceLine>
		                                <SequenceNumeric>{subItem.Item}</SequenceNumeric>"        ;

                    IEnumerable <Models.NotaFiscal> notasReferenciadas = new List <Models.NotaFiscal>();

                    if (due.Completa > 0 || due.CriadoPorNF > 0)
                    {
                        // Pega somente as notas que foram cadastradas NA DUE
                        notasReferenciadas = notaFiscalDAO.ObterNotasFiscaisRemessaDUE(item.NF, item.DueId);
                    }
                    else
                    {
                        // Pega somente as notas que foram importadas PELO ARQUIVO

                        notasReferenciadas = notaFiscalDAO.ObterNotasFiscaisRemessa(item.NF);
                    }

                    foreach (var nfRef in notasReferenciadas)
                    {
                        // <SequenceNumeric>1</SequenceNumeric>
                        // Alterado em 09/04 para
                        // <SequenceNumeric>{nfRef.Item}</SequenceNumeric>

                        var nfRefItem = nfRef.Item == 0 ? 1 : nfRef.Item;

                        xml = xml + $@"
		                                <ReferencedInvoiceLine>
			                                <SequenceNumeric>{nfRefItem}</SequenceNumeric>
			                                <InvoiceIdentificationID schemeID='token'>{nfRef.ChaveNF}</InvoiceIdentificationID>
			                                <GoodsMeasure>
			                                    <TariffQuantity unitCode=''>{nfRef.QuantidadeNF.ToString().PPonto()}</TariffQuantity>
			                                </GoodsMeasure>
		                                </ReferencedInvoiceLine>"        ;
                    }

                    xml = xml + $@"</InvoiceLine>";

                    xml = xml + $@"</Commodity>
	                            <GoodsMeasure>
		                            <NetNetWeightMeasure>{subItem.PesoLiquidoTotal.ToString().PPonto()}</NetNetWeightMeasure>
	                            </GoodsMeasure>
	                            <GovernmentProcedure>
		                            <CurrentCode>{subItem.Enquadramento1Id.ToString()}</CurrentCode>
	                            </GovernmentProcedure>"    ;

                    if (subItem.Enquadramento2Id > 0)
                    {
                        xml = xml + $@"<GovernmentProcedure>
		                                 <CurrentCode>{subItem.Enquadramento2Id.ToString()}</CurrentCode>
	                                   </GovernmentProcedure>"    ;
                    }

                    if (subItem.ComissaoAgente > 0)
                    {
                        xml = xml + $@"
                                    <ValuationAdjustment>
		                                <AdditionCode>149</AdditionCode>
		                                <PercentageNumeric>{subItem.ComissaoAgente.ToString().PPonto()}</PercentageNumeric>
	                                </ValuationAdjustment>"    ;
                    }

                    var dadosAtosConcessorios = documentoUnicoExportacaoDAO.ObterAtosConcessorios(subItem.Id);

                    if (dadosAtosConcessorios != null)
                    {
                        foreach (var atoConcessorio in dadosAtosConcessorios)
                        {
                            xml = xml + $@"
                                    <AdditionalDocument>
                                      <CategoryCode>AC</CategoryCode>
                                      <ID>{atoConcessorio.Numero}</ID>
                                      <ItemID>{atoConcessorio.NumeroItem}</ItemID>
                                      <QuantityQuantity>{atoConcessorio.QuantidadeUtilizada.ToString().PPonto()}</QuantityQuantity>
                                      <ValueWithExchangeCoverAmount>{atoConcessorio.VMLEComCoberturaCambial.ToString().PPonto()}</ValueWithExchangeCoverAmount>
                                      <ValueWithoutExchangeCoverAmount>{atoConcessorio.VMLESemCoberturaCambial.ToString().PPonto()}</ValueWithoutExchangeCoverAmount>
                                      <DrawbackHsClassification>{atoConcessorio.NCMItem}</DrawbackHsClassification>
                                      <DrawbackRecipientId>{atoConcessorio.CNPJBeneficiario}</DrawbackRecipientId>
                                   </AdditionalDocument>";
                        }
                    }

                    var lpcos = documentoUnicoExportacaoDAO.ObterLPCO(subItem.Id);

                    if (lpcos != null)
                    {
                        foreach (var lpco in lpcos)
                        {
                            xml = xml + $@"
                                    <AdditionalDocument>
                                      <CategoryCode>LPCO</CategoryCode>
                                      <ID>{lpco.Numero}</ID>
                                   </AdditionalDocument>";
                        }
                    }

                    xml = xml + "</GovernmentAgencyGoodsItem>";
                }

                if (!string.IsNullOrEmpty(item.Importador?.Descricao))
                {
                    xml = xml + $@"
                            <Importer>
                                <Name languageID=''>{item.Importador?.Descricao}</Name>
                                <Address>
                                    <CountryCode>{item.Importador?.Pais}</CountryCode>
                                    <Line languageID=''>{item.Importador?.Endereco}</Line>
                                </Address>
                            </Importer>";
                }

                IEnumerable <Models.NotaFiscal> notasRef = new List <Models.NotaFiscal>();

                if (due.Completa > 0 || due.CriadoPorNF > 0)
                {
                    // Pega somente as notas que foram cadastradas NA DUE
                    notasRef = notaFiscalDAO.ObterNotasFiscaisRemessaDUE(item.NF, item.DueId);
                }
                else
                {
                    // Pega somente as notas que foram importadas PELO ARQUIVO
                    notasRef = notaFiscalDAO.ObterNotasFiscaisRemessa(item.NF);
                }

                xml = xml + $@"<Invoice>
	                            <ID schemeID='token'>{item.NF}</ID>
	                            <TypeCode>388</TypeCode>"    ;

                var notasRefSemRepeticao = notasRef
                                           .Select(c => new
                {
                    c.ChaveNF,
                    c.CnpjNF
                }).ToList()
                                           .Distinct().ToList();

                foreach (var nfRef in notasRefSemRepeticao)
                {
                    var cpfCnpj      = string.Empty;
                    var cpfFormatado = string.Empty;

                    if (nfRef.CnpjNF.Length >= 11)
                    {
                        cpfFormatado = nfRef.CnpjNF.Substring(nfRef.CnpjNF.Length - 11);
                    }

                    if (ValidacaoCPF.Validar(cpfFormatado))
                    {
                        cpfCnpj = cpfFormatado;
                    }
                    else
                    {
                        cpfCnpj = nfRef.CnpjNF;
                    }

                    xml = xml + $@"
                                <ReferencedInvoice>
		                            <ID schemeID='token'>{nfRef.ChaveNF}</ID>
		                            <TypeCode>REM</TypeCode>
		                            <Submitter>
		                                <ID schemeID='token'>{cpfCnpj}</ID>
		                            </Submitter>
	                            </ReferencedInvoice>"    ;
                }

                xml = xml + $@"</Invoice>";

                xml = xml + $@"<TradeTerms>
	                                <ConditionCode>{item.CondicaoVenda}</ConditionCode>
	                           </TradeTerms>
                        </GoodsShipment>";

                sequenciaItem++;
            }

            xml = xml + $@"
                            <UCR>
	                            <TraderAssignedReferenceID>{due.RUC}</TraderAssignedReferenceID>
                            </UCR>
                        </DeclarationNFe>
                    </Declaration>";

            return(xml);
        }