Exemple #1
0
        // <summary>
        /// Funcion para insertar un gol de un partido, fecha etc concreto.
        /// </summary>
        /// <returns></returns>
        public int addGol(Entidades.Gol datosGol)
        {
            string   sql;
            DataBase _db          = new DataBase();
            int      affectedRows = 0;

            try
            {
                sql = @"INSERT INTO GOL
                            (MINUTO, JUGADOR_GOL, EQUIPO_L_GOL, EQUIPO_V_GOL, FECHA_GOL)
                        VALUES
                            (:minuto, :jugadorGol, :equipoLGol, :equipoVGol, :fechaGol)";

                _db.startDB();
                _db.Sql             = _db.DbConnection.CreateCommand();
                _db.Sql.CommandType = CommandType.Text;
                _db.Sql.CommandText = sql;
                _db.Sql.Parameters.Add(":minuto", OracleDbType.Int32).Value        = datosGol.minuto;
                _db.Sql.Parameters.Add(":jugadorGol", OracleDbType.Varchar2).Value = datosGol.jugadorGol;
                _db.Sql.Parameters.Add(":equipoLGol", OracleDbType.Varchar2).Value = datosGol.equipoLGol;
                _db.Sql.Parameters.Add(":equipoVGol", OracleDbType.Varchar2).Value = datosGol.equipoVGol;
                _db.Sql.Parameters.Add(":fechaGol", OracleDbType.Date).Value       = datosGol.fechaGol;

                affectedRows = _db.execSQL();
            }
            catch (Exception e)
            {
                throw new Exception("Error en addGol(): " + e.Message);
            }
            finally
            {
                _db.closeDB();
            }
            return(affectedRows);
        }
Exemple #2
0
        /// <summary>
        /// Elimina el gol y actualiza el partido con el nuevo resultado
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btAceptarGolVisitante_Click(object sender, EventArgs e)
        {
            if (cbJugadoresVisitante.SelectedItem != null)
            {
                if (!string.IsNullOrEmpty(tbMinutoGolLocal.Text))
                {
                    Entidades.Gol gol;

                    try
                    {
                        gol = new Entidades.Gol
                        {
                            minuto     = Convert.ToInt32(tbMinutoGolVisitante.Text),
                            jugadorGol = cbJugadoresVisitante.SelectedItem.ToString(),
                            equipoLGol = datosPartido.equipoL,
                            equipoVGol = datosPartido.equipoV,
                            fechaGol   = datosPartido.fecha
                        };

                        if (mundial.addGol(gol) > 0)
                        {
                            MessageBox.Show("El gol se ha añadido correctamente.");
                            getGolesPartido();

                            ///Le restamos un gol a partidoentidad para así dejar el resultado coherente al borrado del gol
                            datosPartido.resultadoV = dtgGolesVisitante.RowCount;

                            if (mundial.updateResultadoPartido(datosPartido) > 0)
                            {
                                MessageBox.Show("El resultado del partido se ha modificado correctamente.");
                                lblResultado.Text = datosPartido.resultadoL.ToString() + " - " + datosPartido.resultadoV.ToString();;
                            }
                            else
                            {
                                MessageBox.Show("Ha ocurrido un error actualizando el partido.");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Ha ocurrido un error añadiendo el gol. Inténtelo de nuevo.");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Ha ocurrido un error al añadir el gol: " + ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un jugador para añadir un gol");
                }
            }
            else
            {
                MessageBox.Show("Debe seleccionar un jugador para añadir un gol");
            }
        }
Exemple #3
0
        /// <summary>
        /// Elimina el gol y actualiza el partido con el nuevo resultado
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btDeleteGolesLocal_Click(object sender, EventArgs e)
        {
            if (dtgGolesLocal.CurrentRow != null)
            {
                Entidades.Gol gol;

                try
                {
                    gol = new Entidades.Gol
                    {
                        minuto     = Convert.ToInt32(dtgGolesLocal.CurrentRow.Cells[0].Value),
                        jugadorGol = dtgGolesLocal.CurrentRow.Cells[1].Value.ToString(),
                        equipoLGol = dtgGolesLocal.CurrentRow.Cells[2].Value.ToString(),
                        equipoVGol = dtgGolesLocal.CurrentRow.Cells[3].Value.ToString(),
                        fechaGol   = (DateTime)dtgGolesLocal.CurrentRow.Cells[4].Value
                    };

                    if (mundial.removeGol(gol) > 0)
                    {
                        MessageBox.Show("El gol se ha eliminado correctamente.");
                        getGolesPartido();

                        ///Le restamos un gol a partidoentidad para así dejar el resultado coherente al borrado del gol
                        datosPartido.resultadoL = dtgGolesLocal.RowCount;

                        if (mundial.updateResultadoPartido(datosPartido) > 0)
                        {
                            MessageBox.Show("El resultado del partido se ha modificado correctamente.");
                            lblResultado.Text = datosPartido.resultadoL.ToString() + " - " + datosPartido.resultadoV.ToString();;
                        }
                        else
                        {
                            MessageBox.Show("Ha ocurrido un error actualizando el partido.");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Ha ocurrido un error eliminando el gol. Inténtelo de nuevo.");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error al eliminar el gol: " + ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Debe seleccionar un gol para eliminar");
            }
        }
Exemple #4
0
        /// <summary>
        /// Elimina un gol concreto de la DB
        /// </summary>
        /// <param name="ge"></param>
        /// <returns></returns>
        public int removeGol(Entidades.Gol datosGol)
        {
            string   sql;
            DataBase _db          = new DataBase();
            int      affectedRows = 0;

            try
            {
                sql = @"DELETE 
                        FROM gol 
                        WHERE MINUTO = :minuto 
                        and JUGADOR_GOL = :jugadorGol 
                        and EQUIPO_L_GOL = :equipoLGol 
                        and EQUIPO_V_GOL = :equipoVGol
                        and FECHA_GOL = :fechaGol";

                _db.startDB();
                _db.Sql             = _db.DbConnection.CreateCommand();
                _db.Sql.CommandType = CommandType.Text;
                _db.Sql.CommandText = sql;
                _db.Sql.Parameters.Add(":minuto", OracleDbType.Int32).Value        = datosGol.minuto;
                _db.Sql.Parameters.Add(":jugadorGol", OracleDbType.Varchar2).Value = datosGol.jugadorGol;
                _db.Sql.Parameters.Add(":equipoLGol", OracleDbType.Varchar2).Value = datosGol.equipoLGol;
                _db.Sql.Parameters.Add(":equipoVGol", OracleDbType.Varchar2).Value = datosGol.equipoVGol;
                _db.Sql.Parameters.Add(":fechaGol", OracleDbType.Date).Value       = datosGol.fechaGol;

                affectedRows = _db.execSQL();
            }
            catch (Exception e)
            {
                throw new Exception("Error en removeGol(): " + e.Message);
            }
            finally
            {
                _db.closeDB();
            }
            return(affectedRows);
        }