コード例 #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 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));
        }
コード例 #3
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));
        }