/// <summary> /// 删除防疫信息 /// </summary> /// <param name="taskNumber">任务编号</param> /// <param name="employee">人名</param> /// <returns></returns> public bool DelPrevention(string taskNumber, string employee) { var preventionService = new PreventionService(); var taskService = new TaskService(); task task = taskService.FindByTaskNumber(taskNumber); if (task != null) { foreach ( prevention prevention in preventionService.FindByTaskId(task.Id).Where(m => m.employee.Name.Equals(employee))) { preventionService = new PreventionService(); preventionService.Delete(preventionService.Find(prevention.Id)); } return true; } return false; }
/// <summary> /// 修改防疫信息 /// </summary> /// <param name="updateInfo">防疫页面信息</param> /// <returns></returns> public bool UpdatePreventionInfo(PreventionInfo updateInfo) { var preventionService = new PreventionService(); var taskService = new TaskService(); task task = taskService.FindByTaskNumber(updateInfo.TaskNumber); int count = 0; if (task != null) { foreach (prevention prevention in preventionService.FindByTaskId(task.Id)) { if (count < updateInfo.PreventionInfoDetail.Count) { prevention.PigstyId = long.Parse(updateInfo.PreventionInfoDetail[count].Pigsty); prevention.EmployeeId = long.Parse(updateInfo.EmployeeName); prevention.Time = updateInfo.PreventionInfoDetail[count].DetailTime; prevention.Memo = updateInfo.Meno; preventionService.Update(prevention); } else { preventionService = new PreventionService(); preventionService.Delete(preventionService.Find(prevention.Id)); } count++; } for (; count < updateInfo.PreventionInfoDetail.Count; count++) { preventionService.Insert(new prevention { PigstyId = long.Parse(updateInfo.PreventionInfoDetail[count].Pigsty), EmployeeId = long.Parse(updateInfo.EmployeeName), Time = updateInfo.PreventionInfoDetail[count].DetailTime, Memo = updateInfo.Meno }); } return true; } return false; }