/// <summary>
 ///     删除饲料领取信息
 /// </summary>
 /// <param name="employeename">领取人员</param>
 /// <param name="taskNumber">任务编号</param>
 /// <param name="time">领取时间</param>
 /// <returns></returns>
 public bool DelFodderTake(string employeename, string taskNumber, DateTime time)
 {
     var fodderTakeService = new FodderTakeService();
     var employeeService = new EmployeeService();
     // var taskService = new TaskService();
     employee firstOrDefault = employeeService.FindByName(employeename).FirstOrDefault();
     //var firstOrDefault = taskService.FindByTaskNumber(taskNumber);
     if (firstOrDefault == null)
     {
         return false;
     }
     for (int i = 0; i < fodderTakeService.FindByEmployeeId(firstOrDefault.Id).Count; i++)
     {
         fodder_take fodderTake = fodderTakeService.FindByEmployeeId(firstOrDefault.Id)[i];
         string num = fodderTake.task.TaskNumber;
         if (!time.Date.Equals(fodderTake.Time.Date) && num == taskNumber) continue;
         fodderTakeService = new FodderTakeService();
         fodderTakeService.Delete(fodderTakeService.Find(fodderTake.Id));
     }
     return true;
 }
Beispiel #2
0
        /// <summary>
        ///     查看喂食信息
        /// </summary>
        /// <param name="employeename">选中喂食信息的喂食人员</param>
        /// <param name="taskNumber">喂食任务编号</param>
        /// <param name="time">喂食时间</param>
        /// <returns></returns>
        public FeedInfo CheckFeedInfo(string employeename, string taskNumber, DateTime time)
        {
            var checkFeedInfo = new FeedInfo();
            var feedService = new FeedService();
            var fodderTakeService = new FodderTakeService();
            var employeeService = new EmployeeService();
            //var taskService = new TaskService();
            checkFeedInfo.TaskNumber = taskNumber;
            checkFeedInfo.EmployeeName = employeename;
            checkFeedInfo.TakeDetail = new List<FodderTakeDetail>();
            checkFeedInfo.FeedPig = new List<FeedInfoDetail>();
            employee firstOrDefault = employeeService.FindByName(employeename).FirstOrDefault();
            if (firstOrDefault != null)
                foreach (fodder_take fodderTake in fodderTakeService.FindByEmployeeId(firstOrDefault.Id))
                    //task firstOrDefault = taskService.FindByTaskNumber(taskNumber);
                    //if (firstOrDefault != null)
                    //foreach (fodder_take fodderTake in fodderTakeService.FindByTaskId(firstOrDefault.Id))
                {
                    string num = fodderTake.task.TaskNumber;
                    if (!time.Date.Equals(fodderTake.Time.Date) && num != taskNumber) continue;
                    checkFeedInfo.TakeDetail.Add(new FodderTakeDetail
                                                     {
                                                         FodderType = fodderTake.fodder_type.Name,
                                                         Quantity = fodderTake.Quantity,
                                                         Unit = fodderTake.unit.Name,
                                                         TakeTime = fodderTake.Time
                                                     });
                }

            employee orDefault = employeeService.FindByName(employeename).FirstOrDefault();
            if (orDefault != null)
                foreach (feed feedItem in feedService.FindByEmployeeId(orDefault.Id))
                {
                    string num = feedItem.task.TaskNumber;
                    if (!time.Date.Equals(feedItem.Time.Date) && num != taskNumber) continue;
                    checkFeedInfo.FeedPig.Add(new FeedInfoDetail
                                                  {
                                                      DetailTime = feedItem.Time,
                                                      PigHouse =
                                                          feedItem.pigsty.pig_house.pig_house_type.Name +
                                                          feedItem.pigsty.pig_house.Number,
                                                      Pigsty = feedItem.pigsty.Number + string.Empty
                                                      //FodderType = feedItem.fodder_type.Name,
                                                      //Quantity = feedItem.Quality,
                                                      //Unit = feedItem.unit.Name
                                                  });
                    checkFeedInfo.Meno = feedItem.Memo;
                }
            return checkFeedInfo;
        }
Beispiel #3
0
        /// <summary>
        ///     修改喂食信息
        /// </summary>
        /// <param name="feedInfo">已修改的喂食信息页面类</param>
        /// <param name="time">原时间</param>
        /// <param name="employeeName">原喂食人员名字</param>
        /// <returns></returns>
        public bool UpdateFeedInfo(FeedInfo feedInfo, DateTime time, string employeeName)
        {
            var feedService = new FeedService();
            var fodderTakeService = new FodderTakeService();
            var employeeService = new EmployeeService();
            var taskService = new TaskService();
            int i = 0, j = 0;
            employee firstOrDefault = employeeService.FindByName(employeeName).FirstOrDefault();
            //var firstOrDefault = taskService.FindByTaskNumber(feedInfo.TaskNumber);
            if (firstOrDefault != null)
            {
                foreach (fodder_take fodderTake in fodderTakeService.FindByEmployeeId(firstOrDefault.Id))
                {
                    string num = fodderTake.task.TaskNumber;
                    if (!time.Date.Equals(fodderTake.Time.Date) && num != feedInfo.TaskNumber) continue;
                    if (i < feedInfo.TakeDetail.Count)
                    {
                        fodderTake.EmployeeId = long.Parse(feedInfo.EmployeeName);
                        fodderTake.FodderTypeId = long.Parse(feedInfo.TakeDetail[i].FodderType);
                        fodderTake.Quantity = feedInfo.TakeDetail[i].Quantity;
                        fodderTake.UnitId = long.Parse(feedInfo.TakeDetail[i].Unit);
                        fodderTake.Time = feedInfo.TakeDetail[i].TakeTime;
                        fodderTakeService.Update(fodderTake);
                        i++;
                    }
                    else
                    {
                        fodderTakeService = new FodderTakeService();
                        fodderTakeService.Delete(fodderTakeService.Find(fodderTake.Id));
                    }
                }
                for (; i < feedInfo.TakeDetail.Count; i++)
                {
                    string num = feedInfo.TaskNumber ?? null;
                    long id = taskService.FindByTaskNumber(num).Id;

                    fodderTakeService.Insert(new fodder_take
                                                 {
                                                     TaskId = id,
                                                     EmployeeId = long.Parse(feedInfo.EmployeeName),
                                                     FodderTypeId = long.Parse(feedInfo.TakeDetail[i].FodderType),
                                                     Quantity = feedInfo.TakeDetail[i].Quantity,
                                                     UnitId = long.Parse(feedInfo.TakeDetail[i].Unit),
                                                     Time = feedInfo.TakeDetail[i].TakeTime
                                                 });
                }
                employee orDefault = employeeService.Find(long.Parse(feedInfo.EmployeeName));
                if (orDefault != null)
                    foreach (feed feedItem in feedService.FindByEmployeeId(orDefault.Id))
                    {
                        string num = feedItem.task.TaskNumber;
                        if (!time.Date.Equals(feedItem.Time.Date) && num != feedInfo.TaskNumber) continue;
                        if (j < feedInfo.FeedPig.Count)
                        {
                            feedItem.EmployeeId = long.Parse(feedInfo.EmployeeName);
                            //feedItem.FodderTypeId = long.Parse(feedInfo.FeedPig[j].FodderType);
                            //feedItem.Quality = feedInfo.FeedPig[j].Quantity;
                            //feedItem.UnitId = long.Parse(feedInfo.FeedPig[j].Unit);
                            feedItem.PigstyId = long.Parse(feedInfo.FeedPig[j].Pigsty);
                            feedItem.Time = feedInfo.FeedPig[j].DetailTime;
                            feedItem.Memo = feedInfo.Meno;
                            feedService.Update(feedItem);
                            j++;
                        }
                        else
                        {
                            feedService = new FeedService();
                            feedService.Delete(feedService.Find(feedItem.Id));
                        }
                    }
                for (; j < feedInfo.FeedPig.Count; j++)
                {
                    string num = feedInfo.TaskNumber ?? null;
                    long id = taskService.FindByTaskNumber(num).Id;
                    feedService.Insert(new feed
                                           {
                                               TaskId = id,
                                               EmployeeId = long.Parse(feedInfo.EmployeeName),
                                               PigstyId = long.Parse(feedInfo.FeedPig[j].Pigsty),
                                               //FodderTypeId = long.Parse(feedInfo.FeedPig[j].FodderType),
                                               //Quality = feedInfo.FeedPig[j].Quantity,
                                               //UnitId = long.Parse(feedInfo.FeedPig[j].Unit),
                                               Time = feedInfo.FeedPig[j].DetailTime,
                                               Memo = feedInfo.Meno
                                           });
                }
            }
            else
            {
                return false;
            }
            return true;
        }