コード例 #1
0
ファイル: QuanTriHelper.cs プロジェクト: Nghinv00/ShopOnLine
 private static bool CheckAccess(HtmlHelper helper, SiteMapNode node, string appcode)
 {
     if (node.Roles.Count == 0)
     {
         return(true);
     }
     for (int i = 0; i < node.Roles.Count; i++)
     {
         if (node.Roles[i] != null)
         {
             string           role    = node.Roles[i].ToString();
             HttpSessionState session = HttpContext.Current.Session;
             if (session["_departmentid"] != null && session["_positionid"] != null && session["_unitid"] != null)
             {
                 qtRoleService _role = new qtRoleService();
                 if (_role.CheckUserInRole(TypeHelper.ToInt32(session["_unitid"].ToString())
                                           , TypeHelper.ToInt32(session["_departmentid"].ToString())
                                           , TypeHelper.ToInt32(session["_positionid"].ToString())
                                           , appcode
                                           , role))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
コード例 #2
0
ファイル: RoleController.cs プロジェクト: Nghinv00/ShopOnLine
        public void GetRole(int?depId, int?posId, int?unitId)
        {
            qtRoleService        _service = new qtRoleService();
            IEnumerable <qtRole> list     = _service.FindList().AsQueryable().Where(r => r.ParentId == 0 && r.Status == true && r.Application == "QTHT").OrderBy(m => m.SortOrder);
            string html = string.Empty;

            html += "<table class='grid' style='width: 100%;' id='table-role'>" +
                    "<thead>" +
                    "<tr>" +
                    "<th><input type='checkbox' name='checkall' id='checkall'></th>" +
                    "<th> Tên chức năng </th>" +
                    "<th> Mã chức năng </th>" +
                    "</thead>";
            foreach (qtRole role in list)
            {
                string check = checkRole(role.RoleId, depId, posId, unitId);
                html += "<tr>";
                if (role.Description != null && role.Description.ToString() != "")
                {
                    html += "<td style='text-align:center;'><input type='checkbox' value=" + role.RoleId + " name='cbx[]' class='cbx-parent' id='cbx__' " + check + " ></td><td colspan='2'><b>  " + role.RoleName + "</b></td>";
                }
                else
                {
                    html += "<td></td><td colspan='2'>" + role.Application + "-" + role.RoleName + "</td>";
                }
                html += "</tr>";
                html += RoleChild(role.RoleId, depId, posId, unitId);
            }
            html            += "</table>";
            ViewBag.RoleList = html;
        }
コード例 #3
0
ファイル: RoleController.cs プロジェクト: Nghinv00/ShopOnLine
        public JsonResult GetRoleParentId(int RoleId)
        {
            int?          data;
            qtRoleService _role = new qtRoleService();
            qtRole        role  = _role.FindByKey(RoleId);

            if (role != null && role.ParentId != null)
            {
                data = role.ParentId;
            }
            else
            {
                data = null;
            }
            return(Json(data, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
ファイル: RoleController.cs プロジェクト: Nghinv00/ShopOnLine
        public string RoleChild(int roleId, int?depId, int?posId, int?unitId)
        {
            qtRoleService        _service = new qtRoleService();
            IEnumerable <qtRole> list     = _service.FindList().AsQueryable().Where(r => r.ParentId == roleId && r.Status == true).OrderBy(m => m.SortOrder);
            string html = string.Empty;

            foreach (qtRole item in list)
            {
                string check = checkRole(item.RoleId, depId, posId, unitId);
                html += "<tr>" +
                        "<td style='text-align: center;'><input type='checkbox' value=" + item.RoleId + " parentId='" + item.ParentId + "' name='cbx[]' id='cbx__' " + check + " ></td>" +
                        "<td>&nbsp;&nbsp;&nbsp; + " + item.RoleName + "</td>" +
                        "<td>" + item.Description + "</td>" +
                        "</tr>";
            }
            return(html);
        }
コード例 #5
0
ファイル: QuanTriHelper.cs プロジェクト: Nghinv00/ShopOnLine
 public static bool CheckAccessByUser(SiteMapNode node, string appcode, qtUser user)
 {
     if (user != null)
     {
         if (node.Roles.Count == 0)
         {
             return(true);
         }
         for (int i = 0; i < node.Roles.Count; i++)
         {
             if (node.Roles[i] != null)
             {
                 string        role  = node.Roles[i].ToString();
                 qtRoleService _role = new qtRoleService();
                 return(_role.CheckUserInRole(user.UnitId.Value, user.DepartmentId.Value, user.PositionId.Value, appcode, role));
             }
         }
     }
     return(false);
 }