Пример #1
0
        //

        //
        public ObservableCollection <ListaAlunos> CarregaNotasAluno()
        {
            ObservableCollection <ListaAlunos> ListaAlunos = new ObservableCollection <ListaAlunos>();
            Turma turma = Turma.Instancia;

            if (conexao.getConexao())
            {
                try
                {
                    conexao.Comando = new MySqlCommand("SELECT ROUND(SUM(nt.nota) / COUNT(nt.nota), 2) nota FROM notas_tarefas nt, tarefa t WHERE nt.id_tarefa = t.id AND t.id_turma = @id_turma  AND nt.id_aluno = @id_aluno", conexao.Conexao);
                    conexao.Comando.Parameters.AddWithValue("@id_turma", turma.Id);
                    conexao.Comando.Parameters.AddWithValue("@id_aluno", usuario.Id);
                    conexao.Rdr = conexao.Comando.ExecuteReader();

                    while (conexao.Rdr.Read())
                    {
                        ListaAlunos listaAlunos = new ListaAlunos();
                        listaAlunos.Nome = "";
                        listaAlunos.Nota = conexao.Rdr["nota"].ToString();
                        ListaAlunos.Add(listaAlunos);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
                finally
                {
                    conexao.CloseConnection();
                }
            }
            return(ListaAlunos);
        }
Пример #2
0
        //

        // Retorna as Notas de uma Tarefa do Grupo ou do Aluno
        public ObservableCollection <ListaAlunos> CarregaNotasTarefasGrupo()
        {
            ObservableCollection <ListaAlunos> ListaAlunos = new ObservableCollection <ListaAlunos>();

            if (conexao.getConexao())
            {
                try
                {
                    conexao.Comando = new MySqlCommand("SELECT u.id, u.nome, ROUND(SUM(nt.nota) / COUNT(nt.nota), 2) nota FROM notas_tarefas nt ,usuario u WHERE u.id = nt.id_aluno AND nt.id_tarefa = @id_tarefa AND u.id IN (SELECT ta.id_aluno FROM tarefas_alunos ta WHERE ta.id_tarefa_postada IN (SELECT tal.id_tarefa_postada FROM tarefas_alunos tal ,tarefa_postada tp WHERE tp.id_tarefa = nt.id_tarefa AND tal.id_tarefa_postada = tp.id AND tal.id_aluno = @id_aluno)) GROUP BY u.id, u.nome", conexao.Conexao);
                    conexao.Comando.Parameters.AddWithValue("@id_tarefa", tarefa.Id);
                    conexao.Comando.Parameters.AddWithValue("@id_aluno", usuario.Id);

                    conexao.Rdr = conexao.Comando.ExecuteReader();

                    while (conexao.Rdr.Read())
                    {
                        ListaAlunos alunos = new ListaAlunos();
                        alunos.Nome = conexao.Rdr["nome"].ToString();
                        alunos.Nota = conexao.Rdr["nota"].ToString();
                        ListaAlunos.Add(alunos);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
                finally
                {
                    conexao.CloseConnection();
                }
            }
            return(ListaAlunos);
        }
Пример #3
0
        //

        //Carrega lista de alunos de uma turma
        public ObservableCollection <ListaAlunos> CarregaAlunos()
        {
            ObservableCollection <ListaAlunos> ListaAlunos = new ObservableCollection <ListaAlunos>();
            Turma turma = Turma.Instancia;

            if (conexao.getConexao())
            {
                try
                {
                    conexao.Comando = new MySqlCommand("SELECT u.id, u.nome aluno, u.matricula FROM turma_aluno ta, usuario u WHERE u.id = ta.id_aluno AND ta.id_turma = @id", conexao.Conexao);
                    conexao.Comando.Parameters.AddWithValue("@id", turma.Id);
                    conexao.Rdr = conexao.Comando.ExecuteReader();

                    while (conexao.Rdr.Read())
                    {
                        ListaAlunos listaAlunos = new ListaAlunos();
                        listaAlunos.Id          = Convert.ToInt32(conexao.Rdr["id"].ToString());
                        listaAlunos.Nome        = conexao.Rdr["aluno"].ToString();
                        listaAlunos.Matricula   = Convert.ToInt32(conexao.Rdr["matricula"].ToString());
                        listaAlunos.Selecionado = false;
                        ListaAlunos.Add(listaAlunos);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
                finally
                {
                    conexao.CloseConnection();
                }
            }
            return(ListaAlunos);
        }
Пример #4
0
        //

        // Retorna os Alunos de uma Tarefa
        public ObservableCollection <ListaAlunos> CarregaAlunos()
        {
            ObservableCollection <ListaAlunos> ListaAlunos = new ObservableCollection <ListaAlunos>();

            if (conexao.getConexao())
            {
                try
                {
                    conexao.Comando = new MySqlCommand("SELECT u.id, u.nome, u.matricula FROM tarefa_postada tp, tarefas_alunos ta, usuario u WHERE ta.id_tarefa_postada = tp.id AND u.id = ta.id_aluno AND tp.id = @id", conexao.Conexao);
                    conexao.Comando.Parameters.AddWithValue("@id", tarefaPostada.Id);
                    conexao.Rdr = conexao.Comando.ExecuteReader();

                    while (conexao.Rdr.Read())
                    {
                        ListaAlunos alunos = new ListaAlunos();
                        alunos.Id        = Convert.ToInt32(conexao.Rdr["id"].ToString());
                        alunos.Nome      = conexao.Rdr["nome"].ToString();
                        alunos.Matricula = Convert.ToInt32(conexao.Rdr["matricula"].ToString());
                        ListaAlunos.Add(alunos);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
                finally
                {
                    conexao.CloseConnection();
                }
            }
            return(ListaAlunos);
        }