예제 #1
0
 /// <summary>
 ///     新建防疫信息
 /// </summary>
 /// <param name="newInfo"></param>
 /// <returns></returns>
 public bool CreateTransferPigstyInfo(PreventionInfo newInfo)
 {
     if (newInfo == null) return false;
     var preventionService = new PreventionService();
     var taskStatusTypeService = new TaskStatusTypeService();
     var taskService = new TaskService();
     foreach (Detail newInfoItem in newInfo.PreventionInfoDetail)
     {
         preventionService.Insert(new prevention
                                      {
                                          TaskId = long.Parse(newInfo.TaskNumber),
                                          EmployeeId = long.Parse(newInfo.EmployeeName),
                                          PigstyId = long.Parse(newInfoItem.Pigsty),
                                          Time = newInfoItem.DetailTime,
                                          Memo = newInfo.Meno
                                      });
     }
     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;
 }
예제 #2
0
        /// <summary>
        ///     根据id返回是否有喂饲任务
        /// </summary>
        /// <param name="employeeId">人员id</param>
        /// <returns>返回是否有喂饲任务</returns>
        public string GetFeedTaskById(long employeeId)
        {
            var tasktypeService = new TaskTypeService();
            var taskEmployeeService = new TaskEmployeeService();
            var taskIntervalCycleService = new TaskIntervalCycleService();
            int taskflag = 0;

            var taskService = new TaskService();
            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<task_interval_cycle> taskInterval = taskIntervalCycleService.FindByTaskId(task.TaskId);
                    foreach (task_interval_cycle taskinterval in taskInterval)
                    {
                        for (int i = 0; i < 1000; i++)
                        {
                            //根据任务的循环时间匹配是否有当天的任务
                            if (
                                taskinterval.FirstExecuteDate.AddDays(Convert.ToDouble(taskinterval.CycleDays * i))
                                            .
                                             ToShortDateString() == DateTime.Now.ToShortDateString())
                            {
                                taskflag = 1; //标志
                                break;
                            }
                        }
                    }
                }
            }
            if (taskflag == 0)
            {
                return "今天该员工没有喂饲任务";
            }
            return "";
        }
예제 #3
0
        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;
        }
예제 #4
0
        /// <summary>
        ///     新建淘汰信息
        /// </summary>
        /// <param name="newInfo"></param>
        /// <returns></returns>
        public bool CreateEliminateInfo(EliminateInfo newInfo)
        {
            var salesService = new SaleService();
            var taskStatusTypeService = new TaskStatusTypeService();
            var taskService = new TaskService();
            var pigService = new PigService();
            var pigInfo = new PigInfo();
            var newSale = new sale
            {
                TaskId = long.Parse(newInfo.TaskNumber),
                EmployeeId = long.Parse(newInfo.EmployeeName),
                SaleType = "淘汰",
                Memo = newInfo.Meno
            };

            foreach (Detail salesPigInfo in newInfo.EliminateInfoPigDetail)
            {
                newSale.sale_pig.Add(new sale_pig
                {
                    Time = salesPigInfo.DetailTime,
                    PigId = long.Parse(salesPigInfo.Pig)
                });
                pigInfo.SetState(long.Parse(salesPigInfo.Pig), true);
            }
            salesService.Insert(newSale);
            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;
        }
예제 #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";
 }
예제 #6
0
        /// <summary>
        ///     新建转栏信息
        /// </summary>
        /// <param name="newTransferPigstyInfo">转栏信息页面类</param>
        /// <returns>是否成功</returns>
        public bool CreateTransferPigstyInfo(TransferPigstyInfo newTransferPigstyInfo)
        {
            if (newTransferPigstyInfo == null) return false;
            var transferService = new TransferService();
            var taskStatusTypeService = new TaskStatusTypeService();
            var taskService = new TaskService();
            foreach (TransferPigstyInfoDetail transferPigstyInfoDetail in newTransferPigstyInfo.TransferPigstyInfoDetail
                )
            {
                transferService.Insert(new transfer
                                           {
                                               TaskId = long.Parse(newTransferPigstyInfo.TaskNumber),
                                               PigstyId = long.Parse(transferPigstyInfoDetail.TargetPigsty),
                                               PigId = long.Parse(transferPigstyInfoDetail.Pig),
                                               Time = transferPigstyInfoDetail.TransferPigstyTime,
                                               Memo = newTransferPigstyInfo.Meno
                                           });
            }
            task_status_type taskStatusType = taskStatusTypeService.FindByName("已完成");
            task task = taskService.Find(long.Parse(newTransferPigstyInfo.TaskNumber));
            if (taskStatusType != null && task != null)
            {
                task.TaskStatusId = taskStatusType.Id;
                taskService.Update(task);
            }

            return true;
        }
예제 #7
0
        /// <summary>
        ///     转栏息管理列表
        /// </summary>
        /// <returns></returns>
        public IEnumerable<Info> GetTransferPigstyInfoList()
        {
            var transferService = new TransferService();
            var taskService = new TaskService();
            var taskEmployeeService = new TaskEmployeeService();
            var transferInfoList = new List<Info>();
            IOrderedEnumerable<transfer> transferServiceAll = transferService.FindAll().OrderByDescending(m => m.Time);
            long taskId = 0;
            foreach (transfer transferInfoitem in transferServiceAll)
            {
                if (taskId == transferInfoitem.TaskId || transferInfoitem.task.TaskTypeId == 7) continue;
                transferInfoList.Add(new Info
                                         {
                                             TaskNumber = taskService.Find(transferInfoitem.TaskId).TaskNumber,
                                             EmployeeName =
                                                 taskEmployeeService.GetEmployeeNames(
                                                     taskService.Find(transferInfoitem.TaskId).Id),
                                             Time = transferInfoitem.Time,
                                             Meno = transferInfoitem.Memo
                                         });
                taskId = transferInfoitem.TaskId;
            }

            return transferInfoList;
        }
예제 #8
0
        /// <summary>
        ///     新建巡查信息
        /// </summary>
        /// <param name="newInfo">巡查页面类</param>
        /// <returns></returns>
        public bool CreateInspectInfo(InspectInfo newInfo)
        {
            if (newInfo == null) return false;
            var inspectionService = new InspectionService();
            var taskStatusTypeService = new TaskStatusTypeService();
            var taskService = new TaskService();
            Dictionary<long, Dictionary<long, long>> pigstyAndexception = SortPigstyAndexception(newInfo);
            foreach (var inspectDetail in pigstyAndexception)
            {
                InspectDetail newInfoDetail =
                    newInfo.InspectDetail.FirstOrDefault(m => m.PigHouse.Equals(inspectDetail.Key + ""));
                if (newInfoDetail == null) continue;
                var inspection = new inspection
                                     {
                                         TaskId = long.Parse(newInfo.TaskNumber),
                                         EmployeeId = long.Parse(newInfo.EmployeeName),
                                         PigHouseId = inspectDetail.Key,
                                         Time = newInfoDetail.DetailTime,
                                         Memo = newInfo.Meno
                                     };

                foreach (var pigsty in inspectDetail.Value)
                {
                    inspection.inspection_exception.Add(new inspection_exception
                                                            {
                                                                PigstyId = pigsty.Key,
                                                                ExceptionTypeId = pigsty.Value
                                                            });
                }

                inspectionService.Insert(inspection);
            }
            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;
        }
예제 #9
0
        /// <summary>
        ///     添加生猪
        /// </summary>
        /// <param name="newPigInfo"></param>
        /// <returns></returns>
        public bool CreatePigInfo(PigInfo newPigInfo)
        {
            var pigService = new PigService();
            var transferService = new TransferService();
            var taskStatusTypeService = new TaskStatusTypeService();
            var taskService = new TaskService();
            if (newPigInfo == null) return false;
            long? earNumber = null,
                  femaleParentId = null,
                  mostLikelyMaleParentId = null,
                  secondLikelyMaleParentId = null,
                  thirdLikelyMaleParentId = null;
            if (newPigInfo.EarNumber != null)
                earNumber = long.Parse(newPigInfo.EarNumber);

            if (newPigInfo.FemaleParentNum != null)
                femaleParentId = long.Parse(newPigInfo.FemaleParentNum);
            if (newPigInfo.MostLikelyMaleParentNum != null)
                mostLikelyMaleParentId = long.Parse(newPigInfo.MostLikelyMaleParentNum);
            if (newPigInfo.SecondLikelyMaleParentNum != null)
                secondLikelyMaleParentId = long.Parse(newPigInfo.SecondLikelyMaleParentNum);
            if (newPigInfo.ThirdLikelyMaleParentNum != null)
                thirdLikelyMaleParentId = long.Parse(newPigInfo.ThirdLikelyMaleParentNum);
            if (newPigInfo.TaskNumber == null) return false;
            pigService.Insert(new pig
                                  {
                                      Number = newPigInfo.Number,
                                      EarNumber = earNumber,
                                      Birthday = newPigInfo.Birthday,
                                      RFID = newPigInfo.Rfid,
                                      PigTypeId = long.Parse(newPigInfo.PigType),
                                      FemaleParentId = femaleParentId,
                                      MostLikelyMaleParentId = mostLikelyMaleParentId,
                                      SecondLikelyMaleParentId = secondLikelyMaleParentId,
                                      ThirdLikelyMaleParentId = thirdLikelyMaleParentId,
                                      Memo = newPigInfo.Memo,
                                      State = true
                                  });
            if (newPigInfo.TaskNumber != null)
            {
                transferService.Insert(new transfer
                                           {
                                               TaskId = long.Parse(newPigInfo.TaskNumber),
                                               PigId = pigService.FindByNumber(newPigInfo.Number).Id,
                                               PigstyId = long.Parse(newPigInfo.Pigsty),
                                               Time = newPigInfo.TransferPigstyTime
                                           });
            }

            pigService = new PigService();

            task_status_type taskStatusType = taskStatusTypeService.FindByName("已完成");
            task task = taskService.Find(long.Parse(newPigInfo.TaskNumber));
            if (taskStatusType != null && task != null)
            {
                task.TaskStatusId = taskStatusType.Id;
                taskService.Update(task);
            }
            return true;
        }
예제 #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;
 }
예제 #11
0
 /// <summary>
 ///     巡查信息列表
 /// </summary>
 /// <returns></returns>
 public IEnumerable<Info> GetInspectInfoList()
 {
     var inspectInfoList = new List<Info>();
     var inspectionService = new InspectionService();
     var taskService = new TaskService();
     long taskid = 0, employeeId = 0;
     var dateTime = new DateTime();
     IOrderedEnumerable<inspection> inspectionAll = inspectionService.FindAll().OrderByDescending(m => m.Time);
     foreach (inspection inspection in inspectionAll)
     {
         if (taskid == inspection.TaskId && employeeId == inspection.EmployeeId &&
             dateTime.Date.Equals(inspection.Time.Date)) continue;
         inspectInfoList.Add(new Info
                                 {
                                     TaskNumber = taskService.Find(inspection.TaskId).TaskNumber,
                                     EmployeeName = inspection.employee.Name,
                                     Time = inspection.Time,
                                     Meno = inspection.Memo
                                 });
         taskid = inspection.TaskId;
         employeeId = inspection.EmployeeId;
         dateTime = inspection.Time;
     }
     return inspectInfoList;
 }
예제 #12
0
        public FodderTakeModel GetFodderDetail(FodderTakeModel model)
        {
            //初始化
            var newFodderDetails = new List<FodderDetail>();
            //var newFodderDetail=new FodderDetail();
            //newFodderDetails.Add(newFodderDetail);
            model.TaskDetail = newFodderDetails;

            var pigstyService = new PigstyService();
            var tasktypeService = new TaskTypeService();
            var taskEmployeeService = new TaskEmployeeService();
            var taskpigstyservice = new TaskPigstyService();
            var feedTaskQualityService = new FeedTaskQualityService();
            var taskIntervalCycleService = new TaskIntervalCycleService();
            int taskflag = 0;
            long employeeTaskId = 0;
            var taskService = new TaskService();
            List<task_employee> alltask = taskEmployeeService.FindByEmployeeId(model.ActualEmployeeId);
            //根据任务id找到任务类型,若是当天的喂饲任务,记录taskid
            foreach (task_employee task in alltask)
            {
                long tasktypeid = taskService.Find(task.TaskId).TaskTypeId;
                string tasktype = tasktypeService.Find(tasktypeid).Name;
                if (tasktype == "喂饲")
                {
                    List<task_interval_cycle> taskInterval = taskIntervalCycleService.FindByTaskId(task.TaskId);
                    foreach (task_interval_cycle taskinterval in taskInterval)
                    {
                        for (int i = 0; i < 1000; i++)
                        {
                            //根据任务的循环时间匹配是否有当天的任务
                            if (
                                taskinterval.FirstExecuteDate.AddDays(Convert.ToDouble(taskinterval.CycleDays*i))
                                            .
                                             ToShortDateString() == DateTime.Now.ToShortDateString())
                            {
                                taskflag = 1; //标志
                                employeeTaskId = task.TaskId;
                                break;
                            }
                        }
                    }
                }
            }
            if (taskflag == 1)
            {
                List<task_pigsty> taskPisties = taskpigstyservice.FindByTaskId(employeeTaskId);

                //遍历该任务的所有的猪栏,并将其对应的饲料添加到model.TaskDetail中
                int i;
                foreach (task_pigsty taskPigsty in taskPisties)
                {
                    List<feed_task_quality> taskQuality = feedTaskQualityService.FindByFeedTaskPigstyId(taskPigsty.Id);
                    if (model.TaskDetail.Count == 0)
                    {
                        var fodderDetail = new FodderDetail
                                               {
                                                   FodderTypeName = taskQuality[0].fodder_type.Name,
                                                   //Quality = taskQuality[0].Quality * pigstyService.GetPignumbers(Convert.ToInt64(taskPigsty.PigstyId)),
                                                   //UnitName = taskQuality[0].unit.Name,
                                                   FodderTypeId = taskQuality[0].FodderTypeId,
                                                   //UnitId = taskQuality[0].UnitId
                                               };
                        model.TaskDetail.Add(fodderDetail);
                    }
                    else
                    {
                        int knt = 0; //判断该猪栏的饲料是否跟
                        for (i = 0; i < model.TaskDetail.Count; i++)
                        {
                            if (model.TaskDetail[i].FodderTypeName == taskQuality[0].fodder_type.Name)
                            {
                                //model.TaskDetail[i].Quality = taskQuality[0].Quality*
                                //                              pigstyService.GetPignumbers(
                                //                                  Convert.ToInt64(taskPigsty.PigstyId)) +
                                //                              model.TaskDetail[i].Quality;
                                knt = 1;
                            }
                        }
                        if (knt == 0)
                        {
                            var fodderDetail = new FodderDetail
                                                   {
                                                       FodderTypeName = taskQuality[0].fodder_type.Name,
                                                       //Quality = taskQuality[0].Quality * pigstyService.GetPignumbers(Convert.ToInt64(taskPigsty.PigstyId)),
                                                       //UnitName = taskQuality[0].unit.Name,
                                                       FodderTypeId = taskQuality[0].FodderTypeId,
                                                       //UnitId = taskQuality[0].UnitId
                                                   };
                            model.TaskDetail.Add(fodderDetail);
                        }
                    }
                }
                model.TaskNumber = taskService.Find(employeeTaskId).TaskNumber;
                //任务的全部人员
                List<task_employee> allemployees = taskEmployeeService.FindByTaskId(employeeTaskId);
                string reAllEmployeeName = "";
                for (i = 0; i < allemployees.Count - 1; i++)
                {
                    reAllEmployeeName = reAllEmployeeName + allemployees[i].employee.Name + ",";
                }
                reAllEmployeeName = reAllEmployeeName + allemployees[i].employee.Name;
                model.TaskEmployeeName = reAllEmployeeName;
            }
            return model;
        }
예제 #13
0
        public ActionResult NewSalesInfo()
        {
            if (Session["CheckFeed"] == null || !(bool) Session["AddSalesInfo"] || !(bool) Session["CheckSalesInfo"])
            {
                Response.Write("<script>history.go(0);</script>");
                return View("Error");
            }

            var newInfo = new SalesInfo();
            var taskService = new TaskService();
            if (!newInfo.GetTaskNumberSelect(TaskTypeId).Any())
            {
                const string returnstring = "销售任务的生产信息已全部导入";
                Response.Write("<script language='JavaScript'>alert('" + returnstring + ".');history.go(-1);</script>");
                return Content("");
            }
            if (!newInfo.GetFirstSalesInfoDetail(TaskTypeId))
            {
                newInfo.SalesInfoDetail = new List<SalesInfoDetail> {new SalesInfoDetail()};
            }
            SelectListItem firstOrDefault = newInfo.GetTaskNumberSelect(TaskTypeId).FirstOrDefault();
            if (firstOrDefault != null)
                newInfo.Customer =
                    taskService.Find(long.Parse(firstOrDefault.Value)).customer.Name;
            ViewData["TaskNumber"] = newInfo.GetTaskNumberSelect(TaskTypeId);
            ViewData["pigsty"] = new ListService().GetFirstPigstyList();
            ViewData["Employee"] = new ListService().GetEmployeeList();
            ViewData["pighouse"] = new ListService().GetPigHouseList();
            ViewData["pig"] = new ListService().GetFirstPigList();
            ViewBag.Title = "新建销售信息";
            return View(newInfo);
        }
예제 #14
0
 //ajax返回客户信息
 public string ShowCustomer(string taskNum)
 {
     var taskService = new TaskService();
     string customer = taskService.Find(long.Parse(taskNum)).customer.Name;
     return customer;
 }
예제 #15
0
        /// <summary>
        ///     喂食信息管理列表
        /// </summary>
        /// <returns></returns>
        public IEnumerable<Info> GetFeedInfoList()
        {
            var feedService = new FeedService();
            var taskService = new TaskService();
            var employeeService = new EmployeeService();
            string taskNumber = "";
            task task = null;
            var feedInfoList = new List<Info>();
            var employeeIds = new HashSet<long>();
            foreach (feed employeeId in feedService.FindAll())
            {
                employeeIds.Add(employeeId.EmployeeId);
            }

            foreach (long employeeId in employeeIds)
            {
                feed item = feedService.FindByEmployeeId(employeeId).OrderByDescending(m => m.Time).FirstOrDefault();
                if (item != null) task = taskService.Find(item.TaskId);
                taskNumber = task != null ? task.TaskNumber : "";

                if (item != null)
                {
                    feedInfoList.Add(new Info
                                         {
                                             TaskNumber = taskNumber,
                                             EmployeeName =
                                                 employeeService.Find(
                                                     item.
                                                         EmployeeId).Name,
                                             Time = item.Time,
                                             Meno = item.Memo
                                         });
                    foreach (
                        feed feedInfoitem in feedService.FindByEmployeeId(employeeId).OrderByDescending(m => m.Time))
                    {
                        task = taskService.Find(feedInfoitem.TaskId);
                        taskNumber = task != null ? task.TaskNumber : "";

                        if (item.Time.Date.Equals(feedInfoitem.Time.Date) && item.TaskId == feedInfoitem.TaskId)
                            continue;
                        feedInfoList.Add(new Info
                                             {
                                                 TaskNumber = taskNumber,
                                                 EmployeeName =
                                                     employeeService.Find(
                                                         feedInfoitem.
                                                             EmployeeId).Name,
                                                 Time = feedInfoitem.Time,
                                                 Meno = feedInfoitem.Memo
                                             });
                        item = feedInfoitem;
                    }
                }
            }

            return feedInfoList.OrderByDescending(m => m.Time);
        }
예제 #16
0
        /// <summary>
        ///     新建喂食信息
        /// </summary>
        /// <param name="newFeedInfo"></param>
        /// y
        /// <returns></returns>
        public bool CreateFeedInfo(FeedInfo newFeedInfo)
        {
            var employeeService = new EmployeeService();
            var feedService = new FeedService();
            var fodderTakeService = new FodderTakeService();
            var taskService = new TaskService();
            var fodderTypeService = new FodderTypeService();
            var unitService = new UnitService();
            var taskStatusTypeService = new TaskStatusTypeService();
            long taskId = long.Parse(TaskNumber);
            foreach (FodderTakeDetail takedetail in newFeedInfo.TakeDetail)
            {
                employee firstOrDefault = employeeService.Find(long.Parse(newFeedInfo.EmployeeName));
                if (firstOrDefault != null)
                {
                    var take = new fodder_take
                                   {
                                       TaskId = taskId,
                                       EmployeeId = firstOrDefault.Id,
                                       //FodderTypeId = fodderTypeService.Find(long.Parse(takedetail.FodderType)).Id,
                                       //Quantity = takedetail.Quantity,
                                       //UnitId = unitService.Find(long.Parse(takedetail.Unit)).Id,
                                       Time = takedetail.TakeTime
                                   };
                    fodderTakeService.Insert(take);
                }
            }

            foreach (FeedInfoDetail feedPigDetail in FeedPig)
            {
                var feedinfo = new feed {TaskId = taskId};
                employee firstOrDefault = employeeService.Find(long.Parse(newFeedInfo.EmployeeName));
                if (firstOrDefault != null)
                    feedinfo.EmployeeId = firstOrDefault.Id;
                feedinfo.PigstyId = long.Parse(feedPigDetail.Pigsty);
                //feedinfo.FodderTypeId = long.Parse(feedPigDetail.FodderType);
                //feedinfo.Quality = feedPigDetail.Quantity;
                //feedinfo.UnitId = long.Parse(feedPigDetail.Unit);
                feedinfo.Memo = newFeedInfo.Meno;
                feedinfo.Time = feedPigDetail.DetailTime;
                feedService.Insert(feedinfo);
            }
            task_status_type taskStatusType = taskStatusTypeService.FindByName("正在进行");
            task task = taskService.Find(long.Parse(newFeedInfo.TaskNumber));
            if (taskStatusType != null && task != null)
            {
                task.TaskStatusId = taskStatusType.Id;
                taskService.Update(task);
            }

            return true;
        }