Example #1
0
        public ActionResult Modificar(Player jugador,int year, string team)
        {
            //HttpContext.Request.Params
            ServicioEquipos.SrvEquiposClient cliente = new ServicioEquipos.SrvEquiposClient();
            cliente.RellenarJugador(jugador);

            RouteValueDictionary routeData = new RouteValueDictionary();
            routeData.Add("year", year);
            routeData.Add("team", team);
            ViewBag.error = true;
            //return RedirectToAction("Index", "Equipo",routeData);
            return View("JugadorForm",jugador);
        }
Example #2
0
        public List<Player> GetJugadoresEquipoAƱo(string idTeam, int year)
        {
            List<Player> jugadores = new List<Player>();

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BaseBall"].ConnectionString))
            {
                Player jugador;

                conn.Open();

                SqlCommand comando = conn.CreateCommand();
                comando.CommandType = System.Data.CommandType.Text;
                comando.CommandText = "select m.playerID, m.nameGiven, m.nameFirst, m.nameLast from master as m join Appearances as a on m.playerID = a.playerID ";
                comando.CommandText += "where a.teamID='" + idTeam + "' ";
                comando.CommandText += "and a.yearID =" + year + " order by m.playerID;";

                SqlDataReader reader = comando.ExecuteReader();

                while (reader.Read())
                {
                    jugador = new Player();
                    jugador.PlayerId = reader.GetString(0);
                    jugador.NameGiven = reader.GetString(1);
                    jugador.NameFirst = reader.GetString(2);
                    jugador.NameLast = reader.GetString(3);

                    jugadores.Add(jugador);
                }

                conn.Close();
            }

            return jugadores;
        }
Example #3
0
        public void RellenarJugador(Player jugador)
        {
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BaseBall"].ConnectionString))
            {
                SqlCommand command = conn.CreateCommand();
                command.CommandType = CommandType.Text;
                SqlParameter idjugador = command.Parameters.AddWithValue("@id", jugador.PlayerId);
                SqlParameter nombrejugador = command.Parameters.AddWithValue("@nameFirst", jugador.NameFirst);
                SqlParameter apellidojugador = command.Parameters.AddWithValue("@nameLast", jugador.NameLast);
                SqlParameter apodo = command.Parameters.AddWithValue("@nameGiven", jugador.NameGiven);
                //SqlParameter aƱonac = command.Parameters.AddWithValue("@birthYear", jugador.BirthYear);
                //SqlParameter mesnac = command.Parameters.AddWithValue("@birthMonth", jugador.BirthMonth);
                //SqlParameter dianac = command.Parameters.AddWithValue("@birthDay", jugador.BirthDay);

                command.CommandText = "UPDATE Master" +
                                      " Set nameFirst = @nameFirst" +
                                      ",nameLast = @nameLast " +
                                      ",nameGiven= @nameGiven " +
                                      //",birthYear= @birthYear " +
                                      //",birthMonth= @birthMonth " +
                                      //",birthDay= @birthDay " +
                                      "where playerID = @id;";
                conn.Open();
                command.ExecuteNonQuery();
            }
        }
Example #4
0
        public Player GetJugador(string id)
        {
            Player jugador = new Player();
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BaseBall"].ConnectionString))
            {
                SqlCommand command = conn.CreateCommand();
                SqlParameter idjug = command.Parameters.AddWithValue("@id", id);

                command.CommandType = CommandType.Text;
                command.CommandText = "SELECT        Master.* " +
                                       "FROM Master " +
                                       "WHERE playerID=@id";
                conn.Open();
                SqlDataReader lector = command.ExecuteReader();


                if (lector.Read())
                {

                    jugador.PlayerId = lector[0].ToString();
                    jugador.NameFirst = lector[13].ToString();
                    jugador.NameLast= lector[14].ToString();
                    jugador.NameGiven = lector[15].ToString();

                }
            }
            return jugador;
        }
Example #5
0
 public ActionResult UpDate(Player jugador)
 {
     ServicioEquipos.SrvEquiposClient cliente = new ServicioEquipos.SrvEquiposClient();
     cliente.RellenarJugador(jugador);
     return View("Index");
 }