Exemplo n.º 1
0
    private void ShowUsers()
    {
        ClassUser oUsr = new ClassUser(Convert.ToInt32(ViewState["UserId"].ToString()));
        DataSet oDs;
        Boolean bManager = false;

        if (((oUsr.Permissions & (Int32)Enum.Permissions.ManagerOnly) != 0) || (ViewState["UserId"].ToString() == "0"))
        {
            //	Access to management reports allowed.

            bManager = true;
        }

        if (bManager == false)
        {
            //	This user is restricted to seeing only their own data.

            oDs = oUsr.ShowUsers2(oUsr.UserId);
        }
        else
        {
            //	This user is allowed to access data for multiple users.

            oDs = oUsr.ShowUsers1();
        }

        this.DdlUsers.DataSource = oDs;
        this.DdlUsers.DataTextField = "UserName";
        this.DdlUsers.DataValueField = "UserId";
        this.DdlUsers.DataBind();

        if (bManager == true)
        {
            //	Access to multiple users allows this user to select all users.

            this.DdlUsers.Items.Insert(0, new ListItem("All users", "0"));
        }
    }
    private void ShowUsers()
    {
        ClassUser oUsr = new ClassUser(Convert.ToInt32(ViewState["UserId"].ToString()));
        DataSet oDs;

        if ((oUsr.Permissions & (Int32)Enum.Permissions.ManagerOnly) == 0)
        {
            //	This user is restricted to seeing only their own data.

            if (ViewState["UserId"].ToString() != "0")
            {
                oDs = oUsr.ShowUsers2(oUsr.UserId);
            }
            else
            {
                //	Except this is the superuser, who can see everything.

                oDs = oUsr.ShowUsers1();
            }
        }
        else
        {
            //	This user is allowed to access data for multiple users.

            oDs = oUsr.ShowUsers1();
        }

        this.DdlUsers.DataSource = oDs;
        this.DdlUsers.DataTextField = "UserName";
        this.DdlUsers.DataValueField = "UserId";
        this.DdlUsers.DataBind();
    }