Esempio n. 1
0
        /// <summary>
        /// Faz todas as validações necessárias dos campos da janela
        /// </summary>
        /// <returns>Retorna true se existir inconsistencias na janela</returns>
        private bool ValidaCampos()
        {
            dxErrorProvider.ClearErrors(); // Elimina todo os erros da janela

            if (responsavelDTO.Municipio.Id == 0)
            {
                dxErrorProvider.SetError(municipioTextEdit, "Município inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (responsavelDTO.Responsa == false &&
                responsavelDTO.Contador == false)
            {
                dxErrorProvider.SetError(responsaCheckEdit, "Responsabilidade inválida. Preenchimento obrigatório ao menos para uma das oções.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                dxErrorProvider.SetError(contadorCheckEdit, "Responsabilidade inválida. Preenchimento obrigatório ao menos para uma das oções.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (responsavelDTO.Contador || responsavelDTO.Responsa)
            {
                if (responsavelDTO.Nome == string.Empty)
                {
                    dxErrorProvider.SetError(nomeTextEdit, "Nome inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                }

                if (responsavelDTO.Endereco == string.Empty)
                {
                    dxErrorProvider.SetError(enderecoTextEdit, "Endereço inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                }

                if (responsavelDTO.Numero == string.Empty)
                {
                    dxErrorProvider.SetError(numeroTextEdit, "Número inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                }

                if (responsavelDTO.Bairro == string.Empty)
                {
                    dxErrorProvider.SetError(bairroTextEdit, "Bairro inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                }

                if (responsavelDTO.Cep == string.Empty)
                {
                    dxErrorProvider.SetError(cepTextEdit, "Cep inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                }

                if (responsavelDTO.Municipio.Codigoibge == 0)
                {
                    dxErrorProvider.SetError(codigoIBGEButtonEdit, "Cód. Município inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                }
                else
                {
                    if (responsavelDTO.Municipio.Nome.Trim().Equals(string.Empty))
                    {
                        dxErrorProvider.SetError(codigoIBGEButtonEdit, "Cód. Município não localizado.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical);
                    }
                }

                if (responsavelDTO.Dddtelefone == string.Empty)
                {
                    dxErrorProvider.SetError(dddtelefoneTextEdit, "DDD do Telefone inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                }

                if (responsavelDTO.Telefone == string.Empty)
                {
                    dxErrorProvider.SetError(telefoneTextEdit, "Telefone inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                }

                if (!responsavelDTO.DataNascimento.HasValue)
                {
                    dxErrorProvider.SetError(DataNascimentoDateEdit, "Data de Nascimento inválida. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                }

                if (responsavelDTO.Contato == string.Empty)
                {
                    dxErrorProvider.SetError(contatoTextEdit, "Contato inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                }

                if (responsavelDTO.Cpf == string.Empty)
                {
                    dxErrorProvider.SetError(cpfTextEdit, "CPF inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                }


                if (responsavelDTO.Cnpj == string.Empty && responsavelDTO.Cei == string.Empty)
                {
                    dxErrorProvider.SetError(cnpjTextEdit, "Documentação inválida. Preenchimento obrigatório ao menos para uma das opções.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                    dxErrorProvider.SetError(ceiTextEdit, "Documentação inválida. Preenchimento obrigatório ao menos para uma das opções.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                }


                if (responsavelDTO.Cargo == string.Empty)
                {
                    dxErrorProvider.SetError(cargoTextEdit, "Cargo inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                }

                EventHandler checa; // necessário para chamar o evento dos campos

                if (responsavelDTO.Cnpj != string.Empty)
                {
                    if (Documentos.ValidarCNPJ(responsavelDTO.Cnpj) == false)
                    {
                        dxErrorProvider.SetError(cnpjTextEdit, "CNPJ inválido.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical);
                    }
                    else
                    {
                        checa = cnpjTextEdit_Validated;
                        if (checa != null)
                        {
                            checa(cnpjTextEdit, EventArgs.Empty);
                        }
                    }
                }

                if (responsavelDTO.Cpf != "")
                {
                    if (Documentos.ValidarCPF(responsavelDTO.Cpf) == false)
                    {
                        dxErrorProvider.SetError(cpfTextEdit, "CPF inválido.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical);
                    }
                    else
                    {
                        checa = cpfTextEdit_Validated;
                        if (checa != null)
                        {
                            checa(cpfTextEdit, EventArgs.Empty);
                        }
                    }
                }

                if (responsavelDTO.Cei != "")
                {
                    if (Documentos.ValidarCEI(responsavelDTO.Cei) == false)
                    {
                        dxErrorProvider.SetError(ceiTextEdit, "CEI inválido.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical);
                    }
                    else
                    {
                        checa = ceiTextEdit_Validated;
                        if (checa != null)
                        {
                            checa(ceiTextEdit, EventArgs.Empty);
                        }
                    }
                }

                if (responsavelDTO.Nit != "")
                {
                    checa = nitTextEdit_Validated;
                    if (checa != null)
                    {
                        checa(nitTextEdit, EventArgs.Empty);
                    }
                }

                if (responsavelDTO.Bairro.ToString().Count() > 20) //41739
                {
                    dxErrorProvider.SetError(bairroTextEdit, "O campo bairro possui mais caracteres do que o permitido nos layouts, por gentileza informe dados de modo abreviado. Tamanho máximo: 20 Caracteres.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                }
            }
            return(dxErrorProvider.HasErrors);
        }
Esempio n. 2
0
        private bool ValidaCampos()
        {
            dxErrorProvider.ClearErrors();

            #region BÁSICO
            if (empresaDTO.Razaosocial.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(razaosocialTextEdit, "Razão Social inválida. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (empresaDTO.Nomefantasia.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(nomefantasiaTextEdit, "Nome fantasia inválida. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (empresaDTO.Endereco.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(enderecoTextEdit, "Endereço inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (empresaDTO.Numero.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(numeroTextEdit, "Número inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (empresaDTO.Bairro.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(bairroTextEdit, "Bairro inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (empresaDTO.Cep.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(cepTextEdit, "Cep inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (empresaDTO.Municipio.Codigoibge == 0)
            {
                dxErrorProvider.SetError(codigoibgeButtonEdit, "Cód. Município inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }
            else
            {
                if (empresaDTO.Municipio.Nome.Trim().Equals(string.Empty))
                {
                    dxErrorProvider.SetError(codigoibgeButtonEdit, "Cód. Município não localizado.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical);
                }
            }

            if (empresaDTO.Dddtelefone.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(dddtelefoneTextEdit, "DDD do telefone inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (empresaDTO.Telefone.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(telefoneTextEdit, "Telefone inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (empresaDTO.Tipo.Equals("J")) //PESSOA JURÍDICA (CNPJ)
            {
                if (empresaDTO.Cnpj.Trim().Equals(string.Empty))
                {
                    dxErrorProvider.SetError(cnpjTextEdit, "CNPJ inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                }
                else
                {
                    if (!Documentos.ValidarCNPJ(empresaDTO.Cnpj.Trim()))
                    {
                        dxErrorProvider.SetError(cnpjTextEdit, "CNPJ inválido.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical);
                    }
                }
            }
            else //PESSOA FÍSICA (CPF)
            {
                if (empresaDTO.Cnpj.Trim().Equals(string.Empty))
                {
                    dxErrorProvider.SetError(cnpjTextEdit, "CPF inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                }
                else
                {
                    if (!Documentos.ValidarCPF(empresaDTO.Cnpj.Trim()))
                    {
                        dxErrorProvider.SetError(cnpjTextEdit, "CPF inválido.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical);
                    }
                }
            }

            if (empresaDTO.Iestadual.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(iestadualTextEdit, "Inscrição Estadual inválida. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }
            else
            {
                if (Documentos.ConsisteInscricaoEstadual(empresaDTO.Iestadual.Trim(), empresaDTO.Municipio.UF.Codigo.Trim()) != 0)
                {
                    if (empresaDTO.Municipio.UF.Codigo.Trim().Equals(string.Empty))
                    {
                        dxErrorProvider.SetError(iestadualTextEdit, "Inscrição Estadual inválida.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical);
                    }
                    else
                    {
                        dxErrorProvider.SetError(iestadualTextEdit, "Inscrição Estadual inválida para " + empresaDTO.Municipio.UF.Descricao.Trim(), DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical);
                    }
                }
            }

            if (empresaDTO.Naturezajuridica.Id == 0)
            {
                dxErrorProvider.SetError(naturezajuridicaLookUpEdit, "Nat. Jurídica inválida. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (empresaDTO.CNAE.Codigo.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(cnaeContainerEdit, "CNAE inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (empresaDTO.Email.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(emailTextEdit, "Email inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }
            #endregion

            if (empresaDTO.Bairro.ToString().Count() > 20) //41739
            {
                dxErrorProvider.SetError(bairroTextEdit, "O campo bairro possui mais caracteres do que o permitido nos layouts, por gentileza informe dados de modo abreviado. Tamanho máximo: 20 Caracteres.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (dxErrorProvider.HasErrors)
            {
                MessageBox.Show("O Sistema identificou campos obrigatórios não preenchidos ou preenchidos incorretamente. Impossível prosseguir.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            return(dxErrorProvider.HasErrors);
        }
Esempio n. 3
0
        private bool ValidaCampos()
        {
            dxErrorProvider.ClearErrors();

            if (funcionarioDTO.Contrato.Dataadmissao == null)
            {
                dxErrorProvider.SetError(dataadmissaoDateEdit, "Data de admissão inválida. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (funcionarioDTO.Salario.Count <= 0)
            {
                MessageBox.Show("Não foi identificado nenhum lançamento de salário. Impossível prosseguir.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(true);
            }

            FuncSalarioDTO salarioatual = funcionarioDTO.Salario.Find(delegate(FuncSalarioDTO item)
            {
                return(new DateTime(item.Data.Value.Year, item.Data.Value.Month, 1) <=
                       new DateTime(dataprocessamento.Year, dataprocessamento.Month, 1) && (item.DataReajuste <=
                                                                                            new DateTime(dataprocessamento.Year, dataprocessamento.Month, 1) || !item.DataReajuste.HasValue));
            });

            #region BÁSICO
            if (!funcionarioDTO.Datanascimento.HasValue)
            {
                dxErrorProvider.SetError(datanascimentoDateEdit, "Data de nascimento inválida. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (funcionarioDTO.Nomecompleto.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(nomecompletoTextEdit, "Nome completo inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (funcionarioDTO.Endereco.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(enderecoTextEdit, "Endereço inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (funcionarioDTO.Numero.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(numeroTextEdit, "Número inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (funcionarioDTO.Bairro.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(bairroTextEdit, "Bairro inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (funcionarioDTO.Cep.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(cepTextEdit, "Cep inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (funcionarioDTO.Municipio.Codigoibge == 0)
            {
                dxErrorProvider.SetError(codigoibgeButtonEdit, "Cód. Município inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }
            else
            {
                if (funcionarioDTO.Municipio.Nome.Trim().Equals(string.Empty))
                {
                    dxErrorProvider.SetError(codigoibgeButtonEdit, "Cód. Município não localizado.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical);
                }
            }

            if (funcionarioDTO.Sexo.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(sexocomboBoxEdit, "Sexo inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }
            #endregion

            #region DOCUMENTOS
            if (!funcionarioDTO.Documento.Cpf.Trim().Equals(string.Empty))
            {
                if (!Documentos.ValidarCPF(funcionarioDTO.Documento.Cpf.Trim()))
                {
                    dxErrorProvider.SetError(cpfTextEdit, "CPF inválido.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical);
                }
                else
                {
                    if (funcionarioGL.ExistsCPF(funcionarioDTO.Id, funcionarioDTO.Documento.Cpf.Trim()))
                    {
                        dxErrorProvider.SetError(cpfTextEdit, "CPF inválido. O CPF informado já encontra-se cadastrado nessa empresa para outro funcionário.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Warning);
                    }
                }
            }
            else
            {
                dxErrorProvider.SetError(cpfTextEdit, "CPF inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (funcionarioDTO.Bairro.ToString().Count() > 20) //41739
            {
                dxErrorProvider.SetError(bairroTextEdit, "O campo bairro possui mais caracteres do que o permitido nos layouts, por gentileza informe dados de modo abreviado. Tamanho máximo: 20 Caracteres.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (funcionarioDTO.Endereco.ToString().Count() > 40) //45019
            {
                dxErrorProvider.SetError(enderecoTextEdit, "O campo endereço possui mais caracteres do que o permitido nos layouts, por gentileza informe dados de modo abreviado. Tamanho máximo: 40 Caracteres.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }


            if (dxErrorProvider.HasErrors)
            {
                MessageBox.Show("O Sistema identificou campos obrigatórios não preenchidos ou preenchidos incorretamente. Impossível prosseguir.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            #endregion

            return(dxErrorProvider.HasErrors);
        }
Esempio n. 4
0
        private bool ValidaCampos()
        {
            dxErrorProvider.ClearErrors();

            #region BÁSICO

            if (clienteDTO.Nome.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(txtNome, "Nome inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (clienteDTO.Endereco.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(txtEndereco, " Endereço inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (clienteDTO.Numero.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(txtNumero, "Número inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (clienteDTO.Bairro.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(txtBairro, "Bairro inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            if (clienteDTO.Cidade.Codigoibge == 0)
            {
                dxErrorProvider.SetError(BtnCodMunicipio, "Cód. Município inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }
            else
            {
                if (clienteDTO.Cidade.Nome.Trim().Equals(string.Empty))
                {
                    dxErrorProvider.SetError(BtnCodMunicipio, "Cód. Município não localizado. Preenchimento obrigatório,", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
                }
            }

            if (!clienteDTO.DataCadastro.HasValue)
            {
                dxErrorProvider.SetError(dtCadastro, "Data inválida. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            //if (clienteDTO.Telefone.Trim().Equals(string.Empty))
            //{
            //    dxErrorProvider.SetError(txtTelefone, "Telefone inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            //}

            if (clienteDTO.Celular.Trim().Equals(string.Empty))
            {
                dxErrorProvider.SetError(txtCelular, "Celular inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            }

            //if (clienteDTO.Emissor.Trim().Equals(string.Empty))
            //{
            //    dxErrorProvider.SetError(txtEmissor, "Emissor inválido. Preenchimento obrigatório.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information);
            //}

            if (clienteDTO.Tipo_pessoa.Trim().Equals("J"))
            {
                if (!Documentos.ValidarCNPJ(clienteDTO.Cpf_Cnpj.Trim()))
                {
                    dxErrorProvider.SetError(txt_cpf_cnpj, "CPF/CNPJ inválido.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical);
                }
            }
            else
            {
                {
                    if (!Documentos.ValidarCPF(clienteDTO.Cpf_Cnpj.Trim()))
                    {
                        dxErrorProvider.SetError(txt_cpf_cnpj, "CPF/CNPJ inválido.", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical);
                    }
                }
            }

            #endregion

            if (dxErrorProvider.HasErrors)
            {
                MessageBox.Show("O Sistema identificou campos obrigatórios não preenchidos ou preenchidos incorretamente. Impossível prosseguir.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            return(dxErrorProvider.HasErrors);
        }