Exemplo n.º 1
0
        public bool inserirdesejos(filmespojo filme, PessoaPojo pessoa)

        {
            int opcao = 0;

            Conexao         objCon = new Conexao();
            MySqlConnection Conn   = new MySqlConnection();

            Conn = objCon.OpenConnection();
            MySqlCommand cmdverificar = Conn.CreateCommand();

            string queryverificar = "SELECT status FROM meufilme WHERE pessoaid='" + pessoa.Id + "'and filmeid='" + filme.cod + "'";

            cmdverificar.CommandText = queryverificar;

            MySqlDataReader Reader = cmdverificar.ExecuteReader();

            while (Reader.Read())
            {
                if (Reader.HasRows == true)
                {
                    opcao = 1;
                }
            }

            cmdverificar.Dispose();
            objCon.CloseConnection();


            if (opcao == 1)
            {
                return(false);
            }


            Conn = objCon.OpenConnection();
            MySqlCommand cmd = Conn.CreateCommand();

            string query = "INSERT INTO meufilme (pessoaid, filmeid, status) VALUES('" + pessoa.Id + "', '" + filme.cod + "','0')";


            //create command and assign the query and connection from the constructor
            cmd.CommandText = query;

            //Execute command
            cmd.ExecuteNonQuery();

            //close connection
            cmd.Dispose();
            objCon.CloseConnection();



            return(true);
        }
Exemplo n.º 2
0
        public List <filmespojo> listarinfo()

        {
            List <filmespojo> listafilmes = new List <filmespojo>();

            Conexao         objCon = new Conexao();
            MySqlConnection Conn   = new MySqlConnection();

            Conn = objCon.OpenConnection();
            MySqlCommand cmd = Conn.CreateCommand();

            string query = "SELECT * FROM filmes";



            //create command and assign the query and connection from the constructor

            cmd.CommandText = query;

            MySqlDataReader Reader = cmd.ExecuteReader();

            while (Reader.Read())
            {
                filmespojo f = new filmespojo();
                f.cod        = Reader.GetString(0);
                f.nome       = Reader.GetString(1);
                f.genero     = Reader.GetString(2);
                f.duracao    = Reader.GetString(3);
                f.diretor    = Reader.GetString(4);
                f.imagemref  = Reader.GetString(5);
                f.imdbrating = Reader.GetString(6);
                f.videoref   = Reader.GetString(7);


                listafilmes.Add(f);
            }

            cmd.Dispose();
            objCon.CloseConnection();



            //Execute command
            // cmd.ExecuteNonQuery();

            //close connection
            cmd.Dispose();
            // conexao.close();


            return(listafilmes);
        }
Exemplo n.º 3
0
        public filmespojo selecionarfilme(filmespojo filmecod)

        {
            Conexao         objCon = new Conexao();
            MySqlConnection Conn   = new MySqlConnection();

            Conn = objCon.OpenConnection();
            MySqlCommand cmd = Conn.CreateCommand();

            string query = "SELECT * FROM filmes where cod='" + filmecod.cod + "'";

            filmespojo f = new filmespojo();


            //create command and assign the query and connection from the constructor
            cmd.CommandText = query;

            MySqlDataReader Reader = cmd.ExecuteReader();

            while (Reader.Read())
            {
                f.cod      = Reader.GetString(0);
                f.nome     = Reader.GetString(1);
                f.genero   = Reader.GetString(2);
                f.duracao  = Reader.GetString(3);
                f.diretor  = Reader.GetString(4);
                f.videoref = Reader.GetString(7);
            }



            //Execute command
            // cmd.ExecuteNonQuery();

            //close connection

            cmd.Dispose();
            objCon.CloseConnection();
            return(f);
        }
Exemplo n.º 4
0
        public void removerfilme(filmespojo f)

        {
            Conexao         objCon = new Conexao();
            MySqlConnection Conn   = new MySqlConnection();

            Conn = objCon.OpenConnection();
            MySqlCommand cmd   = Conn.CreateCommand();
            string       query = "DELETE FROM filmes WHERE cod='" + f.cod + "'";



            //create command and assign the query and connection from the constructor
            cmd.CommandText = query;

            //Execute command
            cmd.ExecuteNonQuery();

            //close connection
            objCon.CloseConnection();
            cmd.Dispose();
        }
Exemplo n.º 5
0
        public void atualizarfilme(filmespojo f)

        {
            Conexao         objCon = new Conexao();
            MySqlConnection Conn   = new MySqlConnection();

            Conn = objCon.OpenConnection();
            MySqlCommand cmd   = Conn.CreateCommand();
            string       query = "UPDATE filmes set nome='" + f.nome + "', cod='" + f.cod + "', genero='" + f.genero + "', diretor='" + f.diretor + "', duracao='" + f.duracao + "',videoref='" + f.videoref + "' WHERE cod='" + f.cod + "'";



            //create command and assign the query and connection from the constructor
            cmd.CommandText = query;

            //Execute command
            cmd.ExecuteNonQuery();

            //close connection
            cmd.Dispose();
            objCon.CloseConnection();
        }
Exemplo n.º 6
0
        public void inserirfilme(filmespojo filme)

        {
            Conexao         objCon = new Conexao();
            MySqlConnection Conn   = new MySqlConnection();

            Conn = objCon.OpenConnection();
            MySqlCommand cmd   = Conn.CreateCommand();
            string       query = "INSERT INTO filmes (cod, nome, genero, duracao, diretor,imagemref,nota,videoref) VALUES('" + filme.cod + "', '" + filme.nome + "','" + filme.genero + "','" + filme.duracao + "','" + filme.diretor + "','" + filme.imagemref + "','" + filme.imdbrating + "','" + filme.videoref + "')";

            cmd.CommandText = query;

            //create command and assign the query and connection from the constructor


            //Execute command
            cmd.ExecuteNonQuery();

            //close connection
            cmd.Dispose();
            objCon.CloseConnection();
        }
Exemplo n.º 7
0
        public void removerdesejos(filmespojo f, PessoaPojo usuario)

        {
            Conexao         objCon = new Conexao();
            MySqlConnection Conn   = new MySqlConnection();

            Conn = objCon.OpenConnection();
            MySqlCommand cmd   = Conn.CreateCommand();
            string       query = "DELETE FROM meufilme WHERE filmeid='" + f.cod + "' and status='0' and pessoaid='" + usuario.Id + "'";



            //create command and assign the query and connection from the constructor
            cmd.CommandText = query;

            //Execute command
            cmd.ExecuteNonQuery();

            //close connection
            cmd.Dispose();
            objCon.CloseConnection();
            cmd.Dispose();
        }
Exemplo n.º 8
0
        public List <filmespojo> listardesejos(int id)

        {
            Conexao         objCon = new Conexao();
            MySqlConnection Conn   = new MySqlConnection();

            Conn = objCon.OpenConnection();
            MySqlCommand cmd = Conn.CreateCommand();



            string query = "SELECT filmeid FROM meufilme where pessoaid='" + id + "' and status='0'";

            List <filmespojo> filmes   = new List <filmespojo>();
            List <string>     idfilmes = new List <string>();


            //create command and assign the query and connection from the constructor
            cmd.CommandText = query;

            MySqlDataReader Reader = cmd.ExecuteReader();


            while (Reader.Read())
            {
                idfilmes.Add(Reader.GetString(0));
            }
            Reader.Close();
            Reader.Dispose();
            cmd.Dispose();
            objCon.CloseConnection();



            //Execute command
            // cmd.ExecuteNonQuery();

            //close connection
            Conn = objCon.OpenConnection();
            MySqlCommand cmd2 = Conn.CreateCommand();

            for (int i = 0; i < idfilmes.Count; i++)
            {
                string query2 = "SELECT * FROM filmes where cod='" + idfilmes[i] + "'";

                cmd2.CommandText = query2;

                MySqlDataReader Reader2 = cmd2.ExecuteReader();

                while (Reader2.Read())
                {
                    filmespojo f = new filmespojo();
                    f.cod        = Reader2.GetString(0);
                    f.nome       = Reader2.GetString(1);
                    f.genero     = Reader2.GetString(2);
                    f.duracao    = Reader2.GetString(3);
                    f.diretor    = Reader2.GetString(4);
                    f.imagemref  = Reader2.GetString(5);
                    f.imdbrating = Reader2.GetString(6);
                    System.Diagnostics.Debug.WriteLine(f.diretor);

                    filmes.Add(f);
                }
                Reader2.Close();
            }
            cmd2.Dispose();
            cmd.Dispose();
            objCon.CloseConnection();


            return(filmes);
        }