コード例 #1
0
ファイル: DirectivoCO.cs プロジェクト: lordpiti/footballAPI
 public DirectivoCO(DirectivoVO directivo, List <HcoIntegranteVO> listaHcoIntegrantes,
                    IntegranteVO integrante)
 {
     this.directivo           = directivo;
     base.Integrante          = integrante;
     base.ListaHcoIntegrantes = listaHcoIntegrantes;
 }
コード例 #2
0
        public ArrayList generaDirectiva(int cod_Equipo)
        {
            //sustituir el 4 q multiplica al 22 de abajo por el numero de equipos
            //de la BD
            contador = 22 * 20 + 20 * 4 + (cod_Equipo - 1) * 4;
            ArrayList listaDirectivos = new ArrayList();
            String    cargo;

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

                case 2:
                    cargo = "Vicepresidente";
                    break;

                case 3:
                    cargo = "Director deportivo";
                    break;

                case 4:
                    cargo = "Secretario general";
                    break;

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

                DirectivoVO directivoVO = new DirectivoVO(contador + i, cod_Equipo, cargo, "abogao");

                DirectivoCO directivoInsertar = new DirectivoCO(directivoVO, listaHcoIntegrantes, integranteVO);

                listaDirectivos.Add(directivoInsertar);
            }
            return(listaDirectivos);
        }
コード例 #3
0
        public object execute(DbConnection connection, DbTransaction transaction)
        {
            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;
            directivoCO.Directivo.Cod_Equipo         = hcoIntegranteCreado.Cod_Equipo;
            directivoCO.Directivo.Version_Integrante = hcoIntegranteCreado.Version_Integrante;


            DirectivoVO directivoVO = directivoDAO.create(connection, transaction,
                                                          directivoCO.Directivo);

            return(new DirectivoCO(directivoVO, directivoCO.ListaHcoIntegrantes, integranteVO));
        }
コード例 #4
0
ファイル: DirectivoDAO.cs プロジェクト: lordpiti/footballAPI
        public DirectivoVO updateDirectivo(DbConnection connection, DbTransaction transaction,
                                           DirectivoVO directivoVO)
        {
            try
            {
                DbCommand command = connection.CreateCommand();

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

                command.CommandText = "UPDATE Directivo SET " +
                                      "cargo=@cargo,profesion=@profesion " +
                                      "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         = directivoVO.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         = directivoVO.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         = directivoVO.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 (directivoVO == null)
                {
                    cargoParam.Value = DBNull.Value;
                }
                else
                {
                    cargoParam.Value = directivoVO.Cargo;
                }
                command.Parameters.Add(cargoParam);


                DbParameter profesionParam = command.CreateParameter();
                profesionParam.ParameterName = "@profesion";
                profesionParam.DbType        = DbType.DateTime;
                profesionParam.Size          = 50;
                if (directivoVO.Profesion == null)
                {
                    profesionParam.Value = DBNull.Value;
                }
                else
                {
                    profesionParam.Value = directivoVO.Profesion;
                }
                command.Parameters.Add(profesionParam);

                command.Prepare();

                int insertedRows = command.ExecuteNonQuery();

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

                return(directivoVO);
            }
            catch (DbException e)
            {
                throw new InternalErrorException(e);
            }
        }
コード例 #5
0
ファイル: DirectivoDAO.cs プロジェクト: lordpiti/footballAPI
        public DirectivoVO create(DbConnection connection, DbTransaction transaction, DirectivoVO directivoVO)
        {
            try
            {
                DbCommand command = connection.CreateCommand();

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

                command.CommandText = "INSERT INTO Directivo (cod_Integrante,cod_Equipo,version_Integrante,cargo,profesion) " +
                                      "values (@cod_Integrante,@cod_Equipo,@version_Integrante,@cargo,@profesion)";

                DbParameter cod_IntegranteParam = command.CreateParameter();
                cod_IntegranteParam.ParameterName = "@cod_Integrante";
                cod_IntegranteParam.DbType        = DbType.Int32;
                cod_IntegranteParam.Value         = directivoVO.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         = directivoVO.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         = directivoVO.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 (directivoVO.Cargo == null)
                {
                    cargoParam.Value = DBNull.Value;
                }
                else
                {
                    cargoParam.Value = directivoVO.Cargo;
                }
                command.Parameters.Add(cargoParam);


                DbParameter profesionParam = command.CreateParameter();
                profesionParam.ParameterName = "@profesion";
                profesionParam.DbType        = DbType.String;
                profesionParam.Size          = 30;
                profesionParam.Value         = directivoVO.Profesion;
                command.Parameters.Add(profesionParam);



                command.Prepare();

                int insertedRows = command.ExecuteNonQuery();

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

                IDirectivoIdentifierRetriever directivoIdentifierRetriever = DirectivoIdentifierRetrieverFactory.GetRetriever();

                Int64 directivoIdentifier = directivoIdentifierRetriever.GetGeneratedIdentifier(connection, transaction);


                return(new DirectivoVO((int)directivoIdentifier, directivoVO.Cod_Integrante, directivoVO.Cod_Equipo,
                                       directivoVO.Version_Integrante, directivoVO.Cargo, directivoVO.Profesion));
            }
            catch (DbException e)
            {
                throw new InternalErrorException(e);
            }
        }
コード例 #6
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));
        }