Example #1
0
        private bool validaObjeto()
        {
            Ajudas ajudas = new Ajudas();

            string nome = txtNomeProjeto.Text.Trim();

            if (nome == string.Empty)
            {
                DialogHelper.Alerta("Informe um nome para o projeto.");
                txtNomeProjeto.Focus();
                return(false);
            }

            if (editar == false)
            {
                if (projetoRepository.ProcurarPorNome(txtNomeProjeto.Text))
                {
                    DialogHelper.Informacao("Já existe projeto cadastrado com este nome.");
                    txtNomeProjeto.Focus();
                    return(false);
                }
            }


            if (txtNomeProjeto.Text.Length > 149 || txtNomeProjeto.Text.Length < 2)
            {
                DialogHelper.Alerta("O nome do projeto deve ter entre 150 e ser menor que 2 caracteres");
                txtNomeProjeto.Focus();
                return(false);
            }

            if (CbbUf.SelectedItem == null)
            {
                DialogHelper.Alerta("Selecione o estado.");
                CbbUf.Focus();
                return(false);
            }

            if (CbbCidade.SelectedItem == null)
            {
                DialogHelper.Alerta("Selecione a cidade.");
                CbbCidade.Focus();
                return(false);
            }

            string endereco = txtLogradouro.Text.Trim();

            if (endereco == string.Empty)
            {
                DialogHelper.Alerta("Informe um endereço para o projeto.");
                txtLogradouro.Focus();
                return(false);
            }

            string bairro = txtBairro.Text.Trim();

            if (bairro == string.Empty)
            {
                DialogHelper.Alerta("Informe um bairro para o projeto.");
                txtBairro.Focus();
                return(false);
            }

            return(true);
        }
Example #2
0
        private bool validaObjeto()
        {
            Ajudas ajudas = new Ajudas();

            string nome = txtNome.Text.Trim();

            if (nome == string.Empty)
            {
                DialogHelper.Alerta("Informe um nome para o cliente.");
                txtNome.Focus();
                return(false);
            }

            if (txtNome.Text.Length > 50 || txtNome.Text.Length < 2)
            {
                DialogHelper.Alerta("O nome não pode ter mais que cinquenta caracteres e ser menor que dois caracteres");
                txtNome.Focus();
                return(false);
            }

            string sobrenome = txtSobrenome.Text.Trim();

            if (sobrenome == string.Empty)
            {
                DialogHelper.Alerta("Informe o sobrenome do cliente.");
                txtSobrenome.Focus();
                return(false);
            }

            if (txtSobrenome.Text.Length > 50 || txtSobrenome.Text.Length < 2)
            {
                DialogHelper.Alerta("O sobrenome não pode ter mais que cinquenta caracteres e ser menor que dois caracteres");
                txtSobrenome.Focus();
                return(false);
            }

            if (txtCpf.Text == String.Empty)
            {
                DialogHelper.Alerta("Informe um CPF para o cliente");
                txtCpf.Focus();
                return(false);
            }

            if (!ajudas.ValidaCpf(txtCpf.Text))
            {
                DialogHelper.Alerta("Informe um CPF valido para o cliente");
                txtCpf.Focus();
                return(false);
            }

            if (txtRG.Text == String.Empty)
            {
                DialogHelper.Alerta("Informe um RG para o cliente");
                txtRG.Focus();
                return(false);
            }

            if (dtpDataNasc.Text == String.Empty)
            {
                DialogHelper.Alerta("Informe uma data de nascimento para o cliente");
                dtpDataNasc.Focus();
                return(false);
            }

            else if (!ajudas.ValidaData(dtpDataNasc.Text))
            {
                DialogHelper.Alerta("Informe uma data de nascimento menor que o dia de hoje para o cliente");
                dtpDataNasc.Focus();
                return(false);
            }

            if (txtTelefone1.Text == String.Empty)
            {
                DialogHelper.Alerta("Informe um número de telefone para o cliente");
                txtTelefone1.Focus();
                return(false);
            }

            if (cbCasado.Checked == true)
            {
                string conjuge = txtNomeConjuge.Text.Trim();
                if (conjuge == string.Empty)
                {
                    DialogHelper.Alerta("Informe o nome do cônjuge do cliente.");
                    txtNomeConjuge.Focus();
                    return(false);
                }

                if (txtCpfConjuge.Text == String.Empty)
                {
                    DialogHelper.Alerta("Informe um CPF para o cônjuge");
                    txtCpfConjuge.Focus();
                    return(false);
                }

                if (!ajudas.ValidaCpf(txtCpfConjuge.Text))
                {
                    DialogHelper.Alerta("Informe um CPF valido para o cônjuge");
                    txtCpfConjuge.Focus();
                    return(false);
                }
                if (repCli.ProcurarPorCPF(txtCpfConjuge.Text))
                {
                    DialogHelper.Alerta("CPF do cônjuge já cadastrado");
                    txtCpfConjuge.Focus();
                    return(false);
                }
                if (txtConjugeRg.Text == String.Empty)
                {
                    DialogHelper.Alerta("Informe um RG para o cônjuge");
                    txtCpfConjuge.Focus();
                    return(false);
                }
            }

            if (CbbUf.SelectedItem == null)
            {
                DialogHelper.Alerta("Selecione o estado.");
                CbbUf.Focus();
                return(false);
            }

            if (CbbCidade.SelectedItem == null)
            {
                DialogHelper.Alerta("Selecione a cidade.");
                CbbCidade.Focus();
                return(false);
            }

            string endereco = txtLogradouro.Text.Trim();

            if (endereco == string.Empty)
            {
                DialogHelper.Alerta("Informe um endereço para o cliente.");
                txtLogradouro.Focus();
                return(false);
            }

            string bairro = txtBairro.Text.Trim();

            if (bairro == string.Empty)
            {
                DialogHelper.Alerta("Informe um bairro para o cliente.");
                txtBairro.Focus();
                return(false);
            }

            return(true);
        }