Ejemplo n.º 1
0
        private void btnPlay_Click(object sender, EventArgs e)
        {
            if (txtNome.Text == "Digite seu nome")
            {
                MessageBox.Show("Você deve informar seu nome", "ATENÇÃO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtNome.Focus();
            }
            else if (txtEmail.Text == "Digite seu e-mail")
            {
                MessageBox.Show("Você deve informar seu e-mail", "ATENÇÃO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtEmail.Focus();
            }

            //fghf

            //ugii
            //início do código para inserir o jogador na tabela
            //using System.Data.SqlClient;
            using (SqlConnection conexao = new SqlConnection("Server=AME0556318W10-1\\SQLEXPRESS;Database=db_PerguntasERespostas;Trusted_Connection=Yes"))
            {
                using (SqlCommand comando = new SqlCommand("insert into tb_jogador(nome, sobrenome, email) OUTPUT INSERTED.ID values(@NOME, @SOBRENOME, @EMAIL)", conexao))
                {
                    comando.Parameters.AddWithValue("NOME", txtNome.Text);
                    comando.Parameters.AddWithValue("SOBRENOME", txtSobrenome.Text);
                    comando.Parameters.AddWithValue("EMAIL", txtSobrenome.Text);
                    conexao.Open();

                    int id_jogador = (int)comando.ExecuteScalar();

                    if (id_jogador > 0)
                    {
                        MessageBox.Show("O ID inserido foi: " + id_jogador);

                        MessageBox.Show("Olá " + txtNome.Text.ToUpper() + ". Você está pronto para continuar!!!", "PLAYYYY", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                        /* System.Media.SoundPlayer player = new System.Media.SoundPlayer();
                         * player.SoundLocation = "c:\\vm\\teste\\som.wav";
                         * player.Play();*/


                        //TelaInstrucoes Inst = new TelaInstrucoes();
                        //Inst.ShowDialog();
                        Pergunta1 p1 = new Pergunta1(id_jogador);
                        p1.ShowDialog();
                        Pergunta2 p2 = new Pergunta2(id_jogador);
                        p2.ShowDialog();
                        Pergunta3 p3 = new Pergunta3(id_jogador);
                        p3.ShowDialog();
                        Pergunta4 p4 = new Pergunta4(id_jogador);
                        p4.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("DEU RUIMMMM!!!! Algo aconteceu durante o insert");
                    }
                }
            }
            //fim do código para inserir o jogador na tabela
        }
Ejemplo n.º 2
0
        private void btnPlay_Click(object sender, EventArgs e)
        {
            if (txtNome.Text == "Digite seu nome")
            {
                MessageBox.Show("Você deve informar seu nome", "ATENÇÃO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtNome.Focus();
            }
            else
            {
                //início do código para inserir o jogador na tabela
                //using System.Data.SqlClient;
                using (SqlConnection conexao = new SqlConnection("Server=AME0510021W10-1\\SQLEXPRESS;Database=db_PerguntasERespostas;Trusted_Connection=Yes"))
                {
                    using (SqlCommand comando = new SqlCommand("insert into tb_jogador(nome) OUTPUT INSERTED.ID values(@NOME)", conexao))
                    {
                        comando.Parameters.AddWithValue("NOME", txtNome.Text);
                        conexao.Open();

                        int id_jogador = (int)comando.ExecuteScalar();

                        if (id_jogador > 0)
                        {
                            MessageBox.Show("O id inserido foi: " + id_jogador);

                            MessageBox.Show("Olá " + txtNome.Text.ToUpper() + ". Você está pronto para continuar!!!", "PLAYYYY", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                            //System.Media.SoundPlayer player = new System.Media.SoundPlayer();
                            // player.SoundLocation = "c:\\vm\\teste\\som.wav";
                            // player.Play();

                            Pergunta1 p1 = new Pergunta1(id_jogador);
                            p1.ShowDialog();
                            Pergunta2 p2 = new Pergunta2(id_jogador);
                            p2.ShowDialog();
                            Pergunta3 p3 = new Pergunta3(id_jogador);
                            p3.ShowDialog();
                            Pergunta4 p4 = new Pergunta4(id_jogador);
                            p4.ShowDialog();

                            comando.CommandText = "select COUNT(pergunta) from tb_perguntas where id_jogador = " + id_jogador;
                            SqlDataReader dr_acertos = comando.ExecuteReader();
                            dr_acertos.Read();
                            MessageBox.Show("Sua pontuação é: " + dr_acertos.GetInt32(0));
                            dr_acertos.Close();
                        }
                        else
                        {
                            MessageBox.Show("DEU RUIMMMM!!!! Algo aconteceu durante o insert");
                        }
                    }
                }
                //fim do código para inserir o jogador na tabela
            }
        }
Ejemplo n.º 3
0
        private void btnPlay_Click(object sender, EventArgs e)
        {
            if (txtNome.Text == "Digite seu nome")
            {
                MessageBox.Show("Você deve informar seu nome", "ATENÇÃO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtNome.Focus();
            }
            else
            {
                //início do código para inserir o jogador na tabela
                //using System.Data.SqlClient;
                using (SqlConnection conexao = new SqlConnection("Server=AME0524167W10-1\\SQLEXPRESS;Database=PER;Trusted_Connection=Yes"))
                {
                    using (SqlCommand comando = new SqlCommand("insert into Jogador(nome) OUTPUT INSERTED.ID values(@NOME)", conexao))
                    {
                        comando.Parameters.AddWithValue("NOME", txtNome.Text);
                        conexao.Open();

                        int id_jogador = (int)comando.ExecuteScalar();
                        // if(comando.ExecuteNonQuery() == 1)
                        if (id_jogador > 0)
                        {
                            MessageBox.Show("Olá " + txtNome.Text.ToUpper() + " Seu id é: " + id_jogador + ". Você está pronto para continuar!!!", "PLAYYYY", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                            /* System.Media.SoundPlayer player = new System.Media.SoundPlayer();
                             * player.SoundLocation = "C:\\Users\\andre.sacilotto\\Downloads\\som.wav";
                             * player.Play();*/


                            Pergunta1 P1 = new Pergunta1(id_jogador); Pergunta2 P2 = new Pergunta2(id_jogador);
                            Pergunta3 P3 = new Pergunta3(id_jogador); Pergunta4 P4 = new Pergunta4(id_jogador);

                            P1.ShowDialog(); P2.ShowDialog(); P3.ShowDialog(); P4.ShowDialog();

                            comando.CommandText = "select COUNT(pergunta) from TBPerguntas where id_jogador = @Nun";

                            comando.Parameters.AddWithValue("Nun", id_jogador);
                            SqlDataReader acertos = comando.ExecuteReader();
                            acertos.Read();
                            MessageBox.Show("Sua pontuação é: " + acertos.GetInt32(0));
                            acertos.Close();
                        }
                        else
                        {
                            MessageBox.Show("DEU RUIMMMM!!!! Algo aconteceu durante o insert");
                        }
                    }
                }
                //fim do código para inserir o jogador na tabela
            }
        }
Ejemplo n.º 4
0
        private void btnPlay_Click(object sender, EventArgs e)
        {
            if (txtNome.Text == "Digite seu nome")
            {
                MessageBox.Show("Você deve informar seu nome", "ATENÇÃO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtNome.Focus();
            }
            else
            {
                //início do código para inserir o jogador na tabela
                //using System.Data.SqlClient;
                using (SqlConnection conexao = new SqlConnection("Server=AME0510018W10-1\\SQLEXPRESS;Database=db_PerguntasERespostas;Trusted_Connection=Yes"))
                {
                    using (SqlCommand comando = new SqlCommand("insert into tb_jogador(nome) OUTPUT INSERTED.ID values(@NOME)", conexao))
                    {
                        comando.Parameters.AddWithValue("NOME", txtNome.Text);
                        conexao.Open();

                        int id_jogador = (int)comando.ExecuteScalar();
                        if (id_jogador > 0)
                        {
                            MessageBox.Show("o id inserido foi: " + id_jogador);

                            MessageBox.Show("Olá " + txtNome.Text.ToUpper() + ". Você está pronto para continuar!!!", "PLAYYYY", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                            //execuçao do som

                            /* System.Media.SoundPlayer player = new System.Media.SoundPlayer();
                             * player.SoundLocation = "C:\\Users\\philipe.bmassieu\\Desktop\\cartoon008.wav";
                             * player.Play();
                             */

                            //abertura do formulario de peergunta
                            Pergunta1 p1 = new Pergunta1(id_jogador);
                            p1.ShowDialog();
                            Pergunta2 p2 = new Pergunta2(id_jogador);
                            p2.ShowDialog();
                            Pergunta3 p3 = new Pergunta3(id_jogador);
                            p3.ShowDialog();
                            Pergunta4 p4 = new Pergunta4(id_jogador);
                            p4.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("DEU RUIMMMM!!!! Algo aconteceu durante o insert");
                        }
                    }
                }
                //fim do código para inserir o jogador na tabela
            }
        }