Ejemplo n.º 1
0
        private void pesqAluno_Load(object sender, EventArgs e)
        {
            int      idsala = Convert.ToInt32(txtIDSala.Text);
            DateTime hoje   = DateTime.Now.Date;

            try
            {
                using (var db = new dbEscala())
                {
                    pesq2.dgvPesq.DataSource = db.escala.Where(d => d.sal_aluno.IDSALA == idsala &&
                                                               d.sal_aluno.alunos.ATIVO == 1 &&
                                                               d.DT_FINAL <= hoje &&
                                                               d.sal_aluno.alunos.DT_INICIO <= hoje &&
                                                               d.sal_aluno.alunos.DT_FINAL >= hoje
                                                               ).Select(d => new
                    {
                        ID   = d.sal_aluno.IDALUNO,
                        NOME = d.sal_aluno.alunos.NOME,
                        CPF  = d.sal_aluno.alunos.CPF
                    }).ToList();
                }
            }
            catch (Exception err)
            {
                MessageBox.Show("Erro " + err, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        private void visitaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormCadEscalas fo = new FormCadEscalas();

            try
            {
                using (var db = new dbEscala())
                {
                    config cf = db.config.Find(1);
                    if (cf.DT_FINAL.Date >= DateTime.Now.Date)
                    {
                        if (MessageBox.Show("A última escala ainda está em andamento, deseja prosseguir?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                        {
                            fo.ShowDialog();
                            carregar();
                        }
                    }
                    else
                    {
                        fo.ShowDialog();
                    } carregar();
                }
            }
            catch (Exception err)
            {
                MessageBox.Show("Erro " + err, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 3
0
 private void btCadastrar_Click(object sender, EventArgs e)
 {
     if (dgvSalas.RowCount != 1)
     {
         using (var db = new dbEscala())
         {
             try
             {
                 for (int op = 0; op < dgvSalas.RowCount - 1; op++)
                 {
                     salas sa = new salas();
                     sa.DESCRICAO       = Convert.ToString(dgvSalas.Rows[op].Cells[0].Value);
                     db.Entry(sa).State = System.Data.Entity.EntityState.Added;
                     db.SaveChanges();
                 }
                 MessageBox.Show("Cadastro realizado com sucesso!!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 dgvSalas.Rows.Clear();
                 TxtSala.Focus();
             }
             catch (Exception err)
             {
                 MessageBox.Show("Erro" + err, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     else
     {
         MessageBox.Show("Não há nada cadastrado", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
Ejemplo n.º 4
0
        private void btPDiag_Click(object sender, EventArgs e)
        {
            dbEscala db = new dbEscala();

            pesq.dgvPesq.DataSource = pesquisarSala(pesq.txtPesq.Text);
            db.Dispose();
        }
Ejemplo n.º 5
0
        private bool verifica_cadastro()
        {
            int count = 0;

            try
            {
                using (var db = new dbEscala())
                {
                    if (dgvEscalas.RowCount > 1)
                    {
                        for (int op = 0; op < dgvEscalas.RowCount - 1; op++)
                        {
                            int id = Convert.ToInt32(dgvEscalas.Rows[op].Cells[4].Value);
                            if (Convert.ToInt32(txtIDAluno.Text) == id)
                            {
                                count++;
                            }
                        }
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show("Erro " + err, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (count != 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 6
0
        private bool verifica_cpf(string cpf)
        {
            int count = 0;

            try
            {
                using (var db = new dbEscala())
                {
                    if (db.alunos.Count() != 0)
                    {
                        int prima  = db.alunos.First().ID - 1;
                        int caluno = db.alunos.Count();
                        for (int op = 1; op < caluno + 1; op++)
                        {
                            int    ID = prima + op;
                            alunos al = db.alunos.Find(ID);
                            if (cpf == al.CPF)
                            {
                                count++;
                            }
                        }
                    }
                }
            }catch (Exception err)
            {
            }
            if (count != 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 7
0
        private object pesquisarSala(string pesquisa)
        {
            dbEscala db = new dbEscala();

            return(db.salas.Where(d => d.DESCRICAO.Contains(pesquisa)).Select(d => new
            {
                ID = d.ID,
                DESCRIÇÃO = d.DESCRICAO,
            }).ToList());
        }
Ejemplo n.º 8
0
 private void pesqDiag_Load(object sender, EventArgs e)
 {
     using (var db = new dbEscala())
     {
         pesq.dgvPesq.DataSource = db.salas.Select(d => new
         {
             ID        = d.ID,
             DESCRIÇÃO = d.DESCRICAO
         }).ToList();
     }
 }
Ejemplo n.º 9
0
 public FormMenu()
 {
     try
     {
         dbEscala db    = new dbEscala();
         int      teste = db.alunos.Count();
     }
     catch
     {
         MessageBox.Show("Erro ao tentar conexão com o banco, contate um administrador!!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
         System.Environment.Exit(0);
     }
     InitializeComponent();
 }
Ejemplo n.º 10
0
        private void FormMenu_Load(object sender, EventArgs e)
        {
            timer1.Start();
            DateTime hoje = DateTime.Now.Date;

            try
            {
                using (var db = new dbEscala())
                {
                    dgvEscalas.DataSource = db.escala.Where(d => d.DT_INICIO <= hoje && d.DT_FINAL >= hoje && d.USE == 1).Select(d => new
                    {
                        Nome         = d.sal_aluno.alunos.NOME,
                        Sala         = d.sal_aluno.salas.DESCRICAO,
                        Data_Inicio  = d.DT_INICIO,
                        Data_Término = d.DT_FINAL
                    }).OrderBy(d => d.Sala).ToList();

                    dgvAlunos.DataSource = db.escala.Where(d => d.sal_aluno.alunos.ATIVO == 1).Select(d => new
                    {
                        Nome       = d.sal_aluno.alunos.NOME,
                        CPF        = d.sal_aluno.alunos.CPF,
                        Escalas    = d.sal_aluno.salas.DESCRICAO,
                        DataEscala = d.DT_FINAL
                    }).OrderBy(d => d.Nome).ToList();

                    config cf   = db.config.Find(1);
                    int    hj   = DateTime.Now.Day; //dias atuais
                    int    dt   = cf.DT_FINAL.Day;  // dias da escala gravada
                    int    date = dt - hj;          // verifica quantos dias faltam para o término da escala
                    lbDtInicio.Text = cf.DT_INICIO.ToString("dd/MM/yyyy");
                    lbDtFinal.Text  = cf.DT_FINAL.ToString("dd/MM/yyyy");
                    if (date > 0)
                    {
                        lbFaltam.Text = "Faltam " + date + " dias para o fim da escala";
                    }
                    else
                    {
                        lbFaltam.Text = "Ultima escala Finalizada!!";
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show("Erro " + err, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 11
0
 private void btCadastrar_Click(object sender, EventArgs e)
 {
     try
     {
         using (var db = new dbEscala())
         {
             if (dgvEscalas.RowCount > 1)
             {
                 for (int op = 0; op < dgvEscalas.RowCount - 1; op++)
                 {
                     int    idsal = Convert.ToInt32(dgvEscalas.Rows[op].Cells[1].Value);
                     int    ides  = db.escala.Where(d => d.IDSAL_ALUNO == idsal).FirstOrDefault().ID;
                     escala es    = db.escala.Find(ides);
                     es.DT_INICIO       = Convert.ToDateTime(dtpInicio.Text);
                     es.DT_FINAL        = Convert.ToDateTime(dtpTermino.Text).AddDays(30);
                     es.USE             = 1;
                     db.Entry(es).State = System.Data.Entity.EntityState.Modified;
                     db.SaveChanges();
                 }
                 config cf = db.config.Find(1);
                 cf.DT_INICIO       = Convert.ToDateTime(dtpInicio.Text);
                 cf.DT_FINAL        = Convert.ToDateTime(dtpTermino.Text);
                 db.Entry(cf).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 MessageBox.Show("Escalas cadastradas com sucesso!!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 txtDescAluno.Clear();
                 txtIDAluno.Clear();
                 txtIDSala.Clear();
                 txtNomeSala.Clear();
                 dgvEscalas.Rows.Clear();
             }
             else
             {
                 MessageBox.Show("Nenhum aluno cadastrado ", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
         }
     }
     catch (Exception err)
     {
         MessageBox.Show("Erro " + err, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 12
0
 private void rbCompleto_CheckedChanged(object sender, EventArgs e)
 {
     try
     {
         using (var db = new dbEscala())
         {
             dgvRelatorio.DataSource = db.escala.Select(d => new
             {
                 Nome         = d.sal_aluno.alunos.NOME,
                 Sala         = d.sal_aluno.salas.DESCRICAO,
                 Data_Inicio  = d.DT_INICIO,
                 Data_Término = d.DT_FINAL
             }).OrderBy(d => d.Sala).ToList();
         }
     }
     catch (Exception err)
     {
         MessageBox.Show("Erro " + err, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 13
0
        private object pesquisarAluno(string pesquisa)
        {
            DateTime hoje       = DateTime.Now.Date;
            DateTime dtliberada = hoje.AddDays(-30);
            int      idsala     = Convert.ToInt32(txtIDSala.Text);
            dbEscala db         = new dbEscala();

            return(db.escala.Where(d => d.sal_aluno.alunos.NOME.Contains(pesquisa) &&
                                   d.sal_aluno.IDSALA == idsala &&
                                   d.sal_aluno.alunos.ATIVO == 1 &&
                                   d.DT_FINAL <= dtliberada &&
                                   d.sal_aluno.alunos.DT_INICIO >= hoje &&
                                   d.sal_aluno.alunos.DT_FINAL <= hoje
                                   ).Select(d => new
            {
                ID = d.sal_aluno.IDALUNO,
                NOME = d.sal_aluno.alunos.NOME,
                CPF = d.sal_aluno.alunos.CPF
            }).ToList());
        }
Ejemplo n.º 14
0
 //------------------------------ FIM PESQUISA ALUNO ---------------------------------------------
 private void btAdicionar_Click(object sender, EventArgs e)
 {
     if (txtIDAluno.Text != String.Empty && txtIDSala.Text != String.Empty)
     {
         if (verifica_cadastro())
         {
             int idsala  = Convert.ToInt32(txtIDSala.Text);
             int idaluno = Convert.ToInt32(txtIDAluno.Text);
             if (verificar_data())
             {
                 using (var db = new dbEscala())
                 {
                     int idsalaaluno = db.sal_aluno.Where(d => d.IDALUNO == idaluno && d.IDSALA == idsala).FirstOrDefault().ID;
                     dgvEscalas.Rows.Add(txtDescAluno.Text, idsalaaluno, Convert.ToDateTime(dtpInicio.Text), Convert.ToDateTime(dtpTermino.Text), txtIDAluno.Text);
                     txtDescAluno.Clear();
                     txtIDAluno.Clear();
                     txtIDSala.Clear();
                     txtNomeSala.Clear();
                 }
             }
             else
             {
                 MessageBox.Show("As datas não não correspondentes!!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 dtpInicio.Focus();
             }
         }
         else
         {
             MessageBox.Show("Este Aluno já esta cadastrado!!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     else
     {
         MessageBox.Show("Preencha todos os campos!!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
Ejemplo n.º 15
0
 private void btCadastrar_Click(object sender, EventArgs e)
 {
     if (dgvAlunos.RowCount > 1)
     {
         DateTime hoje = DateTime.Now.Date;
         try
         {
             using (var db = new dbEscala())
             {
                 for (int op = 0; op < dgvAlunos.RowCount - 1; op++)
                 {
                     string cpf   = Convert.ToString(dgvAlunos.Rows[op].Cells[1].Value);
                     int    prima = db.alunos.Where(d => d.CPF == cpf).Count();
                     if (prima != 0)
                     {
                         int       idaluno = db.alunos.Where(d => d.CPF == cpf).FirstOrDefault().ID;
                         alunos    al      = db.alunos.Find(idaluno);
                         sal_aluno sa      = new sal_aluno();
                         sa.IDALUNO         = al.ID;
                         sa.IDSALA          = Convert.ToInt32(dgvAlunos.Rows[op].Cells[4].Value);
                         db.Entry(sa).State = System.Data.Entity.EntityState.Added;
                         db.SaveChanges();
                         escala es = new escala();
                         es.IDSAL_ALUNO     = sa.ID;
                         es.DT_INICIO       = hoje;
                         es.DT_FINAL        = hoje;
                         db.Entry(es).State = System.Data.Entity.EntityState.Added;
                         db.SaveChanges();
                     }
                     else
                     {
                         alunos al = new alunos();
                         al.NOME            = Convert.ToString(dgvAlunos.Rows[op].Cells[0].Value);
                         al.CPF             = Convert.ToString(dgvAlunos.Rows[op].Cells[1].Value);
                         al.DT_INICIO       = Convert.ToDateTime(dgvAlunos.Rows[op].Cells[2].Value);
                         al.DT_FINAL        = Convert.ToDateTime(dgvAlunos.Rows[op].Cells[3].Value);
                         al.ATIVO           = 1;
                         al.DELETADO        = 0;
                         db.Entry(al).State = System.Data.Entity.EntityState.Added;
                         db.SaveChanges();
                         sal_aluno sa = new sal_aluno();
                         sa.IDALUNO         = al.ID;
                         sa.IDSALA          = Convert.ToInt32(dgvAlunos.Rows[op].Cells[4].Value);
                         db.Entry(sa).State = System.Data.Entity.EntityState.Added;
                         db.SaveChanges();
                         escala es = new escala();
                         es.IDSAL_ALUNO     = sa.ID;
                         es.DT_INICIO       = hoje;
                         es.DT_FINAL        = hoje;
                         db.Entry(es).State = System.Data.Entity.EntityState.Added;
                         db.SaveChanges();
                     }
                 }
                 dgvAlunos.Rows.Clear();
                 MessageBox.Show("Aluno cadastrado com sucesso!!! ", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 txtNome.Focus();
             }
         }
         catch (Exception err)
         {
             MessageBox.Show("Erro " + err, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Nenhum Aluno cadastrado!! ", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }