コード例 #1
0
 public static string ValidarCadastro(DTO_Usuario obj)
 {
     if (string.IsNullOrWhiteSpace(obj.Nome))
     {
         throw new Exception("Nome vazio");
     }
     if (obj.CPF.Length != 11)
     {
         throw new Exception("o CPF deve conter 11 digitos");
     }
     if (string.IsNullOrWhiteSpace(obj.UserName))
     {
         throw new Exception("Nom de de usuário vazio");
     }
     if (string.IsNullOrWhiteSpace(obj.Email))
     {
         throw new Exception("Email vazio");
     }
     if (string.IsNullOrWhiteSpace(obj.Senha))
     {
         throw new Exception("Senha vazio");
     }
     if (string.IsNullOrWhiteSpace(obj.SenhaC))
     {
         throw new Exception("Confirmar senha vazio");
     }
     if (obj.Senha != obj.SenhaC)
     {
         throw new Exception("As senhas não correspondem");
     }
     return(DAL_Cadastro.CadastrarUsuario(obj));
 }
コード例 #2
0
ファイル: BLL_Cadastro.cs プロジェクト: AlvesFe/ProjetoDS
        public static string ValidarCadastro(DTO_Cadastro obj)
        {
            if (string.IsNullOrWhiteSpace(obj.nome))
            {
                throw new Exception("Campo nome vazio!");
            }
            if (string.IsNullOrWhiteSpace(obj.userName))
            {
                throw new Exception("Campo Usuário vazio!");
            }
            if (obj.userName.Length < 6)
            {
                throw new Exception("Campo usuário deve ter ao minimo 6 caracteres!");
            }
            if (string.IsNullOrWhiteSpace(obj.email))
            {
                throw new Exception("Campo e-mail vazio!");
            }
            if (string.IsNullOrWhiteSpace(obj.CPF))
            {
                throw new Exception("Campo CPF vazio!");
            }
            if (obj.CPF.Length != 14)
            {
                throw new Exception("Campo CPF deve conter 11 numeros!");
            }
            if (string.IsNullOrWhiteSpace(obj.senha))
            {
                throw new Exception("Campo senha vazio!");
            }
            if (obj.senha.Length < 8)
            {
                throw new Exception("Campo senha deve ter ao minimo 8 caracteres!");
            }
            if (string.IsNullOrWhiteSpace(obj.confSenha))
            {
                throw new Exception("Campo confirmar senha vazio!");
            }
            if (obj.senha != obj.confSenha)
            {
                throw new Exception("Campo senha e confirmar senha não conferem!");
            }

            return(DAL_Cadastro.ValidarCadastro(obj));
        }
コード例 #3
0
 public static DTO_Usuario BuscarUsuario(string cpf)
 {
     if (string.IsNullOrWhiteSpace(cpf))
     {
         throw new Exception("Campo CPF Vazio");
     }
     try
     {
         Convert.ToInt64(cpf);
     }
     catch
     {
         throw new Exception("CPF deve ser numérico!");
     }
     if (cpf.Length != 11)
     {
         throw new Exception("CPF deve ter 13 digitos!");
     }
     return(DAL_Cadastro.BuscarUsuario(cpf));
 }
コード例 #4
0
ファイル: BLL_Cadastro.cs プロジェクト: Nathan985/Project_DS
        public static string ValidCad(DTO_Cadastro objCad)
        {
            if (string.IsNullOrWhiteSpace(objCad.nome))
            {
                throw new Exception("Campo nome vazio!");
            }
            if (string.IsNullOrWhiteSpace(objCad.email))
            {
                throw new Exception("Campo email vazio!");
            }
            if (string.IsNullOrWhiteSpace(objCad.cpf))
            {
                throw new Exception("Campo cpf vazio!");
            }
            if (objCad.cpf.Length != 11)
            {
                throw new Exception("Campo cpf invalido!");
            }
            if (string.IsNullOrWhiteSpace(objCad.pass))
            {
                throw new Exception("Campo senha vazio!");
            }
            if (objCad.pass.Length < 8)
            {
                throw new Exception("A senha deve conter 8 caracteres!");
            }
            if (string.IsNullOrWhiteSpace(objCad.cnfPass))
            {
                throw new Exception("Campo confirmar senha vazio!");
            }
            if (objCad.pass != objCad.cnfPass)
            {
                throw new Exception("Senhas não são iguais!");
            }
            Conexao.Conectar();

            DAL_Cadastro.CadastroPessoa(objCad);

            return("Sucesso");
        }
コード例 #5
0
        public static string CadUsuario(DTO_Usuario obj)
        {
            if (string.IsNullOrWhiteSpace(obj.Nome))
            {
                throw new Exception("Campo Nome Vazio!");
            }
            if (string.IsNullOrWhiteSpace(obj.UserName))
            {
                throw new Exception("Campo UserName Vazio!");
            }
            if (string.IsNullOrWhiteSpace(obj.Email))
            {
                throw new Exception("Campo Email Vazio!");
            }
            if (string.IsNullOrWhiteSpace(obj.CPF))
            {
                throw new Exception("Campo CPF Vazio");
            }
            if (obj.CPF.Length != 11)
            {
                throw new Exception("Campo CPF precisa conter 11 caracteres!");
            }
            try
            {
                Int64.Parse(obj.CPF);
            }
            catch
            {
                throw new Exception("CPF deve ser numérico!");
            }
            if (string.IsNullOrWhiteSpace(obj.RG))
            {
                throw new Exception("Digite o numero dp RG!");
            }
            if (string.IsNullOrWhiteSpace(obj.DataNascimento))
            {
                throw new Exception("Digite a sua Data de Nascimento!");
            }
            if (obj.TelFixo != "")
            {
                if (obj.TelFixo.Length < 10)
                {
                    throw new Exception("Numero de telefone fixo inválido!");
                }
            }
            if (string.IsNullOrWhiteSpace(obj.TelCelular))
            {
                throw new Exception("Preencha o número do seu telefone celular!");
            }
            if (obj.TelCelular.Length < 11)
            {
                throw new Exception("Numero de telefone celular inválido!");
            }
            if (string.IsNullOrWhiteSpace(obj.Tipo))
            {
                throw new Exception("Selecione o cargo do funcionário!");
            }
            if (string.IsNullOrWhiteSpace(obj.Endereco))
            {
                throw new Exception("Digite seu endereço!");
            }
            if (string.IsNullOrWhiteSpace(obj.Numero))
            {
                throw new Exception("Digite o número do imóvel!");
            }
            if (string.IsNullOrWhiteSpace(obj.Bairro))
            {
                throw new Exception("Digite o bairro!");
            }
            if (string.IsNullOrWhiteSpace(obj.Cidade))
            {
                throw new Exception("Digite a cidade!");
            }
            if (string.IsNullOrWhiteSpace(obj.Estado))
            {
                throw new Exception("Selecione o estado!");
            }
            if (string.IsNullOrWhiteSpace(obj.CEP))
            {
                throw new Exception("Preencha o número do CEP!");
            }
            if (obj.CEP.Length < 8)
            {
                throw new Exception("Numero de CEP inválido!");
            }
            if (string.IsNullOrWhiteSpace(obj.Sexo))
            {
                throw new Exception("Selecione o sexo do funcionário!");
            }
            if (string.IsNullOrWhiteSpace(obj.Ativo))
            {
                throw new Exception("Selecione entre ativo ou inativo!");
            }
            if (string.IsNullOrWhiteSpace(obj.Senha))
            {
                throw new Exception("Campo Senha Vazio!");
            }
            if (string.IsNullOrWhiteSpace(obj.ConfSenha))
            {
                throw new Exception("Campo Confirme sua senha");
            }
            if (obj.Senha == obj.ConfSenha)
            {
            }
            else
            {
                throw new Exception("senha diferente");
            }
            switch (obj.AcaoUsuario)
            {
            case "cadastro":
                return(DAL_Cadastro.CadFuncionario(obj));

            //break;
            case "alteracao":
                return(DAL_Cadastro.AlterarFuncionario(obj));

            default:
                throw new Exception("algo errado aconteceu!");
            }
        }