/// <summary> /// 判断法庭案件选择的调解室是否时间存在冲突. /// </summary> /// <param name="iLawsId">法庭ID</param> /// <param name="type">添加 true,编辑 false</param> /// <returns></returns> public bool DateCommon(LawsCase lawsCase, bool type) { using (var db = new Entities()) { var res = false; if (type) { res = db.LawsCase. Any(m => m.iLawsId == lawsCase.iLawsId && m.dAclEndTime == null && ( (lawsCase.dPreStaTime <= m.dPreStaTime && lawsCase.dPreEndTime >= m.dPreStaTime) || //第一种情况 (lawsCase.dPreStaTime >= m.dPreStaTime && lawsCase.dPreEndTime <= m.dPreEndTime) || //第二种情况 (lawsCase.dPreStaTime >= m.dPreStaTime && lawsCase.dPreEndTime >= m.dPreEndTime && lawsCase.dPreStaTime < m.dPreEndTime) || //第三种情况 (lawsCase.dPreStaTime <= m.dPreStaTime && lawsCase.dPreEndTime >= m.dPreEndTime))); //第四种情况 } else { res = db.LawsCase. Any(m => m.iLawsId == lawsCase.iLawsId && m.dAclEndTime == null && m.ID != lawsCase.ID && ( (lawsCase.dPreStaTime <= m.dPreStaTime && lawsCase.dPreEndTime >= m.dPreStaTime) || //第一种情况 (lawsCase.dPreStaTime >= m.dPreStaTime && lawsCase.dPreEndTime <= m.dPreEndTime) || //第二种情况 (lawsCase.dPreStaTime >= m.dPreStaTime && lawsCase.dPreEndTime >= m.dPreEndTime && lawsCase.dPreStaTime < m.dPreEndTime) || //第三种情况 (lawsCase.dPreStaTime <= m.dPreStaTime && lawsCase.dPreEndTime >= m.dPreEndTime))); //第四种情况 } return(res); } }
/// <summary> /// 编辑法庭案件 /// </summary> /// <param name="lawsCase"></param> /// <returns></returns> public int Edit(LawsCase lawsCase) { using (var db = new Entities()) { var laws = db.Laws.Find(lawsCase.iLawsId); lawsCase.sCaseName = string.Empty; lawsCase.iLawOrder = laws.iLawOrder; db.Entry <LawsCase>(lawsCase).State = System.Data.Entity.EntityState.Modified; return(db.SaveChanges()); } }
/// <summary> /// 添加法庭案件 /// </summary> /// <param name="lawsCase"></param> /// <returns></returns> public int Add(LawsCase lawsCase) { using (var db = new Entities()) { var laws = db.Laws.Find(lawsCase.iLawsId); lawsCase.sCaseName = string.Empty; lawsCase.iLawOrder = laws.iLawOrder; db.LawsCase.Add(lawsCase); return(db.SaveChanges()); } }
public void Update(LawsCase lawsCase, string RealName) { var user = Resolve <UserManage>().Get(lawsCase.iUserId.Value); if (user.RealName == RealName) { if (!manage.DateCommon(lawsCase, false)) { if (manage.Edit(lawsCase) > 0) { result.success = true; } } else { result.info = "该法庭在选择的时间上存在冲突,请重新选择时间或者法庭"; } } else { result.info = string.Format("{0}法官不存在,请重新选择!", RealName); } }