public static List <TipoNoticia> Listar() { string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString; SqlConnection objConexao = new SqlConnection(strConectionString); SqlCommand objComando = new SqlCommand("SPE_L_TIPO_ARQUIVO"); objComando.Connection = objConexao; objComando.CommandType = CommandType.StoredProcedure; try { //Abre Conexao objConexao.Open(); //Declara variavel de retorno List <TipoNoticia> objList = new List <TipoNoticia>(); TipoNoticia obj = default(TipoNoticia); IDataReader idrReader = default(IDataReader); idrReader = objComando.ExecuteReader(); while ((idrReader.Read())) { obj = new TipoNoticia(); obj.FromIDataReader(idrReader); objList.Add(obj); } return(objList); } catch (Exception ex) { throw ex; } finally { //Fecha a conexao se aberta if (objConexao.State != ConnectionState.Closed) { objConexao.Close(); } } }
private void LerDados() { TipoNoticia objTipoArquivo = null; List <Comunicado> objDados = null; try { btnNovo.Enabled = true; btnExcluir.Enabled = true; objTipoArquivo = new TipoNoticia(); if (ddlTipoComunicado.SelectedIndex > 0) { objTipoArquivo.ID = Convert.ToInt32(ddlTipoComunicado.SelectedValue.ToString()); } objDados = DoComunicado.Listar(new Comunicado() { TipoComunicado = objTipoArquivo }); if (objDados != null) { listPager.DataSource = objDados; listPager.DataBind(); BindGrid(); } if (objDados.Count <= 0) { btnExcluir.Enabled = false; } } catch (Exception ex) { //Chama o método para gravar erro ((Modulos_Modulos)Master).ExibirAlerta(ex); } }
protected void ddlTipoComunicado_SelectedIndexChanged(object sender, EventArgs e) { TipoNoticia tipoArquivo = null; try { if (ddlTipoComunicado.SelectedIndex > 0) { tipoArquivo = new TipoNoticia() { ID = Convert.ToInt32(ddlTipoComunicado.SelectedValue) }; CarregarComunicado(tipoArquivo); divComunicado.Visible = true; } } catch (Exception ex) { throw ex; } }
private void CarregarComunicado(TipoNoticia objTipoComunicado) { Comunicado comunicado = null; try { ddlComunicado.ClearSelection(); comunicado = new Comunicado() { TipoComunicado = objTipoComunicado }; ddlComunicado.DataSource = DoComunicado.Listar(comunicado); ddlComunicado.DataTextField = "Titulo"; ddlComunicado.DataValueField = "Id"; ddlComunicado.DataBind(); } catch (Exception ex) { throw ex; } }
public static TipoNoticia Obter(TipoNoticia pTipoNoticiaId) { string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString; SqlConnection objConexao = new SqlConnection(strConectionString); SqlCommand objComando = new SqlCommand("SPE_L_TIPO_NOTICIA"); objComando.Connection = objConexao; objComando.CommandType = CommandType.StoredProcedure; objComando.Parameters.Add("@TipoNoticiaId", SqlDbType.Int).Value = pTipoNoticiaId.ID; try { objConexao.Open(); IDataReader idrReader = default(IDataReader); idrReader = objComando.ExecuteReader(); TipoNoticia obj = new TipoNoticia(); while ((idrReader.Read())) { obj.FromIDataReader(idrReader); } return(obj); } catch (Exception ex) { throw ex; } finally { if (objConexao.State != ConnectionState.Closed) { objConexao.Close(); } } }