Beispiel #1
0
        private void PreencherCampos(AlunosModel aluno)
        {
            txt_Nome.Text           = aluno.Nome;
            txt_CodigoAluno.Text    = aluno.Id.ToString();
            txt_MatriculaAluno.Text = aluno.Matricula.ToString();
            txt_Nota_1.Text         = aluno.Nota_1.ToString();
            txt_Nota_2.Text         = aluno.Nota_2.ToString();
            txt_Nota_3.Text         = aluno.Nota_3.ToString();
            txt_Frequencia.Text     = aluno.Frequencia.ToString();

            if (aluno.SituacaoAluno.ToLower() == "aprovado")
            {
                lbl_SituacaoAluno.ForeColor = Color.Green;
                lbl_SituacaoAluno.Text      = aluno.SituacaoAluno.ToString();
            }
            else if (aluno.SituacaoAluno.ToLower() == "recuperação")
            {
                lbl_SituacaoAluno.ForeColor = Color.DarkKhaki;
                lbl_SituacaoAluno.Text      = aluno.SituacaoAluno.ToString();
            }
            else
            {
                lbl_SituacaoAluno.ForeColor = Color.Red;
                lbl_SituacaoAluno.Text      = aluno.SituacaoAluno.ToString();
            }
        }
Beispiel #2
0
        public List <AlunosModel> obeterTodos(string texteParaPesquisar = "%%", string colunaOrdenacao = "nome", string tipoOrdenacao = "ASC")
        {
            texteParaPesquisar = "%" + texteParaPesquisar + "%";
            List <AlunosModel> alunos = new List <AlunosModel>();

            connection.Open();
            command.Connection  = connection;
            command.CommandText = @"SELECT id, nome, matricula, nota_1, nota_2, nota_3, frequencia WHERE nome like @pesquisa ORDER BY " + colunaOrdenacao + " " + tipoOrdenacao;
            command.Parameters.AddWithValue("@PESQUISA", texteParaPesquisar);
            DataTable tabelaEmMemoria = new DataTable();

            tabelaEmMemoria.Load(command.ExecuteReader());
            for (int i = 0; i < tabelaEmMemoria.Rows.Count; i++)
            {
                AlunosModel aluno = new AlunosModel();
                aluno.Id         = Convert.ToInt32(tabelaEmMemoria.Rows[i][0].ToString());
                aluno.Nome       = tabelaEmMemoria.Rows[i][1].ToString();
                aluno.Matricula  = Convert.ToInt16(tabelaEmMemoria.Rows[i][2].ToString());
                aluno.Nota_1     = Convert.ToDouble(tabelaEmMemoria.Rows[i][3].ToString());
                aluno.Nota_2     = Convert.ToDouble(tabelaEmMemoria.Rows[i][4].ToString());
                aluno.Nota_3     = Convert.ToDouble(tabelaEmMemoria.Rows[i][5].ToString());
                aluno.Frequencia = Convert.ToInt16(tabelaEmMemoria.Rows[i][6].ToString());
                alunos.Add(aluno);
            }
            return(alunos);
        }
Beispiel #3
0
        public AlunosModel ObterCodigo(int codigo)
        {
            connection.Open();
            command.Connection  = connection;
            command.CommandText = @"SELECT id, nome, nota_1, nota_2, nota_3, frequencia WHERE id = @ID";
            command.Parameters.AddWithValue("@ID", codigo);
            DataTable tabelaMemoria = new DataTable();

            tabelaMemoria.Load(command.ExecuteReader());
            if (tabelaMemoria.Rows.Count == 0)
            {
                return(null);
            }
            AlunosModel aluno = new AlunosModel();

            aluno.Id         = Convert.ToInt32(tabelaMemoria.Rows[0][0].ToString());
            aluno.Nome       = tabelaMemoria.Rows[0][1].ToString();
            aluno.Matricula  = Convert.ToInt16(tabelaMemoria.Rows[0][2].ToString());
            aluno.Nota_1     = Convert.ToDouble(tabelaMemoria.Rows[0][3].ToString());
            aluno.Nota_2     = Convert.ToDouble(tabelaMemoria.Rows[0][4].ToString());
            aluno.Nota_3     = Convert.ToDouble(tabelaMemoria.Rows[0][5].ToString());
            aluno.Frequencia = Convert.ToInt32(tabelaMemoria.Rows[0][6].ToString());
            connection.Close();
            return(aluno);
        }
Beispiel #4
0
        public bool Alterar(AlunosModel alunos)
        {
            connection.Open();
            command.Connection  = connection;
            command.CommandText = @"UPDATE alunos SET nome = @NOME, matricula = @MATRICULA, nota_1 = @NOTA_1, nota_2 = @NOTA_2, nota_3 = @NOTA_3, frequencia = @FREQUENCIA WHERE id = @ID";
            command.Parameters.AddWithValue("@NOME", alunos.Nome);
            command.Parameters.AddWithValue("@MATRICULA", alunos.Matricula);
            command.Parameters.AddWithValue("@NOTA_1", alunos.Nota_1);
            command.Parameters.AddWithValue("@NOTA_2", alunos.Nota_2);
            command.Parameters.AddWithValue("@NOTA_3", alunos.Nota_3);
            command.Parameters.AddWithValue("@FREQUENCIA", alunos.Frequencia);
            int quantidade = command.ExecuteNonQuery();

            connection.Close();
            return(quantidade == 1);
        }
Beispiel #5
0
        public int Inserir(AlunosModel alunos)
        {
            connection.Open();
            command.Connection  = connection;
            command.CommandText = @"INSERT INTO alunos(nome, nota_1, nota_2, nota_3, frequencia)VALUES(@NOME, @NOTA1, @NOTA2, @NOTA3, @FREQUENCIA)";

            command.Parameters.AddWithValue("@NOME", alunos.Nome);
            command.Parameters.AddWithValue("@NOTA1", alunos.Nota_1);
            command.Parameters.AddWithValue("@NOTA2", alunos.Nota_2);
            command.Parameters.AddWithValue("@NOTA3", alunos.Nota_3);
            command.Parameters.AddWithValue("@FREQUENCIA", alunos.Frequencia);

            int id = Convert.ToInt32(command.ExecuteScalar().ToString());

            connection.Close();
            return(id);
        }
Beispiel #6
0
 public void updateAluno(AlunosModel aluno)
 {
     try
     {
         dao = new ConnectorDAO();
         dao.connect();
         string query = "UPDATE alunos SET NOME = '" + aluno.Nome + "', EMAIL = '" + aluno.Email + "', CELULAR = '" + aluno.Celular + "', DATA_NASCIMENTO = '" + aluno.DataNascimento + "', PLANO = '" + aluno.Plano + "', STATUS = '" + aluno.Status + "' WHERE ID = '" + aluno.Id + "'";
         dao.executeQuery(query);
     }
     catch (Exception ex)
     {
         throw new Exception("Erro ao tentar atualizar o aluno:" + ex.Message);
     }
     finally
     {
         dao = null;
     }
 }
Beispiel #7
0
 public void insertAluno(AlunosModel aluno)
 {
     try
     {
         dao = new ConnectorDAO();
         dao.connect();
         string query = "INSERT INTO alunos (NOME, EMAIL, CELULAR, DATA_NASCIMENTO, PLANO, STATUS) VALUES ('" + aluno.Nome + "', '" + aluno.Email + "', '" + aluno.Celular + "', '" + aluno.DataNascimento + "', '" + aluno.Plano + "', '" + aluno.Status + "')";
         dao.executeQuery(query);
     }
     catch (Exception ex)
     {
         throw new Exception("Erro ao tentar cadastrar o aluno:" + ex.Message);
     }
     finally
     {
         dao = null;
     }
 }
Beispiel #8
0
        public bool Alterar(AlunosModel alunos)
        {
            connection.Open();
            command.Connection  = connection;
            command.CommandText = @"UPDATE alunos SET nome = @NOME, matricula = @MATRICULA, nota_1 = @NOTA_1, nota_2 = @NOTA_2, nota_3 = @NOTA_3, frequencia = @FREQUENCIA, media_notas = @MEDIA, situacao_aluno = @SITUACAO WHERE id = @CODIGO";
            command.Parameters.AddWithValue("@NOME", alunos.Nome);
            command.Parameters.AddWithValue("@MATRICULA", alunos.Matricula);
            command.Parameters.AddWithValue("@NOTA_1", alunos.Nota_1);
            command.Parameters.AddWithValue("@NOTA_2", alunos.Nota_2);
            command.Parameters.AddWithValue("@NOTA_3", alunos.Nota_3);
            command.Parameters.AddWithValue("@FREQUENCIA", alunos.Frequencia);
            command.Parameters.AddWithValue("@MEDIA", alunos.MediaNotas);
            command.Parameters.AddWithValue("@SITUACAO", alunos.SituacaoAluno);
            command.Parameters.AddWithValue("@CODIGO", alunos.Id);
            int quantidade = command.ExecuteNonQuery();

            connection.Close();
            return(quantidade == 1);
        }
Beispiel #9
0
        public int Inserir(AlunosModel alunos)
        {
            connection.Open();
            command.Connection  = connection;
            command.CommandText = @"INSERT INTO alunos(nome, matricula, nota_1, nota_2, nota_3, frequencia, media_notas, situacao_aluno) OUTPUT INSERTED.ID VALUES(@NOME, @MATRICULA, @NOTA1, @NOTA2, @NOTA3, @FREQUENCIA, @MEDIA, @SITUACAO)";


            command.Parameters.AddWithValue("@NOME", alunos.Nome);
            command.Parameters.AddWithValue("@MATRICULA", alunos.Matricula);
            command.Parameters.AddWithValue("@NOTA1", alunos.Nota_1);
            command.Parameters.AddWithValue("@NOTA2", alunos.Nota_2);
            command.Parameters.AddWithValue("@NOTA3", alunos.Nota_3);
            command.Parameters.AddWithValue("@FREQUENCIA", alunos.Frequencia);
            command.Parameters.AddWithValue("@MEDIA", alunos.MediaNotas);
            command.Parameters.AddWithValue("@SITUACAO", alunos.SituacaoAluno);

            int id = Convert.ToInt32(command.ExecuteScalar().ToString());

            connection.Close();
            return(id);
        }
        public ActionResult ExemplosRazor(string nomeAlunoEspecial, int?idade)
        {
            var lista = new List <string>()
            {
                "Anna da Silva",
                "Arthur Lima",
                "Cassio Machado",
                "Daniel Fedrigo",
                "Douglas Freitas",
                "Eduardo Ribas",
                "Eliseu Daroit",
                "Felipe Souza",
                "Gabriel Henz",
                "Gabriel Rosa",
                "Henrique Mentz",
                "Henrique Oestermann",
                "Jennifer Costa",
                "Jonathan Mendes",
                "Leonardo Almeida",
                "Máicon Loenbes",
                "Mateus Ramos",
                "Matheus Schmitz",
                "Mateus Teixeira",
                "Otávio Bubans",
                "Rafael da Silva",
                "Régis Martiny",
                "Rodrigo Scheuer",
                "Pablo Schlusen",
                "Victor Bittencourt",
                nomeAlunoEspecial
            };

            var alunosModel = new AlunosModel()
            {
                ListaCompleta = lista
            };

            return(View(alunosModel));
        }
Beispiel #11
0
        private void btn_Salvar_Click(object sender, EventArgs e)
        {
            AlunosModel aluno = new AlunosModel();

            try
            {
                if (Utils.Exeption(Utils.ValidarMatricula(Convert.ToInt16(txt_MatriculaAluno.Text))))
                {
                    MessageBox.Show(Utils.ValidarMatricula(Convert.ToInt16(txt_MatriculaAluno.Text)));
                    txt_MatriculaAluno.Focus();
                    txt_MatriculaAluno.SelectionStart  = 0;
                    txt_MatriculaAluno.SelectionLength = txt_MatriculaAluno.Text.Length;
                    return;
                }

                else if (Utils.Exeption(Utils.ValidarNome(txt_Nome.Text)))
                {
                    MessageBox.Show(Utils.ValidarNome(txt_Nome.Text));
                    txt_Nome.Focus();
                    return;
                }
                else if (Utils.Exeption(Utils.ValidarNota(Convert.ToDouble(txt_Nota_1.Text))))
                {
                    MessageBox.Show(Utils.ValidarNota(Convert.ToDouble(txt_Nota_1.Text)));
                    txt_Nota_1.Focus();
                    txt_Nota_1.SelectionStart  = 0;
                    txt_Nota_1.SelectionLength = txt_Nota_1.Text.Length;
                    return;
                }
                else if (Utils.Exeption(Utils.ValidarNota(Convert.ToDouble(txt_Nota_2.Text))))
                {
                    MessageBox.Show(Utils.ValidarNota(Convert.ToDouble(txt_Nota_2.Text)));
                    txt_Nota_2.Focus();
                    txt_Nota_2.SelectionStart  = 0;
                    txt_Nota_2.SelectionLength = txt_Nota_2.Text.Length;

                    return;
                }
                else if (Utils.Exeption(Utils.ValidarNota(Convert.ToDouble(txt_Nota_3.Text))))
                {
                    MessageBox.Show(Utils.ValidarNota(Convert.ToDouble(txt_Nota_3.Text)));
                    txt_Nota_3.Focus();
                    txt_Nota_3.SelectionStart  = 0;
                    txt_Nota_3.SelectionLength = txt_Nota_3.Text.Length;
                    return;
                }
                else if (Utils.Exeption(Utils.ValidarFrequencia(Convert.ToInt16(txt_Frequencia.Text))))
                {
                    MessageBox.Show(Utils.ValidarFrequencia(Convert.ToInt16(txt_Frequencia.Text)));
                    txt_Frequencia.Focus();
                    txt_Frequencia.SelectionStart  = 0;
                    txt_Frequencia.SelectionLength = txt_Frequencia.Text.Length;
                    return;
                }
                else if (Utils.Exeption(Utils.ValidarMatricula(Convert.ToInt16(txt_MatriculaAluno.Text))))
                {
                    MessageBox.Show(Utils.ValidarMatricula(Convert.ToInt16(txt_MatriculaAluno.Text)));
                    txt_MatriculaAluno.Focus();
                    txt_MatriculaAluno.SelectionStart  = 0;
                    txt_MatriculaAluno.SelectionLength = txt_MatriculaAluno.Text.Length;
                    return;
                }


                aluno.Matricula     = Convert.ToInt16(txt_MatriculaAluno.Text);
                aluno.Nome          = txt_Nome.Text;
                aluno.Nota_1        = Convert.ToDouble(txt_Nota_1.Text);
                aluno.Nota_2        = Convert.ToDouble(txt_Nota_2.Text);
                aluno.Nota_3        = Convert.ToDouble(txt_Nota_3.Text);
                aluno.Frequencia    = Convert.ToInt16(txt_Frequencia.Text);
                aluno.MediaNotas    = Utils.MediaNotas(Convert.ToDouble(txt_Nota_1.Text), Convert.ToDouble(txt_Nota_2.Text), Convert.ToDouble(txt_Nota_3.Text));
                aluno.SituacaoAluno = Utils.SituacaoMedia(Utils.MediaNotas(Convert.ToDouble(txt_Nota_1.Text), Convert.ToDouble(txt_Nota_2.Text), Convert.ToDouble(txt_Nota_3.Text)));
            }
            catch (Exception)
            {
                MessageBox.Show("ERRO ao Salvar.");
                return;
            }


            if (string.IsNullOrEmpty(txt_CodigoAluno.Text))
            {
                int id = new AlunosRepository().Inserir(aluno);
                txt_CodigoAluno.Text = id.ToString();
                MessageBox.Show("Cadastrado com sucesso!");
            }
            else
            {
                int id = Convert.ToInt32(txt_CodigoAluno.Text);
                aluno.Id = id;
                bool alterou = new AlunosRepository().Alterar(aluno);
                if (alterou)
                {
                    MessageBox.Show("Alterado com sucesso!");
                }
                else
                {
                    MessageBox.Show("Não foi possível Alterar");
                }
            }
        }