private void Btn_CPalestraExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         int          linha     = GV_CPalestraPrincipal.CurrentRow.Index;
         int          cod       = Convert.ToInt32(GV_CPalestraPrincipal.Rows[linha].Cells[0].Value.ToString());
         DialogResult resultado = MessageBox.Show("Deseja mesmo excluir o registro de código " + cod + "?",
                                                  "ATENÇÃO !", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
         if (resultado == DialogResult.Yes)
         {
             // Se o usuário marcar Sim, executa a exclusão
             DALConexoes            cx        = new DALConexoes(DadosDaConexão.StringDeConexão); //Objetos para gravar os dados;
             BLLCadastrarNaPalestra BLLCPales = new BLLCadastrarNaPalestra(cx);
             BLLCPales.Excluir(cod);
             MessageBox.Show("Excluído com Sucesso!", "Informativo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             //Atualiza a tabela!
             this.AtualizaTabelaPrincipal();
         }
         // Se marcar não, nada acontece e a tela é retornada.
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Informativo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#2
0
        private void Btn_partiGravar_Click(object sender, EventArgs e)
        {
            try
            {
                if (Txt_partiCPF.TextLength < 11)
                {
                    MessageBox.Show("CPF precisa de 11 números!", "ERRO!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (this.CPF_Valido(Txt_partiCPF.Text)) //Verifica se o CPF é válido.
                    {
                        ModeloParticipante modelo = new ModeloParticipante
                        {
                            ParticipanteNome            = Txt_partiNome.Text,
                            ParticipanteCPF             = Txt_partiCPF.Text,
                            ParticipanteDataNasc        = dtp_partiNascimento.Value,
                            ParticipanteCodEscolaridade = Convert.ToInt32(Cb_partiEscolaridade.SelectedValue),
                            ParticipanteEmail           = Txt_partiEmail.Text,
                            ParticipanteTelefone        = Txt_partiTelefone.Text
                        };
                        DALConexoes     cx       = new DALConexoes(DadosDaConexão.StringDeConexão); //Objetos para gravar os dados;
                        BLLParticipante BLLParti = new BLLParticipante(cx);

                        if (this.operacao == "inserir") // Cadastra no banco a escolaridade.
                        {
                            BLLParti.Incluir(modelo);
                            MessageBox.Show("Gravado com Sucesso! Código: " + modelo.ParticipanteCod.ToString(), "Informativo",
                                            MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            // Atualiza a tabela no gridview.
                            this.AtualizaTabela();
                        }
                        else // Altera no banco a escolaridade
                        {
                            int linha = dataGridView1.CurrentRow.Index;
                            int cod   = Convert.ToInt32(dataGridView1.Rows[linha].Cells[0].Value.ToString());
                            modelo.ParticipanteCod = cod;
                            BLLParti.Alterar(modelo);
                            MessageBox.Show("Editado com Sucesso!", "Informativo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            // Atualiza a tabela no gridview.
                            this.AtualizaTabela();
                        }
                        this.LimpaTela();
                        this.AlterarBotao(false);
                        this.operacao = "";
                    }
                    else // Se o CPF não for válido!
                    {
                        MessageBox.Show("CPF INVÁLIDO!", "ERRO!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERRO!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public DataTable LocalizarAluno(String Valor)
        {
            DALConexoes    conexao = new DALConexoes(DadosDaConexão.StringDeConexão);
            DataTable      tabela  = new DataTable();
            SqlDataAdapter da      = new SqlDataAdapter("Select Codigo, Nome, CPF from TBParticipante where " +
                                                        "Nome like '%" + Valor + "%' OR CPF like '%" + Valor + "%'",
                                                        conexao.StringConexao);

            da.Fill(tabela);
            return(tabela);
        }
        public void AtualizaTabela()
        {
            DALConexoes    cx      = new DALConexoes(DadosDaConexão.StringDeConexão); //Objetos para gravar os dados;
            SqlCommand     cmd     = new SqlCommand("Select * from TBPalestra", cx.ObjetoConexao);
            SqlDataAdapter adapter = new SqlDataAdapter
            {
                SelectCommand = cmd
            };
            DataTable tabela = new DataTable();

            adapter.Fill(tabela);
            dataGridView1.DataSource = tabela;
        }
示例#5
0
        private void frm_cadastroParticipantes_Load(object sender, EventArgs e)
        {
            DALConexoes     cx       = new DALConexoes(DadosDaConexão.StringDeConexão);
            BLLEscolaridade BLLEscol = new BLLEscolaridade(cx);

            dtp_partiNascimento.Value          = DateTime.Today;
            Cb_partiEscolaridade.DataSource    = BLLEscol.Localizar("%");
            Cb_partiEscolaridade.DisplayMember = "Nome";
            Cb_partiEscolaridade.ValueMember   = "Codigo";
            this.AlterarBotao(false);
            // mostra a tabela no grid view ao iniciar o formulário.
            this.AtualizaTabela();
        }
        public void AtualizaTabelaSecundaria()
        {
            DALConexoes cx  = new DALConexoes(DadosDaConexão.StringDeConexão); //Objetos para gravar os dados;
            SqlCommand  cmd = new SqlCommand("Select CPF, Nome, Codigo from TBParticipante;",
                                             cx.ObjetoConexao);
            SqlDataAdapter adapter = new SqlDataAdapter
            {
                SelectCommand = cmd
            };
            DataTable tabela = new DataTable();

            adapter.Fill(tabela);
            GV_CPalestraAlunos.DataSource = tabela;
        }
示例#7
0
        public void AtualizaTabela()
        {
            DALConexoes cx  = new DALConexoes(DadosDaConexão.StringDeConexão); //Objetos para gravar os dados;
            SqlCommand  cmd = new SqlCommand("select P.Codigo, P.CPF, P.Nome, " +
                                             "P.DataNasc As DataNascimento, P.Email, P.Telefone, E.Nome AS Escolaridade, " +
                                             "P.Cod_Escolaridade From TBParticipante as P inner join TBEscolaridade as E on P.Cod_Escolaridade = E.Codigo",
                                             cx.ObjetoConexao);
            SqlDataAdapter adapter = new SqlDataAdapter
            {
                SelectCommand = cmd
            };
            DataTable tabela = new DataTable();

            adapter.Fill(tabela);
            dataGridView1.DataSource = tabela;
        }
示例#8
0
        private void Btn_CPalestraGravar_Click(object sender, EventArgs e)
        {
            try
            {
                DALConexoes            CX        = new DALConexoes(DadosDaConexão.StringDeConexão); //Objetos para gravar os dados;
                BLLCadastrarNaPalestra BLLCPales = new BLLCadastrarNaPalestra(CX);

                if (this.HaVagas(Convert.ToInt32(CB_CPalestraPalestras.SelectedValue))) //Verifica se há vagas.
                {
                    ModeloCadastrarNaPalestra modelo = new ModeloCadastrarNaPalestra
                    {
                        CPalestraCodAluno    = Convert.ToInt32(Txt_CPalestraCodAluno.Text),
                        CPalestraCodPalestra = Convert.ToInt32(CB_CPalestraPalestras.SelectedValue)
                    };

                    if (this.operacao == "inserir") // Cadastra no banco o cadastro na palestra.
                    {
                        BLLCPales.Incluir(modelo);
                        MessageBox.Show("Gravado com Sucesso! Código: " + modelo.CPalestraCod.ToString(), "Informativo",
                                        MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        // Atualiza a tabela no gridview.
                        this.AtualizaTabelaPrincipal();
                    }
                    else // Altera no banco a O cadastro na Palestra
                    {
                        int linha = GV_CPalestraPrincipal.CurrentRow.Index;
                        int cod   = Convert.ToInt32(GV_CPalestraPrincipal.Rows[linha].Cells[0].Value.ToString());
                        modelo.CPalestraCod = cod;
                        BLLCPales.Alterar(modelo);
                        MessageBox.Show("Editado com Sucesso!", "Informativo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        // Atualiza a tabela no gridview.
                        this.AtualizaTabelaPrincipal();
                    }
                    this.LimpaTela();
                    this.AlterarBotao(false);
                    this.operacao = "";
                }
                else // Se o CPF não for válido!
                {
                    MessageBox.Show("Não há vagas!", "ERRO!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERRO!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Txt_CPalestraPesquisarPrincipal_TextChanged(object sender, EventArgs e)
        {
            DALConexoes            cx        = new DALConexoes(DadosDaConexão.StringDeConexão); //Objetos para gravar os dados;
            BLLCadastrarNaPalestra BLLCPales = new BLLCadastrarNaPalestra(cx);
            String valor = Txt_CPalestraPesquisarPrincipal.Text;

            if (valor == "Digite para pesquisar...")
            {
                // Se o valor do texto for igual ao placeholder ele irá popular a tabela completa.
                this.AtualizaTabelaPrincipal();
            }
            else
            {
                // Se o valor for diferente do placeholder ele irá executar o método de pesquisa.
                GV_CPalestraPrincipal.DataSource = BLLCPales.Localizar(valor);
            }
        }
示例#10
0
        private void Txt_partiPesquisar_TextChanged(object sender, EventArgs e)
        {
            DALConexoes     cx       = new DALConexoes(DadosDaConexão.StringDeConexão); //Objetos para gravar os dados;
            BLLParticipante BLLParti = new BLLParticipante(cx);
            String          valor    = Txt_partiPesquisar.Text;

            if (valor == "Digite para pesquisar...")
            {
                // Se o valor do texto for igual ao placeholder ele irá popular a tabela completa.
                this.AtualizaTabela();
            }
            else
            {
                // Se o valor for diferente do placeholder ele irá executar o método de pesquisa.
                dataGridView1.DataSource = BLLParti.Localizar(valor);
            }
        }
        public void AtualizaTabelaPrincipal()
        {
            DALConexoes cx  = new DALConexoes(DadosDaConexão.StringDeConexão); //Objetos para gravar os dados;
            SqlCommand  cmd = new SqlCommand("Select C.Codigo, Par.Nome, Par.CPF, Pal.Nome As Palestra, " +
                                             "Pal.Data_Hora, Pal.Max_Alunos, C.Cod_Palestra, C.Cod_Aluno As Cod_Participante from ((TBCadastro_Palestra As C inner " +
                                             "join TBPalestra As Pal on C.Cod_Palestra = Pal.Codigo) inner join TBParticipante As " +
                                             "Par ON C.Cod_Aluno = Par.Codigo);",
                                             cx.ObjetoConexao);
            SqlDataAdapter adapter = new SqlDataAdapter
            {
                SelectCommand = cmd
            };
            DataTable tabela = new DataTable();

            adapter.Fill(tabela);
            GV_CPalestraPrincipal.DataSource = tabela;
        }
        private void Txt_CPalestraPesquisarAlunos_TextChanged(object sender, EventArgs e)
        {
            DALConexoes     cx       = new DALConexoes(DadosDaConexão.StringDeConexão); //Objetos para gravar os dados;
            BLLParticipante BLLParti = new BLLParticipante(cx);
            String          valor    = Txt_CPalestraPesquisarAlunos.Text;

            if (valor == "Pesquisar aluno...")
            {
                // Se o valor do texto for igual ao placeholder ele irá popular a tabela completa.
                this.AtualizaTabelaSecundaria();
            }
            else
            {
                // Se o valor for diferente do placeholder ele irá executar o método de pesquisa.

                GV_CPalestraAlunos.DataSource = LocalizarAluno(valor);
            }
        }
        private void Frm_CadastrarAlunoNaPalestra_Load(object sender, EventArgs e)
        {
            //Seta o estado dos botões para desligados.
            this.AlterarBotao(false);

            // Popula a tabela de Cadastrados na Palestra
            this.AtualizaTabelaPrincipal();

            // Popula a tabela de alunos
            this.AtualizaTabelaSecundaria();

            DALConexoes cx      = new DALConexoes(DadosDaConexão.StringDeConexão);
            BLLPalestra BLLPale = new BLLPalestra(cx);

            CB_CPalestraPalestras.DataSource    = BLLPale.Localizar("");
            CB_CPalestraPalestras.ValueMember   = "Codigo";
            CB_CPalestraPalestras.DisplayMember = "Nome";
        }
示例#14
0
        private void Btn_PalestraGravar_Click(object sender, EventArgs e)
        {
            try
            {
                ModeloPalestra modelo = new ModeloPalestra
                {
                    PalestraNome      = Txt_PalestraNome.Text,
                    PalestraDataHora  = Dt_PalestraDataHora.Value,
                    PalestraMaxAlunos = Convert.ToInt32(Txt_PalestraMaxAlunos.Text)
                };
                DALConexoes cx      = new DALConexoes(DadosDaConexão.StringDeConexão); //Objetos para gravar os dados;
                BLLPalestra BLLPale = new BLLPalestra(cx);

                if (this.operacao == "inserir") // Cadastra no banco a escolaridade.
                {
                    BLLPale.Incluir(modelo);
                    MessageBox.Show("Gravado com Sucesso! Código: " + modelo.PalestraCod.ToString(), "Informativo",
                                    MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    // Atualiza a tabela no gridview.
                    this.AtualizaTabela();
                }
                else // Altera no banco a escolaridade
                {
                    int linha = dataGridView1.CurrentRow.Index;
                    int cod   = Convert.ToInt32(dataGridView1.Rows[linha].Cells[0].Value.ToString());
                    modelo.PalestraCod = cod;
                    BLLPale.Alterar(modelo);
                    MessageBox.Show("Editado com Sucesso!", "Informativo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    // Atualiza a tabela no gridview.
                    this.AtualizaTabela();
                }

                this.LimpaTela();
                this.AlterarBotao(false);
                this.operacao = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERRO!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#15
0
        private void Btn_escolaSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                modeloEscolaridade modelo = new modeloEscolaridade
                {
                    escNome = Txt_escolaNome.Text
                };
                DALConexoes     cx  = new DALConexoes(DadosDaConexão.StringDeConexão); //Objetos para gravar os dados;
                BLLEscolaridade blE = new BLLEscolaridade(cx);

                if (this.operacao == "inserir") // Cadastra no banco a escolaridade.
                {
                    blE.Incluir(modelo);
                    MessageBox.Show("Gravado com Sucesso! Código: " + modelo.escCod.ToString(), "Informativo",
                                    MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    // Atualiza a tabela no gridview.
                    this.AtualizaTabela();
                }
                else // Altera no banco a escolaridade
                {
                    int linha = dataGridView1.CurrentRow.Index;
                    int cod   = Convert.ToInt32(dataGridView1.Rows[linha].Cells[0].Value.ToString());
                    modelo.escCod = cod;
                    blE.Alterar(modelo);
                    MessageBox.Show("Editado com Sucesso!", "Informativo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    // Atualiza a tabela no gridview.
                    this.AtualizaTabela();
                }

                this.limpaTela();
                this.AlterarBotao(false);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERRO!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public bool HaVagas(int Palestra)
        {
            DALConexoes cx = new DALConexoes(DadosDaConexão.StringDeConexão);
            //Pegando as vagas atuais.
            SqlCommand cmd = new SqlCommand()
            {
                Connection  = cx.ObjetoConexao,
                CommandText = "select count(*) from TBCadastro_Palestra where Cod_Palestra = " + Palestra.ToString() + ";"
            };

            cx.Conectar();
            SqlDataReader readerAtuais = cmd.ExecuteReader();

            readerAtuais.Read();
            int vagasOcupadas = Convert.ToInt32(readerAtuais.GetValue(0));

            cx.Desconectar();

            //Pegando o número máximo de vagas na palestra.
            cmd.CommandText = "Select Max_Alunos from TBPalestra where Codigo = " + Palestra.ToString() + ";";
            cx.Conectar();
            SqlDataReader readerMax = cmd.ExecuteReader();

            readerMax.Read();
            int MaxVagas = Convert.ToInt32(readerMax.GetValue(0));

            cx.Desconectar();

            //Verificando se há vagas.
            if (vagasOcupadas == MaxVagas)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
示例#17
0
 public BLLEscolaridade(DALConexoes cx)
 {
     this.conexao = cx;
 }
示例#18
0
 public BLLCadastrarNaPalestra(DALConexoes cx)
 {
     this.conexao = cx;
 }
示例#19
0
 public BLLPalestra(DALConexoes cx)
 {
     this.conexao = cx;
 }
 public BLLParticipante(DALConexoes cx)
 {
     this.conexao = cx;
 }