Пример #1
0
        private static void appylySecurity(Control control, secUser user)
        {
            foreach (Control c in control.Controls)
            {
                if (c.GetType() == typeof(DevExpress.XtraEditors.SimpleButton))
                {
                    var theControl = c as DevExpress.XtraEditors.SimpleButton;

                    if (theControl.Tag != null && theControl.Tag.ToString() != "")
                    {
                        var requiredPermission = Convert.ToInt32(c.Tag.ToString());
                        if (!doesUserHaveThisPermission(user, requiredPermission))
                        {
                            theControl.Enabled = false;
                        }
                    }
                }
                appylySecurity(c, user);
            }
        }
Пример #2
0
        private static bool doesUserHaveThisPermission(secUser user, int permission)
        {
            var userHaveThePermission = user.secPermissions.Where(p => p.Id == permission).FirstOrDefault();

            return(userHaveThePermission != null ? true : false);
        }