using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class frmPermisosUsuarios : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (VerificaUsuario(Int32.Parse(Session["UsuarioID"].ToString().Trim())) == 1)
        {
            MostrarControles();
        }
        else
        {
            MostrarMensajeNoAutorizado();
        }
    }

    public int VerificaUsuario(int UsuarioID)
    {
        Int32 Autorizado = 0;
        string connect = System.Configuration.ConfigurationManager.AppSettings["connectionstring"];
        SqlConnection scn = new SqlConnection(connect);
        string select = "SELECT AdministraUsuarios FROM Usuarios WHERE UsuarioID = " + UsuarioID.ToString() + "";
        SqlCommand spcmd = new SqlCommand(select, scn);
        spcmd.CommandType = CommandType.Text;
        SqlDataReader dr;
        scn.Open();
        dr = spcmd.ExecuteReader();
        if (dr.HasRows)
        {
            while (dr.Read())
            {
                Autorizado = Int32.Parse(dr["AdministraUsuarios"].ToString().Trim());
            }
        }
        return Autorizado;
    }

    protected void MostrarControles()
    {
    }

    protected void MostrarMensajeNoAutorizado()
    {
        Alerta.Attributes.Add("style", "display: block;");
    }

    private static string GetConnectionString()
    {
        return ConfigurationManager.ConnectionStrings["SHIOL_CONTA_BTHConnectionString"].ConnectionString;
    }
}