Exemple #1
0
 protected void CPFouCNPJDeveSerValido()
 {
     if (!CPFCNPJ.Validar(CPFCNPJ.Numero))
     {
         ListaErros.Add("Digite um CPF ou CNPJ válido!");
     }
 }
Exemple #2
0
 protected void ValidateCPFCNPJ(Expression <Func <T, string> > cpfcnpjFiled)
 {
     RuleFor(cpfcnpjFiled).Cascade(CascadeMode.StopOnFirstFailure)
     .NotNull().WithMessage("CPF or CNPJ was not provided.")
     .NotEmpty().WithMessage("CPF or CNPJ was not provided.")
     .Must(cpfcnpj => CPFCNPJ.IsCpfOrCnpj(cpfcnpj)).WithMessage("Invalid CPF or CNPJ");;
 }
        private void InsereValores()
        {
            Cliente      = Cliente ?? new Cliente();
            Cliente.Nome = txtNome.Text;
            var CPF = new CPFCNPJ(txtCPFCNPJ.Text);

            Cliente.CPFCNPJ = CPF;
        }
        private void InsereValores()
        {
            Fornecedor      = Fornecedor ?? new Fornecedor();
            Fornecedor.Nome = txtNome.Text;
            var CNPJ = new CPFCNPJ(txtCPFCNPJ.Text);

            Fornecedor.CPFCNPJ = CNPJ;
        }
 private bool EhCPFCNPJValido()
 {
     try{
         var CNPJ = new CPFCNPJ(txtCPFCNPJ.Text);
         return(true);
     }
     catch (ApplicationException)
     {
         MessageBox.Show("CPF ou CNPJ inválido", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     txtCPFCNPJ.Focus();
     return(false);
 }
Exemple #6
0
        public Supplier(string name, CPFCNPJ cPFCNPJ, ICollection <Phone> phones, Company company, Guid id, DateTimeOffset?birthDate = null, RG rg = null)
        {
            Id           = id;
            Name         = name;
            CPFCNPJ      = cPFCNPJ;
            CreationDate = DateTimeOffset.Now;
            Phones       = phones;
            Company      = company;

            if (CPF.IsCpf(cPFCNPJ))
            {
                BirthDate = birthDate;
                RG        = rg;
                if (BirthDate == null || RG == null)
                {
                    throw new InvalidOperationException("Birthdate and RG must be provided for private individual");
                }
            }
        }
Exemple #7
0
        private void BtnImportar_Click(object sender, EventArgs e)
        {
            //Valida se todos CNPJS são iguais
            //Valida Linha a Linha
            string CNPJ = TextImporta.Lines[0].Split(';')[21];

            //Se posssuir CNPJs Diferentes
            foreach (string Line in TextImporta.Lines)
            {
                if (CNPJ != Line.Split(';')[21])
                {
                    MessageBox.Show("CNPJs Diferentes!"); return;
                }
            }

            for (int i = 0; i < Distribuidores.Count; i++)
            {
                if (Distribuidores[i].CNPJ == Convert.ToInt64(new Regex(@"[^\d]").Replace(CNPJ, "")))
                {
                    CmbBoxDistribuidor.SelectedIndex = i;
                }
            }

            if (CmbBoxDistribuidor.SelectedIndex == -1)
            {
                MessageBox.Show("CNPJ não reconhecido!");
            }

            PanelOrdem.Enabled         = true;
            CmbBoxDistribuidor.Enabled = false;

            //Valida Dados
            foreach (string Line in TextImporta.Lines)
            {
                if (Line.Split(';').Count() != 23)
                {
                    TextImporta.Text = ""; MessageBox.Show("Importação inválida!");  return;
                }
            }

            //Valida Linha a Linha
            foreach (string Line in TextImporta.Lines)
            {
                try
                {
                    if (Line.Substring(0, 2) == "ID")
                    {
                        continue;
                    }

                    string  NOME;
                    long    CPFCNPJ;
                    string  OP;
                    long    CODFUND;
                    decimal VALOR;
                    string  STATUS;
                    string  CONTA;

                    BL_FIQ FundoAux = Fundos.FirstOrDefault(x => x.CNPJ == Convert.ToInt64(new Regex(@"[^\d]").Replace(Line.Split(';')[3], "")));

                    CPFCNPJ = Convert.ToInt64(new Regex(@"[^\d]").Replace(Line.Split(';')[21], ""));

                    if (Line.Split(';')[4] == "A")
                    {
                        OP = "AP"; VALOR = Convert.ToDecimal(Line.Split(';')[6]);
                    }
                    else if (Line.Split(';')[4] == "RP")
                    {
                        OP = "R"; VALOR = Convert.ToDecimal(Line.Split(';')[6]);
                    }
                    else if (Line.Split(';')[4] == "RC")
                    {
                        OP = "RC"; VALOR = Convert.ToDecimal(Line.Split(';')[5]);
                    }
                    else
                    {
                        OP = "RT"; VALOR = 0;
                    }

                    NOME    = Line.Split(';')[2];
                    CODFUND = FundoAux.CODFUND;
                    STATUS  = "Pendente";

                    if (OP != "AP")
                    {
                        long BANCO;
                        long AGENCIA;
                        long CC;
                        long DIGITO;

                        BANCO   = Convert.ToInt16(Line.Split(';')[9]);
                        AGENCIA = Convert.ToInt16(Line.Split(';')[10]);

                        //Se não tiver digito, converte ultimo digito da  conta em digito verificador
                        if (Line.Split(';')[12].Length == 0)
                        {
                            CC     = Convert.ToInt32(Line.Split(';')[11].Substring(0, Line.Split(';')[11].Length - 1));
                            DIGITO = Convert.ToInt16(Line.Split(';')[11].Substring(Line.Split(';')[11].Length - 1, 1));
                        }
                        else
                        {
                            CC     = Convert.ToInt32(Line.Split(';')[11]);
                            DIGITO = Convert.ToInt16(Line.Split(';')[12]);
                        }

                        CONTA = BANCO + " - " + AGENCIA + " - " + CC + " - " + DIGITO;
                    }
                    else
                    {
                        CONTA = "VIA TED";
                    }

                    DataGridBoletas.Rows.Add(new string[] { NOME, CPFCNPJ.ToString(), "", OP, FundoAux.NOME, FundoAux.CODFUND.ToString(), VALOR.ToString(), CONTA, STATUS });
                }
                catch { MessageBox.Show("Linha não processada: " + Line); }
            }

            TextImporta.Text = "";
        }