public ViewResult AdviceForm(string key) { ViewBag.Title = "AdviceForm"; if (string.IsNullOrEmpty(key)) { AdviceInfo info = new AdviceInfo(); return View(info); } else { AdviceInfo info = AdviceService.Load(key); return View(info); } }
public JsonResult DeleteAdvice(string key) { AdviceInfo info = new AdviceInfo(); if (!string.IsNullOrEmpty(key)) { info.Id = key; OperationResult opr = AdviceService.Remove(key); return Json(new JsonResultHelper(opr.Message)); } else { return Json(new JsonResultHelper(false, "选择的记录无效", "")); } }
public virtual OperationResult Create(AdviceInfo info) { OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!"); using (var DbContext = new CmsDbContext()) { Advice entity = new Advice(); DESwap.AdviceDTE(info, entity); AdviceRpt.Insert(DbContext, entity); DbContext.SaveChanges(); } result.ResultType = OperationResultType.Success; result.Message = "操作成功!"; return result; }
public override OperationResult Create(AdviceInfo info) { OperationResult result = new OperationResult(OperationResultType.Error, "操作失败,请稍后重试!"); using (var DbContext = new CmsDbContext()) { Advice entity = new Advice(); DESwap.AdviceDTE(info, entity); /*需要设默认值*/ entity.HandleTime = DateTime.Now; AdviceRpt.Insert(DbContext, entity); DbContext.SaveChanges(); } result.ResultType = OperationResultType.Success; result.Message = "操作成功!"; return result; }
public ActionResult SaveAdvice(AdviceInfo info) { OperationResult opr = new OperationResult(OperationResultType.Success); try { if (string.IsNullOrEmpty(info.Id)) { info.Id = System.Guid.NewGuid().ToString(); opr = AdviceService.Create(info); } else { opr = AdviceService.Modify(info); } ViewBag.PromptMsg = opr.Message; } catch (Exception err) { ViewBag.PromptMsg = err.Message; } return View("AdviceForm", info); }
public JsonResult UpdateAdviceValid(string key, string validstatus) { AdviceInfo info = new AdviceInfo(); if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(validstatus)) { info.Id = key; info.SYS_IsValid = int.Parse(validstatus); OperationResult opr = AdviceService.Modify(info); return Json(new JsonResultHelper(opr.Message)); } else { return Json(new JsonResultHelper(false, "选择的记录无效", "")); } }
public PageResult<AdviceInfo> ListByCondition(NameValueCollection searchCondtionCollection, NameValueCollection sortCollection, int pageNumber, int pageSize) { PageResult<AdviceInfo> result = new PageResult<AdviceInfo>(); int skip = (pageNumber - 1) * pageSize; int take = pageSize; List<Advice> list = null; using (var DbContext = new CmsDbContext()) { var query = from i in DbContext.Advice select i; #region 条件 foreach (string key in searchCondtionCollection) { string condition = searchCondtionCollection[key]; switch (key.ToLower()) { case "title": query = query.Where(x => x.Title.Contains(condition)); break; case "language": int language = Convert.ToInt32(condition); query = query.Where(x => x.Language.Equals(language)); break; case "state": int state = Convert.ToInt32(condition); query = query.Where(x => x.State.Equals(state)); break; case "isvalid": int value = Convert.ToInt32(condition); query = query.Where(x => x.SYS_IsValid.Equals(value)); break; default: break; } } #endregion result.TotalRecords = query.Count(); #region 排序 foreach (string sort in sortCollection) { string direct = string.Empty; switch (sort.ToLower()) { case "createtime": if (direct.ToLower().Equals("asc")) { query = query.OrderBy(x => new { x.SYS_CreateTime }).Skip(skip).Take(take); } else { query = query.OrderByDescending(x => new { x.SYS_CreateTime }).Skip(skip).Take(take); } break; case "title": if (direct.ToLower().Equals("asc")) { query = query.OrderBy(x => x.Title).Skip(skip).Take(take); } else { query = query.OrderByDescending(x => x.Title).Skip(skip).Take(take); } break; default: query = query.OrderByDescending(x => new { x.SYS_OrderSeq }).Skip(skip).Take(take); break; } } list = query.ToList(); } #endregion #region linq to entity List<AdviceInfo> ilist = new List<AdviceInfo>(); list.ForEach(x => { AdviceInfo info = new AdviceInfo(); DESwap.AdviceETD(x, info); ilist.Add(info); }); #endregion result.PageSize = pageSize; result.PageNumber = pageNumber; result.Data = ilist; return result; ; }
public static void AdviceDTE(AdviceInfo info, Advice entity) { if (info._IdIsDirty == 1) { entity.Id = info.Id; info._IdIsDirty = 0; } if (info._XIsDirty == 1) { entity.X = info.X; info._XIsDirty = 0; } if (info._YIsDirty == 1) { entity.Y = info.Y; info._YIsDirty = 0; } if (info._ScaleIsDirty == 1) { entity.Scale = info.Scale; info._ScaleIsDirty = 0; } if (info._TitleIsDirty == 1) { entity.Title = info.Title; info._TitleIsDirty = 0; } if (info._DescIsDirty == 1) { entity.Desc = info.Desc; info._DescIsDirty = 0; } if (info._ContactIsDirty == 1) { entity.Contact = info.Contact; info._ContactIsDirty = 0; } if (info._ContactMethodIsDirty == 1) { entity.ContactMethod = info.ContactMethod; info._ContactMethodIsDirty = 0; } if (info._StateIsDirty == 1) { entity.State = info.State; info._StateIsDirty = 0; } if (info._ProgressLogIsDirty == 1) { entity.ProgressLog = info.ProgressLog; info._ProgressLogIsDirty = 0; } if (info._ResultIsDirty == 1) { entity.Result = info.Result; info._ResultIsDirty = 0; } if (info._HandleStaffIdIsDirty == 1) { entity.HandleStaffId = info.HandleStaffId; info._HandleStaffIdIsDirty = 0; } if (info._HandleStaffNameIsDirty == 1) { entity.HandleStaffName = info.HandleStaffName; info._HandleStaffNameIsDirty = 0; } if (info._HandleTimeIsDirty == 1) { entity.HandleTime = info.HandleTime; info._HandleTimeIsDirty = 0; } if (info._SYS_OrderSeqIsDirty == 1) { entity.SYS_OrderSeq = info.SYS_OrderSeq; info._SYS_OrderSeqIsDirty = 0; } if (info._SYS_IsValidIsDirty == 1) { entity.SYS_IsValid = info.SYS_IsValid; info._SYS_IsValidIsDirty = 0; } if (info._SYS_IsDeletedIsDirty == 1) { entity.SYS_IsDeleted = info.SYS_IsDeleted; info._SYS_IsDeletedIsDirty = 0; } if (info._SYS_RemarkIsDirty == 1) { entity.SYS_Remark = info.SYS_Remark; info._SYS_RemarkIsDirty = 0; } if (info._SYS_StaffIdIsDirty == 1) { entity.SYS_StaffId = info.SYS_StaffId; info._SYS_StaffIdIsDirty = 0; } if (info._SYS_StationIdIsDirty == 1) { entity.SYS_StationId = info.SYS_StationId; info._SYS_StationIdIsDirty = 0; } if (info._SYS_DepartmentIdIsDirty == 1) { entity.SYS_DepartmentId = info.SYS_DepartmentId; info._SYS_DepartmentIdIsDirty = 0; } if (info._SYS_CompanyIdIsDirty == 1) { entity.SYS_CompanyId = info.SYS_CompanyId; info._SYS_CompanyIdIsDirty = 0; } if (info._SYS_AppIdIsDirty == 1) { entity.SYS_AppId = info.SYS_AppId; info._SYS_AppIdIsDirty = 0; } if (info._SYS_CreateTimeIsDirty == 1) { entity.SYS_CreateTime = info.SYS_CreateTime; info._SYS_CreateTimeIsDirty = 0; } if (info._SYS_ModifyTimeIsDirty == 1) { entity.SYS_ModifyTime = info.SYS_ModifyTime; info._SYS_ModifyTimeIsDirty = 0; } if (info._SYS_DeleteTimeIsDirty == 1) { entity.SYS_DeleteTime = info.SYS_DeleteTime; info._SYS_DeleteTimeIsDirty = 0; } }
public virtual List<AdviceInfo> ListAllByCondition(NameValueCollection searchCondtionCollection, NameValueCollection sortCollection) { List<Advice> list = null; using (var DbContext = new CmsDbContext()) { var query = from i in DbContext.Advice select i; #region 条件 foreach (string key in searchCondtionCollection) { string condition = searchCondtionCollection[key]; switch (key.ToLower()) { case "isvalid": int value = Convert.ToInt32(condition); query = query.Where(x => x.SYS_IsValid.Equals(value)); break; default: break; } } #endregion #region 排序 foreach (string sort in sortCollection) { string direct = string.Empty; switch (sort.ToLower()) { case "createtime": if (direct.ToLower().Equals("asc")) { query = query.OrderBy(x => new { x.SYS_CreateTime }); } else { query = query.OrderByDescending(x => new { x.SYS_CreateTime }); } break; default: query = query.OrderByDescending(x => new { x.SYS_OrderSeq }); break; } } list = query.ToList(); } #endregion #region linq to entity List<AdviceInfo> ilist = new List<AdviceInfo>(); list.ForEach(x => { AdviceInfo info = new AdviceInfo(); DESwap.AdviceETD(x, info); ilist.Add(info); }); #endregion return ilist;; }
public virtual AdviceInfo Load(string key) { AdviceInfo info = new AdviceInfo(); using (var DbContext = new CmsDbContext()) { Advice entity = AdviceRpt.Get(DbContext, key); DESwap.AdviceETD(entity,info); } return info; }