Beispiel #1
0
        private void CheckPermission()
        {
            //UserPermissionBO userPermission = new UserPermissionBO();
            //userPermission.UserID = UserID;
            //userPermission.Permission = "USERLIST";
            UserPermissionBO result = listPermission.Find(item => item.Permission == "USERLIST");

            if (result != null)
            {
                userListToolStripMenuItem.Enabled = true;
            }
            else
            {
                userListToolStripMenuItem.Enabled = false;
            }

            result = listPermission.Find(item => item.Permission == "USERPERMISSION");
            if (result != null)
            {
                permissionListToolStripMenuItem.Enabled = true;
            }
            else
            {
                permissionListToolStripMenuItem.Enabled = false;
            }
        }
Beispiel #2
0
        public List <UserPermissionBO> GetPermission(int piUserID, string psModule)
        {
            List <UserPermissionBO> list = new List <UserPermissionBO>();
            UserPermissionBO        user;

            try
            {
                /* Because We will put all out values from our (UserRegistration.aspx)
                 *              To in Bussiness object and then Pass it to Bussiness logic and then to
                 *              DataAcess
                 *              this way the flow carry on*/
                SqlCommand cmd = new SqlCommand("usp_USER_GetUserPermision", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@piUserID", piUserID);
                cmd.Parameters.AddWithValue("@psModule", psModule);
                con.Open();
                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    user            = new UserPermissionBO();
                    user.UserID     = int.Parse(reader["UserID"].ToString());
                    user.Permission = reader["PermissionCode"].ToString();
                    list.Add(user);
                }
                reader.Close();
                cmd.Dispose();
            }
            catch (Exception ex)
            {
                list = null;
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
            return(list);
        }