예제 #1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            Banco_dados db = new Banco_dados();

            db.execute_query(db, "DELETE FROM Aula");
            db.execute_query(db, "DELETE FROM aluno_aula");
            if (ch_limp.Checked)
            {
                db.execute_query(db, "DELETE FROM Aluno");
                db.execute_query(db, "DELETE FROM Turma");
                db.execute_query(db, "DELETE FROM Professor");
            }
        }
예제 #2
0
        public void chamada_aluno(Banco_dados db, String recebido, TextBox txt_id, DateTimePicker data_chamada, ComboBox cb_turma, DataGridView data_grid, SerialPort serialListener)
        {
            String cod_professor = txt_id.Text;
            String data          = (data_chamada.Value.Day.ToString() + "/" + data_chamada.Value.Month.ToString() + "/" + data_chamada.Value.Year.ToString());
            String turma         = cb_turma.Text;
            String comando       = ("INSERT INTO Aluno_aula (Cod_aula, RA) " +
                                    "VALUES ((SELECT Cod_aula " +
                                    "FROM Aula WHERE Cod_Professor = (Select Cod_Professor from Professor where RFID = '" + cod_professor + "')" +
                                    " AND Data = '" + data + "'" +
                                    " AND Cod_turma = (SELECT Cod_turma FROM Turma WHERE Nome = '" + turma + "'))," +
                                    " (SELECT RA FROM Aluno WHERE RFID = '" + recebido + "'))");
            string query = ("SELECT RA as RA, Nome as Nome FROM Aluno" +
                            " WHERE RA in (SELECT RA FROM Aluno_aula WHERE Cod_aula = (SELECT MAX(Cod_aula)) " +
                            " ORDER BY Cod_aula)");

            try
            {
                db.execute_query(db, comando);
                Banco_dados abacate = new Banco_dados();
                abacate.get_grid(abacate, query, data_grid, serialListener);
            }catch (MySqlException e)
            {
                Console.WriteLine("Erro @Chamada Aluno : " + e);
            }
        }
예제 #3
0
        private void btnCadastraTurma_Click_1(object sender, EventArgs e)
        {
            Banco_dados db      = new Banco_dados();
            String      id      = txt_id.Text;
            String      nome    = cb_turma.Text;
            String      comando = "INSERT INTO Turma (Cod_professor, Nome) VALUES ((Select Cod_Professor from Professor where RFID = '" + id + "'), '" + nome + "');";

            try
            {
                db.execute_query(db, comando);
            }
            catch (Exception pp)
            {
                MessageBox.Show("Impossível Cadastrar");
            }
        }
예제 #4
0
 public void iniciar_chamada(TextBox txt_id, ComboBox cb_turma, DateTimePicker data_chamada, Banco_dados db)
 {
     try
     {
         String cod_professor = txt_id.Text;
         String cod_turma     = cb_turma.Text;
         String data          = (data_chamada.Value.Day.ToString() + "/" + data_chamada.Value.Month.ToString() + "/" + data_chamada.Value.Year.ToString());
         string comando       = "INSERT INTO Aula (Cod_professor, Data, Cod_turma)" +
                                " VALUES ((Select Cod_Professor from Professor where RFID = '" + cod_professor + "') , '" + data + "'," +
                                " (SELECT Cod_turma FROM Turma WHERE Nome ='" + cod_turma + "'))";
         db.execute_query(db, comando);
     }catch (MySqlException e)
     {
         MessageBox.Show("Impossível iniciar chamada");
         Console.WriteLine("Erro @Iniciar chamada : " + e);
     }
 }
예제 #5
0
        private void recebeString(object o, EventArgs e)
        {
            String recebido = serialListener.ReadLine().Replace("\r", "").ToUpper();//FUNCÇÃO mágica SQL RETORNANDO STRING PARA PRINTAR NO LCD DO ARDUINO

            Console.WriteLine(recebido);

            Banco_dados db = new Banco_dados();//isso aqui é importante?

            try
            {
                db.chamada_aluno(db, recebido, txt_id, data_chamada, cb_turma, data_grid, serialListener);
                String nome    = cb_turma.Text;
                String comando = "INSERT INTO Aluno_turma(RA, Cod_turma) VALUES((SELECT RA FROM Aluno WHERE RFID = '" + recebido + "')," +
                                 " (SELECT Cod_turma FROM Turma WHERE Nome = '" + nome + "'))";
                db.execute_query(db, comando);
                serialListener.WriteLine(recebido);
            }
            catch (Exception a)
            {
                Console.Write(a);
            }
            serialListener.DiscardInBuffer();
        }
예제 #6
0
 private void btnChama_Click(object sender, EventArgs e)
 {
     if (btnChama.Text == "Iniciar")
     {
         try
         {
             Banco_dados db = new Banco_dados();
             if (ch_turma.Checked)
             {
                 String id      = txt_id.Text;
                 String nome    = cb_turma.Text;
                 String comando = "INSERT INTO Turma (Cod_professor, Nome) VALUES ((Select Cod_Professor from Professor where RFID = '" + id + "'), '" + nome + "');";
                 db.execute_query(db, comando);
             }
             db.iniciar_chamada(txt_id, cb_turma, data_chamada, db);
             btnChama.Text = "Terminar";
         }
         catch (Exception E)
         {
             throw new Exception("Erro: " + E);
         }
     }
     else if (btnChama.Text == "Terminar")
     {
         try
         {
             serialListener.Close();
             Close();
             btnChama.Text = "Iniciar";
         }
         catch (Exception E)
         {
             throw new Exception("Erro: " + E);
         }
     }
 }