Ejemplo n.º 1
0
 public AtualizaAluno()
 {
     InitializeComponent();
     modo           = Modo.NovoCliente;
     Titulo.Content = "Novo Aluno";
     aluno          = new AlunoEnt();
 }
Ejemplo n.º 2
0
        //==================================

        public frmAluno(Tranz tra)
        {
            aluno     = new AlunoEnt();
            alunoDAO  = new AlunosDAO();
            tranzacao = tra;
            InitializeComponent();
        }
Ejemplo n.º 3
0
 public AtualizaAluno(ClienteEnt cli)
 {
     aluno = new AlunoEnt();
     aluno.Atribuir(cli);
     InitializeComponent();
     txtid_cliente.Text = aluno.id_cliente.ToString();
 }
Ejemplo n.º 4
0
        public List <AlunoEnt> Lista()
        {
            using (SqlConnection con = new SqlConnection()) //Instanciando conexão
            {
                con.ConnectionString = Properties.Settings.Default.banco;
                SqlCommand cn = new SqlCommand();
                cn.CommandType = CommandType.Text;
                con.Open();
                cn.CommandText = "SELECT * FROM aluno ORDER BY id ASC";
                cn.Connection  = con;
                SqlDataReader   dr;
                List <AlunoEnt> Lista = new List <AlunoEnt>();
                dr = cn.ExecuteReader();

                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        AlunoEnt dado = new AlunoEnt();
                        dado.Id            = Convert.ToString(dr["id"]);
                        dado.Nome          = Convert.ToString(dr["nome"]);
                        dado.Cpf           = Convert.ToString(dr["cpf"]);
                        dado.Rg            = Convert.ToString(dr["rg"]);
                        dado.Telefone      = Convert.ToString(dr["telefone"]);
                        dado.Categoriacnh  = Convert.ToString(dr["categoriacnh"]);
                        dado.Horariodeaula = Convert.ToString(dr["horariodeaula"]);
                        Lista.Add(dado);
                    }
                }
                return(Lista);
            }
        }
Ejemplo n.º 5
0
        public void RenovarMatricula(AlunoEnt al)
        {
            SqlCommand cmd = new SqlCommand(string.Format("select count(id_aluno) from tbl_notas where ano = {0} and id_aluno = {1}", al.ano_recente, al.id_aluno), new Conexao().NovaConexaoBdAtaFinal());

            try
            {
                cmd.Connection.Open();
                int valor = (int)cmd.ExecuteScalar();
                if (valor > 0)
                {
                    throw new Exception("aluno já renovou matrícula");
                }
                alunos.RenovarMatricula(new AtaFinalEnt(al, new GetSerie(al.turma.Ano.id_Ano).Serie));
            }
            catch (Exception erro)
            {
                throw erro;
            }
            finally
            {
                cmd.Connection.Close();
                cmd.Connection.Dispose();
                cmd.Dispose();
            }
        }
Ejemplo n.º 6
0
        public List <AlunoEnt> Buscar(AlunoEnt objtabela)
        {
            using (SqlConnection con = new SqlConnection()) //Instanciando conexão
            {
                con.ConnectionString = Properties.Settings.Default.banco;
                SqlCommand cn = new SqlCommand();
                cn.CommandType = CommandType.Text;
                con.Open();
                cn.CommandText = "SELECT * FROM aluno WHERE nome LIKE @nome";
                //Parâmetros Aluno
                cn.Parameters.Add("nome", SqlDbType.VarChar).Value = objtabela.Nome + "%";
                cn.Connection = con;
                SqlDataReader   dr;
                List <AlunoEnt> Lista = new List <AlunoEnt>();
                dr = cn.ExecuteReader();

                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        AlunoEnt dado = new AlunoEnt();
                        dado.Id            = Convert.ToString(dr["id"]);
                        dado.Nome          = Convert.ToString(dr["nome"]);
                        dado.Cpf           = Convert.ToString(dr["cpf"]);
                        dado.Rg            = Convert.ToString(dr["rg"]);
                        dado.Telefone      = Convert.ToString(dr["telefone"]);
                        dado.Categoriacnh  = Convert.ToString(dr["categoriacnh"]);
                        dado.Horariodeaula = Convert.ToString(dr["horariodeaula"]);
                        Lista.Add(dado);
                    }
                }
                return(Lista);
            }
        }
Ejemplo n.º 7
0
        public string AtualizaAlunos(AlunoEnt aluno)
        {
            Conexao con = new Conexao();

            try
            {
                SqlCommand cmd = new SqlCommand("sp_UpdateAlunos", con.NovaConexaoBdAtaFinal());
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@id_aluno", aluno.id_aluno);
                cmd.Parameters.AddWithValue("@nome", aluno.nome);
                cmd.Parameters.AddWithValue("@id_cliente", aluno.id_cliente);
                cmd.Parameters.AddWithValue("@ano_recente", aluno.ano_recente);
                cmd.Parameters.AddWithValue("@id_turma", aluno.turma.id_turma);
                cmd.Parameters.AddWithValue("@nascimento", aluno.nascimento);
                cmd.Parameters.AddWithValue("@sexo", aluno.sexo);
                cmd.Parameters.AddWithValue("@naturalidade", aluno.naturalidade);
                cmd.Parameters.AddWithValue("@uf", aluno.uf);
                cmd.Parameters.AddWithValue("@dadosClinicos", aluno.dadosClinicos);
                cmd.Parameters.AddWithValue("@remedios", aluno.remedios);
                cmd.Parameters.AddWithValue("@id_mac", aluno.id_mac);
                cmd.Parameters.AddWithValue("@integral", aluno.integral);
                cmd.Connection.Open();
                cmd.ExecuteNonQuery();
                cmd.Clone();
                return(con.mensagens);
            }
            catch (Exception erro)
            {
                return(erro.ToString());
            }
        }
Ejemplo n.º 8
0
 private void MeuGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (MeuGrid.SelectedIndex >= 0)
     {
         AlunoEnt aluno = MeuGrid.Items[MeuGrid.SelectedIndex] as AlunoEnt;
         // MessageBox.Show(aluno.ToString());
         //NavigationService.Navigate(new SistemaShekinahCompleto.Views.ViewsSecretaria.AtualizaAluno( aluno));
     }
 }
Ejemplo n.º 9
0
        public AtualizaAluno(AlunoEnt ent)
        {
            modo           = Modo.AlterarCadastro;
            Titulo.Content = "Atualizar Dados Do Aluno";
            InitializeComponent();
            nome.Text = ent.nome;

            txtid_aluno.Text   = "" + ent.id_aluno;
            txtid_cliente.Text = "" + ent.id_cliente;
        }
Ejemplo n.º 10
0
 private void CarregaAluno(AlunoEnt al)
 {
     al.id_aluno    = txtCA.Text.ToInt();
     al.id_cliente  = txtCod.Text.ToInt();
     al.nome        = txtNome.Text;
     al.ano_recente = txtAno.Text;
     //al.turma deve estar pré carregado
     al.nascimento    = data.Value.Date;
     al.naturalidade  = txtnat.Text;
     al.uf            = txtuf.Text;
     al.sexo          = cb.SelectedIndex > 0 ? cb.Text : "";
     al.integral      = cbIntegral.SelectedIndex > 0 ? cbIntegral.Text : "";
     al.remedios      = txtremedio.Text;
     al.dadosClinicos = txtclinicos.Text;
     al.id_mac        = mask.Text;
 }
Ejemplo n.º 11
0
 public int Excluir(AlunoEnt objtabela)
 {
     using (SqlConnection con = new SqlConnection()) //Instanciando conexão
     {
         con.ConnectionString = Properties.Settings.Default.banco;
         SqlCommand cn = new SqlCommand();
         cn.CommandType = CommandType.Text;
         con.Open();
         cn.CommandText = "DELETE FROM aluno WHERE id = @id";
         //Parâmetros Aluno
         cn.Parameters.Add("id", SqlDbType.VarChar).Value = objtabela.Id;
         cn.Connection = con;
         int qtd = cn.ExecuteNonQuery();
         Console.Write(qtd);
         return(qtd);
     }
 }
Ejemplo n.º 12
0
        private void CarregaControles(AlunoEnt al)
        {
            aluno        = al;
            txtCod.Text  = aluno.id_cliente.ToString();
            txtCA.Text   = aluno.id_aluno.ToString();
            txtNome.Text = aluno.nome;
            txtAno.Text  = aluno.ano_recente;
            cbTurma.Text = aluno.turma.ToString();
            txtnat.Text  = aluno.naturalidade;
            txtuf.Text   = aluno.uf;
            data.Value   = aluno.nascimento.Date < data.MinDate ? data.MinDate : aluno.nascimento.Date;

            txtremedio.Text  = aluno.remedios;
            txtclinicos.Text = aluno.dadosClinicos;
            mask.Text        = aluno.id_mac;
            txtAno.Text      = aluno.ano_recente;
        }
Ejemplo n.º 13
0
 public frmAluno(AlunoEnt al, Tranz tra)
 {
     alunoDAO = new AlunosDAO();
     InitializeComponent();
     tranzacao = tra;
     aluno     = al;
     CarregaControles(aluno);
     if (tra == Tranz.Cadastrar)
     {
         cb.SelectedIndex         = 0;
         cbIntegral.SelectedIndex = 0;
     }
     else if (tra == Tranz.Alterar)
     {
         cb.SelectedIndex         = (int)Enum.Parse(typeof(Sexo), aluno.sexo);
         cbIntegral.SelectedIndex = (int)Enum.Parse(typeof(Integral), aluno.integral);
     }
 }
Ejemplo n.º 14
0
        public static AlunoEnt ParaAluno(this SqlDataReader l)
        {
            AlunoEnt aluno = new AlunoEnt();

            aluno.id_aluno       = int.Parse(l["id_aluno"].ToString());
            aluno.nome           = l["nome"].ToString().Trim();
            aluno.id_cliente     = int.Parse(l["id_Cliente"].ToString());
            aluno.ano_recente    = l["ano_recente"].ToString().Trim();
            aluno.turma.id_turma = int.Parse(l["id_turma"].ToString());
            aluno.nascimento     = DateTime.Parse(l["nascimento"].ToString()).Date;
            aluno.sexo           = l["sexo"].ToString().Trim();
            aluno.naturalidade   = l["naturalidade"].ToString().Trim();
            aluno.uf             = l["uf"].ToString().Trim();
            aluno.dadosClinicos  = l["dadosClinicos"].ToString().Trim();
            aluno.remedios       = l["remedios"].ToString().Trim();
            aluno.id_mac         = l["id_mac"].ToString().Trim();
            aluno.integral       = l["integral"].ToString().Trim();

            return(aluno);
        }
Ejemplo n.º 15
0
        public AlunosEnt SelectAlunos(string strCommando, int id_turma)
        {
            AlunosEnt alunos = new AlunosEnt();
            AlunoEnt  aluno;
            Conexao   con = new Conexao();


            SqlDataAdapter adp = new SqlDataAdapter(strCommando, con.NovaConexaoBdAtaFinal());

            adp.SelectCommand.CommandType = CommandType.StoredProcedure;
            adp.SelectCommand.Parameters.AddWithValue("@ano", DateTime.Now.Year.ToString());
            adp.SelectCommand.Parameters.AddWithValue("@idTurma", id_turma);
            adp.SelectCommand.Connection.Open();
            SqlDataReader leitor = adp.SelectCommand.ExecuteReader();

            while (leitor.Read())
            {
                aluno                 = new AlunoEnt();
                aluno.id_aluno        = leitor.GetInt32(0);
                aluno.id_cliente      = leitor.GetInt32(1);
                aluno.nome            = leitor[2].ToString();
                aluno.pai             = leitor[3].ToString();
                aluno.mae             = leitor[4].ToString();
                aluno.fone_pai        = leitor[5].ToString();
                aluno.fone_mae        = leitor[6].ToString();
                aluno.ano_recente     = leitor[7].ToString();
                aluno.turma.descricao = leitor[8].ToString();
                aluno.nascimento      = DataEnull(leitor[9].ToString());
                aluno.sexo            = leitor[10].ToString();
                aluno.naturalidade    = leitor[11].ToString();
                aluno.uf              = leitor[12].ToString();
                aluno.dadosClinicos   = leitor[13].ToString();
                aluno.remedios        = leitor[14].ToString();
                aluno.id_mac          = leitor[15].ToString();
                aluno.integral        = leitor[16].ToString();
                alunos.Add(aluno);
            }
            adp.SelectCommand.Connection.Close();
            return(alunos);
        }
Ejemplo n.º 16
0
 public int Inserir(AlunoEnt objtabela)
 {
     using (SqlConnection con = new SqlConnection()) //Instanciando conexão
     {
         con.ConnectionString = Properties.Settings.Default.banco;
         SqlCommand cn = new SqlCommand();
         cn.CommandType = CommandType.Text;
         con.Open();
         cn.CommandText = "INSERT INTO aluno ([nome], [cpf], [rg], [telefone], [categoriacnh], [horariodeaula]) VALUES (@nome, @cpf, @rg, @telefone, @categoriacnh, @horariodeaula)";
         //Parâmetros Aluno
         cn.Parameters.Add("nome", SqlDbType.VarChar).Value          = objtabela.Nome;
         cn.Parameters.Add("cpf", SqlDbType.VarChar).Value           = objtabela.Cpf;
         cn.Parameters.Add("rg", SqlDbType.VarChar).Value            = objtabela.Rg;
         cn.Parameters.Add("telefone", SqlDbType.VarChar).Value      = objtabela.Telefone;
         cn.Parameters.Add("categoriacnh", SqlDbType.VarChar).Value  = objtabela.Categoriacnh;
         cn.Parameters.Add("horariodeaula", SqlDbType.VarChar).Value = objtabela.Horariodeaula;
         cn.Connection = con;
         int qtd = cn.ExecuteNonQuery();
         Console.Write(qtd);
         return(qtd);
     }
 }
Ejemplo n.º 17
0
        private void btnAluno_Click(object sender, EventArgs e)
        {
            if (Meucliente.id_cliente == 0)
            {
                txtCod.Focus();
                return;
            }

            AlunoEnt alu = new AlunoEnt();

            alu.Atribuir(Meucliente);
            Form formulario = new frmFormulario()
            {
                FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable
            };
            frmAluno ctr = new frmAluno(alu, Tranz.Cadastrar);

            formulario.Controls.Add(ctr);
            formulario.Size = formulario.Controls[0].Size;
            formulario.ShowDialog();
            Meucliente.filhos = ctr.aluno.filhos;
        }
Ejemplo n.º 18
0
 private void textBox1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         try
         {
             AlunosDAO dao        = new AlunosDAO();
             AlunoEnt  aluno      = dao.SelectPorId(textBox1.Text.ToInt());
             Form      formulario = new frmFormulario()
             {
                 FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable
             };
             formulario.Controls.Add(new frmAluno(aluno, Tranz.Alterar));
             formulario.Size = formulario.Controls[0].Size;
             formulario.ShowDialog();
             this.Close();
         }
         catch (Exception erro)
         {
             MessageBox.Show(erro.Message);
         }
     }
 }
Ejemplo n.º 19
0
 public string InserirNovoAluno(AlunoEnt al)
 {
     if (al.nome == "" || al.nome == null)
     {
         throw new ArgumentException("Nome do aluno é obrigatório");
     }
     if (al.id_cliente == 0)
     {
         throw new ArgumentException("CC invalido");
     }
     if (al.turma.id_turma == 0)
     {
         throw new ArgumentException("informe qual a turma do aluno");
     }
     if (al.nascimento.Date <= DateTime.Now.AddYears(-15).Date || al.nascimento.Date > DateTime.Now.Date)
     {
         throw new ArgumentException("Data de nascimento inválida");
     }
     if (al.sexo == "" || al.sexo == null)
     {
         throw new ArgumentException("Informe qual o gênero do aluno");
     }
     return(alunos.InsertAlunos(al));
 }
Ejemplo n.º 20
0
 public int Editar(AlunoEnt objtabela)
 {
     using (SqlConnection con = new SqlConnection()) //Instanciando conexão
     {
         con.ConnectionString = Properties.Settings.Default.banco;
         SqlCommand cn = new SqlCommand();
         cn.CommandType = CommandType.Text;
         con.Open();
         cn.CommandText = "";
         cn.CommandText = "UPDATE aluno SET nome = @nome, cpf = @cpf, rg = @rg, telefone = @telefone, categoriacnh = @categoriacnh, horariodeaula = horariodeaula WHERE id = @id ";
         //Parâmetros Aluno
         cn.Parameters.Add("id", SqlDbType.VarChar).Value            = objtabela.Id;
         cn.Parameters.Add("nome", SqlDbType.VarChar).Value          = objtabela.Nome;
         cn.Parameters.Add("cpf", SqlDbType.VarChar).Value           = objtabela.Cpf;
         cn.Parameters.Add("rg", SqlDbType.VarChar).Value            = objtabela.Rg;
         cn.Parameters.Add("telefone", SqlDbType.VarChar).Value      = objtabela.Telefone;
         cn.Parameters.Add("categoriacnh", SqlDbType.VarChar).Value  = objtabela.Categoriacnh;
         cn.Parameters.Add("horariodeaula", SqlDbType.VarChar).Value = objtabela.Horariodeaula;
         cn.Connection = con;
         int qtd = cn.ExecuteNonQuery();
         Console.Write(qtd);
         return(qtd);
     }
 }
Ejemplo n.º 21
0
        public string InsertAlunos(AlunoEnt aluno)
        {
            Conexao con = new Conexao();

            try
            {
                SqlCommand cmd = new SqlCommand("sp_InsertAlunos", con.NovaConexaoBdAtaFinal());
                cmd.CommandText = @"
                                    if(select count(nome) from tbl_alunos where nome = @nome) > 0
                                        print ('já existe um aluno com este nome')
                                    else

                                    INSERT INTO [dbo].[tbl_Alunos]
                                   ([nome]
                                   ,[id_cliente]
                                   ,[ano_recente]
                                   ,[id_turma]
                                   ,[nascimento]
                                   ,[sexo]
                                   ,[naturalidade]
                                   ,[uf]
                                   ,[dadosClinicos]
                                   ,[remedios]
                                   ,[id_mac]
                                   ,[integral]) 
                                    
                                    values (
                                    @nome
                                   ,@id_cliente
                                   ,@ano_recente
                                   ,@id_turma
                                   ,@nascimento
                                   ,@sexo
                                   ,@naturalidade
                                   ,@uf
                                   ,@dadosClinicos
                                   ,@remedios
                                   ,@id_mac
                                   ,@integral)
                                    ";
                cmd.Parameters.AddWithValue("@id_aluno", aluno.id_aluno);
                cmd.Parameters.AddWithValue("@nome", aluno.nome);
                cmd.Parameters.AddWithValue("@id_cliente", aluno.id_cliente);
                cmd.Parameters.AddWithValue("@ano_recente", aluno.ano_recente);
                cmd.Parameters.AddWithValue("@id_turma", aluno.turma.id_turma);
                cmd.Parameters.AddWithValue("@nascimento", aluno.nascimento);
                cmd.Parameters.AddWithValue("@sexo", aluno.sexo);
                cmd.Parameters.AddWithValue("@naturalidade", aluno.naturalidade);
                cmd.Parameters.AddWithValue("@uf", aluno.uf);
                cmd.Parameters.AddWithValue("@dadosClinicos", aluno.dadosClinicos);
                cmd.Parameters.AddWithValue("@remedios", aluno.remedios);
                cmd.Parameters.AddWithValue("@id_mac", aluno.id_mac);
                cmd.Parameters.AddWithValue("@integral", aluno.integral);
                cmd.Connection.Open();
                cmd.ExecuteNonQuery();
                cmd.CommandText = "select id_aluno from tbl_alunos where nome = @nome and id_cliente = @id_cliente";

                cmd.CommandType = CommandType.Text;
                SqlDataReader li = cmd.ExecuteReader();
                while (li.Read())
                {
                    aluno.id_aluno = int.Parse(li[0].ToString());
                }
                cmd.Connection.Close();
                if (aluno.turma.Ano.id_nivel == Niveis.Fundamental)
                {
                    AtaFinalEnt ata = new AtaFinalEnt(aluno, new GetSerie(aluno.turma.Ano.id_Ano).Serie);
                    RenovarMatricula(ata);
                }

                return(con.mensagens);
            }
            catch (Exception erro)
            {
                return(erro.ToString());
            }
        }
Ejemplo n.º 22
0
 public List <AlunoEnt> Buscar(AlunoEnt objtabela) //Método Buscar
 {
     return(new AlunoControl().Buscar(objtabela));
 }
Ejemplo n.º 23
0
 public static int Inserir(AlunoEnt objtabela) //Método Inserir
 {
     return(new AlunoControl().Inserir(objtabela));
 }
Ejemplo n.º 24
0
 public static int Excluir(AlunoEnt objtabela) //Método Excluir
 {
     return(new AlunoControl().Excluir(objtabela));
 }
Ejemplo n.º 25
0
 public static int Editar(AlunoEnt objtabela) //Método Editar
 {
     return(new AlunoControl().Editar(objtabela));
 }
Ejemplo n.º 26
0
 public frmRenovarMatricula(AlunoEnt alu)
 {
     Aluno = alu;
     InitializeComponent();
 }
Ejemplo n.º 27
0
        public AlunoEnt SelectAlunoPorId(string str, int idAluno)
        {
            SqlCommand cmd = new SqlCommand(str, new Conexao().NovaConexaoBdAtaFinal());
            AlunoEnt   al;

            try
            {
                cmd.Parameters.AddWithValue("@id", idAluno);
                cmd.Connection.Open();
                SqlDataReader l = cmd.ExecuteReader();
                if (l.Read())
                {
                    al = new AlunoEnt()
                    {
                        id_aluno      = int.Parse(l["id_aluno"].ToString()),
                        nome          = l["nome"].ToString(),
                        id_cliente    = int.Parse(l["id_cliente"].ToString()),
                        ano_recente   = l["ano_recente"].ToString(),
                        nascimento    = DateTime.Parse(l["nascimento"].ToString()),
                        sexo          = l["sexo"].ToString(),
                        naturalidade  = l["naturalidade"].ToString().Trim(),
                        uf            = l["uf"].ToString(),
                        dadosClinicos = l["dadosClinicos"].ToString().Trim(),
                        remedios      = l["remedios"].ToString(),
                        id_mac        = l["id_mac"].ToString(),
                        integral      = l["integral"].ToString(),
                        turma         = new TurmaEnt
                        {
                            id_turma = int.Parse(l["id_turma"].ToString())
                            ,
                            descricao  = l["descricao"].ToString().Trim(),
                            ano        = l["ano"].ToString(),
                            Professeor = new ProfessorEnt
                            {
                                id_prof   = int.Parse(l["id_prof"].ToString()),
                                professor = l["professor"].ToString().Trim(),
                            },
                            Ano = new AnoEnt
                            {
                                id_Ano   = int.Parse(l["id_ano"].ToString()),
                                ano      = l["ano"].ToString(),
                                id_nivel = (Niveis)int.Parse(l["id_nivel"].ToString())
                            }
                            ,
                            Turnos = (Turno)int.Parse(l["id_turno"].ToString())
                        }
                    };
                }
                else
                {
                    throw new Exception("Aluno não encontrado");
                }
                return(al);
            }
            catch (Exception erro)
            {
                throw erro;
            }
            finally
            {
                cmd.Connection.Close();
            }
        }
Ejemplo n.º 28
0
 public string AtualizarAluno(AlunoEnt al)
 {
     return(alunos.AtualizaAlunos(al));
 }