public bool InserirBL(TurmasParticipantes turAlu)
        {
            TurmasBL turBL = new TurmasBL();
            DataSet dsTur = turBL.PesquisarBL(turAlu.TurmaId);

            List<TurmasParticipantes> ltur = PesquisarBL(turAlu.TurmaId);
            if (dsTur.Tables[0].Rows.Count != 0)
            {
                if (ltur.Count >= Convert.ToInt32(dsTur.Tables[0].Rows[0]["nromax"].ToString()))
                {
                    return false;
                }
            }

            TurmasParticipantesDA tParDA = new TurmasParticipantesDA();

            return tParDA.InserirDA(turAlu);
        }
        protected void btnRelatorio_Click(object sender, EventArgs e)
        {
            ChamadasBL chamadasBL = new ChamadasBL();

            int preenchido = 0;
            if (rbSemPreenchimento.Checked)
                preenchido = 0;
            else if (rbComPreenchimento.Checked)
                preenchido = 1;
            TurmasBL turBl = new TurmasBL();
            List<Turmas> lTurmas = turBl.PesquisarBL("ID",ddlTurma.SelectedValue.ToString());

            Session["ldsRel"] = chamadasBL.PesquisarDataSet(ddlMes.SelectedValue, ddlAno.SelectedValue, Convert.ToInt16(ddlTurma.SelectedValue), ddlParticipante.SelectedValue, preenchido, lTurmas[0].DiaSemana).Tables[0];
            if (((DataTable)Session["ldsRel"]).Rows.Count != 0)
            {                                                                                                                                                                                                                                                                                                                                                                                                                                           //l//c
                ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "WinOpen('/Relatorios/RelFrequencia.aspx?mes=" + ddlMes.SelectedItem.Text + "','',600,1005);", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "alert('Sua pesquisa não retornou dados.');", true);
            }
        }
        private void PesquisarParticipanteNotInTurma(int turmaId)
        {
            TurmasBL turBL = new TurmasBL();
            DataSet dsTur = turBL.PesquisarBL(turmaId);

            if (dsTur.Tables[0].Rows.Count != 0)
                lblTurma.Text = (string)dsTur.Tables[0].Rows[0]["descricao"].ToString();

            TurmasParticipantesBL tParBL = new TurmasParticipantesBL();
            DataSet tPar = tParBL.PesquisarParticipantesNotInTurmaBL(turmaId, txtParticipante.Text);

            dtbPesquisaParticipanteNotInTurma = tPar.Tables[0];
            dtgParticipantesNotInTurma.DataSource = tPar;
            dtgParticipantesNotInTurma.DataBind();
            mensagemErro.InnerText = string.Empty;
        }
        private void Pesquisar(int turmaId)
        {
            TurmasBL turBL = new TurmasBL();
            DataSet dsTur = turBL.PesquisarBL(turmaId);

            if (dsTur.Tables[0].Rows.Count != 0)
                lblTurma.Text = (string)dsTur.Tables[0].Rows[0]["descricao"].ToString();
        }
        private void CarregarDados(int id_tur)
        {
            TurmasBL turBL = new TurmasBL();
            DataSet dsTur = turBL.PesquisarBL(id_tur);

            foreach (DataRow ltTur in dsTur.Tables[0].Rows)
            {
                hfId.Value = ltTur["id"].ToString();
                lblcodigo.Text = ltTur["Codigo"].ToString();
                txtDescricao.Text = ltTur["Descricao"].ToString();
                txtSala.Text = ltTur["Sala"].ToString();
                txtNroMax.Text = ltTur["Nromax"].ToString();
                string[] diasSemana = ltTur["DiaSemana"].ToString().Split(new Char[] { ',' });
                foreach (string dia in diasSemana)
                {
                    if (dia != string.Empty)
                        ckbDiasSemana.Items.FindByValue(dia).Selected = true;
                }
                txtDtFim.Text = ltTur["DtFim"].ToString() == string.Empty ? "" : string.Format("{0:dd/MM/yyyy}", (DateTime)ltTur["DtFim"]);
                txtDtInicio.Text = ltTur["DtIni"].ToString() == string.Empty ? "" : string.Format("{0:dd/MM/yyyy}", (DateTime)ltTur["DtIni"]);
                txtHoraFim.Text = ltTur["HoraFim"].ToString() == string.Empty ? "" : String.Format("{0:hh:mm}", (DateTime)ltTur["HoraFim"]);
                txtHoraInicio.Text = ltTur["HoraIni"].ToString() == string.Empty ? "" : String.Format("{0:hh:mm}", (DateTime)ltTur["HoraIni"]);
                ddlEvento.SelectedValue = ltTur["EventoId"].ToString();
                ddlInstrutor.SelectedValue = ltTur["PessoaId"].ToString();

            }
        }
        private void Pesquisar(int id_tur, int id_eve)
        {
            DateTime dataSelecionada = Convert.ToDateTime(txtSelData.Text);
            if (Convert.ToDateTime(txtSelData.Text) > DateTime.Now)
                ExibirMensagem("Não é permitido registrar frequências futuras !");
            else
            {
                DataTable tabela = new DataTable();

                DataColumn coluna1 = new DataColumn("TURMAPARTICIPANTEID", Type.GetType("System.Int32"));
                DataColumn coluna2 = new DataColumn("CODPARTICIPANTE", Type.GetType("System.Int32"));
                DataColumn coluna3 = new DataColumn("DESCPARTICIPANTE", Type.GetType("System.String"));
                DataColumn coluna4 = new DataColumn("PRESENCA", Type.GetType("System.Boolean"));
                DataColumn coluna5 = new DataColumn("DATA", Type.GetType("System.String"));
                DataColumn coluna6 = new DataColumn("ID", Type.GetType("System.Int32"));

                tabela.Columns.Add(coluna1);
                tabela.Columns.Add(coluna2);
                tabela.Columns.Add(coluna3);
                tabela.Columns.Add(coluna4);
                tabela.Columns.Add(coluna5);
                tabela.Columns.Add(coluna6);

                TurmasBL turBL = new TurmasBL();
                TurmasParticipantesBL tParBL = new TurmasParticipantesBL();
                ChamadasBL chaBL = new ChamadasBL();
                List<Turmas> turmas = turBL.PesquisarBL(id_tur, id_eve);

                if (turmas.Count != 0)
                {
                    if (turmas[0].DiaSemana.IndexOf(char.Parse(Convert.ToString((int)dataSelecionada.DayOfWeek + 1))) == -1)
                    {
                        ExibirMensagem("Dia da semana selecionado não cadastrado para essa turma.");
                    }
                }

                foreach (Turmas ltTur in turmas)
                {
                    List<TurmasParticipantes> tPar = tParBL.PesquisarBL(ltTur.Id);

                    foreach (TurmasParticipantes ltTpar in tPar)
                    {
                        DataRow linha = tabela.NewRow();

                        linha["TURMAPARTICIPANTEID"] = ltTpar.Id;
                        linha["CODPARTICIPANTE"] = ltTpar.Pessoa.Codigo;
                        linha["DESCPARTICIPANTE"] = ltTpar.Pessoa.Nome;

                        List<Chamadas> cha = chaBL.PesquisarBL(ltTpar.Id, Convert.ToDateTime(txtSelData.Text));

                        if (cha.Count > 0)
                        {
                            foreach (Chamadas ltCha in cha)
                            {
                                linha["ID"] = ltCha.Id;
                                linha["PRESENCA"] = ltCha.Presenca;
                                linha["DATA"] = ltCha.Data.ToString("dd/MM/yyyy");
                            }
                        }
                        else
                        {
                            linha["ID"] = 0;
                            linha["PRESENCA"] = false;
                            linha["DATA"] = txtSelData.Text;
                        }

                        tabela.Rows.Add(linha);
                    }
                }

                repPermissao.DataSource = tabela;
                repPermissao.DataBind();

                TurmasDiarioBL turDiarioBl = new TurmasDiarioBL();
                DataSet dsTurPar = turDiarioBl.PesquisarBL(utils.ComparaIntComZero(ddlTurmas.SelectedValue), Convert.ToDateTime(txtSelData.Text));

                if (dsTurPar.Tables[0].Rows.Count != 0)
                {
                    hfIdTurDiario.Value = dsTurPar.Tables[0].Rows[0]["id"].ToString();
                    txtObs.Text = dsTurPar.Tables[0].Rows[0]["obs"].ToString();
                }
                else
                {
                    hfIdTurDiario.Value = "";
                    txtObs.Text = "";
                }
            }
        }
        private void CarregarDdlInstrutor()
        {
            TurmasBL turBL = new TurmasBL();
            DataSet dsTur = turBL.PesquisarBL(Convert.ToInt16(ddlTurma.SelectedValue.ToString()));

            lblInstrutor.Text = dsTur.Tables[0].Rows[0]["NOME"].ToString();
        }