Beispiel #1
0
    public static int InserirMenuCircular(MenuCircular pobjMenuCircular)
    {
        string        strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString;
        SqlConnection objConexao         = new SqlConnection(strConectionString);

        SqlCommand objComando = new SqlCommand("SPE_I_MENU_CIRCULAR");

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

        //Define parametros da procedure
        objComando.Parameters.Add("@grupoId", SqlDbType.Int).Value         = pobjMenuCircular.IdGrupo;
        objComando.Parameters.Add("@idiomaId", SqlDbType.Int).Value        = pobjMenuCircular.IdIdioma;
        objComando.Parameters.Add("@titulo", SqlDbType.VarChar, 200).Value = pobjMenuCircular.Titulo;

        if (!String.IsNullOrWhiteSpace(pobjMenuCircular.Target))
        {
            objComando.Parameters.Add("@target", SqlDbType.VarChar, 20).Value = pobjMenuCircular.Target;
        }
        if (!String.IsNullOrWhiteSpace(pobjMenuCircular.Tooltip))
        {
            objComando.Parameters.Add("@tooltip", SqlDbType.VarChar, 200).Value = pobjMenuCircular.Tooltip;
        }
        if (!String.IsNullOrWhiteSpace(pobjMenuCircular.Url))
        {
            objComando.Parameters.Add("@url", SqlDbType.VarChar, 1000).Value = pobjMenuCircular.Url;
        }


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

            IDataReader idrReader = objComando.ExecuteReader();

            if (idrReader.Read())
            {
                return(Convert.ToInt32(idrReader["Identity"]));
            }
            else
            {
                return(-1);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            //Fecha a conexao se aberta
            if (objConexao.State != ConnectionState.Closed)
            {
                objConexao.Close();
            }
        }
    }
Beispiel #2
0
    public static int AtualizarMenuCircular(MenuCircular pobjMenuCircular)
    {
        string        strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString;
        SqlConnection objConexao         = new SqlConnection(strConectionString);

        SqlCommand objComando = new SqlCommand("SPE_U_MENU_CIRCULAR");

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

        //Define parametros da procedure
        objComando.Parameters.Add("@menuCircularId", SqlDbType.Int).Value  = pobjMenuCircular.IdMenuCircular;
        objComando.Parameters.Add("@grupoId", SqlDbType.Int).Value         = pobjMenuCircular.IdGrupo;
        objComando.Parameters.Add("@idiomaId", SqlDbType.Int).Value        = pobjMenuCircular.IdIdioma;
        objComando.Parameters.Add("@titulo", SqlDbType.VarChar, 200).Value = pobjMenuCircular.Titulo;

        objComando.Parameters.Add("@arquivo", SqlDbType.VarChar, 200).Value = pobjMenuCircular.Arquivo;
        if (!String.IsNullOrWhiteSpace(pobjMenuCircular.Target))
        {
            objComando.Parameters.Add("@target", SqlDbType.VarChar, 20).Value = pobjMenuCircular.Target;
        }
        if (!String.IsNullOrWhiteSpace(pobjMenuCircular.Tooltip))
        {
            objComando.Parameters.Add("@tooltip", SqlDbType.VarChar, 200).Value = pobjMenuCircular.Tooltip;
        }
        if (!String.IsNullOrWhiteSpace(pobjMenuCircular.Url))
        {
            objComando.Parameters.Add("@url", SqlDbType.VarChar, 1000).Value = pobjMenuCircular.Url;
        }


        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 #3
0
    public static List <MenuCircular> ListarMenuCircular(int pintIdGrupo, int pintIdIdioma = 0)
    {
        string        strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString;
        SqlConnection objConexao         = new SqlConnection(strConectionString);

        SqlCommand objComando = new SqlCommand("SPE_L_MENU_CIRCULAR");

        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 <MenuCircular> objList = new List <MenuCircular>();
            MenuCircular        obj     = default(MenuCircular);

            IDataReader idrReader = default(IDataReader);

            idrReader = objComando.ExecuteReader();

            while ((idrReader.Read()))
            {
                obj = new MenuCircular();
                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();
            }
        }
    }
    protected void rptMenuCircular_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            MenuCircular item      = (MenuCircular)e.Item.DataItem;
            Image        imgImagem = (Image)e.Item.FindControl("imgImagem");

            imgImagem.ImageUrl = String.Format("{0}/{1}/{2}", ConfigurationManager.AppSettings["BradescoRI.Path.Imagens.ModMenuCircular"], item.IdMenuCircular, item.Arquivo);

            if (!string.IsNullOrWhiteSpace(item.Tooltip))
            {
                imgImagem.ToolTip = item.Tooltip;
            }
        }
    }
Beispiel #5
0
    public static MenuCircular ObterMenuCircular(int pintIdMenuCircular, int pintIdGrupo, int pintIdIdioma)
    {
        string        strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString;
        SqlConnection objConexao         = new SqlConnection(strConectionString);

        SqlCommand objComando = new SqlCommand("SPE_L_MENU_CIRCULAR_ID");

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

        objComando.Parameters.Add("@menuCircularId", SqlDbType.Int).Value = pintIdMenuCircular;
        objComando.Parameters.Add("@grupoId", SqlDbType.Int).Value        = pintIdGrupo;
        objComando.Parameters.Add("@idiomaId", SqlDbType.Int).Value       = pintIdIdioma;

        try
        {
            objConexao.Open();

            MenuCircular obj = new MenuCircular();

            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 #6
0
    public static int InserirArquivo(MenuCircular pobjMenuCircular)
    {
        string        strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString;
        SqlConnection objConexao         = new SqlConnection(strConectionString);

        SqlCommand objComando = new SqlCommand("SPE_I_MENU_CIRCULAR_ARQUIVO");

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

        //Define parametros da procedure
        objComando.Parameters.Add("@menuCircularId", SqlDbType.Int).Value   = pobjMenuCircular.IdMenuCircular;
        objComando.Parameters.Add("@grupoId", SqlDbType.Int).Value          = pobjMenuCircular.IdGrupo;
        objComando.Parameters.Add("@idiomaId", SqlDbType.Int).Value         = pobjMenuCircular.IdIdioma;
        objComando.Parameters.Add("@arquivo", SqlDbType.VarChar, 200).Value = pobjMenuCircular.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();
            }
        }
    }
    private void CarregarObjetos(Utilitarios.TipoTransacao objTipoTransacao)
    {
        switch (objTipoTransacao)
        {
        case Utilitarios.TipoTransacao.Limpar:

            ddlIdioma.SelectedIndex  = 0;
            ddlPaginas.SelectedIndex = 0;
            ddlTarget.SelectedIndex  = 0;
            txtTitulo.Text           = string.Empty;
            txtTooltip.Text          = string.Empty;
            txtUrl.Text = string.Empty;

            break;

        case Utilitarios.TipoTransacao.Salvar:

            if (gobjMenuCircular == null)
            {
                gobjMenuCircular = new MenuCircular();
            }

            gobjMenuCircular.IdMenuCircular = codigo;
            gobjMenuCircular.IdGrupo        = grupo;
            gobjMenuCircular.Titulo         = txtTitulo.Text;
            gobjMenuCircular.IdIdioma       = Convert.ToInt32(ddlIdioma.SelectedValue);

            if (ddlTarget.SelectedValue != "0")
            {
                gobjMenuCircular.Target = ddlTarget.SelectedValue;
            }

            gobjMenuCircular.Tooltip = txtTooltip.Text;
            gobjMenuCircular.Url     = txtUrl.Text;

            if (codigo > 0 && divUpload.Visible)
            {
                gobjMenuCircular.Arquivo = String.Format("{0}_{1}_{2}_{3}", codigo, grupo, ddlIdioma.SelectedValue, fupArquivo.PostedFile.FileName);
            }

            break;

        case Utilitarios.TipoTransacao.Carregar:

            ddlIdioma.SelectedValue = gobjMenuCircular.IdIdioma.ToString();
            ddlIdioma.Enabled       = false;

            if (!String.IsNullOrWhiteSpace(gobjMenuCircular.Target))
            {
                ddlTarget.SelectedValue = gobjMenuCircular.Target;
            }

            txtTitulo.Text  = gobjMenuCircular.Titulo;
            txtTooltip.Text = gobjMenuCircular.Tooltip;
            txtUrl.Text     = gobjMenuCircular.Url;

            if (String.IsNullOrWhiteSpace(gobjMenuCircular.Arquivo))
            {
                divUpload.Visible = true;
                divImagem.Visible = false;
            }
            else
            {
                imgImagem.ImageUrl = String.Format("{0}/{1}/{2}", ConfigurationManager.AppSettings["BradescoRI.Path.Imagens.ModMenuCircular"], gobjMenuCircular.IdMenuCircular, gobjMenuCircular.Arquivo);

                divUpload.Visible = false;
                divImagem.Visible = true;
            }

            break;
        }
    }