コード例 #1
0
        private void cmbGenero_SelectedIndexChanged(object sender, EventArgs e)
        {
            string genero = cmbGenero.SelectedItem.ToString();
            string sql    = "select id_musica as ID, nome as Nome, nome_artista as Artista, album as Albúm, genero as Gênero, ano_lançamento as Ano, qntd_likes as Likes, qntd_dislikes as Dislikes from public.musicas where genero like '%" + genero + "%' ";

            dgvMusicas.DataSource = ConexaoBanco.SelecionarDataSet(sql).Tables[0];
        }
コード例 #2
0
        private void InserirVotos(bool disoulike)
        {
            string        sql;
            List <object> param;

            if (javotou)
            {
                sql = "UPDATE public.votos SET voto = @3 WHERE id_usuario = @1 and id_musica = @2";
            }
            else
            {
                sql = "INSERT INTO public.votos VALUES(DEFAULT,@1,@2,@3)";
            }
            try
            {
                param = new List <object>();
                param.Add(id_usuario);
                param.Add(id_musica);
                param.Add(disoulike);
                ConexaoBanco.Executar(sql, param);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao inserir votos" + ex.Message.ToString(), "Symphony TM", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
        private void frmMusica_FormClosing(object sender, FormClosingEventArgs e)
        {
            string        sql;
            List <object> param;

            if (like)
            {
                qntdLikes++;
                InserirVotos(like);
            }
            else if (dislike)
            {
                qntdDislikes++;
                InserirVotos(!dislike);
            }
            else
            {
                sql   = "UPDATE public.votos SET voto = null WHERE id_usuario = @1 and id_musica = @2";
                param = new List <object>();
                param.Add(id_usuario);
                param.Add(id_musica);
                ConexaoBanco.Executar(sql, param);
            }

            sql   = "UPDATE public.musicas SET qntd_likes = @1, qntd_dislikes = @2 where id_musica = @3 ";
            param = new List <object>();
            param.Add(qntdLikes);
            param.Add(qntdDislikes);
            param.Add(id_musica);
            ConexaoBanco.Executar(sql, param);
        }
コード例 #4
0
        private void btnEntrar_Click(object sender, EventArgs e)
        {
            string        sql   = "select id_usuario from public.usuarios where login = @1 and senha = @2";
            List <object> param = new List <object>();

            param.Add(txtLogin.Text);
            param.Add(txtSenha.Text);
            NpgsqlDataReader dr = ConexaoBanco.Selecionar(sql, param);

            if (dr.Read())
            {
                Int64 id = Convert.ToInt64(dr["id_usuario"]);
                dr.Close();
                Form app = new frmApp(id);
                app.Show();

                /*  txtNome_Animal.Text = dr["nome"].ToString();
                 * txtRaça_Animal.Text = dr["raca"].ToString();
                 * mskDataNasc_Animal.Text = dr["data_nascimento"].ToString();
                 * numValor_Animal.Value = Convert.ToDecimal(dr["valor"]);
                 * cmbProprietario.SelectedValue = Convert.ToInt64(dr["id_proprietario"]);*/
            }
            else
            {
                MessageBox.Show("Usuario ou senha incorretos", "Symphony TM", MessageBoxButtons.OK, MessageBoxIcon.Error);
                dr.Close();
            }
        }
コード例 #5
0
ファイル: ctrlUsuarios.cs プロジェクト: lucassartor/symphony
        private void cmbGenero_SelectedIndexChanged(object sender, EventArgs e)
        {
            string genero = cmbGenero.SelectedItem.ToString();
            string sql    = "select id_usuario as ID, nome as Nome, idade as Idade, genero as Gênero from public.usuarios where genero like '%" + genero + "%' ";

            dgvUsuarios.DataSource = ConexaoBanco.SelecionarDataSet(sql).Tables[0];
        }
コード例 #6
0
ファイル: ctrlUsuarios.cs プロジェクト: lucassartor/symphony
        private void ctrlUsuarios_Load(object sender, EventArgs e)
        {
            cmbGenero.Text   = "Selecione um";
            txtPesquisa.Text = "";

            //string sql = "select(nome, genero, album, data_lançamento, qntd_likes, qntd_dislikes, id_usuario, imagem) from public.musicas order by nome ";
            string sql = "select id_usuario as ID, nome as Nome, idade as Idade, genero as Gênero from public.usuarios order by nome ";

            dgvUsuarios.DataSource = ConexaoBanco.SelecionarDataSet(sql).Tables[0];

            dgvUsuarios.DefaultCellStyle.Font = new Font("Century Gothic", 10);
            dgvUsuarios.BorderStyle           = BorderStyle.None;
            dgvUsuarios.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGray;
            dgvUsuarios.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal;
            dgvUsuarios.DefaultCellStyle.SelectionBackColor = Color.FromArgb(178, 8, 55);
            dgvUsuarios.DefaultCellStyle.SelectionForeColor = Color.WhiteSmoke;
            dgvUsuarios.BackgroundColor = Color.FromArgb(240, 240, 240);

            dgvUsuarios.ColumnHeadersDefaultCellStyle.Font = new Font("Century Gothic", 12);
            dgvUsuarios.EnableHeadersVisualStyles          = false;
            dgvUsuarios.ColumnHeadersBorderStyle           = DataGridViewHeaderBorderStyle.None;
            dgvUsuarios.AutoResizeColumnHeadersHeight();
            dgvUsuarios.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(41, 39, 40);
            dgvUsuarios.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
        }
コード例 #7
0
        private void cmbGenero_SelectedIndexChanged(object sender, EventArgs e)
        {
            string genero     = cmbGenero.SelectedItem.ToString();
            string sql_backup = sql_pesquisa;

            sql_pesquisa          = sql_pesquisa + "and genero like '%" + genero + "%'";
            dgvMusicas.DataSource = ConexaoBanco.SelecionarDataSet(sql_pesquisa).Tables[0];
            sql_pesquisa          = sql_backup;
        }
コード例 #8
0
 private void btnCadastrar_Click(object sender, EventArgs e)
 {
     if (cmbGenero.SelectedIndex != -1)
     {
         try
         {
             string        sql   = "SELECT login FROM public.usuarios WHERE login=@1";
             List <object> param = new List <object>();
             param.Add(txtLogin.Text);
             NpgsqlDataReader dr = ConexaoBanco.Selecionar(sql, param);
             if (dr.Read())
             {
                 MessageBox.Show("Login já existente", "Symphony", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txtLogin.Focus();
                 dr.Close();
             }
             else
             {
                 dr.Close();
                 sql = "INSERT INTO public.usuarios " +
                       "(id_usuario, login, nome, sexo, senha, idade, genero, imagem)" +
                       " VALUES(DEFAULT,@1,@2,@3,@4,@5,@6,@7)";
                 string sexo;
                 if (radFeminino.Checked == true)
                 {
                     sexo = "Feminino";
                 }
                 else
                 {
                     sexo = "Masculino";
                 }
                 List <object> param2 = new List <object>();
                 param2.Add(txtLogin.Text);
                 param2.Add(txtNome.Text);
                 param2.Add(sexo);
                 param2.Add(txtSenha.Text);
                 param2.Add(numIdade.Value);
                 param2.Add(Convert.ToString(cmbGenero.SelectedItem));
                 param2.Add(image2b64);
                 ConexaoBanco.Executar(sql, param2);
                 this.Hide();
                 Form frm = new frmLogin();
                 frm.Show();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Ocorreu um erro" + ex.Message, "Symphony", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Preencha todos os dados", "Symphony", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         cmbGenero.Focus();
     }
 }
コード例 #9
0
 private void txtPesquisa_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == 13)
     {
         if (!String.IsNullOrWhiteSpace(txtPesquisa.Text))
         {
             string pesquisa = txtPesquisa.Text;
             string sql      = "select id_musica as ID, nome as Nome, nome_artista as Artista, album as Albúm, genero as Gênero, ano_lançamento as Ano, qntd_likes as Likes, qntd_dislikes as Dislikes from public.musicas where nome like '%" + pesquisa + "%' or album like '%" + pesquisa + "%' or nome_artista like '%" + pesquisa + "%' ";
             dgvMusicas.DataSource = ConexaoBanco.SelecionarDataSet(sql).Tables[0];
         }
     }
 }
コード例 #10
0
        private void ctrlMusicas_VisibleChanged(object sender, EventArgs e)
        {
            cmbGenero.Text   = "Selecione um";
            txtPesquisa.Text = "";
            lblPlaylist.Hide();
            dgvMusicas.Show();
            string        sql   = "select * from public.votos where id_usuario = @1 and voto = true";
            List <object> param = new List <object>();

            param.Add(id_usuario);
            NpgsqlDataReader dr = ConexaoBanco.Selecionar(sql, param);

            while (dr.Read())
            {
                votos.Add(Convert.ToInt64(dr["id_musica"]));
            }
            dr.Close();
            if (votos.Count <= 0)
            {
                dgvMusicas.Hide();
                lblPlaylist.Show();
            }
            else
            {
                sql = "select id_musica as ID, nome as Nome, nome_artista as Artista, album as Albúm, genero as Gênero, ano_lançamento as Ano, qntd_likes as Likes, qntd_dislikes as Dislikes from public.musicas where (id_musica = " + votos[0].ToString();
                for (int i = 1; i < votos.Count; i++)
                {
                    sql += " or id_musica = " + votos[i].ToString();
                }

                sql          = sql + ")";
                sql_pesquisa = sql;

                dgvMusicas.DataSource = ConexaoBanco.SelecionarDataSet(sql).Tables[0];

                dgvMusicas.DefaultCellStyle.Font = new Font("Century Gothic", 10);
                dgvMusicas.BorderStyle           = BorderStyle.None;
                dgvMusicas.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGray;
                dgvMusicas.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal;
                dgvMusicas.DefaultCellStyle.SelectionBackColor = Color.FromArgb(178, 8, 55);
                dgvMusicas.DefaultCellStyle.SelectionForeColor = Color.WhiteSmoke;
                dgvMusicas.BackgroundColor = Color.FromArgb(240, 240, 240);

                dgvMusicas.ColumnHeadersDefaultCellStyle.Font = new Font("Century Gothic", 12);
                dgvMusicas.EnableHeadersVisualStyles          = false;
                dgvMusicas.ColumnHeadersBorderStyle           = DataGridViewHeaderBorderStyle.None;
                dgvMusicas.AutoResizeColumnHeadersHeight();
                dgvMusicas.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(41, 39, 40);
                dgvMusicas.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
            }

            votos.Clear();
        }
コード例 #11
0
ファイル: ctrlUsuarios.cs プロジェクト: lucassartor/symphony
 private void txtPesquisa_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == 13)
     {
         if (!String.IsNullOrWhiteSpace(txtPesquisa.Text))
         {
             string pesquisa = txtPesquisa.Text;
             string sql      = "select id_usuario as ID, nome as Nome, idade as Idade, genero as Gênero from public.usuarios where nome like '%" + pesquisa + "%' ";
             dgvUsuarios.DataSource = ConexaoBanco.SelecionarDataSet(sql).Tables[0];
         }
     }
 }
コード例 #12
0
        private void ctrlPerfil_Load(object sender, EventArgs e)
        {
            string        sql   = "SELECT * FROM public.usuarios where id_usuario = @1";
            List <object> param = new List <object>();

            param.Add(id_usuario);
            NpgsqlDataReader dr = ConexaoBanco.Selecionar(sql, param);

            if (dr.Read())
            {
                lblNomeUser.Text  = dr["nome"].ToString();
                lblNomeUser2.Text = dr["nome"].ToString();
                lblLogin.Text     = dr["login"].ToString();



                lblGosto.Text = "Curte Música " + dr["genero"].ToString();
                lblIdade.Text = dr["idade"].ToString() + " Anos";

                byte[]       bytes = Convert.FromBase64String(dr["imagem"].ToString());
                Image        image;
                MemoryStream ms = new MemoryStream(bytes);
                image           = Image.FromStream(ms);
                picPerfil.Image = image;
            }

            dr.Close();

            sql = "select nome,genero from public.musicas where id_usuario = " + id_usuario + "order by nome ";
            dgvPlaylist.DataSource = ConexaoBanco.SelecionarDataSet(sql).Tables[0];

            dgvPlaylist.DefaultCellStyle.Font = new Font("Century Gothic", 10);
            dgvPlaylist.BorderStyle           = BorderStyle.None;
            dgvPlaylist.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGray;
            dgvPlaylist.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal;
            dgvPlaylist.DefaultCellStyle.SelectionBackColor = Color.FromArgb(178, 8, 55);
            dgvPlaylist.DefaultCellStyle.SelectionForeColor = Color.WhiteSmoke;
            dgvPlaylist.BackgroundColor = Color.FromArgb(240, 240, 240);

            dgvPlaylist.ColumnHeadersDefaultCellStyle.Font = new Font("Century Gothic", 12);
            dgvPlaylist.EnableHeadersVisualStyles          = false;
            dgvPlaylist.ColumnHeadersBorderStyle           = DataGridViewHeaderBorderStyle.None;
            dgvPlaylist.AutoResizeColumnHeadersHeight();
            dgvPlaylist.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(41, 39, 40);
            dgvPlaylist.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
        }
コード例 #13
0
 private void btnCadastrar_Click(object sender, EventArgs e)
 {
     try
     {
         string sql = "INSERT INTO public.musicas " +
                      "(id_musica, nome, album, genero, ano_lançamento, imagem, id_usuario, link, nome_artista, qntd_likes, qntd_dislikes)" +
                      " VALUES(DEFAULT,@1,@2,@3,@4,@5,@6,@7,@8,0,0)";
         List <object> param = new List <object>();
         param.Add(txtNome.Text);
         param.Add(txtAlbum.Text);
         param.Add(Convert.ToString(cmbGenero.SelectedItem));
         param.Add(Convert.ToDecimal(mskData.Text));
         param.Add(image2b64);
         param.Add(id_usuario);
         param.Add(txtLink.Text);
         param.Add(txtArtista.Text);
         ConexaoBanco.Executar(sql, param);
         MessageBox.Show("Musica: " + txtNome.Text + " Cadastrada", "Symphony TM", MessageBoxButtons.OK, MessageBoxIcon.None);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Erro ao cadastrar musica" + ex.Message.ToString(), "Symphony TM", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #14
0
        private void frmMusica_Load(object sender, EventArgs e)
        {
            string        sql   = "select * from public.musicas where id_musica = @1";
            List <object> param = new List <object>();

            param.Add(id_musica);
            NpgsqlDataReader dr = ConexaoBanco.Selecionar(sql, param);

            dr.Read();
            lblAlbum.Text   = dr["album"].ToString();
            lblData.Text    = dr["ano_lançamento"].ToString();
            lblDislike.Text = dr["qntd_dislikes"].ToString();
            lblLike.Text    = dr["qntd_likes"].ToString();
            lblGenero.Text  = dr["genero"].ToString();
            lblNome.Text    = dr["nome"].ToString();
            lblArtista.Text = dr["nome_artista"].ToString();
            qntdLikes       = Convert.ToInt64(dr["qntd_likes"]);
            qntdDislikes    = Convert.ToInt64(dr["qntd_dislikes"]);
            lblLike.Text    = qntdLikes.ToString();
            lblDislike.Text = qntdDislikes.ToString();


            byte[]       bytes = Convert.FromBase64String(dr["imagem"].ToString());
            Image        image;
            MemoryStream ms = new MemoryStream(bytes);

            image           = Image.FromStream(ms);
            picMusica.Image = image;
            string link = dr["link"].ToString();

            if (link.IndexOf("watch?") >= 0)
            {
                link = link.Replace("watch?", "");
                link = link.Replace("=", "/");
                //link = link + "&autoplay=1";
            }

            sfoVideo.Movie = link;


            dr.Close();

            sql   = "select * from public.votos where id_usuario = @1 and id_musica = @2";
            param = new List <object>();
            param.Add(id_usuario);
            param.Add(id_musica);
            dr = ConexaoBanco.Selecionar(sql, param);
            if (dr.Read())
            {
                try
                {
                    javotou = true;
                    bool voto = Convert.ToBoolean(dr["voto"]);
                    like    = voto;
                    dislike = !voto;

                    if (like)
                    {
                        picLike.ImageLocation = "C:\\Users\\Usuario\\Desktop\\SymphonyLucas17;11\\likeverde.png";
                        qntdLikes--;
                    }
                    else if (dislike)
                    {
                        picDislike.ImageLocation = "C:\\Users\\Usuario\\Desktop\\SymphonyLucas17;11\\dislikevermelho.png";
                        qntdDislikes--;
                    }
                }
                catch (Exception)
                {
                    picLike.ImageLocation    = "C:\\Users\\Usuario\\Desktop\\SymphonyLucas17;11\\likebranco.png";
                    picDislike.ImageLocation = "C:\\Users\\Usuario\\Desktop\\SymphonyLucas17;11\\dislikebranco.png";
                }
            }
            dr.Close();
        }