public ActionResult EditFeedInfo(FeedInfo updateFeedInfo) { DateTime time = DateTime.Parse(Request.Form["SourceTime"]); string employeeName = Request.Form["Name"]; ViewBag.Title = new FeedInfo().UpdateFeedInfo(updateFeedInfo, time, employeeName) ? "修改成功" : "修改失败,请重新操作"; return View("Message"); }
public ActionResult EditFeedInfo(string employeename, string taskNumber, DateTime time) { if (Session["CheckFeed"] == null || !(bool) Session["EditFeedInfo"] || !(bool) Session["CheckFeedInfo"]) { Response.Write("<script>history.go(0);</script>"); return View("Error"); } FeedInfo checkFeedInfo = new FeedInfo().CheckFeedInfo(employeename, taskNumber, time); if (checkFeedInfo == null) { ViewBag.Title = "查看修改失败,请重新进入"; return View("Message"); } var listService = new ListService(); ViewData["pigsty"] = new ListService().GetFirstPigstyList(); ViewData["Employee"] = new ListService().GetEmployeeList(); ViewData["pighouse"] = listService.GetPigHouseList(); ViewData["FodderType"] = new ListService().GetFodderTypeList(); ViewData["unit"] = listService.GetUnitList(); ViewData["SourceTime"] = time; ViewData["Name"] = checkFeedInfo.EmployeeName; ViewBag.Title = "修改喂食信息"; return View("NewFeedInfo", checkFeedInfo); }
/// <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; }
public ActionResult CheckFeedInfo(string employeename, string taskNumber, DateTime time) { if (Session["CheckFeed"] == null || !(bool) Session["CheckFeedInfo"]) { Response.Write("<script>history.go(0);</script>"); return View("Error"); } FeedInfo checkFeedInfo = new FeedInfo().CheckFeedInfo(employeename, taskNumber, time); if (checkFeedInfo != null) { ViewBag.Title = "查看喂食信息"; return View(checkFeedInfo); } ViewBag.Title = "查看失败,请重新进入"; return View("Message"); }
public ActionResult FeedInfo(int pageIndex = 1) { if (Session["CheckFeed"] == null || !(bool) Session["CheckFeedInfo"]) { Response.Write("<script>history.go(0);</script>"); return View("Error"); } const int pageSize = 25; var feedInfo = new FeedInfo(); PagedList<Info> infoPagerList; if (Request.Form["CheckEmployee"] != null) { //Session["FeedChoose"] =Request.Form["SearchChose"]; Session["check"] = Request.Form["CheckEmployee"]; Session["chooseid"] = Request.Form["SearchChose"]; infoPagerList = feedInfo.GetInfoPagedList( feedInfo.GetInfoList(feedInfo.GetFeedInfoList(), Request.Form["CheckEmployee"], Request.Form["SearchChose"]), pageIndex, pageSize); //Session["SearchFeed"] = Request.Form["CheckEmployee"]; } else if (Session["check"] != null && Session["chooseid"] != null && Request.HttpMethod == "POST") { infoPagerList = feedInfo.GetInfoPagedList( feedInfo.GetInfoList(feedInfo.GetFeedInfoList(), Session["check"] as string, Session["chooseid"] as string), pageIndex, pageSize); } else { //Session["FeedChoose"] = new ListService().GetInfoSearchList().FirstOrDefault().Value; Session["check"] = ""; Session["chooseid"] = ""; infoPagerList = feedInfo.GetInfoPagedList(feedInfo.GetFeedInfoList(), pageIndex, pageSize); } if (Request.IsAjaxRequest()) { return PartialView("UCJqInfoList", infoPagerList); } ViewData["Search"] = new ListService().GetInfoSearchList(); return View(infoPagerList); }
public ActionResult NewFeedInfo(FeedInfo newFeedInfo) { ViewBag.Title = newFeedInfo.CreateFeedInfo(newFeedInfo) ? "新建喂食信息成功" : "新建喂食信息失败,请重新创建"; return View("Message"); }
public ActionResult NewFeedInfo() { if (Session["CheckFeed"] == null || !(bool) Session["AddFeedInfo"] || !(bool) Session["CheckFeedInfo"]) { Response.Write("<script>history.go(0);</script>"); return View("Error"); } var newInfo = new FeedInfo(); 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(""); } ViewData["TaskNumber"] = newInfo.GetTaskNumberSelect(TaskTypeId); ViewData["pigsty"] = new ListService().GetFirstPigstyList(); ViewData["Employee"] = new ListService().GetEmployeeList(); ViewData["pighouse"] = new ListService().GetPigHouseList(); ViewData["FodderType"] = new ListService().GetFodderTypeList(); ViewData["unit"] = new ListService().GetUnitList(); ViewBag.Title = "新建喂食信息"; return View(newInfo); }
/// <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; }
/// <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; }