Ejemplo n.º 1
0
    //#region Atualizar
    //public static int AtualizarJCP(JCP pobjJCP)
    //{
    //    string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString;
    //    SqlConnection objConexao = new SqlConnection(strConectionString);

    //    SqlCommand objComando = new SqlCommand("SPE_U_JCP");
    //    objComando.Connection = objConexao;
    //    objComando.CommandType = CommandType.StoredProcedure;

    //    //Define parametros da procedure
    //    objComando.Parameters.Add("@jcpId", SqlDbType.Int).Value = pobjJCP.IdJCP;
    //    objComando.Parameters.Add("@titulo", SqlDbType.VarChar, 200).Value = pobjJCP.Titulo;
    //    objComando.Parameters.Add("@descricao", SqlDbType.VarChar, 200).Value = pobjJCP.Descricao;
    //    objComando.Parameters.Add("@arquivo", SqlDbType.VarChar, 200).Value = pobjJCP.Arquivo;

    //    try
    //    {
    //        //Abre conexão com o banco de dados
    //        objConexao.Open();

    //        //Declara variavel de retorno
    //        int intRetorno = 0;

    //        //Executa comando no banco de dados
    //        intRetorno = objComando.ExecuteNonQuery();

    //        return intRetorno;

    //    }
    //    catch (Exception ex)
    //    {
    //        throw ex;

    //    }
    //    finally
    //    {
    //        //Fecha a conexao se aberta
    //        if (objConexao.State != ConnectionState.Closed)
    //        {
    //            objConexao.Close();
    //        }
    //    }
    //}
    //#endregion

    #region Listar
    public static List <JCP> Listar(int pintIdConteudo, int pintIdIdioma, int pintAno)
    {
        string        strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString;
        SqlConnection objConexao         = new SqlConnection(strConectionString);

        SqlCommand objComando = new SqlCommand("SPE_L_JCP");

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

        //Define parametros da procedure
        objComando.Parameters.Add("@conteudoId", SqlDbType.Int).Value = pintIdConteudo;
        objComando.Parameters.Add("@idiomaId", SqlDbType.Int).Value   = pintIdIdioma;
        objComando.Parameters.Add("@ano", SqlDbType.Int).Value        = pintAno;

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

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

            IDataReader idrReader = default(IDataReader);

            idrReader = objComando.ExecuteReader();

            while ((idrReader.Read()))
            {
                obj = new JCP();
                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();
            }
        }
    }
Ejemplo n.º 2
0
    public static JCP ObterJCP(int pintIdJCP)
    {
        string        strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString;
        SqlConnection objConexao         = new SqlConnection(strConectionString);

        SqlCommand objComando = new SqlCommand("SPE_L_JCP_ID");

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

        objComando.Parameters.Add("@jcpId", SqlDbType.Int).Value = pintIdJCP;

        try
        {
            objConexao.Open();

            JCP obj = new JCP();

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