Пример #1
0
        /// <summary>
        /// 获取需要更新的用户角色
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult GetUserAndUserRole(int id)
        {
            TbSysUser user = suDao.GetByID(id);//获取当前用户

            //修正把密码发送到客户端的问题
            TbSysUser tempUser = new TbSysUser();  //新建一个对象
            ClassValueCopier.Copy(tempUser, user);
            tempUser.SPassword = "";  //把系统后台用户的密码置空

            UserAndUserRole item = new UserAndUserRole();
            if (!string.IsNullOrEmpty(item.IPart.ToString()))
            {
                int partId = (int)item.IPart;
                TbSysPart tempPart = syspartDAO.GetByID(partId);
                if (tempPart != null)
                {
                    item.SPartName = tempPart.SPartName;
                }

            }
            ClassValueCopier.Copy(item, tempUser);
            return Json(item, JsonRequestBehavior.AllowGet);
        }
Пример #2
0
        /// <summary>
        /// 从user和part中获取数据
        /// </summary>
        /// <param name="firstResult"></param>
        /// <param name="pagesize"></param>
        /// <param name="orderBy"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        public JsonResult GetByPageUserAndUserRole(int firstResult, int pagesize, string orderBy, string condition)
        {
            int count = 0;
            condition = HttpUtility.UrlDecode(condition);//对条件解码
            List<UserAndUserRole> Data = new List<UserAndUserRole>();//user加上部门名称的模型集合
            //获取当前页的user;
            IList<TbSysUser> userList = suDao.GetByPageDataBase(firstResult, pagesize, "ID", condition, out count).ToList();
            foreach (TbSysUser item in userList)
            {
                UserAndUserRole tmpChildren = new UserAndUserRole();
                string SPartName = "";
                //为每个user加上部门名称
                if (!string.IsNullOrEmpty(item.IPart.ToString()))
                {
                    int partId = (int)item.IPart;
                    if (partId != 0)
                    {
                        SPartName = syspartDAO.GetByID(partId).SPartName;
                        tmpChildren.SPartName = SPartName;
                    }
                    else
                        tmpChildren.SPartName = "";
                }
                ClassValueCopier.Copy(tmpChildren, item);

                Data.Add(tmpChildren);
            }

            return Json(new
            {
                DataCount = count,
                Data = Data,
            }, JsonRequestBehavior.AllowGet);
        }