public ActionResult FodderTakeConfirm(FodderTakeModel model)
 {
     var fodderTakeService = new FodderTakeService();
     var taskService = new TaskService();
     FodderTakeModel newModel = new FodderDetail().GetFodderDetail(model);
     foreach (FodderDetail actualDetail in model.ActualDetail)
     {
         var newFodderTake = new fodder_take
                                 {
                                     EmployeeId = model.ActualEmployeeId,
                                     TaskId = taskService.FindByTaskNumber(newModel.TaskNumber).Id,
                                     FodderTypeId = actualDetail.FodderTypeId,
                                     Quantity = actualDetail.Quality,
                                     UnitId = actualDetail.UnitId,
                                     Time = Convert.ToDateTime(DateTime.Now),
                                     Memo = model.Memo
                                 };
         fodderTakeService.Insert(newFodderTake);
     }
     return View();
 }
Exemplo n.º 2
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;
        }