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)); }
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)); }
/// <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 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")); } }
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)); }