IEnumerator ContagemDoRelogio()
    {
        relogio.sprite = relogioEmSegundos[30];
        for (int i = 29; i >= 0; i--)
        {
            if (!respondendo)
            {
                yield break;
            }

            yield return(new WaitForSeconds(1));

            relogio.sprite = relogioEmSegundos[i];
        }

        //definindo qual tema nao foi respondido
        if (temas.Count >= 1 && perguntaAtiva.GetTemaId() == temas[0].GetId())
        {
            tema1Total++;
        }
        else if (temas.Count >= 2 && perguntaAtiva.GetTemaId() == temas[1].GetId())
        {
            tema2Total++;
        }
        else if (temas.Count >= 3 && perguntaAtiva.GetTemaId() == temas[2].GetId())
        {
            tema3Total++;
        }
        else if (temas.Count >= 4 && perguntaAtiva.GetTemaId() == temas[3].GetId())
        {
            tema4Total++;
        }

        DesativarPerguntas(0);
        acabouOTempoSND.Play();
        respondendo = false;
    }
Ejemplo n.º 2
0
    public void Incluir(Pergunta pergunta)
    {
        //conexão
        MySqlConnection db = Connection.getConnection();

        //transação
        MySqlTransaction mySQLTransaction;

        mySQLTransaction = db.BeginTransaction();

        try
        {
            //comando na conexão para execução da procedure
            MySqlCommand mySQLcmd = db.CreateCommand();

            //setando a procedure do banco
            mySQLcmd.CommandType = CommandType.StoredProcedure;
            mySQLcmd.CommandText = "Pergunta_Inserir";

            //preenchendo os parametros da procedure
            mySQLcmd.Parameters.AddWithValue("LOC_DESCRICAO", pergunta.GetDescricao());
            mySQLcmd.Parameters.AddWithValue("LOC_CORRETA", pergunta.GetCorreta());
            mySQLcmd.Parameters.AddWithValue("LOC_ERRADA1", pergunta.GetErrada1());
            mySQLcmd.Parameters.AddWithValue("LOC_ERRADA2", pergunta.GetErrada2());
            mySQLcmd.Parameters.AddWithValue("LOC_ERRADA3", pergunta.GetErrada3());
            mySQLcmd.Parameters.AddWithValue("LOC_DIFICULDADE", pergunta.GetDificuldade());
            //mySQLcmd.Parameters.AddWithValue("LOC_SIMULADO", pergunta.GetSimulado());
            mySQLcmd.Parameters.AddWithValue("LOC_FUNCIONARIO_ID", pergunta.GetFuncId());
            mySQLcmd.Parameters.AddWithValue("LOC_TEMA_ID", pergunta.GetTemaId());

            //ligando a transação
            mySQLcmd.Transaction = mySQLTransaction;

            //execução sem retorno
            mySQLcmd.ExecuteNonQuery();

            //commit da transação
            mySQLTransaction.Commit();
        }
        catch (MySqlException ex)
        {
            try
            {
                //rollback caso haja erro no MySQL
                mySQLTransaction.Rollback();
            }
            catch (MySqlException ex1)
            {
                throw new ExcecaoSAG("Erro na inclusão da pergunta. Código " + ex1.ToString());
            }
        }
        catch (ExcecaoSAG ex)
        {
            try
            {
                //rollback caso haja erro na aplicação
                mySQLTransaction.Rollback();
            }
            catch (MySqlException ex1)
            {
                throw new ExcecaoSAG("Erro na inclusão da pergunta. Código " + ex1.ToString());
            }
            throw ex;
        }
        finally
        {
            db.Close();
        }
    }