Ejemplo n.º 1
0
 //internal Persona(string _nombre, string _apellido, int _edad)
 //{
 //    nombre = _nombre;
 //    apellido = _apellido;
 //    edad = _edad;
 //}
 internal Persona(string _nombre, string _apellido, int _edad, Genero _genero)
 {
     nombre = _nombre;
     apellido = _apellido;
     edad = _edad;
     genero = _genero;
 }
Ejemplo n.º 2
0
        public GeneroForm()
        {
            InitializeComponent();

            errorProvider.Icon = Resources.dialogError16x16;
            errorProvider.SetIconPadding(nombreTextBox, -20);

            genero = new Genero();
            formValidator = new FormValidator(this);
            notEmptyRule = new NotEmptyValidationRule(nombreLabel.Text);
        }
Ejemplo n.º 3
0
 public Alumno(int id, string nombre, string apellido1, string apellido2,
     string email, DateTime fechaNacimiento, Genero sexo)
 {
     Id = id;
     Nombre = nombre;
     Apellido1 = apellido1;
     Apellido2 = apellido2;
     Email = email;
     FechaNacimiento = fechaNacimiento;
     Sexo = sexo;
 }
Ejemplo n.º 4
0
 public Cliente(string Nome,
                string CPF,
                string Telefone,
                string Endereco,
                Genero Genero,
                DateTime DataNascimento)
 {
     this.Nome           = Nome;
     this.CPF            = CPF;
     this.Telefone       = Telefone;
     this.Endereco       = Endereco;
     this.Genero         = Genero;
     this.DataNascimento = DataNascimento;
 }
        // GET: Genero/Edit/5
        public ActionResult Edit(Guid id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Genero genero = _generoAppService.ObterPorId(id);

            if (genero == null)
            {
                return(HttpNotFound());
            }
            return(View(genero));
        }
Ejemplo n.º 6
0
        public async Task <Genero> CargarPorId(int idGenero)
        {
            Genero generoCargado = new Genero();
            var    query         = "tokenDeAcceso=" + TokenDeAcceso + "&idGenero=" + idGenero.ToString();
            HttpResponseMessage respuesta;

            respuesta = await AdministradorDePeticionesHttp.Get("PorID?" + query.ToString());

            if (respuesta.IsSuccessStatusCode)
            {
                generoCargado = Servicios.ServicioDeConversionDeJson.ConvertJsonToClass <Genero>(respuesta.Content.ReadAsStringAsync().Result);
            }
            return(generoCargado);
        }
Ejemplo n.º 7
0
        public async Task <GeneroResponseDto> CreateAsync(GeneroRequestDto model)
        {
            var genero = new Genero(model.Nome);

            await _repo.CreateAsync(genero);

            var response = new GeneroResponseDto
            {
                Id   = genero.Id,
                Nome = genero.Nome
            };

            return(response);
        }
Ejemplo n.º 8
0
        public async Task <string> Insert(Genero genero, string token)
        {
            try
            {
                var generoSerializado = JsonConvert.SerializeObject(genero);
                var resposta          = await new RequestAPI().PostApi("Genero/Insert/", token, generoSerializado);

                return(resposta);
            }
            catch (Exception)
            {
                return("Ocorreu algum erro ao se comunicar com a base de dados!");
            }
        }
Ejemplo n.º 9
0
        // GET: Generos/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Genero genero = await db.Generos.FindAsync(id);

            if (genero == null)
            {
                return(HttpNotFound());
            }
            return(View(genero));
        }
Ejemplo n.º 10
0
        public Serie(int id, Genero genero, string titulo, string descricao, int ano)
        {
            this.Id = id;

            this.Genero = genero;

            this.Titulo = titulo;

            this.Descricao = descricao;

            this.Ano = ano;

            this.Excluido = false;
        }
        public bool existeGenero(Genero oGenero)
        {
            IList <Genero> generos = new List <Genero>();

            generos = oGeneroDAO.getAll();
            foreach (Genero a in generos)
            {
                if (oGenero.Equals(a))
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 12
0
        private static Genero crearGenero(Registro reg)
        {
            Genero gen = null;

            if (reg != null)
            {
                gen = new Genero
                {
                    Id     = int.Parse(reg.Get(0)),
                    Nombre = reg.Get(1)
                };
            }
            return(gen);
        }
Ejemplo n.º 13
0
        public static int Jubilarse(int edad, Genero genero)
        {
            int anios;

            if (genero == (Genero)0)
            {
                anios = edad - 60;
            }
            else
            {
                anios = edad - 65;
            }
            return(anios);
        }
Ejemplo n.º 14
0
        public async Task <IActionResult> Incluir(Genero genero)
        {
            try
            {
                Genero aplic = await _servico.Incluir(genero);

                MessageResultData _resultado = MessageResult.Message(Constantes.Constantes.SUCESSO, "Inclusão realizada com sucesso.", MessageTypeEnum.success);
                return(Ok(_resultado));
            }
            catch (Exception ex)
            {
                return(BadRequest(MessageResult.Mensagem(ex)));
            }
        }
Ejemplo n.º 15
0
        public bool AltaGenero(Genero genero)
        {
            DaoGenero dao             = new DaoGenero();
            int       FilasInsertadas = dao.AltaGenero(genero);

            if (FilasInsertadas == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 16
0
 public ActionResult Delete(int id, Genero genero)
 {
     try
     {
         genero = DBConfig.Instance.GeneroRepository.PrimeiroGenero(genero.Id);
         DBConfig.Instance.GeneroRepository.Excluir(genero);
         return(RedirectToAction("Index"));
     }
     catch
     {
         TempData["ErrorMessage"] = "Você tem produtos atrelado à este gênero";
         return(View(genero));
     }
 }
Ejemplo n.º 17
0
        public void Validar(Genero genero)
        {
            string errores = "";

            if (string.IsNullOrEmpty(genero.NombreGenero))
            {
                errores += "Se debe asignar el nombre del genero";
            }

            if (!string.IsNullOrEmpty(errores))
            {
                throw new Exception(errores);
            }
        }
Ejemplo n.º 18
0
        //GENERO:

        public List <Genero> GetGeneros()
        {
            var           consulta = from datos in this.tablaGeneros.AsEnumerable() select datos;
            List <Genero> generos  = new List <Genero>();

            foreach (var g in consulta)
            {
                Genero genero = new Genero();
                genero.IdGenero     = g.Field <int>("IdGenero");
                genero.GeneroNombre = g.Field <String>("Genero");
                generos.Add(genero);
            }
            return(generos);
        }
Ejemplo n.º 19
0
        private string ObtenerSexo(Genero sexo)
        {
            switch (sexo)
            {
            case Genero.Masculino:
                return("Masculino");

            case Genero.Femenino:
                return("Femenino");

            default:
                return("Masculino");
            }
        }
Ejemplo n.º 20
0
        // GET: Generos/Delete/5
        public ActionResult Delete(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Genero genero = db.Genero.Find(id);

            if (genero == null)
            {
                return(HttpNotFound());
            }
            return(View("/Views/Administrativas/Generos/Delete.cshtml", genero));
        }
Ejemplo n.º 21
0
 public ActionResult EfetuarExclusão(int id)
 {
     try
     {
         Genero genero = db.Genero.Find(id);
         db.Genero.Remove(genero);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(RedirectToAction("ErroExcluir"));
     }
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Este metodo sirve para realizar la eliminacion de generos para la base de datos, se requiere
 /// tener el genero seleccionado en la interfaz para aplicar este metodo
 /// </summary>
 private void BorrarGeneros(Genero generoCapturado)
 {
     try
     {
         //Usamos una conexion SQL para realizar lo siguiente
         using (SqlConnection conexiones = CrearConexion())
         {
             //Abrimos la conexion a la base de datos
             conexiones.Open();
             //Aplicamos una variable de transaccion SQL, para asegurarnos de que las operaciones
             //que hagan en esta seccion, los datos que se registren se queden dentro de la base de
             //datos
             using (var trans = conexiones.BeginTransaction())
             {
                 try
                 {
                     //Creamos una variable de comando SQL Server
                     using (var cmd = conexiones.CreateCommand())
                     {
                         //ponemos la transaccion en el comando
                         cmd.Transaction = trans;
                         //Hacemos la consulta para revisar generos con la clave
                         string revisionGenero = string.Format("SELECT COUNT(*) FROM Genero Where Clave_Genero = '{0}'", generoCapturado.Clave_Genero);
                         cmd.CommandText = revisionGenero;
                         Int32 conteo = Convert.ToInt32(cmd.ExecuteScalar());
                         //Se revisa el conteo para confirmar si este genero existe en la base de datos
                         if (conteo != 0)
                         {
                             //Si existe este genero, se puede borrar de la base de datos
                             string queryBorrar = string.Format("DELETE FROM Genero WHERE Nombre_Genero = '{0}' " +
                                                                "AND Clave_Genero = '{1}'", generoCapturado.Nombre_Genero, generoCapturado.Clave_Genero);
                             cmd.CommandText = queryBorrar;
                             cmd.ExecuteNonQuery();
                             MessageBox.Show("Se ha borrado el genero de la base de datos");
                         }
                     }
                     //Se aplican la transaccion dentro de la base de datos
                     trans.Commit();
                 }
                 catch (Exception ex)
                 {
                     trans.Rollback();
                 }
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
Ejemplo n.º 23
0
        public static string ValidarGenero(Genero genero)
        {
            string _retorno = "";

            genero.DtcAtualizacao = DateTime.Now;
            _retorno = genero switch
            {
                _ when genero.Descricao == "" => _retorno = "Descrição inválida.",
                              _ => ""
            };

            return(_retorno);
        }
    }
Ejemplo n.º 24
0
        public async Task <IActionResult> Edit(string id, [Bind("GeneroID,GeneroDescripcion")] Genero genero)
        {
            var validateToken = await ValidatedToken(_configuration, _getHelper, "catalogo");

            if (validateToken != null)
            {
                return(validateToken);
            }

            if (!await ValidateModulePermissions(_getHelper, moduloId, eTipoPermiso.PermisoEscritura))
            {
                return(RedirectToAction(nameof(Index)));
            }

            if (id != genero.GeneroID)
            {
                TempData["toast"] = "Identificacor incorrecto, verifique.";
                return(RedirectToAction(nameof(Index)));
            }

            TempData["toast"] = "Falta información en algún campo, verifique.";
            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(genero);
                    await _context.SaveChangesAsync();

                    TempData["toast"] = "Los datos del género fueron actualizados correctamente.";
                    await BitacoraAsync("Actualizar", genero);

                    return(RedirectToAction(nameof(Index)));
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    if (!GeneroExists(genero.GeneroID))
                    {
                        TempData["toast"] = "Registro inexistente.";
                    }
                    else
                    {
                        TempData["toast"] = "[Error] Los datos del género no fueron actualizados.";
                    }
                    string excepcion = ex.InnerException != null?ex.InnerException.Message.ToString() : ex.ToString();
                    await BitacoraAsync("Actualizar", genero, excepcion);
                }
            }

            return(View(genero));
        }
Ejemplo n.º 25
0
        // GET: Generoes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Genero genero = db.Generoes.Find(id);

            if (genero == null)
            {
                return(HttpNotFound());
            }
            return(View(genero));
        }
Ejemplo n.º 26
0
 public void Alterar(Genero genero,
                     string titulo,
                     string descricao,
                     int ano,
                     double avaliacaoImdb,
                     int classificacaoEtaria)
 {
     this.Genero              = genero;
     this.Titulo              = titulo;
     this.Descricao           = descricao;
     this.Ano                 = ano;
     this.AvaliacaoImdb       = avaliacaoImdb;
     this.ClassificacaoEtaria = classificacaoEtaria;
 }
Ejemplo n.º 27
0
        public async Task <IActionResult> Create(Genero Genero)
        {
            if (!ModelState.IsValid)
            {
                InicializarMensaje(null);
                return(View(Genero));
            }
            Response response = new Response();

            try
            {
                response = await apiServicio.InsertarAsync(Genero,
                                                           new Uri(WebApp.BaseAddress),
                                                           "api/Generos/InsertarGeneros");

                if (response.IsSuccess)
                {
                    var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                    {
                        ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                        ExceptionTrace       = null,
                        Message              = "Se ha creado un Genero",
                        UserName             = "******",
                        LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                        LogLevelShortName    = Convert.ToString(LogLevelParameter.ADV),
                        EntityID             = string.Format("{0} {1}", "Genero:", Genero.IdGenero),
                    });

                    return(RedirectToAction("Index"));
                }

                ViewData["Error"] = response.Message;
                return(View(Genero));
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                    Message              = "Creando Genero",
                    ExceptionTrace       = ex.Message,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "******"
                });

                return(BadRequest());
            }
        }
Ejemplo n.º 28
0
 public bool Editar(Genero GeneroEditar)
 {
     try
     {
         var editar = _DbContext.Genero.FirstOrDefault(x => x.Idgenero == GeneroEditar.Idgenero);
         editar.nombre     = GeneroEditar.nombre;
         editar.definicion = GeneroEditar.definicion;
         _DbContext.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 29
0
        // GET: Generos/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Genero genero = await db.Generoes.FindAsync(id);

            if (genero == null)
            {
                return(HttpNotFound());
            }
            ViewBag.FamiliaID = new SelectList(db.Familias, "ID", "Nome", genero.FamiliaID);
            return(View(genero));
        }
Ejemplo n.º 30
0
 public ActionResult SaveGenero(Genero genero)
 {
     using (BookContext bd = new BookContext())
     {
         genero.DataAlteracao     = DateTime.Now;
         genero.Genero_UsuarioCri = ((Usuario)(Session["User"])).Id;
         bd.Generos.Attach(genero);
         var entry = bd.Entry(genero);
         entry.Property(e => e.DataAlteracao).IsModified     = true;
         entry.Property(e => e.Genero_UsuarioCri).IsModified = true;
         entry.Property(e => e.Descricao).IsModified         = true;
         bd.SaveChanges();
     }
     return(EditGeneros(genero.Id));
 }
Ejemplo n.º 31
0
 public bool Existe(Genero genero)
 {
     try
     {
         _conexion   = new ConexionBd();
         repositorio = new RepositorioGeneros(_conexion.AbrirConexion());
         var existe = repositorio.Existe(genero);
         _conexion.CerrarConexion();
         return(existe);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
 /// <summary>
 /// Edita as informações de um colaborador
 /// </summary>
 /// <param name="cod">Código do colaborador a editar</param>
 /// <param name="nome">Novo nome do colaborador</param>
 /// <param name="idade">Nova idade do colaborador</param>
 /// <param name="genero">Novo género do colaborador</param>
 /// <param name="nif">Novo nif do colaborador</param>
 /// <returns> True se as informações forem editadas corretamente
 /// False se as informações não forem editadas corretamente </returns>
 public static bool EditaColaborador(int cod, string nome, int idade, Genero genero, int nif)
 {
     try
     {
         return(Colaboradores.EditaColaborador(cod, nome, idade, genero, nif));
     }
     catch (IndexOutOfRangeException x)
     {
         throw new FormatException("ERRO: " + x.Message);
     }
     catch (Exception x)
     {
         throw new Exception("ERRO: " + x.Message);
     }
 }
Ejemplo n.º 33
0
 public string Jugar()
 {
     if (Genero.ToLower() == "hembra")
     {
         return($"A jugar con su la {Mascota.TipoDeMascota} {Mascota.Nombre}");
     }
     else if (Genero.ToLower() == "macho")
     {
         return($"A jugar con su el {Mascota.TipoDeMascota} {Mascota.Nombre}");
     }
     else
     {
         return($"A jugar con {Mascota.Nombre}");
     }
 }
Ejemplo n.º 34
0
        private void onOk(object sender, EventArgs e)
        {
            if (formValidator.Validate())
            {
                try
                {
                    using (GeneroRepository repo = new GeneroRepository())
                    {
                        genero = repo.SaveNew(genero);
                    }
                }
                catch (BusinessEntityRepositoryException ex)
                {
                    MessageBox.Show(this, ex.Message + ":\n\n" + ex.InnerException.Message,
                        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    DialogResult = DialogResult.None;

                    return;
                }

                DialogResult = DialogResult.OK;
            }
        }