protected void grvLimitesCalendario_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { e.Cancel = true; var tev_id = Convert.ToInt32(e.Keys["tev_id"].ToString()); var evl_id = Convert.ToInt32(e.Keys["evl_id"].ToString()); var evl = new ACA_EventoLimite() { cal_id = VS_cal_id, tev_id = tev_id, evl_id = evl_id }; ACA_EventoLimiteBO.GetEntity(evl); if (ACA_EventoLimiteBO.Delete(evl)) { lblMessage.Text = UtilBO.GetErroMessage("Limite excluído com sucesso.", UtilBO.TipoMensagem.Sucesso); Pesquisar(); } else { lblMessage.Text = UtilBO.GetErroMessage("Não foi possível excluir.", UtilBO.TipoMensagem.Erro); } } 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 excluir.", UtilBO.TipoMensagem.Erro); } }
/// <summary> /// Recarrega os limites de acordo com os filtros da tela. /// </summary> private void CarregarLimites() { if ((ACA_TipoEventoBO.eLiberacao)_VS_TipoEvento.tev_liberacao == ACA_TipoEventoBO.eLiberacao.Desnecessaria) { _VS_Limites = null; } else { _VS_Limites = ACA_EventoLimiteBO.GetSelectByTipoEvento(_VS_TipoEvento.tev_id); } }
private void Pesquisar() { var lstLimite = ACA_EventoLimiteBO.GetSelectByCalendario(VS_cal_id); var tblTipoEvento = ACA_TipoEventoBO.SelecionaTipoEvento(0, Guid.Empty); var lstTipoPeriodo = ACA_TipoPeriodoCalendarioBO.SelecionaTipoPeriodoCalendarioPorCalendario(VS_cal_id, ApplicationWEB.AppMinutosCacheLongo); int tpc_idRecesso = ACA_ParametroAcademicoBO.ParametroValorInt32PorEntidade(eChaveAcademico.TIPO_PERIODO_CALENDARIO_RECESSO, __SessionWEB.__UsuarioWEB.Usuario.ent_id); string tcp_nomeRecesso = string.Empty; if (tpc_idRecesso > 0) { ACA_TipoPeriodoCalendario tpc = new ACA_TipoPeriodoCalendario { tpc_id = tpc_idRecesso }; ACA_TipoPeriodoCalendarioBO.GetEntity(tpc); tcp_nomeRecesso = tpc.tpc_nome; } var source = lstLimite.Join(tblTipoEvento.Rows.Cast <DataRow>(), evl => evl.tev_id, tev => Convert.ToInt32(tev["tev_id"]), (evl, tev) => new sLimite() { tev_nome = tev["tev_nome"].ToString(), tpc_nome = (evl.tpc_id > 0 ? (evl.tpc_id == tpc_idRecesso ? tcp_nomeRecesso : lstTipoPeriodo.First(tpc => tpc.tpc_id == evl.tpc_id).tpc_nome) : string.Empty), tev_id = evl.tev_id, evl_id = evl.evl_id, evl = evl }) .GroupBy(evl => string.Format("{0}{1}{2}", evl.tev_nome, (string.IsNullOrEmpty(evl.tpc_nome) ? string.Empty : " - "), evl.tpc_nome)) .Select(grp => new { TipoEventoBimestre = grp.Key, Limites = grp.ToList() }) .OrderBy(grp => grp.TipoEventoBimestre); rptLimitesCalendario.DataSource = source; rptLimitesCalendario.DataBind(); }
protected void btnSalvar_Click(object sender, EventArgs e) { if (IsValid) { try { if (ddlAlcance.SelectedValue == "-1") { throw new ValidationException("Alcance é obrigatório."); } else if (ddlAlcance.SelectedValue == "2" && UCComboUAEscola.Esc_ID <= 0) { throw new ValidationException("Escola é obrigatória."); } else if (ddlAlcance.SelectedValue == "3" && UCComboUAEscola.Uad_ID == Guid.Empty) { throw new ValidationException("DRE é obrigatória."); } #region Preenche entity var entity = new ACA_EventoLimite() { cal_id = VS_cal_id, tev_id = UCCTipoEvento.Valor, evl_dataInicio = Convert.ToDateTime(txtDataInicio.Text), evl_dataFim = Convert.ToDateTime(txtDataFim.Text), usu_id = __SessionWEB.__UsuarioWEB.Usuario.usu_id }; if (UCCPeriodoCalendario.Visible) { entity.tpc_id = UCCPeriodoCalendario.Valor[0]; } if (UCComboUAEscola.ExibeComboEscola) { entity.esc_id = UCComboUAEscola.Esc_ID; entity.uni_id = UCComboUAEscola.Uni_ID; } else if (UCComboUAEscola.VisibleUA) { entity.uad_id = UCComboUAEscola.Uad_ID; } #endregion ACA_EventoLimiteBO.Save(entity); lblMessage.Text = UtilBO.GetErroMessage("Dados salvos com sucesso.", UtilBO.TipoMensagem.Sucesso); Pesquisar(); #region Limpar formulário UCCTipoEvento.Valor = -1; UCCTipoEvento_IndexChanged(); txtDataInicio.Text = string.Empty; txtDataFim.Text = string.Empty; ddlAlcance.SelectedIndex = 0; ddlAlcance_SelectedIndexChanged(null, null); UCComboUAEscola.DdlUA.SelectedIndex = 0; UCComboUAEscola.Visible = false; #endregion } 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) { ApplicationWEB._GravaErro(ex); lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar salvar.", UtilBO.TipoMensagem.Erro); } } }