private void AgregarFilaButton_Click(object sender, RoutedEventArgs e) { if (!ValidarJuego()) { return; } Juegos juego = JuegosBLL.Buscar(Convert.ToInt32(JuegoComboBox.SelectedIndex + 1)); if (juego != null) { PrestamosDetalle prd; Prestamo.Detalles.Add( prd = new PrestamosDetalle { PrestamoId = Prestamo.PrestamoId, JuegoId = JuegoComboBox.SelectedIndex + 1, Cantidad = Convert.ToInt32(CantidadTextBox.Text), Descripcion = juego.Descripcion } ); Prestamo.CantidadJuegos += prd.Cantidad; juego.Existencia -= prd.Cantidad; CantidadJuegosTextBox.Text = Prestamo.CantidadJuegos.ToString(); Cargar(); } }
public async Task LoadData(bool more) { if (SelectedIndex == -1) { return; } if (more) { ++Page; LoadedElementCount += 20; } else { Page = 1; LoadedElementCount = 20; } var orders = (JuegoOrderEnum[])Enum.GetValues(typeof(JuegoOrderEnum)); var juegoService = new Services.JuegoService(); var result = await juegoService.GetGamesOrder(Page, orders[SelectedIndex]); if (!more) { Juegos.Clear(); } AddAll(result.Results); }
//Metodo Modificar. private static bool Modificar(Entradas Entrada) { bool key = false; Contexto contexto = new Contexto(); try { Juegos juegos = JuegosBLL.Buscar(Convert.ToInt32(Entrada.JuegoId));; juegos.Existencia += Entrada.Cantidad; JuegosBLL.Modificar(juegos); contexto.Entry(Entrada).State = EntityState.Modified; key = contexto.SaveChanges() > 0; } catch (Exception) { throw; } finally { contexto.Dispose(); } return(key); }
public ActionResult MostrarJuegos(string NOMBRE, string cat, string Estudio) { TimeSpan start = new TimeSpan(DateTime.Now.Ticks); Juegos juego1 = new Juegos() { Id = 1, nombre = "Super Meat Boy", año = 2010, categoria = "Arcade", estudio = "Estudio", puntuacion = 3 }; if (NOMBRE != null) { juego1.nombre = NOMBRE; } TimeSpan stop = new TimeSpan(DateTime.Now.Ticks); string resultado = "Esto tarda " + (stop.TotalMilliseconds - start.TotalMilliseconds) + " Milisegundos"; juego1.resultadoTiempo = resultado; Process currentProcces = Process.GetCurrentProcess(); if (cat != null) { juego1.categoria = cat; } string pid = "El PID es " + currentProcces.Id.ToString(); juego1.resultadoTiempoPID = pid; if (Estudio != null) { juego1.estudio = Estudio; } return(View(juego1)); }
//el modificar detalle es para editar la existencia para restar los juegos epretado public static bool ModificarDetalle(Prestamos prestamo) { Contexto contexto = new Contexto(); bool paso = false; try { //en este parte del codigo recorro la lista del datalle //y luegos busco el id del juego que agregue y modifico la //existencia y luego llamo la bll de jueogo y lo guardo foreach (var item in prestamo.PrestamoDetalle) { Juegos juegos = JuegosBLL.Buscar(item.JuegoId); juegos.Existencia -= item.Cantidad; JuegosBLL.Modificar(juegos); } } catch (Exception) { throw; } finally { contexto.Dispose(); } return(paso); }
public ActionResult Parte1(int ID, string NOMBRE, string cat, string Estudio) { Juegos opc = opciones[ID]; TimeSpan start = new TimeSpan(DateTime.Now.Ticks); TimeSpan stop = new TimeSpan(DateTime.Now.Ticks); string resultado = "Esto tarda " + (stop.TotalMilliseconds - start.TotalMilliseconds) + " Milisegundos"; Process currentProcces = Process.GetCurrentProcess(); string pid = "El PID es " + currentProcces.Id.ToString(); opc.resultadoTiempoPID = pid; opc.resultadoTiempo = resultado; if (NOMBRE != null) { opc.nombre = NOMBRE; } else { if (cat != null) { opc.categoria = cat; } else { if (Estudio != null) { opc.estudio = Estudio; } } } return(View(opc)); }
private void Limpiar() { this.juegos = new Juegos(); this.DataContext = juegos; JuegoIdTextBox.Focus(); JuegoIdTextBox.SelectAll(); }
//Metodo Modificar. private static bool Modificar(Prestamos prestamo) { bool key = false; Contexto contexto = new Contexto(); try { foreach (var item in prestamo.PrestamoDetalle) { Juegos juegos = JuegosBLL.Buscar(item.JuegoId); juegos.Existencia -= item.Cantidad; JuegosBLL.Modificar(juegos); } contexto.Entry(prestamo).State = EntityState.Modified; key = contexto.SaveChanges() > 0; } catch (Exception) { throw; } finally { contexto.Dispose(); } return(key); }
public GamesController() { Juegos acción = new Juegos(); acción.Id = 2; acción.nombre = "Super Meat Boy"; acción.año = 2010; acción.categoria = "Arcade"; acción.estudio = "Estudio"; acción.puntuacion = 2; opciones.Add(acción); Juegos amor = new Juegos(); amor.Id = 3; amor.nombre = "Call of Duty"; amor.año = 2014; amor.categoria = "Action"; amor.estudio = "Infinity ward"; amor.puntuacion = 1; opciones.Add(amor); Juegos Terror = new Juegos(); Terror.Id = 1; Terror.nombre = "Resident Evil"; Terror.año = 2008; Terror.categoria = "Terror"; Terror.estudio = "Capcom"; Terror.puntuacion = 2; opciones.Add(Terror); }
public async Task <IActionResult> PutJuegos([FromRoute] int id, [FromBody] Juegos juegos) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != juegos.JuegosID) { return(BadRequest()); } _context.Entry(juegos).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JuegosExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void InitializeComp() { lblStatusEmp.Text = "Usuario Logueado : " + UnJugador.USUARIO; try { cargarWCF(); UnJuego = trivias.Continuar_Juego((Jugador)UnJugador); //UnJuego = Logica.FabricaLogica.GetLogicaJuego().Continuar_Juego((Jugador)UnJugador); trivias.Close(); if (UnJuego == null) { btnJugar.Enabled = false; btnJugar.BackColor = Color.Red; MessageBox.Show("Usted no tiene un Juego comenzado, vaya a Nuevo Juego"); btnRefrescar.Enabled = true; btnRefrescar.Visible = true; } else { btnJugar.Enabled = true; btnJugar.BackColor = Color.Green; btnRefrescar.Enabled = false; btnRefrescar.Visible = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public async Task <IActionResult> Edit(int id, [Bind("JuegosID,Nombre,Categoria,Descripcion,Estado,Multijugador")] Juegos juegos) { if (id != juegos.JuegosID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(juegos); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JuegosExists(juegos.JuegosID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(juegos)); }
public static void EntradaJuegos(int id, int cantidad) { Juegos juegos = Buscar(id); juegos.Existencia += cantidad; Modificar(juegos); }
//——————————————————————————————————————————————[ SumarJuegos ]—————————————————————————————————————————————— public static void SumarJuegos(int id, double cantidad) { Juegos juegos = Buscar(id); juegos.Existencia += cantidad; Modificar(juegos); }
public ActionResult DeleteConfirmed(int id) { Juegos juegos = db.Juegos.Find(id); db.Juegos.Remove(juegos); db.SaveChanges(); return(RedirectToAction("Index")); }
public void insertarJuego(Juegos juegos) { using (var db = new Mapeo()) { db.juegos.Add(juegos); db.SaveChanges(); } }
// Juegos/Delete/5 public ActionResult Delete(int id) { Juegos juegos = db.Juegos.Find(id); var torneoID = juegos.TorneoID; db.Juegos.Remove(juegos); db.SaveChanges(); return(RedirectToAction("Index", new { id = torneoID })); }
public void prueba_clase(Juegos juego) { using (var db = new Mapeo()) { Juegos juegos = db.juegos.Where(x => x.Id_juego == juego.Id_juego).First(); db.juegos.Remove(juegos); db.SaveChanges(); } }
private void JuegoIdComboBox_DropDownClosed(object sender, EventArgs e) { Juegos juego = JuegosBLL.Buscar(Convert.ToInt32(JuegoIdComboBox.SelectedValue)); if (juego == null) { return; } DescripcionLabel.Content = juego.Descripcion; }
public static bool Guardar(Juegos Juego) { if (!Existe(Juego.JuegoId)) { return(Insertar(Juego)); } else { return(Modificar(Juego)); } }
public async Task <IActionResult> Agregar_juegos([Bind("Nom_juego, Desc_juego, trailer_juego, Img_juego, pre_juego")] Juegos juegos) { if (ModelState.IsValid) { _context.Add(juegos); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Mostrar_juegos))); } return(View(juegos)); }
public async Task <IActionResult> Create([Bind("JuegosID,Nombre,Categoria,Descripcion,Estado,Multijugador")] Juegos juegos) { if (ModelState.IsValid) { _context.Add(juegos); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(juegos)); }
public ActionResult Create([Bind(Include = "JuegosID,TorneoID,EquipoLocalID,EquipoVisitanteID,FechaHoraPartido")] Juegos juegos) { if (ModelState.IsValid) { db.Juegos.Add(juegos); db.SaveChanges(); return(RedirectToAction("Index", new { id = juegos.TorneoID })); } return(View(juegos)); }
public async Task <IActionResult> PostJuegos([FromBody] Juegos juegos) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Juegos.Add(juegos); await _context.SaveChangesAsync(); return(CreatedAtAction("GetJuegos", new { id = juegos.JuegosID }, juegos)); }
private void JuegoIdComboBox_DropDownClosed(object sender, EventArgs e) { Juegos juego = JuegosBLL.Buscar(Convert.ToInt32(JuegoIdComboBox.SelectedValue)); if (juego == null) { return; } prestamo.CantidadJuegos = juego.Existencia; Cantidaddisponible.Content = prestamo.CantidadJuegos.ToString(); DescripcionJuegoLabel.Content = juego.Descripcion; }
private bool ValidarJuego() { bool paso = true; int id = Convert.ToInt32(JuegoComboBox.SelectedIndex); id = id + 1; Juegos juego = JuegosBLL.Buscar(id); if (Convert.ToInt32(JuegoComboBox.SelectedIndex + 1) <= 0) { paso = false; AgregarFilaButton.IsEnabled = false; MessageBox.Show("Debe haber almenos 1 Juego elegido", "Fallo", MessageBoxButton.OK, MessageBoxImage.Warning); CantidadTextBox.Focus(); GuardarButton.IsEnabled = true; } if (CantidadTextBox.Text.Length == 0) { paso = false; AgregarFilaButton.IsEnabled = false; MessageBox.Show("Debe Elejir una cantidad Apropiada", "Fallo", MessageBoxButton.OK, MessageBoxImage.Warning); CantidadTextBox.Focus(); GuardarButton.IsEnabled = true; } if (Convert.ToInt32(CantidadTextBox.Text) > juego.Existencia) { paso = false; AgregarFilaButton.IsEnabled = false; MessageBox.Show("La cantidad que escogio es mayor a la existente", "Fallo", MessageBoxButton.OK, MessageBoxImage.Warning); CantidadTextBox.Focus(); GuardarButton.IsEnabled = true; } if (!Regex.IsMatch(CantidadTextBox.Text, @"^[0-9]+$")) { paso = false; AgregarFilaButton.IsEnabled = false; MessageBox.Show("Debe agregar una cantidad", "Fallo", MessageBoxButton.OK, MessageBoxImage.Warning); CantidadTextBox.Focus(); GuardarButton.IsEnabled = true; } return(paso); }
// GET: AdminJuegos/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Juegos juegos = db.Juegos.Find(id); if (juegos == null) { return(HttpNotFound()); } return(View(juegos)); }
protected void GrillaJuegos_RowDeleting(object sender, GridViewDeleteEventArgs e) { GridViewRow row = GrillaJuegos.Rows[e.RowIndex]; int idJuego = Convert.ToInt32(GrillaJuegos.DataKeys[e.RowIndex].Values[0]); cdc = new ConexionLQDataContext(); Juegos j = (from a in cdc.Juegos where a.id_Juego == idJuego select a).FirstOrDefault(); j.Activo = false; cdc.SubmitChanges(); GrillaJuegos.EditIndex = -1; Mensaje("Eliminado con exito", "Se han eliminado los datos", "success"); this.llenar(); }
private void BuscarButton_Click(object sender, RoutedEventArgs e) { var jueguito = JuegosBLL.Buscar(int.Parse(JuegoIdTextBox.Text)); if (jueguito != null) { Juego = jueguito; } else { Juego = new Juegos(); } DataContext = Juego; }
protected void btn_addJuego_Click(object sender, EventArgs e) { try { Juegos juego = new Juegos(); juego.Nombre = txt_nomJuego.Text; juego.Id_categoria = ddl_catJuego.SelectedIndex + 1; new DAOjuego().insertarJuego(juego); Response.Redirect("Crud_juegos_de_mesa.aspx"); } catch (Exception ex) { return; } }
// GET: AdminJuegos/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Juegos juegos = db.Juegos.Find(id); if (juegos == null) { return(HttpNotFound()); } ViewBag.IdCategoria = new SelectList(db.Categorias, "Id", "Descripcion", juegos.IdCategoria); return(View(juegos)); }
private void Recibiendo(object sender, ReceiveCompletedEventArgs args) { try { System.Messaging.Message unMensaje = JuegosEnCola.EndReceive(args.AsyncResult); unJuego = (Juegos)unMensaje.Body; listaJuegos.Add(unJuego); JuegosEnCola.BeginReceive(new TimeSpan(1, 0, 0, 0)); } catch (Exception ex) { Response.Write("<div id=\"error\" class=\"alert alert-danger\">" + ex.Message + "</div>" + "<script type=\"text/javascript\">window.onload=function(){alertBootstrap();};</script>"); } }
private void BtnJuego_Click(object sender, EventArgs e) { try { UnJuego = new Juegos(); UnJuego.JUGADOR = (Jugador)UnJugador; cargarWCF(); //if (Logica.FabricaLogica.GetLogicaJuego().Continuar_Juego((Jugador)UnJugador) != null) if (trivias.Continuar_Juego((Jugador)UnJugador) != null) { lblError.Text = "Usted ya tiene un juego en proceso!"; } else { //List<Pregunta> listarpreguntas = Logica.FabricaLogica.GetLogicaPreguntas().ListarPreguntas(); List<Pregunta> listarpreguntas = trivias.ListarPreguntas().ToList(); var rnd = new Random(); List<Pregunta> listpreg = listarpreguntas.OrderBy(x => rnd.Next()).ToList(); List<Pregunta> result1 = (from p in listpreg where p.TIPO.ToUpper() == "GEOGRAFIA" select p).Take(3).ToList(); List<Pregunta> result2 = (from p in listpreg where p.TIPO.ToUpper() == "CIENCIAS" select p).Take(3).ToList(); List<Pregunta> result3 = (from p in listpreg where p.TIPO.ToUpper() == "DEPORTES" select p).Take(3).ToList(); List<Contestada> listarandomcontestadas = new List<Contestada>(); foreach (Pregunta preg in result3) { Contestada con = new Contestada(); con.UNA_PRE = preg; con.CORRECTA = false; listarandomcontestadas.Add(con); } foreach (Pregunta preg in result2) { Contestada con = new Contestada(); con.UNA_PRE = preg; con.CORRECTA = false; listarandomcontestadas.Add(con); } foreach (Pregunta preg in result1) { Contestada con = new Contestada(); con.UNA_PRE = preg; con.CORRECTA = false; listarandomcontestadas.Add(con); } var rndm = new Random(); UnJuego.LIST_CON = listarandomcontestadas.OrderBy(x => rndm.Next()).ToArray(); UnJuego.LIST_CON = UnJuego.LIST_CON.OrderBy(x => rndm.Next()).ToArray(); MessageQueue JuegosEnCola = new MessageQueue("FormatName:DIRECT=OS:maxi-netbook\\Private$\\ColaJuegos"); JuegosEnCola.MessageReadPropertyFilter.SetAll(); ((XmlMessageFormatter)JuegosEnCola.Formatter).TargetTypes = new Type[] { typeof(Juegos) }; System.Messaging.Message MsjSalida = new System.Messaging.Message(UnJuego); MessageQueueTransaction MsjTrans = new MessageQueueTransaction(); MsjTrans.Begin(); JuegosEnCola.Send(MsjSalida, MsjTrans); MsjTrans.Commit(); lblError.Text = "Juego en espera"; BtnJuego.Enabled = false; } trivias.Close(); } catch (Exception ex) { lblError.Text = ex.Message; } }
public frmJugar(Juegos pJuego) { InitializeComponent(); UnJuego = pJuego ; }