Ejemplo n.º 1
0
 /// <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;
 }
Ejemplo n.º 2
0
        /// <summary>
        ///     查看防疫信息
        /// </summary>
        /// <param name="taskNumber">任务编号</param>
        /// <returns></returns>
        public PreventionInfo CheckPreventionInfo(string taskNumber, string employeeName)
        {
            var preventionService = new PreventionService();
            var checkPreventionInfo = new PreventionInfo();
            checkPreventionInfo.PreventionInfoDetail = new List<Detail>();
            var taskService = new TaskService();
            task task = taskService.FindByTaskNumber(taskNumber);
            if (task == null) return null;
            task_prevention firstOrDefault = task.task_prevention.FirstOrDefault();
            if (firstOrDefault != null)
            {
                checkPreventionInfo.TaskNumber = taskNumber;
                checkPreventionInfo.EmployeeName = employeeName;
                checkPreventionInfo.DiseaseName = firstOrDefault.prevention_type.Name;
                checkPreventionInfo.Medicine = firstOrDefault.prevention_type.medicine.Name;
                checkPreventionInfo.Quality = firstOrDefault.prevention_type.Quality;
                checkPreventionInfo.Unit = firstOrDefault.prevention_type.unit1.Name;
            }

            foreach (
                prevention preventionItem in
                    preventionService.FindByTaskId(task.Id).Where(m => m.employee.Name.Equals(employeeName)))
            {
                checkPreventionInfo.PreventionInfoDetail.Add(new Detail
                                                                 {
                                                                     PigHouse =
                                                                         preventionItem.pigsty.pig_house.pig_house_type.
                                                                                        Name
                                                                         + preventionItem.pigsty.pig_house.Number,
                                                                     Pigsty = preventionItem.pigsty.Number + "",
                                                                     DetailTime = preventionItem.Time
                                                                 });
            }

            return checkPreventionInfo;
        }
Ejemplo n.º 3
0
        /// <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;
        }