Пример #1
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;
        }
        public ActionResult CheckEliminateInfo(string taskNumber)
        {
            if (Session["CheckEliminateInfo"] == null || !(bool)Session["CheckEliminateInfo"])
            {
                Response.Write("<script>history.go(0);</script>");
                return View("Error");
            }

            EliminateInfo newInfo = new EliminateInfo().CheckEliminateInfo(taskNumber);
            if (newInfo != null)
            {
                ViewBag.Title = "查看淘汰信息";
                return View(newInfo);
            }
            ViewBag.Title = "查看失败,请重新操作";
            return View("Message");
        }
        public ActionResult EditEliminateInfo(string taskNumber)
        {
            if (Session["CheckEliminateInfo"] == null || !(bool)Session["EditEliminateInfo"] || !(bool)Session["CheckEliminateInfo"])
            {
                Response.Write("<script>history.go(0);</script>");
                return View("Error");
            }

            EliminateInfo newInfo = new EliminateInfo().CheckEliminateInfo(taskNumber);
            if (newInfo == null)
            {
                ViewBag.Title = "查看修改失败,请重新操作";
                return View("Message");
            }
            var pighouse= new ListService().GetPigHouseList();
            var pigsty = new ListService().FindPigstyListByPigHouseId(pighouse.FirstOrDefault().Value);
            ViewData["pighouse"] = pighouse;
            ViewData["pigsty"] = pigsty;
            ViewData["Employee"] = new ListService().GetEmployeeList();
            ViewData["pig"] = new ListService().FindPigListByPigstyId(pigsty.FirstOrDefault().Value);
            ViewBag.Title = "修改淘汰信息";
            return View("NewEliminateInfo", newInfo);
        }
Пример #4
0
        /// <summary>
        ///     查看淘汰信息
        /// </summary>
        /// <param name="taskNumber">任务编号</param>
        /// <returns></returns>
        public EliminateInfo CheckEliminateInfo(string taskNumber)
        {
            var checkEliminateInfo = new EliminateInfo();
            var salesService = new SaleService();
            checkEliminateInfo.EliminateInfoPigDetail = new List<Detail>();
            checkEliminateInfo.EliminateInfoPigDetail = new List<Detail>();
            var saleTaskQualityService = new SaleTaskQualityService();
            var transferService = new TransferService();
            task task = new TaskService().FindByTaskNumber(taskNumber);
            if (task == null) return null;
            sale sale = salesService.FindByTaskId(task.Id).FirstOrDefault();
            if (sale == null) return null;
            checkEliminateInfo.TaskNumber = taskNumber;
            checkEliminateInfo.EmployeeName = sale.employee.Name;
            checkEliminateInfo.Meno = sale.Memo;

            foreach (sale_pig EliminatePigItem in sale.sale_pig)
            {
                transfer firstOrDefault =
                    transferService.FindByPigId(EliminatePigItem.PigId).OrderByDescending(m => m.Time).FirstOrDefault();
                if (firstOrDefault != null)
                    if (EliminatePigItem.Time != null)
                        checkEliminateInfo.EliminateInfoPigDetail.Add(new Detail
                        {
                            PigHouse =
                                firstOrDefault.pigsty.pig_house.pig_house_type
                                              .
                                               Name
                                + firstOrDefault.pigsty.pig_house.Number,
                            Pigsty = firstOrDefault.pigsty.Number + "",
                            Pig = EliminatePigItem.pig.Number,
                            DetailTime = (DateTime)EliminatePigItem.Time
                        });
            }
            return checkEliminateInfo;
        }
Пример #5
0
        /// <summary>
        ///     更新修改淘汰信息
        /// </summary>
        /// <param name="updateInfo">淘汰信息页面类</param>
        /// <returns></returns>
        public bool UpdateEliminateInfo(EliminateInfo updateInfo)
        {
            var salesService = new SaleService();
            var salePigService = new SalePigService();
            task task = new TaskService().FindByTaskNumber(updateInfo.TaskNumber);
            var pigInfo = new PigInfo();
            int count = 0;
            if (task == null) return false;
            foreach (sale sale in salesService.FindByTaskId(task.Id))
            {
                sale.EmployeeId = long.Parse(updateInfo.EmployeeName);
                sale.Memo = updateInfo.Meno;
                salesService.Update(sale);
                List<sale_pig> saleList = salePigService.FindBySaleId(sale.Id);
                foreach (sale_pig salePig in saleList)
                {
                    pigInfo.SetState(salePig.PigId, false);
                    if (count < updateInfo.EliminateInfoPigDetail.Count)
                    {
                        salePig.PigId =
                            long.Parse(updateInfo.EliminateInfoPigDetail[count].Pig);
                        salePig.Time = updateInfo.EliminateInfoPigDetail[count].DetailTime;
                        salePigService.Update(salePig);
                        pigInfo.SetState(long.Parse(updateInfo.EliminateInfoPigDetail[count].Pig), true);
                    }
                    else
                    {
                        salePigService = new SalePigService();
                        salePigService.Delete(salePigService.Find(salePig.Id));
                    }
                    count++;
                }
                for (; count < updateInfo.EliminateInfoPigDetail.Count; count++)
                {
                    salePigService.Insert(new sale_pig
                    {
                        SaleId = sale.Id,
                        PigId = long.Parse(updateInfo.EliminateInfoPigDetail[count].Pig),
                        Time = updateInfo.EliminateInfoPigDetail[count].DetailTime
                    });
                    pigInfo.SetState(long.Parse(updateInfo.EliminateInfoPigDetail[count].Pig), true);
                }
            }

            return true;
        }
        public ActionResult EliminateInfo(int pageIndex = 1)
        {
            if (Session["CheckEliminateInfo"] == null || !(bool)Session["CheckEliminateInfo"])
            {
                Response.Write("<script>history.go(0);</script>");
                return View("Error");
            }

            var eliminateInfo = new EliminateInfo();
            const int pageSize = 25;

            PagedList<Info> infoPagerList;
            if (Request.Form["CheckEmployee"] != null)
            {
                // Session["SaleChoose"] = Request.Form["SearchChose"];
                Session["check"] = Request.Form["CheckEmployee"];
                Session["chooseid"] = Request.Form["SearchChose"];
                infoPagerList =
                    eliminateInfo.GetInfoPagedList(
                        eliminateInfo.GetInfoList(eliminateInfo.GetEliminateInfoList(), Request.Form["CheckEmployee"],
                                              Request.Form["SearchChose"]),
                        pageIndex, pageSize);
                //Session["SearchSales"] = Request.Form["CheckEmployee"];
            }
            else if (Session["check"] != null && Session["chooseid"] != null && Request.HttpMethod == "POST")
            {
                infoPagerList =
                    eliminateInfo.GetInfoPagedList(
                        eliminateInfo.GetInfoList(eliminateInfo.GetEliminateInfoList(), Session["check"] as string,
                                              Session["chooseid"] as string),
                        pageIndex, pageSize);
            }
            else
            {
                //Session["SaleChoose"] = new ListService().GetInfoSearchList().FirstOrDefault().Value;
                Session["check"] = "";
                Session["chooseid"] = "";
                infoPagerList = eliminateInfo.GetInfoPagedList(eliminateInfo.GetEliminateInfoList(), pageIndex, pageSize);
            }

            if (Request.IsAjaxRequest())
            {
                return PartialView("UCJqInfoList", infoPagerList);
            }

            ViewData["Search"] = new ListService().GetInfoSearchList();
            return View(infoPagerList);
        }
 public ActionResult EditEliminateInfo(EliminateInfo updateInfo)
 {
     ViewBag.Title = updateInfo.UpdateEliminateInfo(updateInfo) ? "修改成功" : "修改失败,请重新操作";
     return View("Message");
 }
 public ActionResult NewEliminateInfo(EliminateInfo newInfo)
 {
     ViewBag.Title = newInfo.CreateEliminateInfo(newInfo) ? "新建成功" : "新建失败,请重新操作";
     return View("Message");
 }
        public ActionResult NewEliminateInfo()
        {
            if (Session["CheckEliminateInfo"] == null || !(bool)Session["AddEliminateInfo"] || !(bool)Session["CheckEliminateInfo"])
            {
                Response.Write("<script>history.go(0);</script>");
                return View("Error");
            }

            var newInfo = new EliminateInfo();
            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("");
            }

            SelectListItem firstOrDefault = newInfo.GetTaskNumberSelect(TaskTypeId).FirstOrDefault();
            var pighouse = new ListService().GetPigHouseList();
            var pigsty = new ListService().FindPigstyListByPigHouseId(pighouse.FirstOrDefault().Value);

            ViewData["TaskNumber"] = newInfo.GetTaskNumberSelect(TaskTypeId);
            ViewData["Employee"] = new ListService().GetEmployeeList();
            ViewData["pighouse"] = pighouse;
            ViewData["pigsty"] = pigsty;
            ViewData["pig"] = new ListService().FindPigListByPigstyId(pigsty.FirstOrDefault().Value);
            ViewBag.Title = "新建淘汰信息";
            return View(newInfo);
        }