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)); }
/// <summary> /// 远程验证批量添加单元 /// </summary> /// <param name="model"></param> /// <param name="BuildId"></param> /// <returns></returns> public string RemoteCheck(BuildUnitBatchAddModel model) { IBuildUnitBLL unitBll = BLLFactory <IBuildUnitBLL> .GetBLL("BuildUnitBLL"); var lamdaList = new List <Expression <Func <T_BuildUnit, bool> > >(); foreach (var name in model.UnitName) { lamdaList.Add(r => r.UnitName == name); } Expression <Func <T_BuildUnit, bool> > lamda = p => false; Expression <Func <T_BuildUnit, bool> > lamda1 = r => (r.BuildId == model.BuildId); foreach (var expression in lamdaList) { lamda = PredicateBuilder.Or <T_BuildUnit>(lamda, expression); } lamda = PredicateBuilder.And(lamda, lamda1); var unitlist = unitBll.GetList(lamda);//查询 if (unitlist.Count() > 0) { // 校验不通过 return(string.Join(",", unitlist.ToList().Select(q => q.UnitName).Distinct().ToArray())); } else { // 校验通过 return(""); } }
public ActionResult DeleteUnit(int id) { JsonModel jm = new JsonModel(); IBuildUnitBLL unitBll = BLLFactory <IBuildUnitBLL> .GetBLL("BuildUnitBLL"); // 根据指定id值获取实体对象 var unit = unitBll.GetEntity(index => index.Id == id); if (unit == null) { jm.Msg = "该单元不存在"; } else { if (unitBll.Delete(unit)) { //操作日志 jm.Content = "删除单元 " + unit.UnitName; } else { jm.Msg = "删除失败"; } } return(Json(jm, JsonRequestBehavior.AllowGet)); }
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)); }
/// <summary> /// 获取单元Id, 如果没有将新建一个单元 /// </summary> /// <param name="unitName"></param> /// <param name="buildId"></param> /// <returns></returns> private static int GetBuildUnitId(string unitName, int buildId) { int unitId = 0; //楼座接口 IBuildUnitBLL unitBll = BLLFactory <IBuildUnitBLL> .GetBLL("BuildUnitBLL"); var unit = unitBll.GetEntity(b => b.UnitName == unitName && b.BuildId == buildId); if (unit != null) { unitId = unit.Id; } else { unit = new T_BuildUnit() { UnitName = unitName, BuildId = buildId }; try { unitBll.Save(unit); unitId = unit.Id; } catch { unitId = 0; } } return(unitId); }
public ActionResult BatchAddDoor(int unitId) { IBuildUnitBLL unitBll = BLLFactory <IBuildUnitBLL> .GetBLL("BuildUnitBLL"); var entity = unitBll.GetEntity(m => m.Id == unitId); BuildDoorSearchModel model = new BuildDoorSearchModel(); model.UnitId = unitId; model.UnitName = entity.UnitName; model.BuildName = entity.Build.BuildName; model.BuildId = entity.Build.Id; return(View(model)); }
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)); }
/// <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")); } }
public JsonResult GetUnitList(int buildId) { IBuildUnitBLL buildUnitBll = BLLFactory <IBuildUnitBLL> .GetBLL("BuildUnitBLL"); var list = buildUnitBll.GetList(u => u.BuildId == buildId); //转换为下拉列表 List <SelectListItem> buildUnitList = list.Select(c => new SelectListItem() { Text = c.UnitName, Value = c.Id.ToString(), Selected = false, }).ToList(); return(Json(buildUnitList, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 获取单元列表 /// </summary> /// <returns>单元列表</returns> private List <SelectListItem> GetUnitList(int buildId) { //获取单元列表 IBuildUnitBLL UnitBll = BLLFactory <IBuildUnitBLL> .GetBLL("BuildUnitBLL"); var sortModel = this.SettingSorting("Id", true); var list = UnitBll.GetList(u => u.BuildId == buildId, sortModel.SortName, sortModel.IsAsc); //转换为下拉列表并返回 return(list.Select(m => new SelectListItem() { Text = m.UnitName, Value = m.Id.ToString(), Selected = false }).ToList()); }
public JsonResult GetUnitList(int?buildId) { List <object> list = new List <object>(); if (buildId == null) { return(Json(list, JsonRequestBehavior.AllowGet)); } IBuildUnitBLL bll = BLLFactory <IBuildUnitBLL> .GetBLL("BuildUnitBLL"); foreach (var item in bll.GetList(m => m.BuildId == buildId.Value).ToList()) { list.Add(new { Value = item.Id.ToString(), Text = item.UnitName }); } return(Json(list, JsonRequestBehavior.AllowGet)); }
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")); } }
/// <summary> /// 根据楼座ID加载单元列表 /// </summary> /// <param name="buildId">楼座Id</param> /// <returns></returns> public JsonResult AjaxGetUnits(int?buildId) { List <SelectListItem> unitList = new List <SelectListItem>(); if (buildId.HasValue && buildId.Value > 0) { IBuildUnitBLL unitBll = FactoryBLL.BLLFactory <IBuildUnitBLL> .GetBLL("BuildUnitBLL"); unitList.Add(new SelectListItem() { Text = "选择单元", Value = string.Empty, Selected = true }); var units = unitBll.GetList(u => u.BuildId == buildId.Value).OrderBy(u => u.UnitName).Select(u => new SelectListItem() { Text = u.UnitName, Value = u.Id.ToString() }).ToList(); unitList.AddRange(units); } return(Json(unitList)); }
public ActionResult BatchAddUnit(BuildUnitBatchAddModel model) { JsonModel jm = new JsonModel(); var unitId = model.BuildId; var result = RemoteCheck(model); if (!string.IsNullOrEmpty(result)) { jm.Msg = result + "单元已存在"; return(Json(jm, JsonRequestBehavior.AllowGet)); } //如果表单模型验证成功 if (ModelState.IsValid) { IBuildUnitBLL unitBll = BLLFactory <IBuildUnitBLL> .GetBLL("BuildUnitBLL"); List <T_BuildUnit> list = new List <T_BuildUnit>(); for (int i = 0; i < model.UnitName.Length; i++) { T_BuildUnit newUnit = new T_BuildUnit() { UnitName = model.UnitName[i], BuildId = model.BuildId }; list.Add(newUnit); } // 批量保存 unitBll.BatchAddUnit(model.BuildId, list); //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { // 保存异常日志 jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ActionResult ExpenseSettings(ExpenseSettingsModel model) { var currentPropertyPlaceId = GetSessionModel().PropertyPlaceId.Value; if (model.NotificationDate == null) { model.NotificationDate = DateTime.Now.AddDays(1); } IBuildBLL buildBLL = BLLFactory <IBuildBLL> .GetBLL("BuildBLL"); //绑定楼座下拉列表 var buildList = buildBLL.GetList(b => b.PropertyPlaceId == currentPropertyPlaceId, "BuildName", true).ToList(); model.BuildList = buildList.Select(b => new SelectListItem() { Text = b.BuildName, Value = b.Id.ToString() }).ToList(); List <SelectListItem> unitList = new List <SelectListItem>(); unitList.Add(new SelectListItem() { Text = "选择单元", Value = string.Empty }); //绑定单元下拉列表 if (model.BuildId > 0) { IBuildUnitBLL unitBll = FactoryBLL.BLLFactory <IBuildUnitBLL> .GetBLL("BuildUnitBLL"); var units = unitBll.GetList(u => u.BuildId == model.BuildId).OrderBy(u => u.UnitName).Select(u => new SelectListItem() { Text = u.UnitName, Value = u.Id.ToString(), Selected = (u.Id == model.UnitId) }).ToList(); unitList.AddRange(units); } model.UnitList = unitList; //绑定缴费种类名称下拉列表 IPropertyExpenseTypeBLL typeBLL = BLLFactory <IPropertyExpenseTypeBLL> .GetBLL("PropertyExpenseTypeBLL"); model.ExpenseTypeList = typeBLL.GetList(t => t.IsFixed == model.ExpenseClassId && t.PropertyPlaceId == currentPropertyPlaceId).OrderBy(t => t.Name).Select(t => new SelectListItem() { Text = t.Name, Value = t.Id.ToString() }).ToList(); //绑定缴费明细 IBuildUnitBLL unitBLL = BLLFactory <IBuildUnitBLL> .GetBLL("BuildUnitBLL"); if (model.BuildId > 0) { var unit = unitBLL.GetEntity(u => u.BuildId == model.BuildId && u.Id == model.UnitId); if (unit != null) { var doorList = unit.BuildDoors.OrderBy(u => u.DoorName).ToList(); var doorIds = doorList.Select(d => d.Id); IHouseUserExpenseTemplateBLL expenseTemplateBLL = BLLFactory <IHouseUserExpenseTemplateBLL> .GetBLL("HouseUserExpenseTemplateBLL"); var allDoorExpenseByExpenseType = expenseTemplateBLL.GetList(e => e.ExpenseTypeId == model.ExpenseTypeId && e.BuildDoorId != null && doorIds.Contains(e.BuildDoorId.Value)); var houseUserExpenseTemplateList = new List <HouseUserExpenseTemplateModel>(); if (allDoorExpenseByExpenseType.Count() > 0) { var doorExpense = allDoorExpenseByExpenseType.FirstOrDefault(); model.ExpenseCircleId = doorExpense.ExpenseCycleId; model.NotificationDate = doorExpense.NotificationDate; } foreach (var door in doorList) { var houseUserExpenseTemplateModel = new HouseUserExpenseTemplateModel(); houseUserExpenseTemplateModel.DoorId = door.Id; houseUserExpenseTemplateModel.DoorName = door.DoorName; var doorExpense = allDoorExpenseByExpenseType.FirstOrDefault(e => e.BuildDoorId == door.Id); if (doorExpense != null) { houseUserExpenseTemplateModel.Expense = doorExpense.Expense.ToString(); } houseUserExpenseTemplateList.Add(houseUserExpenseTemplateModel); } model.HouseUserExpenseTemplateList = houseUserExpenseTemplateList; } } return(View(model)); }