static void Main(string[] args)
        {
            int  ingreso;
            int  i    = 0;
            int  acum = 0;
            bool validacion;
            char pregunta;
            bool respuesta = true;

            do
            {
                Console.WriteLine("Ingrese el numero {0}:", i);
                int.TryParse(Console.ReadLine(), out ingreso);
                if ((validacion = ValidarNumero.ValidarInt(ingreso, 0, 10000)))
                {
                    acum += ingreso;
                    Console.WriteLine("Desea seguir ingresando numeros (s/n)?");
                    pregunta = Console.ReadKey().KeyChar;
                    Console.WriteLine();
                    respuesta = ValidarRespuesta.ValidaS_N(pregunta);
                    i++;
                }
                else
                {
                    Console.WriteLine("ERROR. ¡Reingresar número >= a 0y <= que 10000");
                }
            } while (validacion == true && respuesta == true);
            Console.WriteLine("El resultado de la suma es {0}", acum);
            Console.ReadKey();
        }
Exemple #2
0
        public void SalvarFolha(FolhaPgmtDTO dto)
        {
            ValidarNumero regexNum = new ValidarNumero();

            regexNum.ValidarDinheiro(dto.vl_SalarioBruto.ToString());

            int dM = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);

            if (dto.ds_Cargo == string.Empty)
            {
                throw new ArgumentException("O cargo não pode ser nulo.");
            }

            if (dto.ds_DiasTrabalhados > dM)
            {
                throw new ArgumentException("Impossivél trabalhar essa quantidade de dias no mês decorrente!");
            }

            FolhaPgmtDatabase db = new FolhaPgmtDatabase();
            int idFolha          = db.SalvarFolha(dto);

            Folha_Pgmt   calcular = new Folha_Pgmt();
            FolhaPgmtDTO folha    = calcular.Folha(idFolha.ToString(), dto);

            dto.id_Folha_Pgmt = idFolha;
            db.AlterarFolha(dto);
        }
        public int AlterarFuncionario(FuncionarioDTO dto)
        {
            ValidarNumero regexNum = new ValidarNumero();
            ValidarTexto  regexTxt = new ValidarTexto();

            regexTxt.ValidarEmail(dto.ds_Email);
            regexTxt.ValidarNome(dto.nm_NomeFunc);
            regexNum.ValidarTelefoneFixo(dto.num_Telefone);
            regexNum.ValidarTelefoneCelular(dto.num_Celular);

            Email email = new Email();

            email.Validar(dto.ds_Email, dto.nm_NomeFunc);

            CPF validar = new CPF();

            validar.ValidarCPF(dto.ds_CPF);

            decimal idade = DateTime.Now.Year - dto.dt_Nasc.Year;

            if (idade < 18)
            {
                throw new ArgumentException("Não é possível cadastrar funcionários menores de 18 anos.");
            }

            if (dto.ds_Logradouro == string.Empty)
            {
                throw new ArgumentException("Logradouro não pode ser nulo.");
            }

            if (dto.ds_Bairro == string.Empty)
            {
                throw new ArgumentException("Bairro não pode ser nulo.");
            }

            if (dto.ds_UF == string.Empty)
            {
                throw new ArgumentException("UF não pode ser nula.");
            }

            if (dto.num_Residencia == string.Empty)
            {
                throw new ArgumentException("Número de residencia não pode ser nulo.");
            }

            DESCripto cripto = new DESCripto();

            dto.nm_NomeFunc  = cripto.Criptografar(Program.chave, dto.nm_NomeFunc);
            dto.ds_CPF       = cripto.Criptografar(Program.chave, dto.ds_CPF);
            dto.num_Celular  = cripto.Criptografar(Program.chave, dto.num_Celular);
            dto.num_Telefone = cripto.Criptografar(Program.chave, dto.num_Telefone);
            dto.ds_Email     = cripto.Criptografar(Program.chave, dto.ds_Email);

            FuncionarioDatabase db = new FuncionarioDatabase();

            return(db.AlterarFuncionario(dto));
        }
        public int CadastrarCliente(ClientesDTO dto)
        {
            if (dto.ds_Bairro == string.Empty)
            {
                throw new ArgumentException("Bairro não pode estar vazio.");
            }

            if (dto.ds_Logradouro == string.Empty)
            {
                throw new ArgumentException("Logradouro não pode estar vazio.");
            }

            if (dto.ds_UF == string.Empty)
            {
                throw new ArgumentException("UF não pode estar vazio.");
            }

            if (dto.ds_CEP == string.Empty)
            {
                throw new ArgumentException("CEP não pode estar vazio.");
            }

            ValidarNumero regexNum = new ValidarNumero();
            ValidarTexto  regexTxt = new ValidarTexto();

            regexTxt.ValidarEmail(dto.ds_Email);
            regexTxt.ValidarNome(dto.nm_Nome);
            regexNum.ValidarTelefoneFixo(dto.num_Telefone);
            regexNum.ValidarTelefoneCelular(dto.num_Celular);

            CPF validar = new CPF();

            validar.ValidarCPF(dto.ds_CPF);

            DESCripto cripto = new DESCripto();

            dto.nm_Nome      = cripto.Criptografar(Program.chave, dto.nm_Nome);
            dto.ds_CPF       = cripto.Criptografar(Program.chave, dto.ds_CPF);
            dto.num_Celular  = cripto.Criptografar(Program.chave, dto.num_Celular);
            dto.num_Telefone = cripto.Criptografar(Program.chave, dto.num_Telefone);
            dto.ds_Email     = cripto.Criptografar(Program.chave, dto.ds_Email);

            ClientesDatabase db = new ClientesDatabase();
            int idCliente       = db.CadastrarCliente(dto);

            if (idCliente == 0)
            {
                throw new ArgumentException("O cliente não foi cadastrado com sucesso!");
            }

            return(idCliente);
        }
 private void TxtValor_Leave(object sender, EventArgs e)
 {
     try
     {
         validarNumero = new ValidarNumero();
         TxtNota.Text  = validarNumero.Zero(TxtNota.Text);
         TxtNota.Text  = validarNumero.Formatar(TxtNota.Text);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        public int CadastroNovoEmprestimo(tb_emprestimo dto, tb_locatario professor)
        {
            try
            {
                DateTime ontem = DateTime.Today;
                ontem = ontem.AddDays(-1);
                if (dto.dt_devolucao.Day - DateTime.Today.Day < 0)
                {
                    throw new ArgumentException("Impossivel devolver um livro ontem!");
                }

                ValidarTexto val = new ValidarTexto();
                val.ValidarEmail(professor.ds_email);
                val.ValidarNome(dto.nm_funcionario);
                val.ValidarNome(professor.nm_locatario);

                ValidarNumero valN = new ValidarNumero();
                valN.ValidarTelefoneCelular(professor.nu_celular);

                AzureBiblioteca db   = new AzureBiblioteca();
                tb_locatario    data = db.tb_locatario.Where(x => x.nu_cpf == professor.nu_cpf).ToList().Single();

                if (data.nm_locatario != null)
                {
                    dto.tb_locatario_id_locatario = data.id_locatario;
                    return(EmprestimoDB.CadastroNovoEmprestimo(dto));
                }

                return(0);
            }
            catch (ArgumentException ex)
            {
                System.Windows.Forms.MessageBox.Show($"{ex.Message}", "Biblioteca",
                                                     MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (Exception)
            {
                AzureBiblioteca db = new AzureBiblioteca();
                int             id;

                db.tb_locatario.Add(professor);
                id = db.SaveChanges();

                dto.tb_locatario_id_locatario = id;

                return(EmprestimoDB.CadastroNovoEmprestimo(dto));
            }

            return(0);
        }
Exemple #7
0
        public int AlterarUsuario(UsuarioDTO dto)
        {
            ValidarNumero regex = new ValidarNumero();

            regex.ValidarSenha(dto.ds_Senha);

            DESCripto cripto = new DESCripto();

            dto.ds_Senha = cripto.Criptografar(Program.chave, dto.ds_Senha);

            UsuarioDatabase db = new UsuarioDatabase();

            return(db.AlterarUsuario(dto));
        }
 private void TxtValor_TextChanged(object sender, EventArgs e)
 {
     validarNumero = new ValidarNumero();
     try
     {
         TxtNota.Text = validarNumero.Validar(TxtNota.Text);
         TxtNota.Select(TxtNota.Text.Length, 0);
         if (TxtNota.Text != "")
         {
             decimal valor = decimal.Parse(TxtNota.Text);
             if (valor > 100)
             {
                 TxtNota.Text = "";
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        static void Main(string[] args)
        {
            int   ingreso;
            int   max  = int.MinValue;
            int   min  = int.MaxValue;
            int   i    = 0;
            int   acum = 0;
            float promedio;
            bool  resultado;

            do
            {
                Console.WriteLine("Ingrese el numero {0}:", i);
                int.TryParse(Console.ReadLine(), out ingreso);
                if ((resultado = ValidarNumero.ValidarInt(ingreso, -100, 100)))
                {
                    if (i == 0 || ingreso > max)
                    {
                        max = ingreso;
                    }
                    if (i == 0 || ingreso < min)
                    {
                        min = ingreso;
                    }
                    acum += ingreso;
                    i++;
                }
                else
                {
                    Console.WriteLine("ERROR. ¡Reingresar número >= a -100 y <= que 100");
                }
            }while (i < 10 || resultado == false);

            promedio = (float)acum / i;
            Console.WriteLine("El maximo es {0}, el minimo es {1} y el promedio es {2}", max, min, promedio);
            Console.ReadKey();
        }
Exemple #10
0
 private void TxtValor_Leave(object sender, EventArgs e)
 {
     validarNumero = new ValidarNumero();
     TxtValor.Text = validarNumero.Zero(TxtValor.Text);
     TxtValor.Text = validarNumero.Formatar(TxtValor.Text);
 }
Exemple #11
0
 private void TxtValor_TextChanged(object sender, EventArgs e)
 {
     validarNumero = new ValidarNumero();
     TxtValor.Text = validarNumero.Validar(TxtValor.Text);
     TxtValor.Select(TxtValor.Text.Length, 0);
 }
 private void TxtValor_LostFocus(object sender, RoutedEventArgs e)
 {
     validarNumero = new ValidarNumero();
     TxtValor.Text = validarNumero.Zero(TxtValor.Text);
     TxtValor.Text = validarNumero.Formatar(TxtValor.Text);
 }