예제 #1
0
        public JsonResult DeleteCompany(int id)
        {
            JsonModel jm = new JsonModel();
            //获取要删除的物业公司
            IPropertyCompanyBLL propertyCompanBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

            T_Company company = propertyCompanBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            //如果该物业公司存在
            if (company == null)
            {
                jm.Msg = "该物业公司不存在";
            }
            else if (company.PropertyPlaces.Count(p => p.DelFlag == ConstantParam.DEL_FLAG_DEFAULT) > 0)
            {
                jm.Msg = "该公司下有小区存在,不能删除";
            }
            else
            {
                //修改指定物业公司中的已删除标识
                company.DelFlag = ConstantParam.DEL_FLAG_DELETE;
                propertyCompanBll.Update(company);
                //操作日志
                jm.Content = "删除物业公司 " + company.Name;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult EditCompany()
        {
            int CompanyId = GetSessionModel().CompanyId.Value;
            IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

            //获取要编辑的物业公司
            T_Company company = propertyCompanyBll.GetEntity(m => m.Id == CompanyId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (company != null)
            {
                //初始化返回页面的模型
                PropertyCompanyModel model = new PropertyCompanyModel()
                {
                    Id      = company.Id,
                    Name    = company.Name,
                    Address = company.Address,
                    Content = company.Content,
                    Tel     = company.Tel
                };
                return(View(model));
            }
            else
            {
                return(RedirectToAction("CompanyDetail"));
            }
        }
예제 #3
0
        public ActionResult Detail()
        {
            //获取登录物业公司
            int CompanyId = GetSessionModel().CompanyId.Value;
            IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

            T_Company company = propertyCompanyBll.GetEntity(m => m.Id == CompanyId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (company != null)
            {
                //初始化返回页面的模型
                PropertyCompanyModel model = new PropertyCompanyModel()
                {
                    Name    = company.Name,
                    Address = company.Address,
                    Content = company.Content,
                    Img     = company.Img,
                    Tel     = company.Tel
                };
                return(View(model));
            }
            else
            {
                return(View());
            }
        }
예제 #4
0
        public ActionResult EditCompany(int id)
        {
            IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

            //获取要编辑的物业公司
            T_Company company = propertyCompanyBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (company != null)
            {
                //初始化返回页面的模型
                SetPropertyCompanyModel model = new SetPropertyCompanyModel()
                {
                    Id      = company.Id,
                    Name    = company.Name,
                    Address = company.Address,
                    Content = company.Content,
                    Tel     = company.Tel,
                    Img     = company.Img
                };
                return(View(model));
            }
            else
            {
                return(RedirectToAction("CompanyList"));
            }
        }
예제 #5
0
        /// <summary>
        /// 编辑小区信息
        /// </summary>
        public JsonModel EditPlace(PropertyPlaceModel model)
        {
            JsonModel jm = new JsonModel();

            //如果表单模型验证成功
            if (ModelState.IsValid)
            {
                IPropertyCompanyBLL companyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

                //如果对应的公司不存在(被删除)
                if (!companyBll.Exist(c => c.Id == model.CompanyId && c.DelFlag == ConstantParam.DEL_FLAG_DEFAULT))
                {
                    jm.Msg = "当前物业总公司不存在";
                }
                else
                {
                    //获取指定ID且未删除的小区
                    IPropertyPlaceBLL placeBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL");

                    T_PropertyPlace place = placeBll.GetEntity(m => m.Id == model.PlaceId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                    if (place != null)
                    {
                        //重新给数据实体赋值
                        place.Name       = model.PlaceName;
                        place.CompanyId  = model.CompanyId;
                        place.ProvinceId = model.ProvinceId;
                        place.CityId     = model.CityId;
                        place.CountyId   = model.CountyId;
                        place.Address    = model.Address;
                        place.Longitude  = model.Longitude;
                        place.Latitude   = model.Latitude;
                        place.Tel        = model.Tel;
                        place.Content    = model.Content;
                        place.PlaceType  = model.PlaceType;
                        place.IsValidate = model.IsValidate ? 0 : 1;
                        //编辑
                        if (placeBll.Update(place))
                        {
                            //日志记录
                            jm.Content = PropertyUtils.ModelToJsonString(model);
                        }
                        else
                        {
                            jm.Msg = "编辑失败";
                        }
                    }
                    else
                    {
                        jm.Msg = "该物业小区不存在";
                    }
                }
            }
            else
            {
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(jm);
        }
예제 #6
0
        public JsonResult SetCompanyInfo(SetPropertyCompanyModel model)
        {
            JsonModel jm = new JsonModel();

            if (ModelState.IsValid)
            {
                //存入文件的路径
                string directory = Server.MapPath(ConstantParam.PROPERTY_COMPANY_DIR);
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                HttpPostedFileBase file     = model.UploadImg;
                string             filename = Path.GetFileName(file.FileName); //获取上传文件名
                string             fileEx   = Path.GetExtension(filename);     //获取上传文件的扩展名

                //存入的文件名
                string FileName = DateTime.Now.ToFileTime().ToString() + fileEx;

                //保存数据文件
                string savrPath = Path.Combine(directory, FileName);
                file.SaveAs(savrPath);

                IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

                T_Company company = propertyCompanyBll.GetEntity(m => m.Id == model.Id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                if (company != null)
                {
                    string oldFile = company.Img;
                    company.Img = ConstantParam.PROPERTY_COMPANY_DIR + FileName;
                    propertyCompanyBll.Update(company);

                    //删除旧图标
                    if (!string.IsNullOrEmpty(oldFile))
                    {
                        oldFile = Server.MapPath(oldFile);
                        FileInfo f = new FileInfo(oldFile);
                        if (f.Exists)
                        {
                            f.Delete();
                        }
                    }
                }

                //日志记录
                //jm.Content = PropertyUtils.ModelToJsonString(company);
            }
            else
            {
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #7
0
        public ContentResult RemoteCheck(PropertyCompanyModel model)
        {
            IPropertyCompanyBLL propertyCompanybll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

            if (propertyCompanybll.Exist(m => m.Name == model.Name && m.Id != model.Id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT))
            {
                return(Content("false"));
            }
            else
            {
                return(Content("true"));
            }
        }
예제 #8
0
        public ActionResult CompanyList(PropertyCompanySearchModel model)
        {
            IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

            //查询条件
            Expression <Func <T_Company, bool> > where = u => (string.IsNullOrEmpty(model.Name) ? true : u.Name.Contains(model.Name)) && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT;

            //排序
            var sortModel = this.SettingSorting("Id", false);
            var list      = propertyCompanyBll.GetPageList(where, sortModel.SortName, sortModel.IsAsc, model.PageIndex);

            return(View(list));
        }
예제 #9
0
        public ActionResult CompanyDetail(int id)
        {
            IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

            //获取要查看的物业公司介绍
            T_Company company = propertyCompanyBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (company != null)
            {
                return(View(company));
            }
            else
            {
                return(RedirectToAction("CompanyList"));
            }
        }
예제 #10
0
        /// <summary>
        /// 获取物业公司列表
        /// </summary>
        /// <returns>物业公司下拉列表</returns>
        public List <SelectListItem> GetCompanyList()
        {
            //获取所有的物业公司列表
            IPropertyCompanyBLL companyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

            var list = companyBll.GetList(u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            //转换为下拉列表
            List <SelectListItem> companyList = list.Select(c => new SelectListItem()
            {
                Text     = c.Name,
                Value    = c.Id.ToString(),
                Selected = false,
            }).ToList();

            return(companyList);
        }
예제 #11
0
        /// <summary>
        /// 获取当前登录的总公司用户所属公司
        /// </summary>
        /// <param name="html">HTML对象</param>
        /// <returns></returns>
        public static string GetPropertyCompanyName(this HtmlHelper html)
        {
            var model = GetSessionModel(html);

            if (model != null)
            {
                int companyId = model.CompanyId.Value;
                IPropertyCompanyBLL companyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

                var company = companyBll.GetEntity(p => p.Id == companyId && p.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                if (company != null)
                {
                    return(company.Name);
                }
            }
            return(null);
        }
예제 #12
0
        /// <summary>
        /// 添加小区
        /// </summary>
        public JsonModel AddPlace(PropertyPlaceModel model)
        {
            JsonModel jm = new JsonModel();

            //如果表单模型验证成功
            if (ModelState.IsValid)
            {
                IPropertyCompanyBLL companyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

                //如果对应的公司不存在(被删除)
                if (!companyBll.Exist(c => c.Id == model.CompanyId && c.DelFlag == ConstantParam.DEL_FLAG_DEFAULT))
                {
                    jm.Msg = "物业总公司不存在";
                }
                else
                {
                    IPropertyPlaceBLL placeBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL");

                    T_PropertyPlace place = new T_PropertyPlace()
                    {
                        Name       = model.PlaceName,
                        CompanyId  = model.CompanyId,
                        ProvinceId = model.ProvinceId,
                        CityId     = model.CityId,
                        CountyId   = model.CountyId,
                        Address    = model.Address,
                        Longitude  = model.Longitude,
                        Latitude   = model.Latitude,
                        Tel        = model.Tel,
                        Content    = model.Content,
                        PlaceType  = model.PlaceType,
                        IsValidate = model.IsValidate ? 0 : 1
                    };
                    //添加小区并指定系统角色
                    placeBll.AddPlace(place);
                    //日志记录
                    jm.Content = PropertyUtils.ModelToJsonString(model);
                }
            }
            else
            {
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(jm);
        }
예제 #13
0
        public ActionResult SetPlatCompanyInfo(int id)
        {
            IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

            T_Company company = propertyCompanyBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (company != null)
            {
                SetPropertyCompanyModel model = new SetPropertyCompanyModel()
                {
                    Id  = id,
                    Img = company.Img
                };
                return(View(model));
            }
            else
            {
                return(RedirectToAction("CompanyList"));
            }
        }
예제 #14
0
        public ActionResult EditCompanyUser(int?id)
        {
            // 参数校验
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ICompanyUserBLL companyUserBll = BLLFactory <ICompanyUserBLL> .GetBLL("CompanyUserBLL");

            var companyUserInfo = companyUserBll.GetEntity(index => index.Id == id && index.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (companyUserInfo != null)
            {
                CompanyUserModel companyUserModel = new CompanyUserModel();

                companyUserModel.CompanyUserId = companyUserInfo.Id;
                companyUserModel.UserName      = companyUserInfo.UserName;
                companyUserModel.TrueName      = companyUserInfo.TrueName;
                companyUserModel.Memo          = companyUserInfo.Memo;
                companyUserModel.Tel           = companyUserInfo.Tel;
                companyUserModel.Phone         = companyUserInfo.Phone;
                companyUserModel.Email         = companyUserInfo.Email;
                companyUserModel.HeadPath      = companyUserInfo.HeadPath;
                companyUserModel.CompanyId     = GetSessionModel().CompanyId.Value;
                // 获取指定小区的名称
                IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

                var propertyCompany = propertyCompanyBll.GetEntity(m => m.Id == companyUserModel.CompanyId);
                if (propertyCompany != null)
                {
                    companyUserModel.CompanyName = propertyCompany.Name;
                }

                return(View(companyUserModel));
            }
            else
            {
                return(RedirectToAction("UserList"));
            }
        }
예제 #15
0
        public ActionResult AddCompanyUser()
        {
            // 获取物业总公司管理员所属的物业总公司
            int companyId = GetSessionModel().CompanyId.Value;
            // 获取指定物业总公司的名称
            IPropertyCompanyBLL propertyCompanyBLL = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

            var company = propertyCompanyBLL.GetEntity(m => m.Id == companyId);

            if (company != null)
            {
                CompanyUserModel model = new CompanyUserModel()
                {
                    CompanyName = company.Name
                };

                return(View(model));
            }

            return(View());
        }
예제 #16
0
        public ActionResult SetCompanyAdministrator(int id)
        {
            //获取要设置的物业总公司
            IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

            T_Company company = propertyCompanyBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (company != null)
            {
                //返回初始化模型页面
                CompanyUserModel model = new CompanyUserModel();
                model.CompanyId   = company.Id;
                model.CompanyName = company.Name;
                ViewBag.Admins    = company.CompanyUsers.Where(u => u.IsMgr == ConstantParam.USER_ROLE_MGR).Select(u => u.UserName).ToList();
                return(View(model));
            }
            else
            {
                return(RedirectToAction("CompanyList"));
            }
        }
예제 #17
0
        public JsonResult EditCompany(PropertyCompanyModel model)
        {
            JsonModel jm = new JsonModel();

            //如果表单模型验证成功
            if (ModelState.IsValid)
            {
                IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

                T_Company company = propertyCompanyBll.GetEntity(m => m.Id == model.Id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                if (company != null)
                {
                    company.Name    = model.Name;
                    company.Address = model.Address;
                    company.Content = model.Content;
                    company.Tel     = model.Tel;
                    //保存到数据库
                    if (propertyCompanyBll.Update(company))
                    {
                        //日志记录
                        jm.Content = PropertyUtils.ModelToJsonString(model);
                    }
                    else
                    {
                        jm.Msg = "编辑失败";
                    }
                }
                else
                {
                    jm.Msg = "该物业公司不存在";
                }
            }
            else
            {
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #18
0
        public ActionResult Index(int id = 1)
        {
            PlatformIndexModel model = new PlatformIndexModel();

            #region 用户、公司、小区、业主个数统计

            //获取平台用户个数并赋值
            IPlatformUserBLL platformUserBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL");

            model.PlatformUserCount = platformUserBll.Count(u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            //获取物业公司个数并赋值
            IPropertyCompanyBLL companyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

            model.CompanyCount = companyBll.Count(u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            //获取物业小区个数并赋值
            IPropertyPlaceBLL placeBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL");

            model.PlaceCount = placeBll.Count(u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            //获取业主个数并赋值
            IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

            model.OwnerCount = ownerBll.Count(u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            //获取一周内登录个数
            DateTime beforeWeek = DateTime.Now.AddDays(-7);
            model.OwnerWeekLoginCount = ownerBll.Count(u => u.LatelyLoginTime >= beforeWeek);

            //获取一个月内登录个数
            DateTime beforeMonth = DateTime.Now.AddMonths(-1);
            model.OwnerMonthLoginCount = ownerBll.Count(u => u.LatelyLoginTime >= beforeMonth);

            #endregion

            #region 公司小区个数及业主个数统计(柱状图)

            //公司小区、业主个数模型集合
            var barDatas = new List <BarDataModel>();

            //获取物业公司名称及下辖小区个数及业主个数 数据并转换为Json字符串
            var companyList = companyBll.GetList(u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT).ToList();
            foreach (var c in companyList)
            {
                BarDataModel data = new BarDataModel();
                //物业公司名称
                data.CompanyName = c.Name;
                var placeList = c.PropertyPlaces.Where(u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //该物业公司的小区个数
                data.PlaceCount = placeList.Count();

                var userPlaces = new List <R_UserPlace>();
                //遍历物业小区
                foreach (var p in placeList)
                {
                    //遍历物业小区业主关联
                    foreach (var u in p.UserPlaces.ToList())
                    {
                        //如果不包含,则添加
                        if (!userPlaces.Contains(u))
                        {
                            userPlaces.Add(u);
                        }
                    }
                }
                //赋值 业主个数
                data.OwnerCount = userPlaces.Count;
                barDatas.Add(data);
            }
            model.BarJsonData = PropertyUtils.ModelToJsonString(barDatas);
            #endregion

            #region 小区业主列表数据
            //获取所有小区业主数据
            var list = placeBll.GetList(u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT).ToList().Select(p => new OwnerDataModel()
            {
                PlaceName   = p.Name,
                CompanyName = p.Company.Name,
                OwnerCount  = p.UserPlaces.Count
            });
            //降序排序分页并赋值
            model.OwnerDatas = list.OrderByDescending(m => m.OwnerCount).ToPagedList(id, ConstantParam.PAGE_SIZE);
            #endregion

            return(View(model));
        }
예제 #19
0
        public JsonResult AddCompany(PropertyCompanyModel model)
        {
            JsonModel jm = new JsonModel();

            //如果表单模型验证成功
            if (ModelState.IsValid)
            {
                IPropertyCompanyBLL propertyCompanyBll = BLLFactory <IPropertyCompanyBLL> .GetBLL("PropertyCompanyBLL");

                //如果图片不为空
                if (model.UploadImg != null)
                {
                    //存入文件的路径
                    string directory = Server.MapPath(ConstantParam.PROPERTY_COMPANY_DIR);
                    if (!Directory.Exists(directory))
                    {
                        Directory.CreateDirectory(directory);
                    }

                    HttpPostedFileBase file     = model.UploadImg;
                    string             filename = Path.GetFileName(file.FileName);       //获取上传文件名
                    string             fileEx   = System.IO.Path.GetExtension(filename); //获取上传文件扩展名

                    //存入的文件名
                    string FileName = DateTime.Now.ToFileTime().ToString() + fileEx;

                    //保存的数据文件
                    string savrPath = Path.Combine(directory, FileName);
                    file.SaveAs(savrPath);

                    //初始化平台物业公司数据实体
                    T_Company company = new T_Company()
                    {
                        Name    = model.Name,
                        Address = model.Address,
                        Content = model.Content,
                        Tel     = model.Tel,
                        Img     = ConstantParam.PROPERTY_COMPANY_DIR + FileName
                    };

                    //保存
                    propertyCompanyBll.AddCompany(company);

                    //日志记录
                    jm.Content = PropertyUtils.ModelToJsonString(company);
                }

                else
                {
                    //初始化平台物业公司数据实体
                    T_Company Company = new T_Company()
                    {
                        Name    = model.Name,
                        Address = model.Address,
                        Content = model.Content,
                        Tel     = model.Tel
                    };

                    //保存
                    propertyCompanyBll.AddCompany(Company);

                    //日志记录
                    jm.Content = PropertyUtils.ModelToJsonString(Company);
                }
            }
            else
            {
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }