Beispiel #1
0
    bool ReadModLinksFromFile(string path, out ModLinks modlinks)
    {
        modlinks = null;

        if (!File.Exists(path))
        {
            System.Windows.Forms.MessageBox.Show("No modlinks file found at " + path);
            return(false);
        }

        bool returnResult = true;

        XmlSerializer serializer = new XmlSerializer(typeof(ModLinks));
        FileStream    fstream    = null;

        try
        {
            fstream  = new FileStream(path, FileMode.Open);
            modlinks = serializer.Deserialize(fstream) as ModLinks;
        }
        catch (System.Exception e)
        {
            System.Windows.Forms.MessageBox.Show("Error loading modlinks file " + e.Message);
            returnResult = false;
        }
        finally
        {
            fstream.Close();
        }

        return(returnResult);
    }
Beispiel #2
0
    public static ModLinks Obter(int pintId)
    {
        string        strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString;
        SqlConnection objConexao         = new SqlConnection(strConectionString);

        SqlCommand objComando = new SqlCommand("SPE_L_MODULO_LINKS_ID");

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

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

        try
        {
            objConexao.Open();

            ModLinks obj = new ModLinks();

            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();
            }
        }
    }
Beispiel #3
0
    public static int Inserir(ModLinks pobjModLinks)
    {
        string        strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString;
        SqlConnection objConexao         = new SqlConnection(strConectionString);

        SqlCommand objComando = new SqlCommand("SPE_I_MODULO_LINKS");

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

        //Define parametros da procedure
        objComando.Parameters.Add("@conteudoId", SqlDbType.Int).Value = pobjModLinks.ID;
        objComando.Parameters.Add("@grupoId", SqlDbType.Int).Value    = pobjModLinks.IdGrupo;

        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();
            }
        }
    }
Beispiel #4
0
    private void CarregarObjetos(Utilitarios.TipoTransacao objTipoTransacao)
    {
        switch (objTipoTransacao)
        {
        //Carregar Dados do Usuario
        case Utilitarios.TipoTransacao.Salvar:

            if (gobjModLinks == null)
            {
                gobjModLinks = new ModLinks();
            }

            gobjModLinks.ID      = IdConteudo;
            gobjModLinks.IdGrupo = Convert.ToInt32(ddlGrupoLink.SelectedValue);

            break;

        //Descarregar Dados do Usuario
        case Utilitarios.TipoTransacao.Carregar:
            ddlGrupoLink.SelectedValue = gobjModLinks.IdGrupo.ToString();

            break;
        }
    }