Пример #1
0
        // GET de Partido1Controller(UNO)
        internal Partido Retrieve(int idpartido)
        {
            MySqlConnection con     = Connect();
            MySqlCommand    command = con.CreateCommand();

            command.CommandText = "select * from partido where idpartido=" + idpartido;

            try
            {
                con.Open();
                MySqlDataReader res = command.ExecuteReader();

                Partido p = null;


                if (res.Read())
                {
                    Debug.WriteLine("Recuperado: " + res.GetInt16(0) + " " + res.GetString(1) + " " + res.GetString(2) + " " + res.GetDouble(3) + " " + res.GetInt32(0));
                    p = new Partido(res.GetInt16(0), res.GetString(1), res.GetString(2), res.GetDouble(3), res.GetInt32(0));
                }

                con.Close();

                return(p);
            }
            catch (MySqlException e)
            {
                Debug.WriteLine("Error de conexión");
                return(null);
            }
        }
Пример #2
0
        //PUT de Partido1Controller
        internal void Update(Partido d, int idpartido)
        {
            MySqlConnection con     = Connect();
            MySqlCommand    command = con.CreateCommand();

            command.CommandText = "update apuesta.partido set equipoL='" + d.EqLocal.ToString() + "',equipoV='" + d.EqVisitante.ToString() + "',mercado='" + d.Mercado + "',TotalGoles='" + d.TotalGoles + "' where idpartido=" + idpartido;
            Debug.WriteLine("comando " + command.CommandText);
            try
            {
                con.Open();
                command.ExecuteNonQuery();
                con.Close();
            }
            catch (MySqlException e)
            {
                Debug.WriteLine(e.Message);
            }
        }
Пример #3
0
        //POST de Partido1Controller
        internal void Save(Partido d)
        {
            MySqlConnection con     = Connect();
            MySqlCommand    command = con.CreateCommand();

            //command.CommandText = "insert into partido (equipoL, equipoV, mercado, TotalGoles) values (' "+d.EqLocal+ "',' " +d.EqVisitante+ "'," +d.Mercado+ "," +d.TotalGoles+ ")";
            command.CommandText = "Insert Into partido (equipoL, equipoV, mercado, TotalGoles) values ('" + d.EqLocal + "', '" + d.EqVisitante + "', '" + d.Mercado.ToString() + "' , '" + d.TotalGoles.ToString() + "')";
            Debug.WriteLine("comando " + command.CommandText);
            try
            {
                con.Open();
                command.ExecuteNonQuery();
                con.Close();
            }
            catch (MySqlException e)
            {
                Debug.WriteLine(e.Message);
            }
        }