public ActionResult DeletePaymentType(int id)
        {
            JsonModel jm = new JsonModel();
            IPropertyExpenseTypeBLL propertyExpenseTypeBll = BLLFactory <IPropertyExpenseTypeBLL> .GetBLL("PropertyExpenseTypeBLL");

            //获取要删除的类别
            T_PropertyExpenseType propertyExpense = propertyExpenseTypeBll.GetEntity(m => m.Id == id);

            if (propertyExpense == null)
            {
                jm.Msg = "该类别不存在";
            }
            else if (propertyExpense.PropertyExpenseNos.Count > 0 || propertyExpense.HouseUserExpenseTemplates.Count > 0 ||
                     propertyExpense.HouseUserExpenseDetails.Count > 0)
            {
                jm.Msg = "已有该类别的缴费相关记录,无法删除";
            }
            else
            {
                if (propertyExpenseTypeBll.Delete(propertyExpense))
                {
                    //操作日志
                    jm.Content = "删除缴费类别 " + propertyExpense.Name;
                }
                else
                {
                    jm.Msg = "删除失败";
                }
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
        public ActionResult EditPaymentType(int id)
        {
            IPropertyExpenseTypeBLL propertyExpenseTypeBll = BLLFactory <IPropertyExpenseTypeBLL> .GetBLL("PropertyExpenseTypeBLL");

            //获取要编辑的类别
            T_PropertyExpenseType propertyExpenseType = propertyExpenseTypeBll.GetEntity(m => m.Id == id);

            if (propertyExpenseType != null)
            {
                //初始化返回页面的模型
                PropertyExpenseTypeModel model = new PropertyExpenseTypeModel()
                {
                    ExpenseTypeId = propertyExpenseType.Id,
                    IsFixed       = propertyExpenseType.IsFixed,
                    Name          = propertyExpenseType.Name,
                    Memo          = propertyExpenseType.Memo,
                    TypeList      = getTypeList(propertyExpenseType.IsFixed)
                };
                return(View(model));
            }
            else
            {
                return(RedirectToAction("PaymentTypeList"));
            }
        }
        public JsonResult EditPaymentType(PropertyExpenseTypeModel model)
        {
            JsonModel jm = new JsonModel();

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

                T_PropertyExpenseType propertyExpenseType = propertyExpenseTypeBll.GetEntity(m => m.Id == model.ExpenseTypeId);
                if (propertyExpenseType != null)
                {
                    propertyExpenseType.IsFixed = model.IsFixed.Value;
                    propertyExpenseType.Name    = model.Name;
                    propertyExpenseType.Memo    = model.Memo;
                    //编辑
                    if (propertyExpenseTypeBll.Update(propertyExpenseType))
                    {
                        //日志记录
                        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));
        }