/// <summary> /// Parâmetros para efetuar a alteração preservando a data de criação /// </summary> /// <param name="qs"></param> /// <param name="entity"></param> protected override void ParamAlterar(QueryStoredProcedure qs, ACA_ObjetoAprendizagem entity) { entity.oap_dataAlteracao = DateTime.Now; base.ParamAlterar(qs, entity); qs.Parameters.RemoveAt("@oap_dataCriacao"); }
protected void _btnSalvar_Click(object sender, EventArgs e) { try { List <int> lstCiclos = CriarListaTipoCiclo(); if (!lstCiclos.Any()) { throw new ValidationException("Selecione pelo menos um ciclo."); } ACA_ObjetoAprendizagem obj = new ACA_ObjetoAprendizagem { IsNew = _VS_oap_id <= 0, oap_descricao = _txtDescricao.Text, tds_id = _VS_tds_id, oae_id = _VS_oae_id, cal_ano = _VS_cal_ano, oap_situacao = (_ckbBloqueado.Checked ? (byte)ObjetoAprendizagemSituacao.Bloqueado : (byte)ObjetoAprendizagemSituacao.Ativo), oap_id = _VS_oap_id }; ACA_ObjetoAprendizagemBO.Save(obj, lstCiclos); if (_VS_oap_id > 0) { ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Update, "oap_id: " + obj.oap_id); __SessionWEB.PostMessages = UtilBO.GetErroMessage("Objeto de conhecimento alterado com sucesso.", UtilBO.TipoMensagem.Sucesso); } else { ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Insert, "oap_id: " + obj.oap_id); __SessionWEB.PostMessages = UtilBO.GetErroMessage("Objeto de conhecimento incluído com sucesso.", UtilBO.TipoMensagem.Sucesso); } Session["tds_id_oae"] = _VS_tds_id; Session["cal_ano_oae"] = _VS_cal_ano; Session["oae_id"] = _VS_oae_id; Session["oae_idPai"] = _VS_oae_idPai; Response.Redirect(__SessionWEB._AreaAtual._Diretorio + "Academico/ObjetoAprendizagem/CadastroEixo.aspx", false); HttpContext.Current.ApplicationInstance.CompleteRequest(); } 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 o objeto de conhecimento.", UtilBO.TipoMensagem.Erro); } }
private void LoadEdit(int oap_id) { try { ACA_ObjetoAprendizagem objetoAp = new ACA_ObjetoAprendizagem { oap_id = oap_id }; ACA_ObjetoAprendizagemBO.GetEntity(objetoAp); _txtDescricao.Text = objetoAp.oap_descricao; _ckbBloqueado.Checked = objetoAp.oap_situacao == (byte)ObjetoAprendizagemSituacao.Bloqueado; Dictionary <int, bool> ciclos = ACA_ObjetoAprendizagemTipoCicloBO.SelectBy_ObjetoAprendizagem(oap_id); if (ciclos.Any(p => !p.Value)) { lblMessageCiclos.Text = UtilBO.GetErroMessage(GetGlobalResourceObject("Academico", "ObjetoAprendizagem.Cadastro.lblMessageCiclos.Text").ToString(), UtilBO.TipoMensagem.Informacao); } foreach (RepeaterItem item in rptCampos.Items) { CheckBox ckbCampo = (CheckBox)item.FindControl("ckbCampo"); if (ckbCampo != null) { HiddenField hdnId = (HiddenField)item.FindControl("hdnId"); if (hdnId != null) { ckbCampo.Checked = ciclos.Any(p => p.Key == Convert.ToInt32(hdnId.Value)); ckbCampo.Enabled = !ciclos.Any(p => p.Key == Convert.ToInt32(hdnId.Value)) || ciclos.Any(p => p.Key == Convert.ToInt32(hdnId.Value) && !p.Value); } } } } catch (Exception ex) { ApplicationWEB._GravaErro(ex); _lblMessage.Text = UtilBO.GetErroMessage("Erro ao carregar o objeto de conhecimento.", UtilBO.TipoMensagem.Erro); } }
protected void _grvObjetoAprendizagem_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Deletar") { try { int index = int.Parse(e.CommandArgument.ToString()); int id = Convert.ToInt32(_grvObjetoAprendizagem.DataKeys[index].Value); ACA_ObjetoAprendizagem entity = new ACA_ObjetoAprendizagem { oap_id = id }; if (ACA_ObjetoAprendizagemBO.Excluir(entity)) { VS_ListaObjetos.RemoveAt(index); VS_ListaObjetos = VS_ListaObjetos.OrderBy(q => q.oap_descricao).ToList(); _grvObjetoAprendizagem.DataSource = VS_ListaObjetos; _grvObjetoAprendizagem.DataBind(); ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Delete, "oap_id: " + id); ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "ScrollToTop", "setTimeout('window.scrollTo(0,0);', 0);", true); _lblMessage.Text = UtilBO.GetErroMessage("Objeto de conhecimento excluído com sucesso.", UtilBO.TipoMensagem.Sucesso); } } catch (ValidationException ex) { ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "ScrollToTop", "setTimeout('window.scrollTo(0,0);', 0);", true); _lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta); } catch (Exception ex) { ApplicationWEB._GravaErro(ex); ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "ScrollToTop", "setTimeout('window.scrollTo(0,0);', 0);", true); _lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar excluir o objeto de conhecimento.", UtilBO.TipoMensagem.Erro); } } }
/// <summary> /// Parâmetros para efetuar a exclusão lógica. /// </summary> /// <param name="qs"></param> /// <param name="entity"></param> protected override void ParamDeletar(QueryStoredProcedure qs, ACA_ObjetoAprendizagem entity) { Param = qs.NewParameter(); Param.DbType = DbType.Int32; Param.ParameterName = "@oap_id"; Param.Size = 4; Param.Value = entity.oap_id; qs.Parameters.Add(Param); Param = qs.NewParameter(); Param.DbType = DbType.Byte; Param.ParameterName = "@oap_situacao"; Param.Size = 1; Param.Value = 3; qs.Parameters.Add(Param); Param = qs.NewParameter(); Param.DbType = DbType.DateTime; Param.ParameterName = "@oap_dataAlteracao"; Param.Size = 16; Param.Value = DateTime.Now; qs.Parameters.Add(Param); }
/// <summary> /// Método alterado para que o delete não faça exclusão física e sim lógica (update). /// </summary> /// <param name="entity">Entidade ACA_AreaConhecimento</param> /// <returns>true = sucesso | false = fracasso</returns> public override bool Delete(ACA_ObjetoAprendizagem entity) { __STP_DELETE = "NEW_ACA_ObjetoAprendizagem_UPDATE_Situacao"; return(base.Delete(entity)); }
/// <summary> /// Método alterado para que o update não faça a alteração da data de criação /// </summary> /// <param name="entity">Entidade ACA_AreaConhecimento</param> /// <returns>true = sucesso | false = fracasso</returns> protected override bool Alterar(ACA_ObjetoAprendizagem entity) { __STP_UPDATE = "NEW_ACA_ObjetoAprendizagem_UPDATE"; return(base.Alterar(entity)); }
/// <summary> /// Parâmetros para efetuar a inclusão preservando a data de criação /// </summary> /// <param name="qs"></param> /// <param name="entity"></param> protected override void ParamInserir(QuerySelectStoredProcedure qs, ACA_ObjetoAprendizagem entity) { entity.oap_dataCriacao = DateTime.Now; entity.oap_dataAlteracao = DateTime.Now; base.ParamInserir(qs, entity); }