Esempio n. 1
0
 public EntrenadorCO(EntrenadorVO entrenador, List <HcoIntegranteVO> listaHcoIntegrantes,
                     IntegranteVO integrante)
 {
     this.entrenador          = entrenador;
     base.Integrante          = integrante;
     base.ListaHcoIntegrantes = listaHcoIntegrantes;
 }
Esempio n. 2
0
        public ArrayList generaCuerpoTecnico(int cod_Equipo)
        {
            //sustituir el 4 q multiplica al 22 de abajo por el numero de equipos
            //de la BD
            contador = 22 * 20 + (cod_Equipo - 1) * 4;
            ArrayList listaEntrenadores = new ArrayList();
            String    cargo;

            for (int i = 1; i < 5; i++)
            {
                switch (i)
                {
                case 1:
                    cargo = "Primer entrenador";
                    break;

                case 2:
                    cargo = "Segundo entrenador";
                    break;

                case 3:
                    cargo = "Entrenador de porteros";
                    break;

                case 4:
                    cargo = "Ayudante";
                    break;

                default:
                    cargo = "Utillero";
                    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);

                EntrenadorVO entrenadorVO = new EntrenadorVO(contador + i, cod_Equipo, cargo, generador.generarFechaAleatoriaPartido());

                EntrenadorCO entrenadorInsertar = new EntrenadorCO(entrenadorVO, listaHcoIntegrantes, integranteVO);

                listaEntrenadores.Add(entrenadorInsertar);
            }
            return(listaEntrenadores);
        }
Esempio n. 3
0
        public object execute(DbConnection connection, DbTransaction transaction)
        {
            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;
            entrenadorCO.Entrenador.Cod_Equipo     = hcoIntegranteCreado.Cod_Equipo;

            //linea anadida
            entrenadorCO.Entrenador.Version_Integrante = hcoIntegranteCreado.Version_Integrante;
            EntrenadorVO entrenadorVO = entrenadorDAO.create(connection, transaction,
                                                             entrenadorCO.Entrenador);

            return(new EntrenadorCO(entrenadorVO, entrenadorCO.ListaHcoIntegrantes, integranteVO));
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        public EntrenadorVO updateEntrenador(DbConnection connection, DbTransaction transaction,
                                             EntrenadorVO entrenadorVO)
        {
            try
            {
                DbCommand command = connection.CreateCommand();

                if (transaction != null)
                {
                    command.Transaction = transaction;
                }

                command.CommandText = "UPDATE Entrenador SET " +
                                      "cargo=@cargo,fecha_Profesional=@fechaProfesional " +
                                      "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         = entrenadorVO.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         = entrenadorVO.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         = entrenadorVO.Version_Integrante;
                version_IntegranteParam.Size          = 32;
                command.Parameters.Add(version_IntegranteParam);


                DbParameter cargoParam = command.CreateParameter();
                cargoParam.ParameterName = "@cargo";
                cargoParam.DbType        = DbType.String;
                cargoParam.Size          = 50;
                if (entrenadorVO == null)
                {
                    cargoParam.Value = DBNull.Value;
                }
                else
                {
                    cargoParam.Value = entrenadorVO.Cargo;
                }
                command.Parameters.Add(cargoParam);


                DbParameter fechaProfesionalParam = command.CreateParameter();
                fechaProfesionalParam.ParameterName = "@fechaProfesional";
                fechaProfesionalParam.DbType        = DbType.DateTime;
                fechaProfesionalParam.Size          = 50;

                /* if (entrenadorVO.FechaProfesional == null) fechaProfesionalParam.Value = DBNull.Value;
                 * else*/fechaProfesionalParam.Value = entrenadorVO.FechaProfesional;
                command.Parameters.Add(fechaProfesionalParam);

                command.Prepare();

                int insertedRows = command.ExecuteNonQuery();

                if (insertedRows == 0)
                {
                    throw new SQLException("errorrrrrrr");
                }

                return(entrenadorVO);
            }
            catch (DbException e)
            {
                throw new InternalErrorException(e);
            }
        }
Esempio n. 6
0
        public EntrenadorVO create(DbConnection connection, DbTransaction transaction, EntrenadorVO entrenadorVO)
        {
            try
            {
                DbCommand command = connection.CreateCommand();

                if (transaction != null)
                {
                    command.Transaction = transaction;
                }

                command.CommandText = "INSERT INTO Entrenador (cod_Integrante,cod_Equipo,version_Integrante,cargo,fecha_Profesional) " +
                                      "values (@cod_Integrante,@cod_Equipo,@version_Integrante,@cargo,@fechaProfesional)";

                DbParameter cod_IntegranteParam = command.CreateParameter();
                cod_IntegranteParam.ParameterName = "@cod_Integrante";
                cod_IntegranteParam.DbType        = DbType.Int32;
                cod_IntegranteParam.Value         = entrenadorVO.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         = entrenadorVO.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         = entrenadorVO.Version_Integrante;
                version_IntegranteParam.Size          = 32;
                command.Parameters.Add(version_IntegranteParam);


                DbParameter cargoParam = command.CreateParameter();
                cargoParam.ParameterName = "@cargo";
                cargoParam.DbType        = DbType.String;
                cargoParam.Size          = 50;
                if (entrenadorVO.Cargo == null)
                {
                    cargoParam.Value = DBNull.Value;
                }
                else
                {
                    cargoParam.Value = entrenadorVO.Cargo;
                }
                command.Parameters.Add(cargoParam);


                DbParameter fechaProfesionalParam = command.CreateParameter();
                fechaProfesionalParam.ParameterName = "@fechaProfesional";
                fechaProfesionalParam.DbType        = DbType.DateTime;
                fechaProfesionalParam.Size          = 100;
                fechaProfesionalParam.Value         = entrenadorVO.FechaProfesional;
                command.Parameters.Add(fechaProfesionalParam);



                command.Prepare();

                int insertedRows = command.ExecuteNonQuery();

                if (insertedRows == 0)
                {
                    throw new SQLException("errorrrrrrr");
                }

                IEntrenadorIdentifierRetriever entrenadorIdentifierRetriever = EntrenadorIdentifierRetrieverFactory.GetRetriever();

                Int64 entrenadorIdentifier = entrenadorIdentifierRetriever.GetGeneratedIdentifier(connection, transaction);


                return(new EntrenadorVO((int)entrenadorIdentifier, entrenadorVO.Cod_Integrante, entrenadorVO.Cod_Equipo,
                                        entrenadorVO.Version_Integrante, entrenadorVO.Cargo, entrenadorVO.FechaProfesional));
            }
            catch (DbException e)
            {
                throw new InternalErrorException(e);
            }
        }