public ActionResult CheckSalesInfo(string taskNumber) { if (Session["CheckFeed"] == null || !(bool) Session["CheckSalesInfo"]) { Response.Write("<script>history.go(0);</script>"); return View("Error"); } SalesInfo newInfo = new SalesInfo().CheckSalesInfo(taskNumber); if (newInfo != null) { ViewBag.Title = "查看销售信息"; return View(newInfo); } ViewBag.Title = "查看失败,请重新操作"; return View("Message"); }
/// <summary> /// 查看销售信息 /// </summary> /// <param name="taskNumber">任务编号</param> /// <returns></returns> public SalesInfo CheckSalesInfo(string taskNumber) { var checkSalesInfo = new SalesInfo(); var salesService = new SaleService(); checkSalesInfo.SalesInfoPigDetail = new List<Detail>(); checkSalesInfo.SalesInfoDetail = new List<SalesInfoDetail>(); 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; checkSalesInfo.TaskNumber = taskNumber; checkSalesInfo.EmployeeName = sale.employee.Name; checkSalesInfo.Meno = sale.Memo; checkSalesInfo.Customer = task.customer.Name; foreach (sale_task_quality saleTaskItem in saleTaskQualityService.FindByTaskId(task.Id)) { checkSalesInfo.SalesInfoDetail.Add(new SalesInfoDetail { PigType = saleTaskItem.pig_type.Name, Price = saleTaskItem.Price, Quantity = saleTaskItem.Quality }); } foreach (sale_pig salePigItem in sale.sale_pig) { transfer firstOrDefault = transferService.FindByPigId(salePigItem.PigId).OrderByDescending(m => m.Time).FirstOrDefault(); if (firstOrDefault != null) if (salePigItem.Time != null) checkSalesInfo.SalesInfoPigDetail.Add(new Detail { PigHouse = firstOrDefault.pigsty.pig_house.pig_house_type . Name + firstOrDefault.pigsty.pig_house.Number, Pigsty = firstOrDefault.pigsty.Number + "", Pig = salePigItem.pig.Number, DetailTime = (DateTime) salePigItem.Time }); } return checkSalesInfo; }
public ActionResult EditSalesInfo(string taskNumber) { if (Session["CheckFeed"] == null || !(bool) Session["EditSalesInfo"] || !(bool) Session["CheckSalesInfo"]) { Response.Write("<script>history.go(0);</script>"); return View("Error"); } SalesInfo newInfo = new SalesInfo().CheckSalesInfo(taskNumber); if (newInfo == null) { ViewBag.Title = "查看修改失败,请重新操作"; return View("Message"); } ViewData["pigsty"] = new ListService().GetFirstPigstyList(); ViewData["Employee"] = new ListService().GetEmployeeList(); ViewData["pighouse"] = new ListService().GetPigHouseList(); ViewData["pig"] = new ListService().GetFirstPigList(); ViewBag.Title = "修改销售信息"; return View("NewSalesInfo", newInfo); }
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); }
public ActionResult EditSalesInfo(SalesInfo updateInfo) { ViewBag.Title = updateInfo.UpdatesalesInfo(updateInfo) ? "修改成功" : "修改失败,请重新操作"; return View("Message"); }
public ActionResult SalesInfo(int pageIndex = 1) { if (Session["CheckFeed"] == null || !(bool) Session["CheckSalesInfo"]) { Response.Write("<script>history.go(0);</script>"); return View("Error"); } var salesInfo = new SalesInfo(); 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 = salesInfo.GetInfoPagedList( salesInfo.GetInfoList(salesInfo.GetSalesInfoList(), 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 = salesInfo.GetInfoPagedList( salesInfo.GetInfoList(salesInfo.GetSalesInfoList(), Session["check"] as string, Session["chooseid"] as string), pageIndex, pageSize); } else { //Session["SaleChoose"] = new ListService().GetInfoSearchList().FirstOrDefault().Value; Session["check"] = ""; Session["chooseid"] = ""; infoPagerList = salesInfo.GetInfoPagedList(salesInfo.GetSalesInfoList(), pageIndex, pageSize); } if (Request.IsAjaxRequest()) { return PartialView("UCJqInfoList", infoPagerList); } ViewData["Search"] = new ListService().GetInfoSearchList(); return View(infoPagerList); }
public ActionResult NewSalesInfo(SalesInfo newInfo) { ViewBag.Title = newInfo.CreateSalesInfo(newInfo) ? "新建成功" : "新建失败,请重新操作"; return View("Message"); }
/// <summary> /// 更新修改销售信息 /// </summary> /// <param name="updateInfo">销售信息页面类</param> /// <returns></returns> public bool UpdatesalesInfo(SalesInfo 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.SalesInfoPigDetail.Count) { salePig.PigId = long.Parse(updateInfo.SalesInfoPigDetail[count].Pig); salePig.Time = updateInfo.SalesInfoPigDetail[count].DetailTime; salePigService.Update(salePig); pigInfo.SetState(long.Parse(updateInfo.SalesInfoPigDetail[count].Pig), true); } else { salePigService = new SalePigService(); salePigService.Delete(salePigService.Find(salePig.Id)); } count++; } for (; count < updateInfo.SalesInfoPigDetail.Count; count++) { salePigService.Insert(new sale_pig { SaleId = sale.Id, PigId = long.Parse(updateInfo.SalesInfoPigDetail[count].Pig), Time = updateInfo.SalesInfoPigDetail[count].DetailTime }); pigInfo.SetState(long.Parse(updateInfo.SalesInfoPigDetail[count].Pig), true); } } return true; }
/// <summary> /// 新建销售信息 /// </summary> /// <param name="newInfo"></param> /// <returns></returns> public bool CreateSalesInfo(SalesInfo 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.SalesInfoPigDetail) { 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; }