protected void btnPesquisar_Click(object sender, EventArgs e) { using (var bm = new BMProcesso()) { DateTime dtIni, dtFim; DateTime?dtIniConvertido = null, dtFimConvertido = null; if (DateTime.TryParse(txtDataInicio.Text, out dtIni)) { dtIniConvertido = dtIni; } if (DateTime.TryParse(txtDataFim.Text, out dtFim)) { dtFimConvertido = dtFim; } int idProcessoresposta = 0; int.TryParse(txtProcessoResposta.Text, out idProcessoresposta); var ufs = ListBoxesUF.RecuperarIdsSelecionados <int>().ToList(); int idEtapa = 0; int.TryParse(cbxDemanda.SelectedValue, out idEtapa); var usuario = ucLupaUsuario.SelectedUser; var consulta = bm.BuscarHistorico(!string.IsNullOrWhiteSpace(cbxProcesso.SelectedValue) ? (int?)int.Parse(cbxProcesso.SelectedValue) : null, usuario, dtIniConvertido, dtFimConvertido, idProcessoresposta, null, ufs, idEtapa); if (consulta != null && consulta.Any()) { btnPesquisar.CssClass = "btn btn-default mostrarload"; Filtros.CssClass = "panel-collapse collapse"; } lblQuantidadeEncontrada.Text = string.Format("<b>Total de registros encontrados:</b> {0}", consulta.Count); dgRelatorio.DataSource = consulta; Session.Add("dsRelatorio", consulta); WebFormHelper.ValidarVisibilidadeCamposGrid(dgRelatorio, chkListaCamposVisiveis.Items); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { HttpCookie filtroCookie = Request.Cookies["activeFiltroGroup"]; if (filtroCookie != null) { Filtros.CssClass = "panel-collapse collapse in"; } return; } using (var bm = new BMProcesso()) { WebFormHelper.PreencherLista(bm.ObterTodos().OrderBy(x => x.Nome).ToList(), cbxProcesso, true, false); } var listaStatusResposta = ((IEnumerable <enumStatusProcessoResposta>)Enum.GetValues(typeof(enumStatusProcessoResposta))).Select(c => new { ID = (int)c, Nome = c.GetDescription() }).ToList(); WebFormHelper.PreencherListaCustomizado(listaStatusResposta, cbxStatus, "ID", "Nome", true, false); var listaUnidades = new ManterUsuario().ObterTodosIQueryable() .Select(x => x.Unidade) .Distinct() .ToList() .Select(nomeUnidade => new { ID = nomeUnidade, Nome = nomeUnidade }) .Where(x => !string.IsNullOrWhiteSpace(x.Nome)) .OrderBy(y => y.Nome) .AsEnumerable(); listUnidades.PreencherItens(listaUnidades, "ID", "Nome"); if (!IsPostBack) { if (chkListaCamposVisiveis.Items.Count == 0) { PreencherCheckBoxPadrao(); } } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { HttpCookie filtroCookie = Request.Cookies["activeFiltroGroup"]; if (filtroCookie != null) { Filtros.CssClass = "panel-collapse collapse in"; } return; } var ufs = new ManterUf().ObterTodosUf(); ListBoxesUF.PreencherItens(ufs, "ID", "Nome"); using (var bm = new BMProcesso()) { WebFormHelper.PreencherLista(bm.ObterTodos(), cbxProcesso, true, false); } }
public ManterProcesso() : base() { bmProcesso = new BMProcesso(); }
protected void btnPesquisar_Click(object sender, EventArgs e) { using (var bm = new BMProcesso()) { int idProcesso, idEtapa; var solicitacoes = new RelatorioSolicitacaoDemandas().ObterSolicitacoes(); int idProcessoResposta; if (int.TryParse(txtProcessoResposta.Text, out idProcessoResposta)) { solicitacoes = solicitacoes.Where(x => x.EtapaResposta.ProcessoResposta.ID == idProcessoResposta); } if (int.TryParse(cbxProcesso.SelectedValue, out idProcesso) && idProcesso > 0) { solicitacoes = solicitacoes.Where(x => x.IdProcesso == idProcesso); } if (int.TryParse(cbxDemanda.SelectedValue, out idEtapa) && idEtapa > 0) { solicitacoes = solicitacoes.Where(x => x.IdEtapa == idEtapa); } var usuario = ucLupaUsuario.SelectedUser; if (usuario != null) { solicitacoes = solicitacoes.Where(x => x.IdUsuario == usuario.ID); } DateTime dtAbertura, dtIni, dtFim; DateTime?dtIniConvertido = null, dtFimConvertido = null; if (DateTime.TryParse(txtDataAbertura.Text, out dtAbertura)) { solicitacoes = solicitacoes.Where(x => x.DataAbertura.Date == dtAbertura.Date); } if (DateTime.TryParse(txtDataInicio.Text, out dtIni)) { dtIniConvertido = dtIni; solicitacoes = solicitacoes.Where(x => x.EtapaResposta.ListaCampoResposta.Any(c => c.Nome == "Data de Início da Capacitação" && DateTime.Parse(c.Resposta) >= dtIniConvertido)); } if (DateTime.TryParse(txtDataFim.Text, out dtFim)) { dtFimConvertido = dtFim; solicitacoes = solicitacoes.Where(x => x.EtapaResposta.ListaCampoResposta.Any(c => c.Nome == "Data de Término da Capacitação" && DateTime.Parse(c.Resposta) >= dtFimConvertido)); } int idStatus = 0; if (int.TryParse(cbxStatus.SelectedValue, out idStatus)) { solicitacoes = solicitacoes.Where(x => (int)x.Status == idStatus); } var unidades = listUnidades.RecuperarIdsSelecionados <string>().ToList(); if (unidades.Any()) { solicitacoes = solicitacoes.Where(x => unidades.Any(u => u == x.Unidade)); } var consulta = solicitacoes.ToList(); if (consulta != null && consulta.Any()) { btnPesquisar.CssClass = "btn btn-default mostrarload"; Filtros.CssClass = "panel-collapse collapse"; var camposPrevisto = consulta.Select(x => x.EtapaResposta.ListaCampoResposta.Where(cr => cr.Campo.Nome == "Valor Previsto de Inscrição" || cr.Campo.Nome == "Valor Previsto de Passagem" || cr.Campo.Nome == "Valor Previsto de Diária").Select(c => c.Resposta)); var resulCamposPrevisto = camposPrevisto.Where(x => x != null).Select(x => x.FirstOrDefault()); var valorTotalPrevisto = resulCamposPrevisto.Where(x => x != null).Sum(x => double.Parse(x)); lblValorTotalPrevisto.Text = string.Format("<b>Valor Total Previsto:</b> {0}", valorTotalPrevisto); var camposExecutado = consulta.Select(x => x.EtapaResposta.ListaCampoResposta.Where(cr => cr.Campo.Nome == "Valor Executado de Inscrição" || cr.Campo.Nome == "Valor Executado de Passagem" || cr.Campo.Nome == "Valor Executado de Diária" ).Select(c => c.Resposta)); var resulCamposExecutado = camposExecutado.Where(x => x != null).Select(x => x.FirstOrDefault()); var valorTotalExecutado = resulCamposExecutado.Where(x => x != null).Sum(x => double.Parse(x)); lblValorTotalExecutado.Text = string.Format("<b>Valor Total Executado:</b> {0}", valorTotalExecutado); componenteGeracaoRelatorio.Visible = true; } else { componenteGeracaoRelatorio.Visible = false; } divTotalizadores.Visible = true; lblQuantidadeEncontrada.Text = string.Format("<b>Total de registros encontrados:</b> {0}", consulta.Count()); var usuarioSessao = new ManterUsuario().ObterUsuarioLogado(); var hashCache = usuarioSessao.ID.ToString(); Session["hashCache"] = hashCache; rptCabecalho.DataSource = null; rptCabecalho.DataBind(); rptRelatorio.DataSource = solicitacoes; rptRelatorio.DataBind(); dvResultado.Visible = true; Cache["dsRelatorio_" + hashCache] = Session["dsRelatorio"] = consulta; Cache["idEtapa"] = idEtapa; } }