Пример #1
0
        public List<Teams> CargarEquipos(int año)
        {

            List<Teams> listaequipos;
            using (BaseballEntities contexto = new BaseballEntities())
            {                
                var equip = from equipos in contexto.Teams where equipos.yearID == año select equipos;
                listaequipos = equip.ToList();               
            }
            
            return listaequipos;
                      
        }
Пример #2
0
        public int[] CargarAños()
        {
            int[] limitesanos = new int[2];
            using (BaseballEntities contexto = new BaseballEntities())
            {                
                var anomin = (contexto.Teams.Select(año => año.yearID)).Min();
                limitesanos[0] = anomin;

                var anomax= (contexto.Teams.Select(año => año.yearID)).Max();
                limitesanos[1] = anomax;
            }
            return limitesanos;
        }
Пример #3
0
        public Master jugadorCargar (string idjugador)
        {
            Master jugador;
            using (BaseballEntities contexto = new BaseballEntities())
            {

                var varjugador = (from jugadores in contexto.Master
                           where jugadores.playerID == idjugador
                           select jugadores).First();

                jugador = (Master)varjugador;

            }
            
            return jugador;
        }
Пример #4
0
        public List<Master> CargarJugadores(string equipoID, int año)
        {
            List<Master> listajugadores;
            using (BaseballEntities contexto = new BaseballEntities())
            {
      
                var varjugadores = from apariciones in contexto.Appearances
                                   join jugadores in contexto.Master 
                                   on apariciones.playerID equals jugadores.playerID
                                   where apariciones.teamID==equipoID & apariciones.yearID==año
                                   select  jugadores;

                listajugadores = varjugadores.ToList();

            }
      
            return listajugadores;

        }
Пример #5
0
        private List<Salaries> obtenerSalarios(string idjugador)
        {
            List<Salaries> listasalarios;
            using (BaseballEntities contexto = new BaseballEntities())
            {

                var salariosvar = from salarios in contexto.Salaries
                                  where salarios.playerID == idjugador
                                  select salarios;
                listasalarios = salariosvar.ToList();

            }
            return listasalarios;
        }
Пример #6
0
        public void insertarJugador()
        {
            Master jugador = new Master();

            jugador.playerID = textBox1.Text;
            jugador.nameFirst = textBox2.Text;
            jugador.nameLast = textBox3.Text;
            jugador.nameGiven = textBox10.Text;
            jugador.birthCountry = textBox4.Text;
            jugador.birthState = textBox5.Text;
            jugador.birthCity = textBox6.Text;
            jugador.birthDay = dateTimePicker1.Value.Day;
            jugador.birthMonth = dateTimePicker1.Value.Month;
            jugador.birthYear = dateTimePicker1.Value.Year;
            

            
            using (BaseballEntities contexto = new BaseballEntities())
            {

                var varjugador = (from jugadores in contexto.Master
                                 where jugadores.playerID == jugador.playerID
                                 select jugadores).First();

                varjugador.nameFirst = jugador.nameFirst;
                varjugador.nameLast = jugador.nameLast;
                varjugador.nameGiven = jugador.nameGiven;
                varjugador.birthCity = jugador.birthCity;
                varjugador.birthCountry = jugador.birthCountry;

                contexto.SaveChanges();
               
            }
        }
Пример #7
0
        public List<string[]> desgloseSalarios(string equipoID, int año)
        {
            List<string[]> listadesglose = new List<string[]>();
            using (BaseballEntities contexto = new BaseballEntities())
            {
              
                var desglose = from salarios in contexto.Salaries
                               join jugadores in contexto.Master
                               on salarios.playerID equals jugadores.playerID
                               where salarios.teamID == equipoID & salarios.yearID == año
                               select new { nombre = jugadores.nameFirst, apellido = 
                               jugadores.nameLast, salario = salarios.salary };

                foreach(var item in desglose)
                {
                    string[] registro = new string[3];
                    registro[0] = item.nombre;
                    registro[1] = item.apellido;
                    registro[2] = item.salario.ToString();
                    listadesglose.Add(registro);
                }
            }
            return listadesglose;
        }
Пример #8
0
        private List<string[]>  historicoSalarios(string idequipo)
        {
            List<string[]> listasalarios=new List<string[]>();
            
            using (BaseballEntities contexto = new BaseballEntities())
            {

                var salariosvar = from salarios in contexto.Salaries
                                  where salarios.teamID == idequipo
                                  group salarios by salarios.yearID into g
                                  select new { ano = g.Key , suma= g.Select(suma => suma.salary).Sum()};
                int cont = 0;
                
                foreach (var item in salariosvar)
                {
                    string[] salariosx = new string[2];
                    salariosx[0] = item.ano.ToString();
                    salariosx[1] = item.suma.ToString();
                    listasalarios.Add(salariosx);
                    
                }
                                  
            }
            
            return listasalarios;


        }