Esempio n. 1
0
        public void LoadTree(long RoleID)
        {
            UserAccessRightsCollec objCollec = new UserAccessRightsCollec();

            objCollec = objUserAccessRightsDL.Get(RoleID);

            foreach (UserAccessRights obj in objCollec)
            {
                if (treeView1.Nodes.Count > 0)
                {
                    for (int i = 0; i < treeView1.Nodes.Count; i++)
                    {
                        LoadNode(treeView1.Nodes[i], obj);
                    }
                }
            }
        }
Esempio n. 2
0
        private void LoadControls(Control.ControlCollection Items)
        {
            UserAccessRights_DL objUserAccessRightsDL = new UserAccessRights_DL(ConnectionStringClass.GetConnection());

            try
            {
                foreach (Control var in Items)
                {
                    if (var.GetType().Equals(typeof(Button)))
                    {
                        if ((!var.Name.Equals("btnExit")) && (!var.Name.Equals("btnClose")))
                        {
                            UserAccessRights obj = objUserAccessRightsDL.Get(var.Name, CurrentUser.UserRoleID);
                            if (obj != null)
                            {
                                if (obj.Permission == "Active")
                                {
                                    var.Visible = true;
                                }
                                else
                                {
                                    var.Visible = false;
                                }
                            }
                        }
                    }
                    if (var != null)
                    {
                        LoadControls(var.Controls);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }