public void CarregarGrupos() { DataSet dsGruposAtual = new DataSet(); dsGruposAtual = Grupo_DB.SelectAllGruposAtual(Convert.ToInt32(Session["codPIAtivo"]), Convert.ToInt32(Session["codAtr"])); int qtdGrupos = dsGruposAtual.Tables[0].Rows.Count; Label lbl = new Label(); for (int i = 0; i < qtdGrupos; i++) { int codGrupo = Convert.ToInt32(dsGruposAtual.Tables[0].Rows[i]["gru_codigo"]); string[] matriculasAlunos = Grupo_Aluno_DB.SelectAllMatriculaByGrupo(codGrupo); string[] nomesAlunos = Funcoes.NomeAlunosByMatricula(matriculasAlunos); Table table = new Table(); table.ID = "tabelaGrupo" + i; table.CssClass = "tableGrupos"; table.Style.Add("width", "45%"); lbl = new Label(); lbl.Text = "<br/> <hr>"; pnlGrupos.Controls.Add(lbl); TableHeaderRow thr = new TableHeaderRow(); TableHeaderCell th = new TableHeaderCell(); th.Text = dsGruposAtual.Tables[0].Rows[i]["GRU_NOME_PROJETO"].ToString(); thr.Cells.Add(th); table.Rows.Add(thr); TableRow row; TableCell cell; for (int j = 0; j < nomesAlunos.Length; j++) { row = new TableRow(); cell = new TableCell(); cell.Text = nomesAlunos[j]; row.Cells.Add(cell); table.Rows.Add(row); } //ADICIONANDO OS COMPONENTES PARA O PAINEL pnlGrupos.Controls.Add(table); } }
public void CarregarGruposFinalizar(int codGrupo) { string[] codAlunos = Grupo_Aluno_DB.SelectAllMatriculaByGrupo(codGrupo); string[] nomesAlunos = Funcoes.NomeAlunosByMatricula(codAlunos); string[] codEnvolvidas = (string[])Session["codEnvolvidas"]; string[] nomesMaterias = Funcoes.MateriasByCodigo(codEnvolvidas); nomesDisciplinas = nomesMaterias; string[] atrEnvolvidas = (string[])Session["atrEnvolvidas"]; atribuicaoEnvolvidas = atrEnvolvidas; DataTable dt = new DataTable(); DataRow dr = dt.NewRow(); dt.Columns.Add("Integrantes", typeof(string)); //ADICIONA A PRIMEIRA COLUNA DO CABEÇALHO (INTEGRANTES) //ADICIONA AS COLUNAS DO CABEÇALHO COM OS "IDs" DE ACORDO COM O NOME DO ALUNO for (int i = 0; i < codEnvolvidas.Length; i++) { dt.Columns.Add(nomesMaterias[i], typeof(string)); } for (int j = 0; j < nomesAlunos.Length; j++) { dr = dt.NewRow(); for (int i = 0; i < codEnvolvidas.Length; i++) { if (i == 0) //COLUNA FOR IGUAL A 0 { dr["Integrantes"] = nomesAlunos[j].ToString(); break; } } dt.Rows.Add(dr); } Table table = new Table(); Label lblNotas, lblAlunos; table.ID = "tableFinalizarGrupos"; table.ClientIDMode = System.Web.UI.ClientIDMode.Static; table.CssClass = "tableAlunosNotas"; PanelFinalizarGrupo.Controls.Add(table); int rowsCount = dt.Rows.Count; int colsCount = dt.Columns.Count; TableHeaderRow thr = new TableHeaderRow(); TableHeaderCell th = new TableHeaderCell(); Label lblCabecalho = new Label(); th.Text = "INTEGRANTES"; th.Style.Add("background-color", "#FFF"); th.Style.Add("border", "transparent"); thr.Cells.Add(th); for (int i = 0; i < codEnvolvidas.Length; i++) { th = new TableHeaderCell(); lblCabecalho = new Label(); lblCabecalho.Text = nomesMaterias[i]; th.Style.Add("text-align", "center"); th.Controls.Add(lblCabecalho); thr.Cells.Add(th); } table.Rows.Add(thr); for (int rowIndex = 0; rowIndex < rowsCount; rowIndex++) { TableRow row = new TableRow(); row.ID = rowIndex.ToString(); //PARA O ZEBRADO for (int colIndex = 0; colIndex < colsCount; colIndex++) { TableCell cell = new TableCell(); if (colIndex == 0) { lblAlunos = new Label(); lblAlunos.ID = "lblAlunosRow_" + rowIndex + "_Col_" + colIndex; lblAlunos.ClientIDMode = System.Web.UI.ClientIDMode.Static; lblAlunos.Style.Add("font-weight", "bold"); lblAlunos.Text = Funcoes.SplitNomes(dt.Rows[rowIndex][colIndex].ToString()); lblAlunos.ToolTip = dt.Rows[rowIndex][colIndex].ToString(); lblAlunos.Attributes["data-toggle"] = "tooltip"; cell.Controls.Add(lblAlunos); } else { lblNotas = new Label(); lblNotas.ID = "lblNotasRow_" + (rowIndex) + "_Col_" + colIndex; lblNotas.ClientIDMode = System.Web.UI.ClientIDMode.Static; cell.Style.Add("text-align", "center"); lblNotas.Text = Funcoes.CalcularMediaPonderadaAlunoDisciplinas(Convert.ToInt32(Session["codPIAtivo"]), codAlunos[rowIndex], Convert.ToInt32(atrEnvolvidas[colIndex - 1])).ToString(); cell.Controls.Add(lblNotas); } row.Cells.Add(cell); } table.Rows.Add(row); } //ScriptManager.RegisterStartupScript(this, this.GetType(), "ZebradoGridAvaliar", "ZebradoGridAvaliar();", true); }
private void CarregaTableAvaliar(int codGrupo, DataSet dsCriteriosPesos) { string[] codAlunos = Grupo_Aluno_DB.SelectAllMatriculaByGrupo(codGrupo); string[] nomeAlunos = Funcoes.NomeAlunosByMatricula(codAlunos); Session["matriculasAlunos"] = codAlunos; DataTable dt = new DataTable(); DataRow dr = dt.NewRow(); dt.Columns.Add(" ", typeof(string)); //ADICIONA UMA COLUNA DO CABEÇALHO VAZIA //ADICIONA AS COLUNAS DO CABEÇALHO COM OS "IDs" DE ACORDO COM O NOME DO ALUNO for (int i = 0; i < nomeAlunos.Length; i++) { dt.Columns.Add(Funcoes.SplitNomes((i + 1) + nomeAlunos[i].ToString()), typeof(string)); } string pesos = ""; for (int j = 0; j < dsCriteriosPesos.Tables[0].Rows.Count; j++) { dr = dt.NewRow(); for (int i = 0; i < nomeAlunos.Length + 1; i++) { if (i == 0) //COLUNA FOR IGUAL A 0 { pesos += dsCriteriosPesos.Tables[0].Rows[j]["cpi_peso"].ToString() + "|"; dr[" "] = dsCriteriosPesos.Tables[0].Rows[j]["cge_nome"].ToString() + " (" + dsCriteriosPesos.Tables[0].Rows[j]["cpi_peso"].ToString() + ")"; } } dt.Rows.Add(dr); } valorPeso.Value = pesos.ToString(); //VARIAVEL USADO PARA CALCULAR MÉDIA NO SCRIPT Table table = new Table(); TextBox txbNotas; Label lblCriterios; table.ID = "tableAvaliar"; table.ClientIDMode = System.Web.UI.ClientIDMode.Static; table.CssClass = "gridViewAvaliar"; panelAvaliar.Controls.Add(table); int rowsCount = dt.Rows.Count; int colsCount = dt.Columns.Count; Session["rowsCount"] = rowsCount; Session["colsCount"] = colsCount; TableHeaderRow thr = new TableHeaderRow(); TableHeaderCell th = new TableHeaderCell(); Label lblCabecalho = new Label(); th.Text = " "; th.Style.Add("background-color", "#FFF"); th.Style.Add("border", "transparent"); thr.Cells.Add(th); for (int i = 0; i < nomeAlunos.Length; i++) { th = new TableHeaderCell(); lblCabecalho = new Label(); lblCabecalho.Text = Funcoes.SplitNomes(nomeAlunos[i].ToString()); lblCabecalho.ToolTip = nomeAlunos[i].ToString(); lblCabecalho.Attributes["data-toggle"] = "tooltip"; th.Style.Add("text-align", "center"); th.Controls.Add(lblCabecalho); thr.Cells.Add(th); } table.Rows.Add(thr); for (int rowIndex = 0; rowIndex < rowsCount; rowIndex++) { TableRow row = new TableRow(); row.ID = rowIndex.ToString(); //PARA O ZEBRADO for (int colIndex = 0; colIndex < colsCount; colIndex++) { TableCell cell = new TableCell(); if (colIndex == 0) { lblCriterios = new Label(); lblCriterios.ID = "lblCriteriosRow_" + rowIndex + "_Col_" + colIndex; lblCriterios.ClientIDMode = System.Web.UI.ClientIDMode.Static; lblCriterios.Text = dt.Rows[rowIndex][colIndex].ToString(); cell.Controls.Add(lblCriterios); } else { txbNotas = new TextBox(); txbNotas.ID = "txtNotasRow_" + (rowIndex) + "_Col_" + colIndex; txbNotas.ClientIDMode = System.Web.UI.ClientIDMode.Static; txbNotas.CssClass = "text"; txbNotas.MaxLength = 3; //txbNotas.Attributes["type"] = "Number"; txbNotas.Attributes["min"] = "0"; txbNotas.Attributes["max"] = "10"; txbNotas.Attributes["onkeyup"] = "funcaoImpedirValorAvaliar(this.id);"; txbNotas.Attributes["onblur"] = "funcaoAtualizarMedia(this.id);"; cell.Style.Add("text-align", "center"); txbNotas.Text = dt.Rows[rowIndex][colIndex].ToString(); RequiredFieldValidator rfvTxb = new RequiredFieldValidator(); rfvTxb.ID = "rfvTxb" + rowIndex + "_Col_" + colIndex; rfvTxb.ControlToValidate = "txtNotasRow_" + rowIndex + "_Col_" + colIndex; rfvTxb.EnableClientScript = true; rfvTxb.ErrorMessage = " *"; rfvTxb.ForeColor = System.Drawing.Color.Red; RangeValidator ranTxb = new RangeValidator(); ranTxb.ID = "ranTxb" + rowIndex + "_Col_" + colIndex; ranTxb.ControlToValidate = "txtNotasRow_" + rowIndex + "_Col_" + colIndex; ranTxb.MinimumValue = "0"; ranTxb.MaximumValue = "10"; ranTxb.Type = ValidationDataType.Double; ranTxb.EnableClientScript = true; ranTxb.ErrorMessage = " *"; ranTxb.ForeColor = System.Drawing.Color.Red; cell.Controls.Add(txbNotas); cell.Controls.Add(rfvTxb); cell.Controls.Add(ranTxb); } row.Cells.Add(cell); } table.Rows.Add(row); } TableRow rowMedia = new TableRow(); Label lblMedia = new Label(); for (int colIndex = 0; colIndex < colsCount; colIndex++) { TableCell cell = new TableCell(); cell.CssClass = "mediaAvaliar"; lblMedia = new Label(); lblMedia.ID = "lblMediaRow_" + table.Rows.Count + "_Col_" + colIndex; lblMedia.ClientIDMode = System.Web.UI.ClientIDMode.Static; if (colIndex == 0) { lblMedia.Text = "Média Ponderada Individual: "; } else { lblMedia.Text = " "; } cell.Controls.Add(lblMedia); rowMedia.Cells.Add(cell); } table.Rows.Add(rowMedia); ScriptManager.RegisterStartupScript(this, this.GetType(), "ZebradoGridAvaliar", "ZebradoGridAvaliar();", true); }
protected void btnFinalizarCriarPi_Click(object sender, EventArgs e) { //INSERINDO NA TABELA PROJETO_INTER Projeto_Inter pi = new Projeto_Inter(); pi.Pri_codigo = Convert.ToInt32(lblCodigoPiAut.Text); pi.Pri_semestre = Convert.ToInt32(Session["semestre"]); pi.Cur_nome = Session["curso"].ToString(); Semestre_Ano san = new Semestre_Ano(); san = Semestre_Ano_DB.Select(); pi.San_codigo = san; Projeto_Inter_DB.Insert(pi); string sqlInsertEventos = ""; //INSERINDO NA TABELA EVENTOS if (desc[0] != "") { for (int i = 0; i < desc.Length; i++) { Eventos eve = new Eventos(); eve.Pri_codigo = pi; eve.Eve_tipo = desc[i]; eve.Eve_usuario = Session["nome"].ToString(); sqlInsertEventos += "(0," + eve.Pri_codigo.Pri_codigo + ",'" + dat[i] + "','" + eve.Eve_tipo + "','" + eve.Eve_usuario + "'),"; } Eventos_DB.Insert(sqlInsertEventos.Substring(0, sqlInsertEventos.Length - 1)); } //INSERINDO NA TABELA ATRIBUICAO_PI int[] atrDisciplina = listAtrDisciplinas.ToArray(); int[] codDisciplina = listCodDisciplinas.ToArray(); string[] nomeProf = listNomeProfEnvolvidos.ToArray(); string sqlInsertAtribuicaoPI = ""; for (int i = 0; i < atrDisciplina.Length; i++) { Atribuicao_PI atr = new Atribuicao_PI(); atr.Adi_codigo = atrDisciplina[i]; atr.Pri_codigo = pi; atr.Dis_codigo = codDisciplina[i]; atr.Pro_nome = nomeProf[i]; sqlInsertAtribuicaoPI += "(" + atr.Pri_codigo.Pri_codigo + "," + atr.Adi_codigo + "," + atr.Dis_codigo + ",'" + atr.Pro_nome + "'),"; } Atribuicao_PI_DB.Insert(sqlInsertAtribuicaoPI.Substring(0, sqlInsertAtribuicaoPI.Length - 1)); //INSERINDO NA TABELA CRITERIO_PI string sqlInsertCriterioPI = ""; int indiceCrit = 0; foreach (ListItem li in listaCritPi.Items) { TextBox txtPeso = (TextBox)PanelCriterios.FindControl("txtCriterio" + (indiceCrit)); for (int i = 0; i < atrDisciplina.Length; i++) { Criterio_PI critPi = new Criterio_PI(); Criterios_Gerais crit = new Criterios_Gerais(); Atribuicao_PI atr = new Atribuicao_PI(); atr.Adi_codigo = atrDisciplina[i]; crit.Cge_codigo = Convert.ToInt32(li.Value); critPi.Cge_codigo = crit; critPi.Adi_codigo = atr; critPi.Pri_codigo = pi; critPi.Cpi_peso = Convert.ToInt32(txtPeso.Text); critPi.Cpi_usuario = Session["nome"].ToString(); sqlInsertCriterioPI += "(0," + critPi.Cge_codigo.Cge_codigo + "," + critPi.Pri_codigo.Pri_codigo + "," + critPi.Adi_codigo.Adi_codigo + "," + critPi.Cpi_peso + ",'" + critPi.Cpi_usuario + "'),"; } indiceCrit++; } Criterio_PI_DB.Insert(sqlInsertCriterioPI.Substring(0, sqlInsertCriterioPI.Length - 1)); //INSERINDO NA TABELA GRUPO int ultCodGrupo = Grupo_DB.SelectUltimoCod(); if (ultCodGrupo == -2) { ultCodGrupo = 1; } else { ultCodGrupo++; } string sqlInsertGrupo = ""; string sqlInsertGrupoAluno = ""; for (int i = 1; i < index; i++) { if (ViewState["NomeGrupo" + i.ToString()] != null) { string nomeGrupo = ViewState["NomeGrupo" + i.ToString()].ToString(); Grupo gru = new Grupo(); gru.Gru_codigo = ultCodGrupo; gru.Gru_nome_projeto = nomeGrupo; gru.Pri_codigo = pi; gru.Gru_usuario = Session["nome"].ToString(); sqlInsertGrupo += "(" + gru.Gru_codigo + "," + gru.Pri_codigo.Pri_codigo + ",'" + gru.Gru_nome_projeto + "',null,0,'" + gru.Gru_usuario + "'),"; Grupo_Aluno gal = new Grupo_Aluno(); gal.Gru_codigo = gru; gal.Gal_usuario = Session["nome"].ToString(); string[] codAlunos = ViewState["CodAlunos" + i.ToString()].ToString().Split('|'); for (int j = 0; j < codAlunos.Length - 1; j++) { if (codAlunos[j] != null) { gal.Alu_matricula = codAlunos[j]; sqlInsertGrupoAluno += "('" + gal.Alu_matricula + "'," + gal.Gru_codigo.Gru_codigo + ",'" + gal.Gal_usuario + "'),"; } } } ultCodGrupo++; } Grupo_DB.Insert(sqlInsertGrupo.Substring(0, sqlInsertGrupo.Length - 1)); Grupo_Aluno_DB.Insert(sqlInsertGrupoAluno.Substring(0, sqlInsertGrupoAluno.Length - 1)); Session["codPIAtivo"] = Funcoes.SelectCodPIAtivoByAtr(Convert.ToInt32(Session["codAtr"])); DataSet dsGruposAvaliar = new DataSet(); dsGruposAvaliar = Grupo_DB.SelectAllGruposAvaliar(Convert.ToInt32(Session["codPIAtivo"]), Convert.ToInt32(Session["codAtr"])); Session["GruposAvaliar"] = dsGruposAvaliar; ScriptManager.RegisterStartupScript(this, this.GetType(), "myModalPiCadastrado", "msgFinalizarCadastroPi();", true); }
protected void gdvProjetos_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "verDetalhes") { GridViewRow gvr = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); //pega a linha da grid pela fonte do comando Label lblCodigoGrupo = (Label)gdvProjetos.Rows[gvr.RowIndex].FindControl("lblCodigo"); int gru_codigo = Convert.ToInt32(lblCodigoGrupo.Text); LinkButton lblNome = (LinkButton)gdvProjetos.Rows[gvr.RowIndex].FindControl("lblNome"); string gru_nome = lblNome.Text; //Grupo gru = Grupo_DB.Select(gru_codigo); Label lblCodigoPI = (Label)gdvProjetos.Rows[gvr.RowIndex].FindControl("lblCodigoPI"); int CodigoPI = Convert.ToInt32(lblCodigoPI.Text); Label lblCurso = (Label)gdvProjetos.Rows[gvr.RowIndex].FindControl("lblCurso"); string nome_curso = lblCurso.Text; Label lblSemestreCurso = (Label)gdvProjetos.Rows[gvr.RowIndex].FindControl("lblSemestreCurso"); string semestre_curso = lblSemestreCurso.Text; Label lblStatus = (Label)gdvProjetos.Rows[gvr.RowIndex].FindControl("lblStatus"); string status = lblStatus.Text; lblInformacoes.Text = "<pre>Grupo: " + gru_nome + " / Curso: " + nome_curso + "</br>Semestre: " + semestre_curso + " / Status: " + status + "</pre>"; /*lblNomeGrupoModal.Text = gru_nome; * lblCursoModal.Text = nome_curso; //pega o nome do curso e coloca na célula da coluna correspondente ao curso daquela linha * lblSemestreModal.Text = semestre_curso; * lblStatusModal.Text = status;*/ DataSet cod_disciplina = Atribuicao_PI_DB.SelectDisciplinaByCod(CodigoPI); DataSet nome_professor = Atribuicao_PI_DB.SelectNomeProfessor(CodigoPI); int qtd = nome_professor.Tables[0].Rows.Count; string[] professores = new string[qtd]; for (int i = 0; i < qtd; i++) { professores[i] = nome_professor.Tables[0].Rows[i]["pro_nome"].ToString(); } string[] matriculas_alunos = Grupo_Aluno_DB.SelectAllMatriculaByGrupo(gru_codigo); string[] nome_alunos = Funcoes.NomeAlunosByMatricula(matriculas_alunos); string[] nome_disciplina = Funcoes.DisciplinasByCodigo(cod_disciplina); DataTable dt = new DataTable(); dt.Columns.Add("T", typeof(string)); dt.Columns.Add("Detalhes", typeof(string)); DataRow dr = dt.NewRow(); for (int i = 0; i < matriculas_alunos.Length; i++) //Lista com alunos { dr["T"] = "Alunos"; dr["Detalhes"] = dr["Detalhes"] + nome_alunos[i] + ", "; } dt.Rows.Add(dr); dr = dt.NewRow(); for (int i = 0; i < nome_disciplina.Length; i++) //Lista com disciplina { dr["T"] = "Disciplinas"; dr["Detalhes"] = dr["Detalhes"] + nome_disciplina[i] + ", "; } dt.Rows.Add(dr); dr = dt.NewRow(); for (int i = 0; i < qtd; i++) //Lista com professores { dr["T"] = "Professores"; dr["Detalhes"] = dr["Detalhes"] + professores[i] + ", "; } dt.Rows.Add(dr); gdvDetalhes.DataSource = dt; gdvDetalhes.DataBind(); foreach (GridViewRow linha in gdvDetalhes.Rows) //percorre cada linha da grid { Label lblDetalhes = (Label)linha.FindControl("lblDetalhes"); //acha o label de Nome e liga a outro label string[] split = lblDetalhes.Text.Split(','); lblDetalhes.Text = ""; for (int i = 0; i < split.Length - 1; i++) { lblDetalhes.Text = lblDetalhes.Text + split[i] + "</br>"; } } UpdatePanelModalNovoCriterio.Update(); ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true); } if (e.CommandName == "projHabilitar") { GridViewRow gvr = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); //pega a linha da grid pela fonte do comando Label lblCodigo = (Label)gdvProjetos.Rows[gvr.RowIndex].FindControl("lblCodigo"); //string lblCodigo = gdvProjetos.Rows[gvr.RowIndex].Cells[0].Text; int cod = Convert.ToInt32(lblCodigo.Text); if (Grupo_DB.Update(cod) == 0) { CarregaGrid(); UpdatePanelAtivados.Update(); lblMsg.Text = "Projeto habilitado para alterações de nota com Sucesso!"; } else { CarregaGrid(); UpdatePanelAtivados.Update(); lblMsg.Text = "Erro ao habilitar projeto!"; } } }