Esempio n. 1
0
        /// <summary>
        /// Retorna as vigências da posição e por disciplina.
        /// </summary>
        /// <param name="listDocentesPosicoes">Lista com as posições do docente.</param>
        /// <param name="posicao">Posição.</param>
        /// <param name="tud_id">Id das disciplinas.</param>
        public void RetornaDocentesPosicao(ref List <TUR_Turma_Docentes_Disciplina> listDocentesPosicoes, byte posicao, long tud_id)
        {
            foreach (GridViewRow row in grvControleVigencia.Rows)
            {
                TUR_Turma_Docentes_Disciplina entityDoc = new TUR_Turma_Docentes_Disciplina
                {
                    indice     = row.RowIndex,
                    doc_nome   = grvControleVigencia.DataKeys[row.RowIndex].Values["doc_nome"].ToString(),
                    entDocente = new TUR_TurmaDocente
                    {
                        doc_id             = (long)grvControleVigencia.DataKeys[row.RowIndex].Values["doc_id"],
                        col_id             = (long)grvControleVigencia.DataKeys[row.RowIndex].Values["col_id"],
                        crg_id             = (int)grvControleVigencia.DataKeys[row.RowIndex].Values["crg_id"],
                        coc_id             = (int)grvControleVigencia.DataKeys[row.RowIndex].Values["coc_id"],
                        tdt_posicao        = posicao,
                        tdt_tipo           = 1, // Regular
                        tud_id             = tud_id,
                        tdt_vigenciaInicio = Convert.ToDateTime(grvControleVigencia.DataKeys[row.RowIndex].Values["tdt_vigenciaInicio"]),
                        tdt_vigenciaFim    = string.IsNullOrEmpty(grvControleVigencia.DataKeys[row.RowIndex].Values["tdt_vigenciaFim"].ToString()) ? new DateTime() : Convert.ToDateTime(grvControleVigencia.DataKeys[row.RowIndex].Values["tdt_vigenciaFim"]),
                        tdt_id             = (int)grvControleVigencia.DataKeys[row.RowIndex].Values["tdt_id"],
                        IsNew = (int)grvControleVigencia.DataKeys[row.RowIndex].Values["tdt_id"] > 0 ? false : true
                    }
                };

                listDocentesPosicoes.Add(entityDoc);
            }
        }
Esempio n. 2
0
        protected void grvControleVigencia_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Deletar")
            {
                try
                {
                    List <TUR_Turma_Docentes_Disciplina> list = RetornaDadosGrid();

                    foreach (TUR_Turma_Docentes_Disciplina Item in list)
                    {
                        // Remove do cache as turmas do docente.
                        TUR_TurmaBO.RemoveCacheDocenteControleTurma(__SessionWEB.__UsuarioWEB.Usuario.ent_id, Item.entDocente.doc_id);
                    }

                    list.Remove(list.Find(p => p.indice == Convert.ToInt32(e.CommandArgument)));
                    AtualizaGrid(list);
                    CarregarDocenteVigente(list);
                }
                catch (Exception ex)
                {
                    ApplicationWEB._GravaErro(ex);
                    lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar excluir a vigência do docente.", UtilBO.TipoMensagem.Erro);
                }
            }

            if (e.CommandName == "Editar")
            {
                try
                {
                    List <TUR_Turma_Docentes_Disciplina> list   = RetornaDadosGrid();
                    TUR_Turma_Docentes_Disciplina        entity = list.Find(p => p.indice == Convert.ToInt32(e.CommandArgument));

                    uccDocente.Valor    = new long[] { -1, -1, -1, -1 };
                    uccDocente.Valor    = new[] { entity.entDocente.doc_id, entity.entDocente.col_id, entity.entDocente.crg_id, entity.entDocente.coc_id };
                    txtVigenciaIni.Text = entity.entDocente.tdt_vigenciaInicio.ToString("dd/MM/yyyy");
                    txtVigenciaFim.Text = entity.entDocente.tdt_vigenciaFim != new DateTime() ? entity.entDocente.tdt_vigenciaFim.ToString("dd/MM/yyyy") : string.Empty;
                    lblIndice.Text      = entity.indice.ToString();
                    lbltdt_id.Text      = entity.entDocente.tdt_id.ToString();

                    if (uccDocente.Valor[0] == -1)
                    {
                        uccDocente._Combo.Items.Add(new ListItem(entity.doc_nome, entity.entDocente.doc_id.ToString() + ";" +
                                                                 entity.entDocente.col_id.ToString() + ";" +
                                                                 entity.entDocente.crg_id.ToString() + ";" +
                                                                 entity.entDocente.coc_id.ToString()));
                        uccDocente.Valor         = new[] { entity.entDocente.doc_id, entity.entDocente.col_id, entity.entDocente.crg_id, entity.entDocente.coc_id };
                        uccDocente.PermiteEditar = false;
                    }
                }
                catch (Exception ex)
                {
                    ApplicationWEB._GravaErro(ex);
                    lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar editar a vigência do docente.", UtilBO.TipoMensagem.Erro);
                }
            }
        }
Esempio n. 3
0
    protected void rptDocentes_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        long tud_id       = Convert.ToInt64(((Label)e.Item.FindControl("lbltud_id")).Text);
        byte posicao      = Convert.ToByte(((Label)e.Item.FindControl("lblposicao")).Text);
        int  qtdedocentes = Convert.ToInt32(((Label)e.Item.FindControl("lblqtdedocentes")).Text);
        int  tds_id       = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "tds_id"));

        ControleVigenciaDocentes UCControleVigenciaDocentes = (ControleVigenciaDocentes)e.Item.FindControl("UCControleVigenciaDocentes");

        TUR_Turma_Docentes_Disciplina entity = listTurmaDocentes.Find(p => (p.entDocente.tud_id == tud_id && p.entDocente.tdt_posicao == posicao && p.entDocente.tdt_situacao == 1));

        UCControleVigenciaDocentes.CarregarDocente
            (entity.doc_nome, posicao, qtdedocentes, tud_id, ref dtDocentesEscola, tds_id
            , escola_esc_id, escola_uni_id, professorEspecialista, escola_bloqueioAtribuicaoDocente, ref DtVigenciasDocentes);
    }
Esempio n. 4
0
        /// <summary>
        /// Carrega docente vigente.
        /// </summary>
        private void CarregarDocenteVigente(List <TUR_Turma_Docentes_Disciplina> list)
        {
            TUR_Turma_Docentes_Disciplina entityDocenteAtual = list.Find(p => (p.entDocente.tdt_vigenciaInicio <= DateTime.Now.Date &&
                                                                               (p.entDocente.tdt_vigenciaFim == new DateTime() || p.entDocente.tdt_vigenciaFim >= DateTime.Now.Date)));

            if (entityDocenteAtual.entDocente != null)
            {
                txtNomeDocente.Text = entityDocenteAtual.doc_nome;
                lblposicao.Text     = entityDocenteAtual.indice.ToString();
                lblTud_id.Text      = entityDocenteAtual.entDocente.tud_id.ToString();
            }
            else
            {
                txtNomeDocente.Text = string.Empty;
                lblposicao.Text     = string.Empty;
                lblTud_id.Text      = string.Empty;
            }

            updBotao.Update();
        }
Esempio n. 5
0
        /// <summary>
        /// Cria uma lista de dados da grid.
        /// </summary>
        /// <returns>Lista dos docentes por disciplina.</returns>
        public List <TUR_Turma_Docentes_Disciplina> RetornaDadosGrid()
        {
            List <TUR_Turma_Docentes_Disciplina> list = new List <TUR_Turma_Docentes_Disciplina>();

            try
            {
                foreach (GridViewRow row in grvControleVigencia.Rows)
                {
                    string dataInicio = grvControleVigencia.DataKeys[row.RowIndex].Values["tdt_vigenciaInicio"].ToString();
                    string dataFim    = grvControleVigencia.DataKeys[row.RowIndex].Values["tdt_vigenciaFim"].ToString();

                    TUR_Turma_Docentes_Disciplina entity = new TUR_Turma_Docentes_Disciplina
                    {
                        indice   = row.RowIndex,
                        doc_nome = grvControleVigencia.DataKeys[row.RowIndex].Values["doc_nome"].ToString(),

                        entDocente = new TUR_TurmaDocente
                        {
                            doc_id             = (long)grvControleVigencia.DataKeys[row.RowIndex].Values["doc_id"],
                            col_id             = (long)grvControleVigencia.DataKeys[row.RowIndex].Values["col_id"],
                            crg_id             = (int)grvControleVigencia.DataKeys[row.RowIndex].Values["crg_id"],
                            coc_id             = (int)grvControleVigencia.DataKeys[row.RowIndex].Values["coc_id"],
                            tdt_vigenciaInicio = string.IsNullOrEmpty(dataInicio) ? new DateTime() : Convert.ToDateTime(dataInicio),
                            tdt_vigenciaFim    = string.IsNullOrEmpty(dataFim) ? new DateTime() : Convert.ToDateTime(dataFim),
                            tdt_id             = (int)grvControleVigencia.DataKeys[row.RowIndex].Values["tdt_id"],
                            tdt_tipo           = 1 // Regular
                        }
                    };

                    list.Add(entity);
                }
            }
            catch (Exception ex)
            {
                ApplicationWEB._GravaErro(ex);
                lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar ler os dados na tabela.", UtilBO.TipoMensagem.Erro);
            }

            return(list);
        }
Esempio n. 6
0
        protected void btnSalvar_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    List <TUR_Turma_Docentes_Disciplina> list = RetornaDadosGrid();

                    DateTime vigenciaInicio = Convert.ToDateTime(txtVigenciaIni.Text);
                    DateTime vigenciaFim    = string.IsNullOrEmpty(txtVigenciaFim.Text) ? new DateTime() : Convert.ToDateTime(txtVigenciaFim.Text);
                    int      tdt_id         = string.IsNullOrEmpty(lbltdt_id.Text) ? 0 : Convert.ToInt32(lbltdt_id.Text);

                    // Se for uma alteração deleta do list e adiciona novamente
                    if (!string.IsNullOrEmpty(lblIndice.Text))
                    {
                        list.Remove(list.Find(p => p.indice == Convert.ToInt32(lblIndice.Text)));
                    }

                    DateTime dtFim2 = vigenciaFim == new DateTime() ? DateTime.MaxValue : vigenciaFim;

                    // Verifica se não existe conflito de datas
                    foreach (TUR_Turma_Docentes_Disciplina item in list)
                    {
                        DateTime dtFim = item.entDocente.tdt_vigenciaFim == new DateTime() ? DateTime.MaxValue : item.entDocente.tdt_vigenciaFim;

                        if (GestaoEscolarUtilBO.ExisteConflitoDatas(item.entDocente.tdt_vigenciaInicio, dtFim, vigenciaInicio, dtFim2))
                        {
                            throw new ValidationException("Existe conflito entre as vigências.");
                        }
                    }

                    // RF_076
                    string periodoVigencia;
                    if (!RHU_ColaboradorCargoBO.ValidarVigenciaPorData(uccDocente.Valor, vigenciaInicio, vigenciaFim, out periodoVigencia))
                    {
                        throw new ValidationException
                                  ("A vigência do docente na turma deve estar dentro da vigência do seu cargo (" +
                                  periodoVigencia + ").");
                    }

                    TUR_Turma_Docentes_Disciplina entDoc = new TUR_Turma_Docentes_Disciplina
                    {
                        doc_nome   = uccDocente.TextoSelecionado,
                        entDocente = new TUR_TurmaDocente
                        {
                            doc_id             = uccDocente.Doc_id,
                            col_id             = uccDocente.Valor[1],
                            crg_id             = (int)uccDocente.Valor[2],
                            coc_id             = (int)uccDocente.Valor[3],
                            tdt_vigenciaInicio = vigenciaInicio,
                            tdt_vigenciaFim    = vigenciaFim,
                            tdt_id             = tdt_id
                        }
                    };

                    list.Add(entDoc);
                    AtualizaGrid(list);
                    LimparCampos();

                    CarregarDocenteVigente(list);
                }
                catch (ValidationException ex)
                {
                    lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta);
                }
                catch (Exception ex)
                {
                    ApplicationWEB._GravaErro(ex);
                    lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar salvar o docente.", UtilBO.TipoMensagem.Erro);
                }
            }
        }