Beispiel #1
0
    public static List <ModPerfilAdr> Listar(int pintIdiomaId)
    {
        string        strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString;
        SqlConnection objConexao         = new SqlConnection(strConectionString);

        SqlCommand objComando = new SqlCommand("SPE_L_MODULO_PERFIL_ADR");

        objComando.Connection  = objConexao;
        objComando.CommandType = CommandType.StoredProcedure;

        if (pintIdiomaId > 0)
        {
            objComando.Parameters.Add("@idiomaId", SqlDbType.Int).Value = pintIdiomaId;
        }

        try
        {
            //Abre Conexao
            objConexao.Open();

            //Declara variavel de retorno
            List <ModPerfilAdr> objList = new List <ModPerfilAdr>();
            ModPerfilAdr        obj     = default(ModPerfilAdr);

            IDataReader idrReader = default(IDataReader);

            idrReader = objComando.ExecuteReader();

            while ((idrReader.Read()))
            {
                obj = new ModPerfilAdr();
                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();
            }
        }
    }
Beispiel #2
0
    public static ModPerfilAdr Obter(int pintId)
    {
        string        strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString;
        SqlConnection objConexao         = new SqlConnection(strConectionString);

        SqlCommand objComando = new SqlCommand("SPE_L_MODULO_PERFIL_ADR_ID");

        objComando.Connection  = objConexao;
        objComando.CommandType = CommandType.StoredProcedure;

        objComando.Parameters.Add("@perfilAdrId", SqlDbType.Int).Value = pintId;

        try
        {
            objConexao.Open();

            ModPerfilAdr obj = new ModPerfilAdr();

            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();
            }
        }
    }