示例#1
0
        public static string NuevoJuego(Model.Catalogo Juego)
        {
            string resultado = "";

            using (EntityConnection con = conexion())
            {
                Model.WIZELLEntities        model    = new Model.WIZELLEntities(con);
                IQueryable <Model.Catalogo> Catalogo = model.Catalogo.Where(x => x.Titulo == Juego.Titulo && x.Consola == Juego.Consola);
                if (!Catalogo.Any())
                {
                    model.Catalogo.Add(Juego);
                }
                else
                {
                    Model.Catalogo Catalogo2 = Catalogo.First();
                    Catalogo2.Cantidad = Juego.Cantidad;
                    if (Juego.Cantidad == 0)
                    {
                        bool Estatus = Catalogo.First().Estatus;
                        Estatus = Juego.Estatus;
                    }
                }
                model.SaveChanges();
                return(resultado);
            }
        }
示例#2
0
 private void buttonGuardar_Click(object sender, EventArgs e)
 {
     Model.Catalogo Juego = new Model.Catalogo();
     if (IdJuegoSelected != 0)
     {
         Juego.IdJuego = IdJuegoSelected;
     }
     Juego.Titulo      = textBoxTitulo.Text.TrimEnd();
     Juego.Genero      = comboBoxGenero.Text;
     Juego.Consola     = comboBoxConsola.Text;
     Juego.Descripcion = textBoxDescripcion.Text.TrimEnd();
     Juego.Cantidad    = Convert.ToInt32(textBoxCantidad.Text);
     if (Juego.Cantidad > 0)
     {
         Juego.Estatus = true;
     }
     else
     {
         Juego.Estatus = false;
     }
     Juego.FechaIngreso = dateTimePickerIngreso.Value;
     Acciones.NuevoJuego(Juego);
     dataGridViewJuegos.DataSource = Acciones.Catalogo("");
     dataGridViewJuegos.Refresh();
     LimpiarCatalogo();
 }