Beispiel #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 ActionResult CheckCureInfo(string employeename, string taskNumber, int order)
        {
            if (Session["CheckFeed"] == null || !(bool) Session["CheckCureInfo"])
            {
                Response.Write("<script>history.go(0);</script>");
                return View("Error");
            }

            CureInfo checkCureInfo = new CureInfo().CheckCureInfo(employeename, taskNumber, order);
            if (checkCureInfo == null)
            {
                ViewBag.Title = "查看失败,请重新操作";
                return View("Message");
            }
            ViewBag.Title = "查看治疗信息";
            return View(checkCureInfo);
        }
        public ActionResult CureInfo(int pageIndex = 1)
        {
            if (Session["CheckFeed"] == null || !(bool) Session["CheckCureInfo"])
            {
                Response.Write("<script>history.go(0);</script>");
                return View("Error");
            }

            const int pageSize = 25;

            var cureInfo = new CureInfo();
            PagedList<Info> infoPagerList;
            if (Request.Form["CheckEmployee"] != null)
            {
                Session["check"] = Request.Form["CheckEmployee"];
                Session["chooseid"] = Request.Form["SearchChose"];
                infoPagerList =
                    cureInfo.GetInfoPagedList(
                        cureInfo.GetCureInfo(cureInfo.GetCureInfo(), Request.Form["CheckEmployee"],
                                             Request.Form["SearchChose"]), pageIndex, pageSize);
                //Session["SearchCure"] = Request.Form["CheckEmployee"];
            }
            else if (Session["check"] != null && Session["chooseid"] != null && Request.HttpMethod == "POST")
            {
                infoPagerList =
                    cureInfo.GetInfoPagedList(cureInfo.GetCureInfo(cureInfo.GetCureInfo(), Session["check"] as string,
                                                                   Session["chooseid"] as string), pageIndex, pageSize);
            }
            else
            {
                Session["check"] = "";
                Session["chooseid"] = "";
                infoPagerList = cureInfo.GetInfoPagedList(cureInfo.GetCureInfo(), pageIndex, pageSize);
            }

            if (Request.IsAjaxRequest())
            {
                return PartialView("UCJqInfoList", infoPagerList);
            }
            ViewData["Search"] = new ListService().GetInfoSearchList();
            return View(infoPagerList);
        }
Beispiel #4
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;
        }
Beispiel #5
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;
 }
        public bool DelCureInfo(string employeename, string taskNumber, int order)
        {
            if (Session["CheckFeed"] == null || !(bool) Session["DelCureInfo"] || !(bool) Session["CheckCureInfo"])
            {
                return false;
            }

            var checkCureInfo = new CureInfo();

            return checkCureInfo.DelCureInfo(employeename, taskNumber, order);
        }
 public ActionResult NewCureInfo(CureInfo newInfo)
 {
     if (newInfo != null)
     {
         if (newInfo.CreateCureInfo(newInfo))
         {
             ViewBag.Title = "新建成功";
             return View("Message");
         }
     }
     ViewBag.Title = "新建失败,请重新操作";
     return View("Message");
 }
        public ActionResult NewCureInfo()
        {
            if (Session["CheckFeed"] == null || !(bool) Session["AddCureInfo"] || !(bool) Session["CheckCureInfo"])
            {
                Response.Write("<script>history.go(0);</script>");
                return View("Error");
            }

            var newInfo = new CureInfo();
            IEnumerable<SelectListItem> taskNumberList = newInfo.GetTaskNumberSelect(TaskTypeId);
            if (!taskNumberList.Any())
            {
                const string returnstring = "任务为空,请先添加任务";
                Response.Write("<script language='JavaScript'>alert('" + returnstring + ".');history.go(-1);</script>");
                return Content("");
            }
            SelectListItem firstOrDefault = newInfo.GetTaskNumberSelect(TaskTypeId).FirstOrDefault();
            long taskId = 0;
            if (firstOrDefault != null)
                taskId = long.Parse(firstOrDefault.Value);

            var listService = new ListService();

            ViewData["TaskNumber"] = newInfo.GetTaskNumberSelect(TaskTypeId);
            ViewData["pigsty"] = listService.GetFirstPigstyList();
            ViewData["Employee"] = listService.GetEmployeeList();
            ViewData["pighouse"] = listService.GetPigHouseList();
            ViewData["Medicine"] = listService.GetMedicineList();
            ViewData["CureType"] = listService.GetCureTypeList();
            ViewData["unit"] = listService.GetUnitList();
            ViewData["pig"] = listService.GetFirstPigList();
            ViewData["Order"] = listService.GetCureTaskOrder(taskId);
            ViewBag.Title = "新建治疗信息";
            return View(newInfo);
        }
        public ActionResult EditCureInfo(CureInfo newInfo)
        {
            if (newInfo != null)
            {
                if (newInfo.UpdateCureInfo(newInfo, Request.Form["Name"]))
                {
                    ViewBag.Title = "修改成功";
                    return View("Message");
                }
            }

            ViewBag.Title = "修改失败,请重新操作";
            return View("Message");
        }
        public ActionResult EditCureInfo(string employeename, string taskNumber, int order)
        {
            if (Session["CheckFeed"] == null || !(bool) Session["EditCureInfo"] || !(bool) Session["CheckCureInfo"])
            {
                Response.Write("<script>history.go(0);</script>");
                return View("Error");
            }

            CureInfo checkCureInfo = new CureInfo().CheckCureInfo(employeename, taskNumber, order);
            if (checkCureInfo == null)
            {
                ViewBag.Title = "查看修改失败,请重新操作";
                return View("Message");
            }
            long taskId = 0;
            SelectListItem firstOrDefault = checkCureInfo.GetTaskNumberSelect(TaskTypeId).FirstOrDefault();
            if (firstOrDefault != null)
                taskId = long.Parse(firstOrDefault.Value);
            ViewData["Name"] = employeename;

            var listService = new ListService();

            ViewData["TaskNumber"] = checkCureInfo.GetTaskNumberSelect(TaskTypeId);
            ViewData["pigsty"] = listService.GetFirstPigstyList();
            ViewData["Employee"] = listService.GetEmployeeList();
            ViewData["pighouse"] = listService.GetPigHouseList();
            ViewData["Medicine"] = listService.GetMedicineList();
            ViewData["CureType"] = listService.GetCureTypeList();
            ViewData["unit"] = listService.GetUnitList();
            ViewData["pig"] = listService.GetFirstPigList();
            ViewData["Order"] = listService.GetCureTaskOrder(taskId);
            ViewBag.Title = "修改治疗信息";
            return View("NewCureInfo", checkCureInfo);
        }