protected void btnSalvar_Click(object sender, EventArgs e) { if (ValidarCampos()) { RelatorioBLL RelBLL = new RelatorioBLL(); FUN_TBL_RELATORIO uptRel = new FUN_TBL_RELATORIO(); Resultado res = new Resultado(); uptRel.RELATORIO = txtRelatorio.Text; uptRel.TITULO = txtTitulo.Text; uptRel.ARQUIVO = txtOrigem.Text; uptRel.ID_TIPO_RELATORIO = short.Parse(ddlTipo.SelectedValue); uptRel.RELATORIO_EXTENSAO = txtExtensao.Text; if (!String.IsNullOrEmpty(txtCodigo.Text)) { uptRel.ID_RELATORIO = int.Parse(txtCodigo.Text); res = RelBLL.UpdateData(uptRel); } else { uptRel.ID_RELATORIO = 0; res = RelBLL.InsertData(uptRel); } if (res.Ok) { txtCodigo.Text = uptRel.ID_RELATORIO.ToString(); btnInserirParam.Enabled = true; grdRelatorio.DataBind(); } MostraMensagem(spanMensagemDetalhe, res.Mensagem, (res.Ok) ? "n_ok" : "n_error"); } }
public Resultado InsertData(FUN_TBL_RELATORIO uptRelatorio) { Resultado res = new Resultado(); try { var ja_existe = m_DbContext.FUN_TBL_RELATORIO.FirstOrDefault(p => p.ID_RELATORIO == uptRelatorio.ID_RELATORIO); if (ja_existe == null) { decimal max_key = m_DbContext.FUN_TBL_RELATORIO.Max(r => r.ID_RELATORIO); uptRelatorio.ID_RELATORIO = max_key + 1; m_DbContext.FUN_TBL_RELATORIO.Add(uptRelatorio); int rows_inserted = m_DbContext.SaveChanges(); if (rows_inserted > 0) { res.Sucesso(String.Format("{0} registro(s) inserido(s).", rows_inserted)); } } } catch (Exception ex) { res.Erro("Problemas contate o administrador do sistema: \\n" + ex.Message); } return(res); }
public Resultado UpdateData(FUN_TBL_RELATORIO uptRelatorio) { Resultado res = new Resultado(); try { var atualiza = m_DbContext.FUN_TBL_RELATORIO.FirstOrDefault(p => p.ID_RELATORIO == uptRelatorio.ID_RELATORIO); if (atualiza != null) { atualiza.RELATORIO = uptRelatorio.RELATORIO; atualiza.TITULO = uptRelatorio.TITULO; atualiza.ARQUIVO = uptRelatorio.ARQUIVO; atualiza.ID_TIPO_RELATORIO = uptRelatorio.ID_TIPO_RELATORIO; atualiza.RELATORIO_EXTENSAO = uptRelatorio.RELATORIO_EXTENSAO; int rows_updated = m_DbContext.SaveChanges(); if (rows_updated > 0) { res.Sucesso(String.Format("{0} registro(s) atualizado(s).", rows_updated)); } } } catch (Exception ex) { res.Erro("Problemas contate o administrador do sistema: \\n" + ex.Message); } return(res); }
private void CarregarDetalhesRelatorio(int CodRelatorio) { RelatorioBLL RelBLL = new RelatorioBLL(); FUN_TBL_RELATORIO rel = RelBLL.ConsultarRelatorio(CodRelatorio); CarregaDropDowList(ddlTipo, RelBLL.GetRelatorioTipos().ToList <Object>(), "NM_TIPO", "ID_TIPO_RELATORIO"); txtCodigo.Text = rel.ID_RELATORIO.ToString(); txtRelatorio.Text = rel.RELATORIO; ddlTipo.SelectedValue = rel.ID_TIPO_RELATORIO.ToString(); txtTitulo.Text = rel.TITULO; txtOrigem.Text = rel.ARQUIVO; txtExtensao.Text = rel.RELATORIO_EXTENSAO; }
public new Resultado InsertData(FUN_TBL_RELATORIO uptRelatorio) { return(base.InsertData(uptRelatorio)); }
public new Resultado UpdateData(FUN_TBL_RELATORIO uptRelatorio) { return(base.UpdateData(uptRelatorio)); }