Exemple #1
0
        /// <summary>
        /// Intial area drop down data
        /// </summary>
        protected void InitAreaDropDownData(bool filterByuser = false)
        {
            //删除单位的缓存信息
            //ResSettings.SettingsInSession.RemoveCache(typeof(List<ResCompany>));

            var user      = ResSettings.SettingsInSession.User;
            var provinces = ResSettings.SettingsInSession.AllProvince();
            var areas     = ResSettings.SettingsInSession.AllAreas();

            if (filterByuser)
            {
                if (user.ProvinceId > 0)
                {
                    provinces = provinces.Where(x => x.CompanyId == user.ProvinceId).ToList();
                }
                if (user.AreaId > 0)
                {
                    areas = areas.Where(x => x.CompanyId == user.AreaId).ToList();
                }
            }

            ViewBag.Provinces = provinces;
            ViewBag.Areas     = areas;
            ViewBag.Actives   = ResSettings.SettingsInSession.Actives;

            ViewBag.ProvincesDic = CrosourceController.GetStrengthDict(areas);
            ViewBag.AreasDic     = CrosourceController.GetStrengthDict(areas);
        }
Exemple #2
0
        //
        //	用户 - 编辑
        // GET:		/User/Edit
        // POST:		/User/Edit
        //

        public ActionResult Edit(long?id)
        {
            var user      = ResSettings.SettingsInSession.User;
            var provinces = ResSettings.SettingsInSession.AllProvince();
            var areas     = ResSettings.SettingsInSession.AllAreas();

            var allRoles = ResUserHelper.UserType.GetItems();
            var roles    = new List <ResPickListItem>();

            roles.AddRange(roles);

            if (user.ProvinceId > 0)
            {
                roles.Clear();
                if (user.ProvinceId == ResCompanyHelper.Shanghai)
                {
                    roles.Add(allRoles.Find(x => x.PickListItemId == ResUserHelper.CityAdmin));
                }

                roles.Add(allRoles.Find(x => x.PickListItemId == ResUserHelper.Export));
                provinces = provinces.Where(x => x.CompanyId == user.ProvinceId).ToList();
            }
            if (user.AreaId > 0)
            {
                roles.Clear();
                roles.Add(allRoles.Find(x => x.PickListItemId == ResUserHelper.Export));
                areas = areas.Where(x => x.CompanyId == user.AreaId).ToList();
            }

            if (user.UserTypePKID == ResUserHelper.Admin)
            {
                roles = allRoles;
            }


            ViewBag.Provinces    = provinces;
            ViewBag.Areas        = areas;
            ViewBag.Roles        = roles;
            ViewBag.ProvincesDic = CrosourceController.GetStrengthDict(ResSettings.SettingsInSession.AllProvince());
            ViewBag.AreasDic     = CrosourceController.GetStrengthDict(areas);

            if (id == null)
            {
                return(Request.IsAjaxRequest() ? (ActionResult)PartialView() : View());
            }
            else
            {
                var model = APBplDef.ResUserBpl.PrimaryGet(id.Value);
                return(Request.IsAjaxRequest() ? (ActionResult)PartialView(model) : View(model));
            }
        }