Esempio n. 1
0
        /// <summary>
        ///     查看治疗信息
        /// </summary>
        /// <param name="employeename">治疗人员</param>
        /// <param name="taskNumber">任务编号</param>
        /// <param name="order">疗程号</param>
        /// <returns></returns>
        public CureInfo CheckCureInfo(string employeename, string taskNumber, int order)
        {
            var curePigService = new CurePigService();
            var cureTaskCourseService = new CureTaskCourseService();
            var cureMethodService = new CureMethodService();
            var transferService = new TransferService();
            var taskService = new TaskService();
            var cureMedicineService = new CureMedicineService();
            cure_task_course cureTaskCourse =
                cureTaskCourseService.FindByTaskId(taskService.FindByTaskNumber(taskNumber).Id).FirstOrDefault(
                    m => m.Order == order);
            var checkCureInfo = new CureInfo
                                    {
                                        TaskNumber = taskNumber,
                                        Order = order,
                                        EmployeeName = employeename,
                                        CureDetail = new List<CureDetail>(),
                                        PigDetail = new List<Detail>()
                                    };
            if (cureTaskCourse == null) return checkCureInfo;

            foreach (
                cure_pig curePig in
                    curePigService.FindByCureTaskCourseId(cureTaskCourse.Id).Where(
                        m => m.employee.Name.Equals(employeename)))
            {
                transfer firstOrDefault =
                    transferService.FindByPigId(curePig.PigId).OrderByDescending(m => m.Time).FirstOrDefault();
                if (firstOrDefault != null)
                    checkCureInfo.PigDetail.Add(new Detail
                                                    {
                                                        PigHouse = firstOrDefault.pigsty.pig_house.pig_house_type.Name
                                                                   + firstOrDefault.pigsty.pig_house.Number,
                                                        Pigsty = firstOrDefault.pigsty.Number + "",
                                                        Pig = firstOrDefault.pig.Number,
                                                        DetailTime = (DateTime) curePig.CureTime
                                                    });
            }
            foreach (cure_method cureMethod in cureMethodService.FindByCureTaskCourseId(cureTaskCourse.Id))
            {
                var medicineList = new List<CureMedicineDetail>();
                foreach (cure_medicine cureMedicine in cureMedicineService.FindByCureMethoId(cureMethod.Id))
                {
                    medicineList.Add(new CureMedicineDetail
                                         {
                                             Medicine = cureMedicine.medicine.Name,
                                             Quality = cureMedicine.Quality,
                                             Unit = cureMedicine.unit.Name
                                         });
                }
                checkCureInfo.CureDetail.Add(new CureDetail
                                                 {
                                                     CureType = cureMethod.cure_type.Name,
                                                     CureMedicineDetail = medicineList
                                                 });
            }
            return checkCureInfo;
        }
        public MedicineTakeModel GetCureTaskByEmployeeId(long employeeId)
        {
            var medicineTakeModel = new MedicineTakeModel();

            var tasktypeService = new TaskTypeService();
            var taskEmployeeService = new TaskEmployeeService();
            var taskService = new TaskService();
            var cureTaskMethodService = new CureTaskMethodService();
            var cureTaskCourseService = new CureTaskCourseService();
            var cureTaskMedicineService = new CureTaskMedicineService();
            int taskflag = 0;
            long employeeTaskId = 0;
            long cureCourseId = 0;
            List<task_employee> alltask = taskEmployeeService.FindByEmployeeId(employeeId);
            //根据任务id找到任务类型,若是当天的治疗任务,记录taskid
            foreach (task_employee task in alltask)
            {
                long tasktypeid = taskService.Find(task.TaskId).TaskTypeId;
                string tasktype = tasktypeService.Find(tasktypeid).Name;
                if (tasktype == "治疗")
                {
                    //判断当前记录的时间是否和任务中某一个疗程的开始时间相同,若是,则代表当天有治疗任务
                    List<cure_task_course> cureTaskCourses = cureTaskCourseService.FindByTaskId(task.TaskId);
                    foreach (cure_task_course cureTaskCourse in cureTaskCourses)
                    {
                        if (cureTaskCourse.Time.ToShortDateString() == DateTime.Now.ToShortDateString())
                        {
                            taskflag = 1;
                            employeeTaskId = task.TaskId;
                            cureCourseId = cureTaskCourse.Id;
                            medicineTakeModel.TaskCourseId = cureCourseId;
                        }
                    }
                }
            }
            if (taskflag == 1)
            {
                List<cure_task_method> cureTaskMethods = cureTaskMethodService.FindByCureTaskCourseId(cureCourseId);
                var cureDetails = new List<CureDetail>();
                CureDetail cureDetail = null;
                medicineTakeModel.CureTaskType = cureDetails;
                foreach (cure_task_method cureTaskMethod in cureTaskMethods)
                {
                    cureDetail = new CureDetail();
                    cureDetail.CureType = cureTaskMethod.cure_type.Name;
                    cureDetails.Add(cureDetail);
                    var cureMedicineDetails = new List<CureMedicineDetail>();
                    cureDetail.CureMedicineDetail = cureMedicineDetails;
                    CureMedicineDetail cureMedicineDetail = null;
                    List<cure_task_medicine> cureTaskMedicines =
                        cureTaskMedicineService.FindByCureTaskMethodId(cureTaskMethod.Id);
                    foreach (cure_task_medicine cureTaskMedicine in cureTaskMedicines)
                    {
                        cureMedicineDetail = new CureMedicineDetail();
                        cureMedicineDetail.Medicine = cureTaskMedicine.medicine.Name;
                        cureMedicineDetail.Quality = cureTaskMedicine.Quality;
                        cureMedicineDetail.Unit = cureTaskMedicine.unit.Name;
                        cureMedicineDetails.Add(cureMedicineDetail);
                    }
                }

                medicineTakeModel.TaskNumber = taskService.Find(employeeTaskId).TaskNumber;
                List<task_employee> allemployees = taskEmployeeService.FindByTaskId(employeeTaskId);
                int i;
                string reAllEmployeeName = "";
                for (i = 0; i < allemployees.Count - 1; i++)
                {
                    reAllEmployeeName = reAllEmployeeName + allemployees[i].employee.Name + ",";
                }
                reAllEmployeeName = reAllEmployeeName + allemployees[i].employee.Name;
                medicineTakeModel.EmloyeeName = reAllEmployeeName;
            }
            return medicineTakeModel;
        }
Esempio n. 3
0
 /// <summary>
 ///     根据任务id查找疗程号的下拉列表框
 /// </summary>
 /// <returns></returns>
 public IEnumerable<SelectListItem> GetCureTaskOrder(long taskId)
 {
     var cureTaskCourseService = new CureTaskCourseService();
     IEnumerable<SelectListItem> cureTaskCourseList = cureTaskCourseService.FindByTaskId(taskId).
                                                                            Select(
                                                                                cureTaskCourseItem =>
                                                                                new SelectListItem
                                                                                    {
                                                                                        Text =
                                                                                            cureTaskCourseItem
                                                                                                .Order + "",
                                                                                        Value =
                                                                                            cureTaskCourseItem
                                                                                                .Order + ""
                                                                                    }).OrderBy(m => m.Text);
     return cureTaskCourseList;
 }
Esempio n. 4
0
 /// <summary>
 ///     根据任务id查找相关的疗程号
 /// </summary>
 /// <param name="taskId">任务id</param>
 /// <returns></returns>
 public string GetCureTaskOrder(int taskId)
 {
     var cureTaskCourseService = new CureTaskCourseService();
     return cureTaskCourseService.GetCureTaskOrder(taskId);
 }
Esempio n. 5
0
 /// <summary>
 ///     根据id查找当天是否有治疗任务
 /// </summary>
 /// <param name="employeeId">人员id</param>
 /// <returns>返回是否当天有治疗任务</returns>
 public string GetCureTaskById(long employeeId)
 {
     var tasktypeService = new TaskTypeService();
     var taskEmployeeService = new TaskEmployeeService();
     var taskService = new TaskService();
     var cureTaskCourseService = new CureTaskCourseService();
     int taskflag = 0;
     List<task_employee> alltask = taskEmployeeService.FindByEmployeeId(employeeId);
     //根据任务id找到任务类型,若是当天的治疗任务,记录taskid
     foreach (task_employee task in alltask)
     {
         long tasktypeid = taskService.Find(task.TaskId).TaskTypeId;
         string tasktype = tasktypeService.Find(tasktypeid).Name;
         if (tasktype == "治疗")
         {
             //判断当前记录的时间是否和任务中某一个疗程的开始时间相同,若是,则代表当天有治疗任务
             List<cure_task_course> cureTaskCourses = cureTaskCourseService.FindByTaskId(task.TaskId);
             foreach (cure_task_course cureTaskCourse in cureTaskCourses)
             {
                 if (cureTaskCourse.Time.ToShortDateString() == DateTime.Now.ToShortDateString())
                 {
                     taskflag = 1;
                 }
             }
         }
     }
     if (taskflag == 1)
     {
         return "1";
     }
     return "2";
 }
Esempio n. 6
0
        public bool UpdateCureTask(CureTask updateTask)
        {
            var taskService = new TaskService();

            task task = taskService.FindByTaskNumber(updateTask.TaskNumber);

            if (task == null)
            {
                return false;
            }

            task.StartTime = updateTask.StartTime;
            task.EndTime = updateTask.EndTime;
            task.Memo = updateTask.Memo;

            new TaskEmployeeService().UpdateByNumberStr(task, updateTask.EmployeeNumber);

            var pigService = new PigService();

            List<long> pigList =
                (from taskDetail in updateTask.CureDetail
                 from pig in taskDetail.Pig.Split(',')
                 select pigService.FindByNumber(pig).Id).ToList();

            int oldLen = task.task_pig.Count;
            int newLen = pigList.Count;
            int leastLen = oldLen < newLen ? oldLen : newLen;
            for (int i = 0; i < leastLen; i++)
            {
                task.task_pig.ElementAt(i).PigId = pigList[i];
            }
            var taskPigService = new TaskPigService();
            for (int i = leastLen; i < oldLen; i++)
            {
                taskPigService.Delete(taskPigService.Find(task.task_pig.ElementAt(i).Id));
            }
            for (int i = leastLen; i < newLen; i++)
            {
                task.task_pig.Add(new task_pig
                                      {
                                          PigId = pigList[i]
                                      });
            }

            oldLen = task.cure_task_course.Count;
            newLen = updateTask.CureCourse.Count;
            leastLen = oldLen < newLen ? oldLen : newLen;

            var cureTaskMedicineService = new CureTaskMedicineService();
            var cureTaskMethodService = new CureTaskMethodService();
            for (int i = 0; i < leastLen; i++)
            {
                CureCourse cureCourse = updateTask.CureCourse[i];
                task.cure_task_course.ElementAt(i).Order = cureCourse.CureOrder;
                task.cure_task_course.ElementAt(i).Time = cureCourse.CureTime;

                int oldLen2 = task.cure_task_course.ElementAt(i).cure_task_method.Count;
                int newLen2 = cureCourse.CureMethod.Count;
                int leastLen2 = oldLen2 < newLen2 ? oldLen2 : newLen2;
                for (int j = 0; j < leastLen2; j++)
                {
                    task.cure_task_course.ElementAt(i).cure_task_method.ElementAt(j).CureTypeId =
                        long.Parse(cureCourse.CureMethod[j].CureType);
                    int oldLen3 =
                        task.cure_task_course.ElementAt(i).cure_task_method.ElementAt(j).cure_task_medicine.Count;
                    int newLen3 = cureCourse.CureMethod[j].CureMedicine.Count;
                    int leastLen3 = oldLen3 < newLen3 ? oldLen3 : newLen3;
                    for (int k = 0; k < leastLen3; k++)
                    {
                        Medicine medicine = cureCourse.CureMethod[j].CureMedicine[k];
                        if (medicine.Quality <= 0)
                        {
                            continue;
                        }
                        task.cure_task_course.ElementAt(i).cure_task_method.ElementAt(j).cure_task_medicine.ElementAt(k)
                            .MedicineId
                            = long.Parse(medicine.MedicineName);
                        task.cure_task_course.ElementAt(i).cure_task_method.ElementAt(j).cure_task_medicine.ElementAt(k)
                            .Quality = medicine.Quality;
                        task.cure_task_course.ElementAt(i).cure_task_method.ElementAt(j).cure_task_medicine.ElementAt(k)
                            .UnitId = long.Parse(medicine.Unit);
                    }

                    for (int k = leastLen; k < oldLen3; k++)
                    {
                        cureTaskMedicineService.Delete(
                            cureTaskMedicineService.Find(
                                task.cure_task_course.ElementAt(i).cure_task_method.ElementAt(j).cure_task_medicine.
                                     ElementAt(k).Id));
                    }
                    for (int k = leastLen; k < newLen3; k++)
                    {
                        Medicine medicine = cureCourse.CureMethod[j].CureMedicine[k];
                        if (medicine.Quality <= 0)
                        {
                            continue;
                        }
                        task.cure_task_course.ElementAt(i)
                            .cure_task_method.ElementAt(j)
                            .cure_task_medicine.Add(new cure_task_medicine
                                                        {
                                                            MedicineId
                                                                =
                                                                long
                                                                .
                                                                Parse
                                                                (medicine
                                                                     .
                                                                     MedicineName),
                                                            Quality
                                                                =
                                                                medicine
                                                                .
                                                                Quality,
                                                            UnitId
                                                                =
                                                                long
                                                                .
                                                                Parse
                                                                (medicine
                                                                     .
                                                                     Unit)
                                                        });
                    }
                }

                for (int j = leastLen2; j < oldLen2; j++)
                {
                    cure_task_method cureTaskMethod = task.cure_task_course.ElementAt(i).cure_task_method.ElementAt(j);
                    foreach (cure_task_medicine cureTaskMedicine in cureTaskMethod.cure_task_medicine)
                    {
                        cureTaskMedicineService.Delete(cureTaskMedicineService.Find(cureTaskMedicine.Id));
                    }
                    cureTaskMethodService.Delete(cureTaskMethodService.Find(cureTaskMethod.Id));
                }
                for (int j = leastLen2; j < newLen2; j++)
                {
                    CureMethod cureMethod = cureCourse.CureMethod[j];
                    var medicineList = new Collection<cure_task_medicine>();

                    foreach (Medicine medicine in cureMethod.CureMedicine.Where(medicine => !(medicine.Quality <= 0)))
                    {
                        medicineList.Add(new cure_task_medicine
                                             {
                                                 MedicineId = long.Parse(medicine.MedicineName),
                                                 Quality = medicine.Quality,
                                                 UnitId = long.Parse(medicine.Unit)
                                             });
                    }
                    task.cure_task_course.ElementAt(i).cure_task_method.Add(new cure_task_method
                                                                                {
                                                                                    CureTypeId =
                                                                                        long.Parse(cureMethod.CureType),
                                                                                    cure_task_medicine = medicineList
                                                                                });
                }
            }

            var cureTaskCourseService = new CureTaskCourseService();
            for (int i = leastLen; i < oldLen; i++)
            {
                foreach (cure_method cureMethod in task.cure_task_course.ElementAt(i).cure_method)
                {
                    foreach (cure_medicine cureMedicine in cureMethod.cure_medicine)
                    {
                        cureTaskMedicineService.Delete(cureTaskMedicineService.Find(cureMedicine.Id));
                    }
                    cureTaskMethodService.Delete(cureTaskMethodService.Find(cureMethod.Id));
                }
                cureTaskCourseService.Delete(cureTaskCourseService.Find(task.cure_task_course.ElementAt(i).Id));
            }

            for (int i = leastLen; i < newLen; i++)
            {
                var methodList = new Collection<cure_task_method>();
                CureCourse cureCourse = updateTask.CureCourse[i];

                foreach (CureMethod cureMethod in cureCourse.CureMethod)
                {
                    var medicineList = new Collection<cure_task_medicine>();

                    foreach (Medicine medicine in cureMethod.CureMedicine.Where(medicine => !(medicine.Quality <= 0)))
                    {
                        medicineList.Add(new cure_task_medicine
                                             {
                                                 MedicineId = long.Parse(medicine.MedicineName),
                                                 Quality = medicine.Quality,
                                                 UnitId = long.Parse(medicine.Unit)
                                             });
                    }

                    methodList.Add(new cure_task_method
                                       {
                                           CureTypeId = long.Parse(cureMethod.CureType),
                                           cure_task_medicine = medicineList
                                       });
                }
                task.cure_task_course.Add(new cure_task_course
                                              {
                                                  Order = cureCourse.CureOrder,
                                                  Time = cureCourse.CureTime,
                                                  cure_task_method = methodList
                                              });
            }

            taskService.Update(task);

            return true;
        }
Esempio n. 7
0
        /// <summary>
        ///     删除指定任务编号的任务
        /// </summary>
        /// <param name="taskNumber">任务编号</param>
        /// <returns>返回删除是否成功</returns>
        public bool DeleteTask(string taskNumber)
        {
            task task = FindByTaskNumber(taskNumber);

            if (task == null || new FeedService().FindByTaskId(task.Id).Count > 0 ||
                new FodderTakeService().FindByTaskId(task.Id).Count > 0 ||
                new TransferService().FindByTaskId(task.Id).Count > 0 ||
                new PreventionService().FindByTaskId(task.Id).Count > 0 ||
                new InspectionService().FindByTaskId(task.Id).Count > 0 ||
                new SaleService().FindByTaskId(task.Id).Count > 0)
            {
                return false;
            }

            var cureMethodService = new CureMethodService();
            cure_task_course cureCourse = task.cure_task_course.FirstOrDefault();
            if (cureCourse != null && cureMethodService.FindByCureTaskCourseId(cureCourse.Id).Count > 0)
            {
                return false;
            }

            var saleTaskQualityService = new SaleTaskQualityService();
            foreach (sale_task_quality delItem in task.sale_task_quality)
            {
                saleTaskQualityService.Delete(saleTaskQualityService.Find(delItem.Id));
            }

            var transferTaskPigService = new TaskPigService();
            foreach (task_pig transferTaskPig in task.task_pig)
            {
                transferTaskPigService.Delete(transferTaskPigService.Find(transferTaskPig.Id));
            }

            var taskIntervalCycleService = new TaskIntervalCycleService();
            foreach (task_interval_cycle item in task.task_interval_cycle)
            {
                taskIntervalCycleService.Delete(taskIntervalCycleService.Find(item.Id));
            }

            var taskPigstyService = new TaskPigstyService();
            var feedTaskQualityService = new FeedTaskQualityService();
            foreach (task_pigsty item in task.task_pigsty)
            {
                foreach (feed_task_quality delItem in item.feed_task_quality)
                {
                    feedTaskQualityService.Delete(feedTaskQualityService.Find(delItem.Id));
                }
                taskPigstyService.Delete(taskPigstyService.Find(item.Id));
            }

            var taskEmployeeService = new TaskEmployeeService();
            foreach (task_employee item in task.task_employee)
            {
                taskEmployeeService.Delete(taskEmployeeService.Find(item.Id));
            }

            var cureTaskCourseService = new CureTaskCourseService();
            var cureTaskMethodService = new CureTaskMethodService();
            var cureTaskMedicineService = new CureTaskMedicineService();
            foreach (cure_task_course cureTaskCourse in task.cure_task_course)
            {
                foreach (cure_task_method cureTaskMethod in cureTaskCourse.cure_task_method)
                {
                    foreach (cure_task_medicine cureTaskMedicine in cureTaskMethod.cure_task_medicine)
                    {
                        cureTaskMedicineService.Delete(cureTaskMedicineService.Find(cureTaskMedicine.Id));
                    }
                    cureTaskMethodService.Delete(cureTaskMethodService.Find(cureTaskMethod.Id));
                }
                cureTaskCourseService.Delete(cureTaskCourseService.Find(cureTaskCourse.Id));
            }

            var taskPreventionService = new TaskPreventionService();
            foreach (task_prevention taskPrevention in task.task_prevention)
            {
                taskPreventionService.Delete(taskPreventionService.Find(taskPrevention.Id));
            }

            var taskPigHouseService = new TaskPigHouseService();
            foreach (task_pighouse taskPighouse in task.task_pighouse)
            {
                taskPigHouseService.Delete(taskPigHouseService.Find(taskPighouse.Id));
            }

            var taskRepository = new TaskRepository();
            taskRepository.Delete(taskRepository.Find(task.Id));

            return true;
        }
Esempio n. 8
0
        /// <summary>
        ///     修改治疗信息
        /// </summary>
        /// <param name="newInfo">治疗信息页面类</param>
        /// <param name="employeename">原人员名字</param>
        /// <returns></returns>
        public bool UpdateCureInfo(CureInfo newInfo, string employeename)
        {
            var curePigService = new CurePigService();
            var cureTaskCourseService = new CureTaskCourseService();
            var cureMethodService = new CureMethodService();

            var taskService = new TaskService();
            int count = 0, j = 0;
            var cureMedicineService = new CureMedicineService();
            cure_task_course cureTaskCourse =
                cureTaskCourseService.FindByTaskId(taskService.FindByTaskNumber(newInfo.TaskNumber).Id).FirstOrDefault(
                    m => m.Order == newInfo.Order);
            if (cureTaskCourse == null) return false;
            //治疗生猪信息更新
            foreach (cure_pig curePig in curePigService.FindByCureTaskCourseId(cureTaskCourse.Id))
            {
                if (!curePig.employee.Name.Equals(employeename)) continue;
                if (count < newInfo.PigDetail.Count)
                {
                    curePig.EmployeeId = long.Parse(newInfo.EmployeeName);
                    curePig.PigId = long.Parse(newInfo.PigDetail[count].Pig);
                    curePig.CureTime = newInfo.PigDetail[count].DetailTime;
                    curePig.Memo = newInfo.Meno;
                    curePigService.Update(curePig);
                }
                else
                {
                    curePigService = new CurePigService();
                    curePigService.Delete(curePigService.Find(curePig.Id));
                }
                count++;
            }
            for (; count < newInfo.PigDetail.Count; count++)
            {
                curePigService.Insert(new cure_pig
                                          {
                                              CureTaskCourseId = cureTaskCourse.Id,
                                              EmployeeId = long.Parse(newInfo.EmployeeName),
                                              PigId = long.Parse(newInfo.PigDetail[count].Pig),
                                              CureTime = newInfo.PigDetail[count].DetailTime,
                                              Memo = newInfo.Meno
                                          });
            }
            count = 0;
            //治疗方式信息更新
            foreach (cure_method cureMethod in cureMethodService.FindByCureTaskCourseId(cureTaskCourse.Id))
            {
                j = 0;
                if (count < newInfo.CureDetail.Count)
                {
                    cureMethod.CureTypeId = long.Parse(newInfo.CureDetail[count].CureType);
                    cureMethodService.Update(cureMethod);
                    //治疗药物信息更新
                    foreach (cure_medicine cureMedicine in cureMedicineService.FindByCureMethoId(cureMethod.Id))
                    {
                        if (j < cureMethod.cure_medicine.Count)
                        {
                            cureMedicine.MedicineId =
                                long.Parse(newInfo.CureDetail[count].CureMedicineDetail[j].Medicine);
                            cureMedicine.Quality = newInfo.CureDetail[count].CureMedicineDetail[j].Quality;
                            cureMedicine.UnitId = long.Parse(newInfo.CureDetail[count].CureMedicineDetail[j].Unit);
                            cureMedicineService.Update(cureMedicine);
                        }
                        else
                        {
                            cureMedicineService = new CureMedicineService();
                            cureMedicineService.Delete(cureMedicineService.Find(cureMedicine.Id));
                        }
                        j++;
                    }
                    for (; j < cureMethod.cure_medicine.Count; j++)
                    {
                        cureMedicineService.Insert(new cure_medicine
                                                       {
                                                           CureMethodId = cureMethod.Id,
                                                           MedicineId =
                                                               long.Parse(
                                                                   newInfo.CureDetail[count].CureMedicineDetail[j].
                                                                       Medicine),
                                                           Quality =
                                                               newInfo.CureDetail[count].CureMedicineDetail[j].Quality,
                                                           UnitId =
                                                               long.Parse(
                                                                   newInfo.CureDetail[count].CureMedicineDetail[j].Unit)
                                                       });
                    }
                }
                else
                {
                    cureMethodService = new CureMethodService();
                    cureMedicineService.ClearCureMedicine(cureMethod);
                    cureMethodService.Delete(cureMethodService.Find(cureMethod.Id));
                }
                count++;
            }
            for (; count < newInfo.CureDetail.Count; count++)
            {
                var cure = new cure_method
                               {
                                   CureTaskCourseId = cureTaskCourse.Id,
                                   CureTypeId = long.Parse(newInfo.CureDetail[count].CureType)
                               };
                foreach (CureMedicineDetail cureMedicineItem in newInfo.CureDetail[count].CureMedicineDetail)
                {
                    cure.cure_medicine.Add(new cure_medicine
                                               {
                                                   MedicineId = long.Parse(cureMedicineItem.Medicine),
                                                   Quality = cureMedicineItem.Quality,
                                                   UnitId = long.Parse(cureMedicineItem.Unit)
                                               });
                }
                cureMethodService.Insert(cure);
            }
            return true;
        }
Esempio n. 9
0
        /// <summary>
        ///     删除治疗信息
        /// </summary>
        /// <param name="employeename">治疗人员</param>
        /// <param name="taskNumber">任务编号</param>
        /// <param name="order">疗程号</param>
        /// <returns></returns>
        public bool DelCureInfo(string employeename, string taskNumber, int order)
        {
            var curePigService = new CurePigService();
            var cureTaskCourseService = new CureTaskCourseService();
            var cureMethodService = new CureMethodService();

            var taskService = new TaskService();
            var cureMedicineService = new CureMedicineService();
            cure_task_course cureTaskCourse =
                cureTaskCourseService.FindByTaskId(taskService.FindByTaskNumber(taskNumber).Id).FirstOrDefault(
                    m => m.Order == order);
            if (cureTaskCourse == null) return false;

            foreach (
                cure_pig curePig in
                    curePigService.FindByCureTaskCourseId(cureTaskCourse.Id).Where(
                        m => m.employee.Name.Equals(employeename)))
            {
                foreach (cure_method cureMethod in cureMethodService.FindByCureTaskCourseId(curePig.Id))
                {
                    cureMedicineService.ClearCureMedicine(cureMethod);
                    cureMethodService = new CureMethodService();
                    cureMethodService.Delete(cureMethodService.Find(cureMethod.Id));
                }
                curePigService = new CurePigService();
                curePigService.Delete(curePigService.Find(curePig.Id));
            }
            return true;
        }
Esempio n. 10
0
 /// <summary>
 ///     新建治疗信息
 /// </summary>
 /// <param name="newInfo"></param>
 /// <returns></returns>
 public bool CreateCureInfo(CureInfo newInfo)
 {
     var curePigService = new CurePigService();
     var cureTaskCourseService = new CureTaskCourseService();
     var cureMethodService = new CureMethodService();
     var taskStatusTypeService = new TaskStatusTypeService();
     var taskService = new TaskService();
     cure_task_course cureTaskCourse =
         cureTaskCourseService.FindByTaskId(long.Parse(newInfo.TaskNumber)).FirstOrDefault(
             m => m.Order == newInfo.Order);
     if (cureTaskCourse == null) return false;
     foreach (Detail detail in newInfo.PigDetail)
     {
         curePigService.Insert(new cure_pig
                                   {
                                       EmployeeId = long.Parse(newInfo.EmployeeName),
                                       CureTaskCourseId = cureTaskCourse.Id,
                                       PigId = long.Parse(detail.Pig),
                                       CureTime = detail.DetailTime,
                                       Memo = newInfo.Meno
                                   });
     }
     foreach (CureDetail cureDetail in newInfo.CureDetail)
     {
         var cureMethod = new cure_method
                              {
                                  CureTaskCourseId = cureTaskCourse.Id
                                  ,
                                  CureTypeId = long.Parse(cureDetail.CureType)
                              };
         foreach (CureMedicineDetail cureMedicineDetail in cureDetail.CureMedicineDetail)
         {
             cureMethod.cure_medicine.Add(new cure_medicine
                                              {
                                                  MedicineId = long.Parse(cureMedicineDetail.Medicine),
                                                  Quality = cureMedicineDetail.Quality,
                                                  UnitId = long.Parse(cureMedicineDetail.Unit)
                                              });
         }
         cureMethodService.Insert(cureMethod);
     }
     task_status_type taskStatusType = taskStatusTypeService.FindByName("正在进行");
     task task = taskService.Find(long.Parse(newInfo.TaskNumber));
     if (taskStatusType != null && task != null)
     {
         task.TaskStatusId = taskStatusType.Id;
         taskService.Update(task);
     }
     return true;
 }