Example #1
0
        public bool addUsuario(int id, string apodo, string descripcion, string nombre, int edad, string correo,
                               string username, string password)
        {
            TParcialEntities2 tstDb = new TParcialEntities2();
            UsuariosCreae     uc    = new UsuariosCreae();
            Usuario           user  = new Usuario
            {
                Id_Usuario  = id,
                Apodo       = apodo,
                Descripcion = descripcion,
                Saldo       = 0,
            };
            Persona p = new Persona
            {
                Id_Persona = id,
                Nombre     = nombre,
                Edad       = edad,
                Correo     = correo,
                Username   = username,
                Password   = password
            };

            if (uc.TieneMasDeDieciOcho(p.Edad))
            {
                tstDb.Persona.Add(p);
                tstDb.Usuario.Add(user);
                tstDb.SaveChanges();
                return(true);
            }
            return(false);
        }
Example #2
0
        public void deletePersona(int idPersona)
        {
            TParcialEntities2 tstDb  = new TParcialEntities2();
            Persona           person = new Persona();

            person.Id_Persona         = idPersona;
            tstDb.Entry(person).State = System.Data.Entity.EntityState.Deleted;
            tstDb.SaveChanges();
        }
Example #3
0
        public void deleteJuego(int id)
        {
            TParcialEntities2 tstDb = new TParcialEntities2();
            Juego             guemu = new Juego();

            guemu.Id_Juego           = id;
            tstDb.Entry(guemu).State = System.Data.Entity.EntityState.Deleted;
            tstDb.SaveChanges();
        }
Example #4
0
        public void deleteUsuario(int idPersona)
        {
            TParcialEntities2 tstDb = new TParcialEntities2();
            Usuario           user  = new Usuario();

            user.Id_Usuario         = idPersona;
            tstDb.Entry(user).State = System.Data.Entity.EntityState.Deleted;
            tstDb.SaveChanges();
        }
Example #5
0
        public void DeleteJuegoID(int idjuego, int idventa)
        {
            TParcialEntities2 tstDb   = new TParcialEntities2();
            Detalle_Venta     detalle = new Detalle_Venta();

            detalle.Id_Juego           = idjuego;
            detalle.Id_Venta           = idventa;
            tstDb.Entry(detalle).State = System.Data.Entity.EntityState.Deleted;
            tstDb.SaveChanges();
        }
Example #6
0
        public bool ValidarLogIn(string User, string Password)
        {
            TParcialEntities2 tstDb = new TParcialEntities2();
            var lstPersonas         = from k in tstDb.Persona where k.Username == User select k;

            foreach (var item in lstPersonas)
            {
                if (item.Username == User && item.Password == Password)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #7
0
        public bool AgregarVenta(int Id_Venta, int ID_Usuario, DateTime fecha)
        {
            TParcialEntities2 tstdb = new TParcialEntities2();
            Venta             venta = new Venta
            {
                Id_Venta   = Id_Venta,
                Id_Usuario = ID_Usuario,
                Fecha      = fecha
            };

            tstdb.Venta.Add(venta);
            tstdb.SaveChanges();
            return(true);
        }
Example #8
0
        public List <Venta> GetVentas()
        {
            List <Venta>      lstventa = new List <Venta>();
            TParcialEntities2 tstdb    = new TParcialEntities2();
            var lst = from k in tstdb.Venta select k;

            foreach (var item in lst)
            {
                Venta v = new Venta();
                v.Id_Venta = item.Id_Venta;
                lstventa.Add(v);
            }
            return(lstventa);
        }
Example #9
0
        public void AgregarDetalle(int ID_Venta, int ID_Juego, int importe, int Cantidad)
        {
            TParcialEntities2 tstDb = new TParcialEntities2();

            Detalle_Venta DV = new Detalle_Venta
            {
                Id_Juego = ID_Juego,
                Id_Venta = ID_Venta,
                Importe  = importe,
                Cantidad = Cantidad
            };

            tstDb.Detalle_Venta.Add(DV);
            tstDb.SaveChanges();
        }
Example #10
0
        public void addJuego(int id, string Nombre, int Precio, string Descripcion)
        {
            TParcialEntities2 tstDb = new TParcialEntities2();
            string            foto  = "/Fotos/07.jpg";
            Juego             jogo  = new Juego
            {
                Id_Juego    = id,
                Nombre      = Nombre,
                Precio      = Precio,
                Descripcion = Descripcion,
                Foto        = foto
            };

            tstDb.Juego.Add(jogo);
            tstDb.SaveChanges();
        }
Example #11
0
        public Juego getJuego(int ID)
        {
            TParcialEntities2 tstDb   = new TParcialEntities2();
            Juego             Objuego = new Juego();
            var lstPersonas           = from k in tstDb.Juego where k.Id_Juego == ID select k;

            foreach (var item in lstPersonas)
            {
                Objuego.Nombre      = item.Nombre;
                Objuego.Precio      = item.Precio;
                Objuego.Descripcion = item.Descripcion;
                Objuego.Id_Juego    = item.Id_Juego;
                Objuego.Foto        = item.Foto;
            }
            return(Objuego);
        }
Example #12
0
        public List <Juego> getJuegos()
        {
            TParcialEntities2 tstDb    = new TParcialEntities2();
            List <Juego>      lstjuego = new List <Juego>();
            var lstPersonas            = from k in tstDb.Juego select k;

            foreach (var item in lstPersonas)
            {
                Juego game = new Juego();
                game.Nombre      = item.Nombre;
                game.Precio      = item.Precio;
                game.Descripcion = item.Descripcion;
                game.Id_Juego    = item.Id_Juego;
                game.Foto        = item.Foto;
                lstjuego.Add(game);
            }
            return(lstjuego);
        }
Example #13
0
        public List <Persona> getallPersonas()
        {
            TParcialEntities2 tstDb = new TParcialEntities2();
            List <Persona>    lst   = new List <Persona>();
            var lstPersonas         = from k in tstDb.Persona select k;

            foreach (var item in lstPersonas)
            {
                Persona p = new Persona();
                p.Id_Persona = item.Id_Persona;
                p.Nombre     = item.Nombre;
                p.Username   = item.Username;
                p.Correo     = item.Correo;
                p.Password   = item.Password;
                p.Edad       = item.Edad;
                lst.Add(p);
            }
            return(lst);
        }
Example #14
0
        public Persona getPersona(string User)
        {
            TParcialEntities2 tstDb = new TParcialEntities2();
            Persona           p     = new Persona();
            var lstPersonas         = from k in tstDb.Persona where k.Username == User select k;

            foreach (var item in lstPersonas)
            {
                if (item.Username == User)
                {
                    p.Id_Persona = item.Id_Persona;
                    p.Nombre     = item.Nombre;
                    p.Usuario    = item.Usuario;
                    p.Correo     = item.Correo;
                    p.Password   = item.Password;
                }
            }
            return(p);
        }
Example #15
0
        public List <Juego> getAllVentas()
        {
            List <Juego>      vtn   = new List <Juego>();
            TParcialEntities2 tstDb = new TParcialEntities2();
            var lstPersonas         = from k in tstDb.Venta
                                      join j in tstDb.Detalle_Venta
                                      on k.Id_Venta equals j.Id_Venta
                                      join l in tstDb.Juego on j.Id_Juego equals l.Id_Juego
                                      select new
            { Venta = k, Detalle_Venta = j, Juego = l };

            foreach (var item in lstPersonas)
            {
                Juego v = new Juego();
                v.Id_Juego    = item.Venta.Id_Venta;
                v.Nombre      = item.Juego.Nombre;
                v.Precio      = item.Detalle_Venta.Importe;
                v.Descripcion = item.Juego.Descripcion;
                vtn.Add(v);
            }
            return(vtn);
        }
Example #16
0
        public void AddAdmin(int id, int sueldo, string nombre, int edad, string correo,
                             string username, string password)
        {
            TParcialEntities2 tstDb = new TParcialEntities2();
            Administrador     admin = new Administrador
            {
                Sueldo   = sueldo,
                Id_Admin = id
            };
            Persona p = new Persona
            {
                Id_Persona = id,
                Nombre     = nombre,
                Edad       = edad,
                Correo     = correo,
                Username   = username,
                Password   = password
            };

            tstDb.Persona.Add(p);

            tstDb.Administrador.Add(admin);
            tstDb.SaveChanges();
        }