public static List <Banners> ListarBanners(int pintIdGrupo, int pintIdIdioma = 0) { string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString; SqlConnection objConexao = new SqlConnection(strConectionString); SqlCommand objComando = new SqlCommand("SPE_L_BANNERS"); objComando.Connection = objConexao; objComando.CommandType = CommandType.StoredProcedure; //Define parametros da procedure objComando.Parameters.Add("@grupoId", SqlDbType.Int).Value = pintIdGrupo; if (pintIdIdioma > 0) { objComando.Parameters.Add("@idiomaId", SqlDbType.Int).Value = pintIdIdioma; } try { //Abre Conexao objConexao.Open(); //Declara variavel de retorno List <Banners> objList = new List <Banners>(); Banners obj = default(Banners); IDataReader idrReader = default(IDataReader); idrReader = objComando.ExecuteReader(); while ((idrReader.Read())) { obj = new Banners(); 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(); } } }
public static Banners ObterBanner(int pintIdBanner, int pintIdGrupo, int pintIdIdioma) { string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString; SqlConnection objConexao = new SqlConnection(strConectionString); SqlCommand objComando = new SqlCommand("SPE_L_BANNERS_ID"); objComando.Connection = objConexao; objComando.CommandType = CommandType.StoredProcedure; objComando.Parameters.Add("@bannerId", SqlDbType.Int).Value = pintIdBanner; objComando.Parameters.Add("@grupoId", SqlDbType.Int).Value = pintIdGrupo; objComando.Parameters.Add("@idiomaId", SqlDbType.Int).Value = pintIdIdioma; try { objConexao.Open(); Banners obj = new Banners(); IDataReader idrReader = default(IDataReader); idrReader = objComando.ExecuteReader(); while ((idrReader.Read())) { obj.FromIDataReader(idrReader); } return(obj); } catch (Exception ex) { throw ex; } finally { //Fecha a conexao se aberta if (objConexao.State != ConnectionState.Closed) { objConexao.Close(); } } }