Пример #1
0
        protected void gvFechamento_DataBound(object sender, EventArgs e)
        {
            UCTotalRegistros.Total = CLS_ArquivoEfetivacaoBO.GetTotalRecords();

            // Seta propriedades necessárias para ordenação nas colunas.
            ConfiguraColunasOrdenacao(gvFechamento);

            if ((!string.IsNullOrEmpty(gvFechamento.SortExpression)) && (__SessionWEB.BuscaRealizada.PaginaBusca == PaginaGestao.LoteFechamento))
            {
                Dictionary <string, string> filtros = __SessionWEB.BuscaRealizada.Filtros;

                if (filtros.ContainsKey("VS_Ordenacao"))
                {
                    filtros["VS_Ordenacao"] = gvFechamento.SortExpression;
                }
                else
                {
                    filtros.Add("VS_Ordenacao", gvFechamento.SortExpression);
                }

                if (filtros.ContainsKey("VS_SortDirection"))
                {
                    filtros["VS_SortDirection"] = gvFechamento.SortDirection.ToString();
                }
                else
                {
                    filtros.Add("VS_SortDirection", gvFechamento.SortDirection.ToString());
                }

                __SessionWEB.BuscaRealizada = new BuscaGestao
                {
                    PaginaBusca = PaginaGestao.LoteFechamento
                    ,
                    Filtros = filtros
                };
            }
        }
Пример #2
0
        protected void gvFechamento_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Exportar")
            {
                try
                {
                    int   index  = int.Parse(e.CommandArgument.ToString());
                    int   esc_id = Convert.ToInt32(gvFechamento.DataKeys[index]["esc_id"]);
                    int   uni_id = Convert.ToInt32(gvFechamento.DataKeys[index]["uni_id"]);
                    int   cal_id = Convert.ToInt32(gvFechamento.DataKeys[index]["cal_id"]);
                    int   tpc_id = Convert.ToInt32(gvFechamento.DataKeys[index]["tpc_id"]);
                    Int64 tur_id = Convert.ToInt64(gvFechamento.DataKeys[index]["tur_id"]);

                    string ordemAluno = ACA_ParametroAcademicoBO.ParametroValorPorEntidade(eChaveAcademico.ORDENACAO_COMBO_ALUNO, __SessionWEB.__UsuarioWEB.Usuario.ent_id);

                    ordemAluno = string.IsNullOrEmpty(ordemAluno) ? "1" : ordemAluno;
                    DataTable dt = CLS_ArquivoEfetivacaoBO.ExportacaoAlunosFechamento(esc_id, uni_id, cal_id, tur_id, tpc_id,
                                                                                      GestaoEscolarUtilBO.nomePadraoPeriodo_Calendario(__SessionWEB.__UsuarioWEB.Usuario.ent_id),
                                                                                      GetGlobalResourceObject("Mensagens", "MSG_DISCIPLINA_PLURAL").ToString(),
                                                                                      Convert.ToInt16(ordemAluno));
                    if (dt.Rows.Count == 0)
                    {
                        throw new ValidationException("Não existem itens para essa turma");
                    }

                    CLS_ArquivoEfetivacao entity = new CLS_ArquivoEfetivacao
                    {
                        aef_id            = -1,
                        esc_id            = esc_id,
                        uni_id            = uni_id,
                        cal_id            = cal_id,
                        tpc_id            = tpc_id,
                        tur_id            = tur_id,
                        aef_dataCriacao   = DateTime.Now,
                        aef_dataAlteracao = DateTime.Now,
                        aef_tipo          = (short)CLS_ArquivoEfetivacaoBO.eTipoArquivoEfetivacao.Exportacao,
                        aef_situacao      = (short)CLS_ArquivoEfetivacaoBO.eSituacao.Ativo,
                        IsNew             = true
                    };

                    if (CLS_ArquivoEfetivacaoBO.Save(entity))
                    {
                        VS_NomeArquivoCSV     = dt.Rows[0][0] + "_" + dt.Rows[0][1] + "_" + dt.Rows[0][2] + "-" + dt.Rows[0][3] + "_" + entity.aef_id + ".csv";
                        VS_ConteudoArquivoCSV = GestaoEscolarUtilBO.ConverterTabelaParaArquivoCSV(dt).ToString();

                        ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Insert, "aef_id: " + entity.aef_id);
                        lblMsgDownload.Text = UtilBO.GetErroMessage("Arquivo gerado com sucesso.", UtilBO.TipoMensagem.Sucesso);// +
                        //UtilBO.GetErroMessage("O nome do arquivo será utilizado para importação, portanto não deve ser alterado.", UtilBO.TipoMensagem.Alerta);
                        Pesquisar();
                        ScriptManager.RegisterStartupScript(Page, typeof(Page), "Donwload", "$(document).ready(function() { $('#divDownload').dialog({title: 'Download do arquivo do fechamento do bimestre'}).dialog('open'); });", true);
                    }
                }
                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 gerar o arquivo.", UtilBO.TipoMensagem.Erro);
                }
            }

            if (e.CommandName == "Importar")
            {
                try
                {
                    gvFechamento.EditIndex = int.Parse(e.CommandArgument.ToString());
                }
                catch (Exception ex)
                {
                    ApplicationWEB._GravaErro(ex);
                    _lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar carregar o sistema.", UtilBO.TipoMensagem.Erro);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// O método realiza a importação dos registros que foram analisados com sucesso.
        /// </summary>
        private void ImportarArquivo()
        {
            try
            {
                List <LoteFechamento> listaSucesso = VS_listaLoteFechamento.Where(p => p.status == LoteStatus.Sucess).ToList();

                if (listaSucesso.Any())
                {
                    int sucesso, erro;

                    VS_listaLoteFechamento = CLS_ArquivoEfetivacaoBO.SalvarRegistrosLote(__SessionWEB.__UsuarioWEB.Usuario.ent_id, listaSucesso, VS_arquivo, out sucesso, out erro);

                    // Configura e atualiza GridView
                    UCComboQtdePaginacao.Valor = 10;
                    grvArquivo.PageIndex       = 0;
                    grvArquivo.PageSize        = Convert.ToInt32(UCComboQtdePaginacao.Valor);
                    grvArquivo.DataBind();

                    // Configura importação dos registro do arquivo
                    lblSucesso.Text = sucesso.ToString();
                    lblErro.Text    = erro.ToString();
                    lblTotal.Text   = (sucesso + erro).ToString();

                    ConfigurarPasso(ePasso.ImportacaoArquivo);

                    // Configura mensagem da importação dos registro
                    lblMessage.Text = sucesso > 0 ?
                                      (
                        erro > 0 ?
                        UtilBO.GetMessage(String.Format("Importação de dados de {0} de {1} realizada com sucesso, porém alguns registros não foram importados devido a erros encontrados.", nomeEfetivacao.ToLower(), nomeBimestre.ToLower()), UtilBO.TipoMensagem.Sucesso) :
                        UtilBO.GetMessage(String.Format("Importação de dados de {0} de {1} realizada com sucesso.", nomeEfetivacao.ToLower(), nomeBimestre.ToLower()), UtilBO.TipoMensagem.Sucesso)
                                      ) :
                                      UtilBO.GetMessage(String.Format("Não foi possível realizar importação de dados de {0} de {1} devido a erros encontrados.", nomeEfetivacao.ToLower(), nomeBimestre.ToLower()), UtilBO.TipoMensagem.Erro);

                    if (sucesso > 0)
                    {
                        ApplicationWEB._GravaLogSistema
                        (
                            LOG_SistemaTipo.Insert,
                            String.Format("Importação de dados de {0} de {1} - sucesso: {2} / erro: {3} / tur_id: {4} / tpc_id: {5}",
                                          nomeEfetivacao.ToLower(), nomeBimestre.ToLower(), sucesso.ToString(), erro.ToString(), VS_tur_id.ToString(), VS_tpc_id.ToString())
                        );
                    }
                }
                else
                {
                    lblMessage.Text = UtilBO.GetMessage("Não existem registros processados com sucesso para realizar a importação.", UtilBO.TipoMensagem.Alerta);
                }
            }
            catch (ValidationException ex)
            {
                lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Erro);
            }
            catch (Exception ex)
            {
                ApplicationWEB._GravaErro(ex);
                lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar importar dados do arquivo.", UtilBO.TipoMensagem.Erro);
            }
            finally
            {
                updMessage.Update();
            }
        }
Пример #4
0
        /// <summary>
        /// O método analisa os registros do arquivo de fechamento.
        /// </summary>
        private void AnalisarArquivo()
        {
            try
            {
                //if (ValidarNomeArquivo())
                if (GestaoEscolarUtilBO.VerificarArquivo(fupArquivo.PostedFile))
                {
                    int sucesso, erro;

                    string nomeArquivoSemExtensao = Path.GetFileNameWithoutExtension(fupArquivo.PostedFile.FileName);
                    string nomeArquivo            = fupArquivo.PostedFile.FileName;
                    int    tamanhoArquivo         = fupArquivo.PostedFile.ContentLength;
                    string typeMime = fupArquivo.PostedFile.ContentType;

                    Stream arquivo = CopiarArquivo(fupArquivo.PostedFile.InputStream);

                    VS_arquivo = CriarAnexo(arquivo, nomeArquivo, tamanhoArquivo, typeMime);

                    arquivo.Position = 0;

                    VS_listaLoteFechamento = CLS_ArquivoEfetivacaoBO.AnalisarRegistrosLote
                                             (
                        (string)GetGlobalResourceObject("Mensagens", "MSG_DISCIPLINA"),
                        __SessionWEB.__UsuarioWEB.Usuario.ent_id,
                        VS_cal_id, VS_tpc_id, VS_tur_id,
                        arquivo, nomeArquivoSemExtensao,
                        out sucesso, out erro
                                             );

                    if (VS_listaLoteFechamento.Any())
                    {
                        UCComboQtdePaginacao.Valor = 10;
                        grvArquivo.PageIndex       = 0;
                        grvArquivo.PageSize        = UCComboQtdePaginacao.Valor;
                        grvArquivo.DataBind();
                        updArquivo.Update();

                        // Configura análise dos registro do arquivo
                        lblSucesso.Text = sucesso.ToString();
                        lblErro.Text    = erro.ToString();
                        lblTotal.Text   = (sucesso + erro).ToString();

                        ConfigurarPasso(ePasso.AnaliseArquivo);
                    }
                    else
                    {
                        lblMessage.Text = UtilBO.GetErroMessage("Não existem registros para analisar no arquivo enviado.", UtilBO.TipoMensagem.Alerta);
                        updMessage.Update();
                    }
                }
            }
            catch (ValidationException ex)
            {
                lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta);
            }
            catch (ArgumentException ex)
            {
                lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta);
            }
            catch (Exception ex)
            {
                lblMessage.Text = UtilBO.GetErroMessage("Erro ao realizar a análise dos registros do arquivo.", UtilBO.TipoMensagem.Erro);
                ApplicationWEB._GravaErro(ex);
            }
            finally
            {
                updMessage.Update();
            }
        }