Exemplo n.º 1
0
        public ActionResult EditUnit(BuildUnitSearchModel model)
        {
            JsonModel jm = new JsonModel();

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

                T_BuildUnit unitInfo = unitBll.GetEntity(m => m.Id == model.UnitId);
                if (unitInfo != null)
                {
                    unitInfo.UnitName = model.UnitName;
                    // 保存到数据库
                    unitBll.Update(unitInfo);

                    //日志记录
                    jm.Content = PropertyUtils.ModelToJsonString(model);
                }
                else
                {
                    jm.Msg = "该单元不存在";
                }
            }
            else
            {
                // 保存异常日志
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult AddUnit(BuildUnitSearchModel model)
        {
            JsonModel     jm      = new JsonModel();
            IBuildUnitBLL unitBll = BLLFactory <IBuildUnitBLL> .GetBLL("BuildUnitBLL");

            if (unitBll.Exist(m => m.UnitName == model.UnitName && m.Id != model.UnitId && m.BuildId == model.BuildId))
            {
                jm.Msg = "该单元名称已经存在";
            }
            //如果表单模型验证成功
            else if (ModelState.IsValid)
            {
                T_BuildUnit newUnit = new T_BuildUnit()
                {
                    UnitName = model.UnitName,
                    BuildId  = model.BuildId
                };
                // 保存到数据库
                unitBll.Save(newUnit);

                //日志记录
                jm.Content = PropertyUtils.ModelToJsonString(model);
            }
            else
            {
                // 保存异常日志
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public ActionResult BatchAddUnit(int buildId)
        {
            IBuildBLL buildBll = BLLFactory <IBuildBLL> .GetBLL("BuildBLL");

            var entity = buildBll.GetEntity(m => m.Id == buildId);
            BuildUnitSearchModel model = new BuildUnitSearchModel();

            model.BuildName = entity.BuildName;
            model.BuildId   = buildId;
            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult UnitList(BuildUnitSearchModel model)
        {
            IBuildUnitBLL unitBll = BLLFactory <IBuildUnitBLL> .GetBLL("BuildUnitBLL");

            int propertyPlaceId = GetSessionModel().PropertyPlaceId.Value;

            Expression <Func <T_BuildUnit, bool> > where = w => (string.IsNullOrEmpty(model.BuildName) ? true : w.Build.BuildName.Contains(model.BuildName)) && (model.BuildId == 0 ? true : w.BuildId == model.BuildId) && (string.IsNullOrEmpty(model.UnitName) ? true : w.UnitName.Contains(model.UnitName)) && w.Build.PropertyPlaceId == propertyPlaceId;

            // 排序模型
            var sortModel = this.SettingSorting("Id", false);

            model.List = unitBll.GetPageList(where, sortModel.SortName, sortModel.IsAsc, model.PageIndex) as PagedList <T_BuildUnit>;
            return(View(model));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 远程验证指定单元名称是否存在
        /// </summary>
        /// <param name="unitName">单元名称</param>
        /// <param name="id">单元id,新增时恒为0,修改单元名称时不为0</param>
        public ContentResult RemoteCheckExist(BuildUnitSearchModel model)
        {
            IBuildUnitBLL unitBll = BLLFactory <IBuildUnitBLL> .GetBLL("BuildUnitBLL");

            // 楼座名称已存在
            if (unitBll.Exist(m => m.UnitName == model.UnitName && m.Id != model.UnitId && m.BuildId == model.BuildId))
            {
                // 校验不通过
                return(Content("false"));
            }
            else
            {
                return(Content("true"));
            }
        }
Exemplo n.º 6
0
        public ActionResult EditUnit(int id)
        {
            IBuildUnitBLL unitBll = BLLFactory <IBuildUnitBLL> .GetBLL("BuildUnitBLL");

            var unitInfo = unitBll.GetEntity(index => index.Id == id);

            if (unitInfo != null)
            {
                BuildUnitSearchModel unitModel = new BuildUnitSearchModel();
                unitModel.BuildName = unitInfo.Build.BuildName;
                unitModel.UnitName  = unitInfo.UnitName;
                unitModel.UnitId    = id;
                unitModel.BuildId   = unitInfo.Build.Id;
                return(View(unitModel));
            }
            else
            {
                return(RedirectToAction("UnitList"));
            }
        }