/// <summary> /// 添加和编辑的显示页面 /// </summary> /// <returns></returns> public ActionResult Edit(string id) { Bus_TakeError md = new Bus_TakeError(); if (!string.IsNullOrEmpty(id) && id.Length == 36) { //show 编辑 ViewBag.ShowModel = md = service.GetModel(id); } else { ViewBag.ShowModel = new Bus_TakeError(); } return(View()); }
public int UpdateEntityModel(Bus_TakeError model) { if (model == null || string.IsNullOrEmpty(model.ID)) { return(-1); } var searchModel = DbSession.Bus_TakeErrorRepository.LoadEntities(s => s.ID == model.ID).FirstOrDefault(); if (searchModel == null) { return(-1); } searchModel.IsPass = model.IsPass; searchModel.OkTime = DateTime.Now; int reTes = DbSession.SaveChange(); return(reTes); }
public ActionResult Review(string id) { var model = new Bus_TakeError() { ID = id, IsPass = TakeErrorStatusEnum.Pass.GetHashCode() }; var res = service.UpdateEntityModel(model); if (res > 0) { result.statusCode = "200"; result.message = GlobalLngResource.GetRes("operSuccess"); } else { result.statusCode = "300"; result.message = GlobalLngResource.GetRes("operFailure"); } return(Json(result)); }
public ActionResult Edit(Bus_TakeError model) { if (model == null) { result.statusCode = "300"; result.message = GlobalLngResource.GetRes("noRecords"); return(Json(result)); } if (!ModelState.IsValid) { result.statusCode = "300"; result.message = GlobalLngResource.GetRes("UIInputModelDataError"); return(Json(result)); } if (CurrentUserInfo == null) { return(RedirectToAction("Login", "Login")); } try { model.UserId = CurrentUserInfo.Id; var res = service.OperateModel(model); if (res > 0) { result.statusCode = "200"; result.message = GlobalLngResource.GetRes("operSuccess"); } else { result.statusCode = "300"; result.message = GlobalLngResource.GetRes("operFailure"); } } catch { result.statusCode = "300"; result.message = GlobalLngResource.GetRes("sysException"); } return(Json(result)); }
public ActionResult Index(Bus_TakeError model) { int count = 0; try { if (CurrentUserInfo == null) { return(RedirectToAction("Login", "Login")); } #region 判断当前角色是否存在 普通人 var isPerRole = false; var roleDesc = EnumDescription <HRL.Model.Enums.Role> .GetVisaTypeEnumDescription((int)HRL.Model.Enums.Role.r_ordPer); if (CurrentUserInfo.RoleList.Select(r => r.RoleName).Contains(roleDesc)) { ViewBag.CurRole = "1"; isPerRole = true; } #endregion if (isPerRole) { model.UserId = CurrentUserInfo.Id; } var temp = service.GetPaging(model, out count); ViewBag.ShowList = temp; ViewBag.total = count; ViewBag.Model = model; return(View()); } catch (Exception ex) { result.statusCode = "300"; result.message = GlobalLngResource.GetRes("sysException"); return(Json(result)); } }
/// <summary> /// 修改或者添加一条数据 /// </summary> /// <param name="model">实体参数</param> /// <returns>大于0,操作成功,反之失败</returns> public int OperateModel(Bus_TakeError model) { if (!string.IsNullOrEmpty(model.ID) && model.ID.Length == 36) { //编辑 var existModel = this.LoadEntities(t => t.ID == model.ID).FirstOrDefault(); existModel.FromSource = model.FromSource; existModel.ActionId = model.ActionId; existModel.TypeVal = model.TypeVal; existModel.ResCompany = model.ResCompany; existModel.ResCompanyId = model.ResCompanyId; existModel.ResPerson = model.ResPerson; //existModel.AttributeID = model.AttributeID; existModel.DelFlag = 0; existModel.AccessCompany = model.AccessCompany; existModel.AccessCompanyId = model.AccessCompanyId; existModel.IsOverTime = model.IsOverTime; existModel.IsSearch = model.IsSearch; existModel.OverQuality = model.OverQuality; existModel.Remark = model.Remark; existModel.LevelRecords = model.LevelRecords; #region 性质 var existAttributes = DbSession.Bus_TakeErrorAttributeRepository.LoadEntities(ur => ur.AttributeID == existModel.ID); //删除现有数据 foreach (var item in existAttributes) { DbSession.Bus_TakeErrorAttributeRepository.DeleteEntity(item); } if (model.AttributeIds != null) { foreach (var attrId in model.AttributeIds) { Bus_TakeErrorAttribute attrModel = new Bus_TakeErrorAttribute(); attrModel.ID = Guid.NewGuid().ToString(); attrModel.AttributeID = existModel.ID; attrModel.AttributeIDItem = attrId; DbSession.Bus_TakeErrorAttributeRepository.AddEntity(attrModel); } } #endregion } else if (string.IsNullOrEmpty(model.ID)) { //添加 var addModel = new Bus_TakeError(); addModel.ID = Guid.NewGuid().ToString(); addModel.FromSource = model.FromSource; addModel.ActionId = model.ActionId; addModel.TypeVal = model.TypeVal; addModel.ResCompany = model.ResCompany; addModel.ResCompanyId = model.ResCompanyId; addModel.ResPerson = model.ResPerson; //addModel.AttributeID = model.AttributeID; addModel.DelFlag = 0; addModel.AccessCompany = model.AccessCompany; addModel.CreateTime = DateTime.Now; addModel.AccessCompanyId = model.AccessCompanyId; addModel.IsOverTime = model.IsOverTime; addModel.IsSearch = model.IsSearch; addModel.OverQuality = model.OverQuality; addModel.Remark = model.Remark; addModel.LevelRecords = model.LevelRecords; addModel.OrderBy = model.OrderBy; addModel.IsPass = 0; addModel.UserId = model.UserId; DbSession.Bus_TakeErrorRepository.AddEntity(addModel); #region 新增性质 //添加 if (model.AttributeIds != null) { foreach (var attrId in model.AttributeIds) { Bus_TakeErrorAttribute attrModel = new Bus_TakeErrorAttribute(); attrModel.ID = Guid.NewGuid().ToString(); attrModel.AttributeID = addModel.ID; attrModel.AttributeIDItem = attrId; DbSession.Bus_TakeErrorAttributeRepository.AddEntity(attrModel); } } #endregion } return(DbSession.SaveChange()); }
public List <Bus_TakeError> GetPaging(Bus_TakeError model, out int count) { IList <Bus_TakeError> backDtList = new List <Bus_TakeError>(); //延迟加载; var isAsc = model.orderDirection == "asc" ? true : false; var temp = this.LoadEntities(l => l.DelFlag == 0); //Bus_TakeErrorService takeErrorService = new Bus_TakeErrorService(); //var temp1 = from t in takeErrorService.LoadEntities(tr => tr.DelFlag == 0) // join ml in langService.LoadEntities(ml => ml.COLUMN_NAME == "Bus_TakeError_FromSource") on t.FromSource equals ml.ID // join ml2 in langService.LoadEntities(ml2 => ml2.COLUMN_NAME == "Bus_TakeError_TypeVal") on t.TypeVal equals ml2.ID // join ml3 in langService.LoadEntities(ml3 => ml3.COLUMN_NAME == "Bus_TakeError_OverQuality") on t.FromSource equals ml3.ID // select new // { // FromSource = ml.COLUMN_NAME, // ActionId = t.ActionId, // TypeVal = ml.COLUMN_NAME, // CreateTime = t.CreateTime, // ResCompany = t.ResCompany, // OverQuality = ml3.COLUMN_NAME // }; //foreach (var one in temp1.ToList()) //{ // Bus_TakeError takeObj = new Bus_TakeError(); // takeObj.FromSource = one.FromSource; // takeObj.ActionId = one.ActionId; // takeObj.TypeVal = one.TypeVal; // takeObj.CreateTime = one.CreateTime; // takeObj.ResCompany = one.ResCompany; // takeObj.OverQuality = one.OverQuality; // backDtList.Add(takeObj); //} if (!string.IsNullOrEmpty(model.UserId)) { temp = temp.Where(l => l.UserId == model.UserId); } if (!string.IsNullOrEmpty(model.ResCompany)) { temp = temp.Where(l => l.ResCompany.Contains(model.ResCompany)); } if (!string.IsNullOrEmpty(model.FromSource)) { temp = temp.Where(l => l.FromSource == model.FromSource); } if (!string.IsNullOrEmpty(model.TypeVal)) { temp = temp.Where(l => l.TypeVal == model.TypeVal); } if (!string.IsNullOrEmpty(model.OverQuality)) { temp = temp.Where(l => l.OverQuality == model.OverQuality); } if (model.BeginCreateTime != null && model.EndCreateTime != null) { temp = temp.Where(l => l.CreateTime >= model.BeginCreateTime && l.CreateTime <= model.EndCreateTime); } if (!string.IsNullOrEmpty(model.UserId)) { temp = temp.Where(l => l.UserId == model.UserId); } model.orderField = !string.IsNullOrEmpty(model.orderField) ? model.orderField : "CreateTime"; temp = temp.OrderByQueryable(model.orderField, model.orderDirection); var resList = temp.ToPaging(model.pageCurrent, model.pageSize, out count); var sourceList = langService.LoadEntities(s => s.TABLE_NAME == "Bus_TakeError_FromSource"); var valList = langService.LoadEntities(s => s.TABLE_NAME == "Bus_TakeError_TypeVal"); var overList = langService.LoadEntities(s => s.TABLE_NAME == "Bus_TakeError_OverQuality"); foreach (var item in resList) { var sourceObj = sourceList.Where(p => p.ID == item.FromSource).FirstOrDefault(); if (sourceObj != null) { item.FromSourceName = sourceObj.COLUMN_NAME; } var typeObj = valList.Where(p => p.ID == item.TypeVal).FirstOrDefault(); if (typeObj != null) { item.TypeValName = typeObj.COLUMN_NAME; } var overObj = overList.Where(p => p.ID == item.OverQuality).FirstOrDefault(); if (overObj != null) { item.OverQualityName = overObj.COLUMN_NAME; } } return(resList); }