public InfoJugadorEditar(IntegranteVO integranteVO, HcoIntegranteVO hcoIntegranteVO, JugadorVO jugadorVO) { this.integranteVO = integranteVO; this.hcoIntegranteVO = hcoIntegranteVO; this.jugadorVO = jugadorVO; }
public JugadorCO(JugadorVO jugador, List <HcoIntegranteVO> listaHcoIntegrantes, IntegranteVO integrante) { base.Integrante = integrante; base.ListaHcoIntegrantes = listaHcoIntegrantes; this.jugador = jugador; }
public object execute(DbConnection connection, DbTransaction transaction) { IntegranteDAO integranteDAO = new IntegranteDAO(); JugadorDAO jugadorDAO = new JugadorDAO(); HcoIntegranteDAO hcoIntegranteDAO = new HcoIntegranteDAO(); IntegranteVO integranteVO = jugadorCO.Integrante; int cod_Integrante = jugadorCO.Jugador.Cod_Integrante; if (integranteDAO.Exists(connection, transaction, cod_Integrante)) { } else { integranteVO = integranteDAO.create(connection, transaction, jugadorCO.Integrante); cod_Integrante = integranteVO.Cod_Integrante; } HcoIntegranteVO hcoIntegranteCreado = null; foreach (HcoIntegranteVO hcoIntegrante in jugadorCO.ListaHcoIntegrantes) { hcoIntegrante.Cod_Integrante = cod_Integrante; hcoIntegranteCreado = hcoIntegranteDAO.create(connection, transaction, hcoIntegrante); } jugadorCO.Jugador.Cod_Integrante = cod_Integrante; jugadorCO.Jugador.Cod_Equipo = hcoIntegranteCreado.Cod_Equipo; jugadorCO.Jugador.Version_Integrante = hcoIntegranteCreado.Version_Integrante; JugadorVO jugadorVO = jugadorDAO.create(connection, transaction, jugadorCO.Jugador); return(new JugadorCO(jugadorVO, jugadorCO.ListaHcoIntegrantes, integranteVO)); }
public JugadorVO updateJugador(DbConnection connection, DbTransaction transaction, JugadorVO jugadorVO) { try { DbCommand command = connection.CreateCommand(); if (transaction != null) { command.Transaction = transaction; } command.CommandText = "UPDATE Jugador SET " + "altura=@altura,posicion=@posicion,pierna=@pierna " + "WHERE cod_Integrante=@cod_Integrante AND cod_Equipo=@cod_Equipo " + "AND version_Integrante=@version_Integrante"; DbParameter cod_IntegranteParam = command.CreateParameter(); cod_IntegranteParam.ParameterName = "@cod_Integrante"; cod_IntegranteParam.DbType = DbType.Int32; cod_IntegranteParam.Value = jugadorVO.Cod_Integrante; cod_IntegranteParam.Size = 32; command.Parameters.Add(cod_IntegranteParam); DbParameter cod_EquipoParam = command.CreateParameter(); cod_EquipoParam.ParameterName = "@cod_Equipo"; cod_EquipoParam.DbType = DbType.Int32; cod_EquipoParam.Value = jugadorVO.Cod_Equipo; cod_EquipoParam.Size = 32; command.Parameters.Add(cod_EquipoParam); DbParameter version_IntegranteParam = command.CreateParameter(); version_IntegranteParam.ParameterName = "@version_Integrante"; version_IntegranteParam.DbType = DbType.Int32; version_IntegranteParam.Value = jugadorVO.Version_Integrante; version_IntegranteParam.Size = 32; command.Parameters.Add(version_IntegranteParam); DbParameter alturaParam = command.CreateParameter(); alturaParam.ParameterName = "@altura"; alturaParam.DbType = DbType.Double; alturaParam.Value = jugadorVO.Altura; alturaParam.Size = 32; command.Parameters.Add(alturaParam); DbParameter posicionParam = command.CreateParameter(); posicionParam.ParameterName = "@posicion"; posicionParam.DbType = DbType.String; posicionParam.Size = 50; if (jugadorVO.Posicion == null) { posicionParam.Value = DBNull.Value; } else { posicionParam.Value = jugadorVO.Posicion; } command.Parameters.Add(posicionParam); DbParameter piernaParam = command.CreateParameter(); piernaParam.ParameterName = "@pierna"; piernaParam.DbType = DbType.String; piernaParam.Size = 50; if (jugadorVO.Pierna == null) { piernaParam.Value = DBNull.Value; } else { piernaParam.Value = jugadorVO.Pierna; } command.Parameters.Add(piernaParam); command.Prepare(); int insertedRows = command.ExecuteNonQuery(); if (insertedRows == 0) { throw new SQLException("errorrrrrrr"); } return(jugadorVO); } catch (DbException e) { throw new InternalErrorException(e); } }
public JugadorVO create(DbConnection connection, DbTransaction transaction, JugadorVO jugadorVO) { try { DbCommand command = connection.CreateCommand(); if (transaction != null) { command.Transaction = transaction; } command.CommandText = "INSERT INTO Jugador (cod_Integrante,cod_Equipo,version_Integrante,altura,posicion,pierna) values (@cod_Integrante,@cod_Equipo,@version_Integrante,@altura,@posicion,@pierna)"; DbParameter cod_IntegranteParam = command.CreateParameter(); cod_IntegranteParam.ParameterName = "@cod_Integrante"; cod_IntegranteParam.DbType = DbType.Int32; cod_IntegranteParam.Value = jugadorVO.Cod_Integrante; cod_IntegranteParam.Size = 32; command.Parameters.Add(cod_IntegranteParam); DbParameter cod_EquipoParam = command.CreateParameter(); cod_EquipoParam.ParameterName = "@cod_Equipo"; cod_EquipoParam.DbType = DbType.Int32; cod_EquipoParam.Value = jugadorVO.Cod_Equipo; cod_EquipoParam.Size = 32; command.Parameters.Add(cod_EquipoParam); DbParameter version_IntegranteParam = command.CreateParameter(); version_IntegranteParam.ParameterName = "@version_Integrante"; version_IntegranteParam.DbType = DbType.Int32; version_IntegranteParam.Value = jugadorVO.Version_Integrante; version_IntegranteParam.Size = 32; command.Parameters.Add(version_IntegranteParam); DbParameter alturaParam = command.CreateParameter(); alturaParam.ParameterName = "@altura"; alturaParam.DbType = DbType.Double; alturaParam.Value = jugadorVO.Altura; alturaParam.Size = 32; command.Parameters.Add(alturaParam); DbParameter posicionParam = command.CreateParameter(); posicionParam.ParameterName = "@posicion"; posicionParam.DbType = DbType.String; posicionParam.Size = 50; if (jugadorVO.Posicion == null) { posicionParam.Value = DBNull.Value; } else { posicionParam.Value = jugadorVO.Posicion; } command.Parameters.Add(posicionParam); DbParameter piernaParam = command.CreateParameter(); piernaParam.ParameterName = "@pierna"; piernaParam.DbType = DbType.String; piernaParam.Size = 50; if (jugadorVO.Pierna == null) { piernaParam.Value = DBNull.Value; } else { piernaParam.Value = jugadorVO.Pierna; } command.Parameters.Add(piernaParam); command.Prepare(); int insertedRows = command.ExecuteNonQuery(); if (insertedRows == 0) { throw new SQLException("errorrrrrrr"); } IJugadorIdentifierRetriever jugadorIdentifierRetriever = JugadorIdentifierRetrieverFactory.GetRetriever(); Int64 jugadorIdentifier = jugadorIdentifierRetriever.GetGeneratedIdentifier(connection, transaction); return(new JugadorVO((int)jugadorIdentifier, jugadorVO.Cod_Integrante, jugadorVO.Cod_Equipo, jugadorVO.Version_Integrante, jugadorVO.Altura, jugadorVO.Posicion, jugadorVO.Pierna)); } catch (DbException e) { throw new InternalErrorException(e); } }
public ArrayList generaPlantilla(int cod_Equipo) { contador = (cod_Equipo - 1) * 22; String posicion; ArrayList listaJugadores = new ArrayList(); for (int i = 1; i < 23; i++) { switch (i) { case 1: posicion = "Portero"; break; case 2: posicion = "Lateral derecho"; break; case 3: posicion = "Lateral izquierdo"; break; case 4: posicion = "Defensa central"; break; case 5: posicion = "Defensa central"; break; case 6: posicion = "Mediocentro defensivo"; break; case 7: posicion = "Interior derecho"; break; case 8: posicion = "Mediocentro ofensivo"; break; case 9: posicion = "Delantero centro"; break; case 10: posicion = "Mediapunta"; break; case 11: posicion = "Extremo izquierdo"; break; case 12: posicion = "Lateral derecho"; break; case 13: posicion = "Portero"; break; case 14: posicion = "Lateral izquierdo"; break; case 15: posicion = "Defensa central"; break; case 16: posicion = "Defensa central"; break; case 17: posicion = "Delantero centro"; break; case 18: posicion = "Extremo derecho"; break; case 19: posicion = "Delantero"; break; case 20: posicion = "Mediocentro defensivo"; break; case 21: posicion = "Mediocentro ofensivo"; break; case 22: posicion = "Mediapunta"; break; default: posicion = "Polivalente"; break; } IntegranteVO integranteVO = new IntegranteVO(contador + i, generador.generarNombreAleatorio(), generador.generarApellidoAleatorio(), generador.generarFechaAleatoriaNacimiento(), null); HcoIntegranteVO hcoIntegranteVO = new HcoIntegranteVO(contador + i, cod_Equipo, generador.generarFechaAleatoriaPartido(), DateTime.MinValue, generador.generarFechaAleatoriaPartido(), 20000, i); var listaHcoIntegrantes = new List <HcoIntegranteVO>(); listaHcoIntegrantes.Add(hcoIntegranteVO); JugadorVO jugadorVO = new JugadorVO(contador + i, cod_Equipo, generador.generarAltura(), posicion, generador.generarZurdoDiestro()); JugadorCO jugadorInsertar = new JugadorCO(jugadorVO, listaHcoIntegrantes, integranteVO); listaJugadores.Add(jugadorInsertar); } return(listaJugadores); }
public object execute(DbConnection connection, DbTransaction transaction) { var equipoVO = equipoTotal.Equipo; var estadioVO = equipoTotal.Estadio; var listaJugadores = equipoTotal.ListaJugadores; var listaEntrenadores = equipoTotal.ListaEntrenadoresCreate; var listaDirectivos = equipoTotal.ListaDirectivosCreate; //Creamos el EquipoVO if (equipoVO != null) { EquipoDAO equipoDAO = new EquipoDAO(); equipoVO = equipoDAO.create(connection, transaction, equipoVO); } //Creamos el EstadioVO if (estadioVO != null) { EstadioDAO estadioDAO = new EstadioDAO(); estadioVO = estadioDAO.create(connection, transaction, estadioVO); } //Creamos todos los jugadoresCOs if (listaJugadores != null) { HcoIntegranteDAO hcoIntegranteDAO = new HcoIntegranteDAO(); IntegranteDAO integranteDAO = new IntegranteDAO(); JugadorDAO jugadorDAO = new JugadorDAO(); foreach (JugadorCO jugadorCO in listaJugadores) { IntegranteVO integranteVO = jugadorCO.Integrante; int cod_Integrante = jugadorCO.cod_Integrante(); if (integranteDAO.Exists(connection, transaction, cod_Integrante)) { } else { integranteVO = integranteDAO.create(connection, transaction, jugadorCO.Integrante); cod_Integrante = integranteVO.Cod_Integrante; } HcoIntegranteVO hcoIntegranteCreado = null; foreach (HcoIntegranteVO hcoIntegrante in jugadorCO.ListaHcoIntegrantes) { hcoIntegrante.Cod_Integrante = cod_Integrante; hcoIntegranteCreado = hcoIntegranteDAO.create(connection, transaction, hcoIntegrante); } //linea anadida if (jugadorCO.GetType().Name.Equals("JugadorCO")) { (jugadorCO as JugadorCO).Jugador.Cod_Integrante = cod_Integrante; (jugadorCO as JugadorCO).Jugador.Version_Integrante = hcoIntegranteCreado.Version_Integrante; JugadorVO jugadorVO = jugadorDAO.create(connection, transaction, (jugadorCO as JugadorCO).Jugador); } } } //creamos todos los EntrenadorCOs if (listaEntrenadores != null) { foreach (EntrenadorCO entrenadorCO in listaEntrenadores) { IntegranteDAO integranteDAO = new IntegranteDAO(); EntrenadorDAO entrenadorDAO = new EntrenadorDAO(); HcoIntegranteDAO hcoIntegranteDAO = new HcoIntegranteDAO(); IntegranteVO integranteVO = entrenadorCO.Integrante; int cod_Integrante = entrenadorCO.Entrenador.Cod_Integrante; if (integranteDAO.Exists(connection, transaction, cod_Integrante)) { } else { integranteVO = integranteDAO.create(connection, transaction, entrenadorCO.Integrante); cod_Integrante = integranteVO.Cod_Integrante; } HcoIntegranteVO hcoIntegranteCreado = null; foreach (HcoIntegranteVO hcoIntegrante in entrenadorCO.ListaHcoIntegrantes) { hcoIntegrante.Cod_Integrante = cod_Integrante; hcoIntegranteCreado = hcoIntegranteDAO.create(connection, transaction, hcoIntegrante); } entrenadorCO.Entrenador.Cod_Integrante = cod_Integrante; //linea anadida if (entrenadorCO.GetType().Name.Equals("EntrenadorCO")) { (entrenadorCO as EntrenadorCO).Entrenador.Cod_Integrante = cod_Integrante; (entrenadorCO as EntrenadorCO).Entrenador.Version_Integrante = hcoIntegranteCreado.Version_Integrante; EntrenadorVO entrenadorVO = entrenadorDAO.create(connection, transaction, (entrenadorCO as EntrenadorCO).Entrenador); } } } //Creamos todos los DirectivoCOs if (listaDirectivos != null) { foreach (DirectivoCO directivoCO in listaDirectivos) { IntegranteDAO integranteDAO = new IntegranteDAO(); DirectivoDAO directivoDAO = new DirectivoDAO(); HcoIntegranteDAO hcoIntegranteDAO = new HcoIntegranteDAO(); IntegranteVO integranteVO = directivoCO.Integrante; int cod_Integrante = directivoCO.Directivo.Cod_Integrante; if (integranteDAO.Exists(connection, transaction, cod_Integrante)) { } else { integranteVO = integranteDAO.create(connection, transaction, directivoCO.Integrante); cod_Integrante = integranteVO.Cod_Integrante; } HcoIntegranteVO hcoIntegranteCreado = null; foreach (HcoIntegranteVO hcoIntegrante in directivoCO.ListaHcoIntegrantes) { hcoIntegrante.Cod_Integrante = cod_Integrante; hcoIntegranteCreado = hcoIntegranteDAO.create(connection, transaction, hcoIntegrante); } directivoCO.Directivo.Cod_Integrante = cod_Integrante; //linea anadida if (directivoCO.GetType().Name.Equals("DirectivoCO")) { (directivoCO as DirectivoCO).Directivo.Cod_Integrante = cod_Integrante; (directivoCO as DirectivoCO).Directivo.Version_Integrante = hcoIntegranteCreado.Version_Integrante; DirectivoVO directivoVO = directivoDAO.create(connection, transaction, (directivoCO as DirectivoCO).Directivo); } } } return(new EquipoTotalCO <JugadorCO>(equipoVO, listaJugadores, listaEntrenadores, null, listaDirectivos, null, estadioVO)); }