예제 #1
0
파일: User.cs 프로젝트: openhbc/openhbc
 public User(string id,string username, string firstname, string surname, SecurityRole userRole)
 {
     _userID = id;
     _userName = username;
     _firstname = firstname;
     _surname = surname;
     _userRole = userRole;
 }
예제 #2
0
 public RoleSecurityDetailsUI(SecurityRole role, Login p)
 {
     parent = p;
     InitializeComponent();
     grpRights_Layout();
     populateFromRole(role);
     _role = role;
 }
예제 #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            List<string> rightsSelected = new List<string>();

            //check if a role name was assigned
            if(this.txtBxRoleName.Text == "")
            {
                MessageBox.Show(this, "You need to enter the role name?", "Role name WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            //check if any checkbox was ticked, if not warn pop up message so a rights are selected
            foreach(CheckBox checkBox in grpRights.Controls)
            {
                if(checkBox.Checked)
                {
                    //if there is something that is checked let me know
                    rightsSelected.Add(checkBox.Name);

                    //break;
                }
            }
            if (rightsSelected.Count<=0)
            {
                MessageBox.Show(this, "Please assign rights to this role?", "Right Assignment WARNING", MessageBoxButtons.OK,MessageBoxIcon.Warning);
                return;
            }

            string[] rightsListNames = rightsSelected.ToArray();
            if(_role != null)
            {

                Entity.EditRole(_role.RoleId,txtBxRoleName.Text,rightsListNames);
                _role = null;
            }
            else
            {
                Entity.AddNewSecurityRole(txtBxRoleName.Text, rightsListNames);
            }
            parent.SetUserControl(new SecurityMgmtUI(1,parent));
        }
예제 #4
0
        private void populateFromRole(SecurityRole role)
        {
            this.SuspendLayout();
            List<string> tmpnames = role.GetRightNames();

            txtBxRoleName.Text = role.RoleName;

            foreach(CheckBox chbx in grpRights.Controls)
            {
                if(tmpnames.Contains(chbx.Name))
                {
                    chbx.Checked = true;
                }

            }

            this.ResumeLayout();
        }
예제 #5
0
 public static bool DeleteRole(SecurityRole role)
 {
     return DeleteRole(Int32.Parse(role.RoleId));
 }
예제 #6
0
        public static SecurityRole[] roleList()
        {
            List<SecurityRole> roles = new List<SecurityRole>();
            SecurityRole role = new SecurityRole();
            List<int> rightLst = new List<int>();

            string getRolesSql = " select roleId, roleName from roles";
            string[][] _roles = db.multiColRowResult(getRolesSql);

            string getRoleRightLinkSql = "SELECT roleId, rightId FROM roleRightLink";
            string[][] roleRights = db.multiColRowResult(getRoleRightLinkSql);

            int roleID = -1;
            string roleName = "";

            foreach(string[] s in _roles)
            {
                roleID = Int32.Parse(s[0]);
                roleName = s[1].ToString();

                foreach(string[] str in roleRights)
                {
                    if(roleID == Int32.Parse(str[0].ToString()))
                    {
                        rightLst.Add(Int32.Parse(str[1].ToString()));
                    }
                }

                role = new SecurityRole(roleID.ToString(), roleName, rightLst.ToArray());
                roles.Add(role);
                rightLst.Clear();

            }

                return roles.ToArray();
        }
예제 #7
0
 public static void EditRole(SecurityRole role)
 {
     EditRole(role.RoleId, role.RoleName, Utility.ConvertIntArrayToString(role.RoleRights.ToArray()));
 }
예제 #8
0
파일: User.cs 프로젝트: openhbc/openhbc
 public User(string userName, string userid, SecurityRole userRole)
 {
     _userName = userName;
     _userID = userid;
     _userRole = userRole;
 }