コード例 #1
0
        public void Alterar(FornecedorDTO forncedor)
        {
            //=========================NOME==============================

            string nome = forncedor.Nome;

            nome = nome.Trim();
            int qtdNome = nome.Count();

            if (qtdNome > 200)
            {
                throw new ValidacaoException("Nome do fornecedor não pode passar de 200 caracteres.");
            }
            else if (qtdNome == 0)
            {
                throw new ValidacaoException("Nome do fornecedor não pode ser nulo.");
            }

            //=========================Email==============================

            string email = forncedor.Email;

            email = email.Trim();
            int qtdEmail = email.Count();

            if (qtdEmail > 100)
            {
                throw new ValidacaoException("Email não pode passar de 100 caracteres.");
            }
            else if (qtdEmail == 0)
            {
                throw new ValidacaoException("Email é obrigatório.");
            }

            Validacoes.ValidarEmail validacaoEmail = new Validacoes.ValidarEmail();
            bool e = validacaoEmail.VerificarEmail(email);

            if (e == false)
            {
                throw new ValidacaoException("Email inválido.");
            }

            //=========================CNPJ==============================

            string cnpj = forncedor.CNPJ;

            Validacoes.ValidarCPF_CNPJ validCnpj = new Validacoes.ValidarCPF_CNPJ();
            bool c = validCnpj.VerificaCpfCnpj(cnpj);

            if (cnpj == "  .   .   /    -")
            {
                throw new ValidacaoException("CNPJ é obrigatório.");
            }
            else if (c == false)
            {
                throw new ValidacaoException("CNPJ inválido.");
            }

            //=========================TELEFONE==============================

            string telefone = forncedor.Telefone;

            Validacoes.ValidarTelefone validTelefone = new Validacoes.ValidarTelefone();
            bool t = validTelefone.VerificarTelefone(telefone);

            if (t == false)
            {
                throw new ValidacaoException("Telefone inválido");
            }

            // ============================ CIDADE =============================

            string cidade = forncedor.Cidade;

            cidade = cidade.Trim();
            int qtdCidade = cidade.Count();

            if (qtdCidade > 50)
            {
                throw new ValidacaoException("O campo 'Cidade' não pode possuir mais de 50 caracteres.");
            }
            else if (qtdCidade == 0)
            {
                throw new ValidacaoException("O campo 'Cidade' é obrigatório.");
            }

            // ============================ RUA ===============================

            string rua = forncedor.Rua;

            rua = rua.Trim();
            int qtdRua = rua.Count();

            if (qtdRua > 200)
            {
                throw new ValidacaoException("O campo 'Rua' não pode possuir mais de 200 caracteres.");
            }
            else if (qtdRua == 0)
            {
                throw new ValidacaoException("O campo 'Rua' é obrigatório.");
            }


            FornecedorDataBase DB = new FornecedorDataBase();

            DB.Alterar(forncedor);
        }
コード例 #2
0
ファイル: ClienteBusiness.cs プロジェクト: JVNeiva/SIGMA
        public void Alterar(ClienteDTO dto)
        {
            ClienteDatabase db = new ClienteDatabase();


            //NOME
            if (dto.Nome == string.Empty)
            {
                throw new Exception("O campo 'Nome' é obrigatório.");
            }

            //RG
            if (dto.RG == "  ,   ,   -")
            {
                throw new Exception("O campo 'RG' é obrigatório.");
            }

            //Nascimento
            if (dto.Nascimento == "  /  /")
            {
                throw new Exception("O campo 'Nascimento' é obrigatório.");
            }

            //CPF
            if (dto.CPF == "   ,   ,   -")
            {
                throw new Exception("O campo 'CPF' é obrigatório.");
            }

            if (dto.CPF == "000,000,000-00" || dto.CPF == "111,111,111-11" || dto.CPF == "222,222,222-22" ||
                dto.CPF == "333,333,333-33" || dto.CPF == "444,444,444-44" || dto.CPF == "555,555,555-55" ||
                dto.CPF == "666,666,666-66" || dto.CPF == "777,777,777-77" || dto.CPF == "888,888,888-88" ||
                dto.CPF == "999,999,999-99" || dto.CPF == "123,456,789-10" || dto.CPF == "121,212,121-21")
            {
                throw new Exception("CPF Inválido.");
            }


            //TELEFONE
            Validacoes.ValidarTelefone telefone = new Validacoes.ValidarTelefone();

            if (dto.Telefone == string.Empty)
            {
                throw new Exception("O campo 'Telefone' é obrigatório.");
            }
            bool validTell = telefone.VerificarTelefone(dto.Telefone);

            if (validTell == false)
            {
                throw new Exception("Telefone inválido.");
            }

            //EMAIL
            Validacoes.ValidarEmail email = new Validacoes.ValidarEmail();
            if (dto.Email == string.Empty)
            {
                throw new Exception("O campo 'E-mail' é obrigatório.");
            }
            bool ValidEmail = email.VerificarEmail(dto.Email);

            if (ValidEmail == false)
            {
                throw new Exception("Email inválido.");
            }

            //CIDADE
            if (dto.Cidade == string.Empty)
            {
                throw new Exception("O campo 'Cidade' é obrigatório.");
            }

            //ESTADO
            Validacoes.ValidarUF estado = new Validacoes.ValidarUF();
            if (dto.Estado == string.Empty)
            {
                throw new Exception("O campo 'Estado' é obrigatório.");
            }
            bool ValidUf = estado.VerificarUf(dto.Estado);

            if (ValidUf == false)
            {
                throw new Exception("Estado inválido.");
            }

            //BAIRRO
            if (dto.Bairro == string.Empty)
            {
                throw new Exception("O campo 'Bairro' é obrigatório.");
            }


            db.Alterar(dto);
        }
コード例 #3
0
ファイル: ClienteBusiness.cs プロジェクト: JVNeiva/SIGMA
        public int Salvar(ClienteDTO dto)
        {
            ClienteDatabase database = new ClienteDatabase();

            //NOME
            if (dto.Nome == string.Empty)
            {
                throw new Exception("O campo 'Nome' é obrigatório.");
            }

            //RG
            if (dto.RG == "  ,   ,   -")
            {
                throw new Exception("O campo 'RG' é obrigatório.");
            }

            //Nascimento
            if (dto.Nascimento == "  /  /")
            {
                throw new Exception("O campo 'Nascimento' é obrigatório.");
            }

            Validacoes.ValidarData data = new Validacoes.ValidarData();
            bool validData = data.validaData(dto.Nascimento);

            if (validData == false)
            {
                throw new Exception("Nascimento inválido.");
            }

            if (validData == true)
            {
                DateTime agora = DateTime.Now;
                int      ano   = agora.Year;


                DateTime nasc    = Convert.ToDateTime(dto.Nascimento);
                int      anoNasc = nasc.Year;

                string agoraTexto = Convert.ToString(agora);
                string nascTexto  = Convert.ToString(nasc);

                int ResAnos = ano - anoNasc;

                if (ResAnos > 150)
                {
                    throw new Exception("A data informada é inválida.");
                }

                if (anoNasc > ano)
                {
                    throw new Exception("A data informada é inválida.");
                }

                if (agoraTexto == nascTexto)
                {
                    throw new Exception("A data informada é inválida.");
                }
            }

            //CPF
            if (dto.CPF == "   ,   ,   -")
            {
                throw new Exception("O campo 'CPF' é obrigatório.");
            }

            Validacoes.ValidarCPF cpf = new Validacoes.ValidarCPF();
            bool validouCpf           = cpf.VerificarCpf(dto.CPF);

            if (validouCpf == false)
            {
                throw new Exception("CPF inválido.");
            }


            //TELEFONE
            Validacoes.ValidarTelefone telefone = new Validacoes.ValidarTelefone();

            if (dto.Telefone == string.Empty)
            {
                throw new Exception("O campo 'Telefone' é obrigatório.");
            }
            bool validTell = telefone.VerificarTelefone(dto.Telefone);

            if (validTell == false)
            {
                throw new Exception("Telefone inválido.");
            }

            //EMAIL
            Validacoes.ValidarEmail email = new Validacoes.ValidarEmail();
            if (dto.Email == string.Empty)
            {
                throw new Exception("O campo 'E-mail' é obrigatório.");
            }
            bool ValidEmail = email.VerificarEmail(dto.Email);

            if (ValidEmail == false)
            {
                throw new Exception("Email inválido.");
            }

            //CIDADE
            if (dto.Cidade == string.Empty)
            {
                throw new Exception("O campo 'Cidade' é obrigatório.");
            }

            //ESTADO
            Validacoes.ValidarUF estado = new Validacoes.ValidarUF();
            if (dto.Estado == string.Empty)
            {
                throw new Exception("O campo 'Estado' é obrigatório.");
            }
            bool ValidUf = estado.VerificarUf(dto.Estado);

            if (ValidUf == false)
            {
                throw new Exception("Estado inválido.");
            }

            //BAIRRO
            if (dto.Bairro == string.Empty)
            {
                throw new Exception("O campo 'Bairro' é obrigatório.");
            }


            return(database.Salvar(dto));
        }
コード例 #4
0
ファイル: FuncionarioBusiness.cs プロジェクト: JVNeiva/SIGMA
        public void Alterar(FuncionarioDTO dto)
        {
            FuncionarioDatabase fornecedorDB = new FuncionarioDatabase();

            if (dto.Nome == string.Empty)
            {
                throw new Exception("O campo 'Nome' é obrigatório.");
            }

            //RG
            if (dto.RG == "  ,   ,   -")
            {
                throw new Exception("O campo 'CPF' é obrigatório.");
            }

            //Nascimento
            if (dto.Nascimento == "  /  /")
            {
                throw new Exception("O campo 'Nascimento' é obrigatório.");
            }

            //CPF
            if (dto.CPF == "   ,   ,   -")
            {
                throw new Exception("O campo 'CPF' é obrigatório.");
            }

            if (dto.CPF == "000,000,000-00" || dto.CPF == "111,111,111-11" || dto.CPF == "222,222,222-22" ||
                dto.CPF == "333,333,333-33" || dto.CPF == "444,444,444-44" || dto.CPF == "555,555,555-55" ||
                dto.CPF == "666,666,666-66" || dto.CPF == "777,777,777-77" || dto.CPF == "888,888,888-88" ||
                dto.CPF == "999,999,999-99" || dto.CPF == "123,456,789-10" || dto.CPF == "121,212,121-21")
            {
                throw new Exception("CPF Inválido.");
            }

            //TELEFONE
            Validacoes.ValidarTelefone telefone = new Validacoes.ValidarTelefone();

            if (dto.Telefone == string.Empty)
            {
                throw new Exception("O campo 'Telefone' é obrigatório.");
            }
            bool validTell = telefone.VerificarTelefone(dto.Telefone);

            if (validTell == false)
            {
                throw new Exception("Telefone inválido.");
            }


            //EMAIL
            Validacoes.ValidarEmail email = new Validacoes.ValidarEmail();
            bool valiemail = email.VerificarEmail(dto.Email);

            if (dto.Email == string.Empty)
            {
                throw new Exception("O campo 'E-mail' é obrigatório.");
            }

            if (valiemail == false)
            {
                throw new Exception("Email inválido.");
            }


            if (dto.Cidade == string.Empty)
            {
                throw new Exception("O campo 'Cidade' é obrigatório.");
            }

            //ESTADO
            Validacoes.ValidarUF uf = new Validacoes.ValidarUF();
            bool validar            = uf.VerificarUf(dto.Estado);

            if (dto.Estado == string.Empty)
            {
                throw new Exception("O campo 'Estado' é obrigatório.");
            }

            if (validar == false)
            {
                throw new Exception("Cidade inválida.");
            }


            if (dto.Bairro == string.Empty)
            {
                throw new Exception("O campo 'Bairro' é obrigatório.");
            }

            if (dto.Rua == string.Empty)
            {
                throw new Exception("O campo 'Rua' é obrigatório.");
            }


            //CEP
            if (dto.CEP == "     -")
            {
                throw new Exception("O campo 'CEP' é obrigatório.");
            }

            fornecedorDB.Alterar(dto);
        }
コード例 #5
0
ファイル: FuncionarioBusiness.cs プロジェクト: JVNeiva/SIGMA
        public int Salvar(FuncionarioDTO dto)
        {
            FuncionarioDatabase database = new FuncionarioDatabase();

            if (dto.Nome == string.Empty)
            {
                throw new Exception("O campo 'Nome' é obrigatório.");
            }

            //RG
            if (dto.RG == "  ,   ,   -")
            {
                throw new Exception("O campo 'CPF' é obrigatório.");
            }

            //Nascimento
            if (dto.Nascimento == "  /  /")
            {
                throw new Exception("O campo 'Nascimento' é obrigatório.");
            }

            //CPF
            if (dto.CPF == "   ,   ,   -")
            {
                throw new Exception("O campo 'CPF' é obrigatório.");
            }

            Validacoes.ValidarCPF cpf = new Validacoes.ValidarCPF();
            bool validouCpf           = cpf.VerificarCpf(dto.CPF);

            if (validouCpf == false)
            {
                throw new Exception("CPF inválido.");
            }


            //TELEFONE
            Validacoes.ValidarTelefone telefone = new Validacoes.ValidarTelefone();

            if (dto.Telefone == string.Empty)
            {
                throw new Exception("O campo 'Telefone' é obrigatório.");
            }
            bool validTell = telefone.VerificarTelefone(dto.Telefone);

            if (validTell == false)
            {
                throw new Exception("Telefone inválido.");
            }


            //EMAIL
            Validacoes.ValidarEmail email = new Validacoes.ValidarEmail();
            bool valiemail = email.VerificarEmail(dto.Email);

            if (dto.Email == string.Empty)
            {
                throw new Exception("O campo 'E-mail' é obrigatório.");
            }

            if (valiemail == false)
            {
                throw new Exception("Email inválido.");
            }


            if (dto.Cidade == string.Empty)
            {
                throw new Exception("O campo 'Cidade' é obrigatório.");
            }

            //ESTADO
            Validacoes.ValidarUF uf = new Validacoes.ValidarUF();
            bool validar            = uf.VerificarUf(dto.Estado);

            if (dto.Estado == string.Empty)
            {
                throw new Exception("O campo 'Estado' é obrigatório.");
            }

            if (validar == false)
            {
                throw new Exception("Cidade inválida.");
            }


            if (dto.Bairro == string.Empty)
            {
                throw new Exception("O campo 'Bairro' é obrigatório.");
            }

            if (dto.Rua == string.Empty)
            {
                throw new Exception("O campo 'Rua' é obrigatório.");
            }


            //CEP
            if (dto.CEP == "     -")
            {
                throw new Exception("O campo 'CEP' é obrigatório.");
            }

            return(database.Salvar(dto));
        }
コード例 #6
0
        public void Alterar(ClienteDTO cliente)
        {
            //=-=-=-=-----=-=-=--=-=-=-NOME-==--=-=-=-=-=-=-=-=-=-=-=-=
            string nome = cliente.Nome;

            nome = nome.Trim();
            int qtdNome = nome.Count();

            if (qtdNome > 100)
            {
                throw new ValidacaoException("O nome do cliente não pode passar de 100 caracteres.");
            }
            else if (qtdNome == 0)
            {
                throw new ValidacaoException("O nome do cliente é obrigatório.");
            }

            //-----------------------EMAIL--------------------------
            string email = cliente.Email;

            email = email.Trim();
            int qtdEmail = email.Count();

            if (qtdEmail > 100)
            {
                throw new ValidacaoException("Este Email é muito grande.\nO limite é 100 caracteres. ");
            }
            else if (qtdEmail == 0)
            {
                throw new ValidacaoException("Email é obrigatório.");
            }

            Validacoes.ValidarEmail ValidarEmail = new Validacoes.ValidarEmail();
            bool e = ValidarEmail.VerificarEmail(email);

            if (e == false)
            {
                throw new ValidacaoException("Email inválido.");
            }

            //-------------------------RG----------------------------
            string rg = cliente.Rg;

            if (rg == "  ,   ,   -")
            {
                throw new ValidacaoException("RG é obrigatório.");
            }

            //------------------------CPF-------------------------
            string cpf = cliente.Cpf;

            if (cpf == "   ,   ,   -")
            {
                throw new ValidacaoException("CPF é obrigatório.");
            }

            //-------------------CIDADE----------------------------
            string cidade = cliente.Cidade;

            cidade = cidade.Trim();
            int qtdCidade = cidade.Count();

            if (qtdCidade > 50)
            {
                throw new ValidacaoException("Cidade não pode passar de 50 caracteres.");
            }
            else if (qtdCidade == 0)
            {
                throw new ValidacaoException("Cidade é obrigatória.");
            }

            //------------------RUA---------------------------------
            string rua = cliente.Rua;

            rua = rua.Trim();
            int qtdRua = rua.Count();

            if (qtdRua > 150)
            {
                throw new ValidacaoException("Rua não pode passar de 150 caracteres");
            }
            else if (qtdRua == 0)
            {
                throw new ValidacaoException("Rua é obrigatório.");
            }

            //--------------------TELEFONE---------------------------
            string telefone = cliente.Telefone;

            Validacoes.ValidarTelefone validarTell = new Validacoes.ValidarTelefone();
            bool t = validarTell.VerificarTelefone(telefone);

            if (t == false)
            {
                throw new ValidacaoException("Telefone incorreto.");
            }

            //--------------------NASCIMENTO--------------------------

            if (cliente.DataNascimento == "  /  /")
            {
                throw new ValidacaoException("Nascimento é obrigatório.");
            }

            Validacoes.ValidarData data = new Validacoes.ValidarData();
            bool validData = data.validaData(cliente.DataNascimento);

            if (validData == false)
            {
                throw new ValidacaoException("Nascimento inválido.");
            }

            if (validData == true)
            {
                DateTime agora = DateTime.Now;
                int      ano   = agora.Year;

                DateTime nasc    = Convert.ToDateTime(cliente.DataNascimento);
                int      anoNasc = nasc.Year;

                string agoraTexto = Convert.ToString(agora);
                string nascTexto  = Convert.ToString(nasc);

                int ResAnos = ano - anoNasc;

                if (ResAnos > 150)
                {
                    throw new ValidacaoException("A data informada é inválida.");
                }

                if (anoNasc > ano)
                {
                    throw new ValidacaoException("A data informada é inválida.");
                }

                if (agoraTexto == nascTexto)
                {
                    throw new ValidacaoException("A data informada é inválida.");
                }
            }

            // ============================ NUMERO =============================

            string numero = cliente.Numero;

            numero = numero.Trim();
            int qtdNumero = numero.Count();

            if (qtdNumero > 6)
            {
                throw new ValidacaoException("O número informado é muito grande.");
            }


            ClienteDataBase DB = new ClienteDataBase();

            DB.Alterar(cliente);
        }