using Estsh.Core.Model.Result; using Microsoft.AspNetCore.Mvc; using Estsh.Core.Models; using Estsh.Core.Controllers; using System.Collections; using Estsh.Core.Util; using Estsh.Core.Services.IServices; namespace Estsh.Core.Web.Controllers { public class CarManagerController : BaseController { private ICarManagerService service; public CarManagerController(ICarManagerService _service) { service = _service; } public ActionResult Index() { return View(); } /// /// 获取菜单管理列表数据 /// /// /// /// /// /// public ActionResult getCarManagerListByPage(string supplierName, string txtStartTime, string txtEnhtime, Pager pager, String direction, String sort, string enabled = "Y") { int factoryId = CurrentEmp.FactoryId; Hashtable result = new Hashtable(); result.Add("pager.pageNo", pager.pageNo); //Hashtable dataHt = new Hashtable(); Hashtable dataHt = this.service.getCarManagerListByPage(supplierName, txtStartTime, txtEnhtime, enabled, factoryId, pager, direction, sort); result.Add("rows", dataHt["dataList"]); result.Add("pager.totalRows", dataHt["totalCount"]); result.Add("sort", sort); result.Add("direction", direction); return Json(result); } //public ActionResult getSelectSupplier() //{ // Hashtable result = new Hashtable(); // List menuList = this.service.getSelectSupplier(); // result.Add("list", menuList); // return Json(result); //} /// /// 编辑菜单 /// /// /// public ActionResult editOrder(String orderNo) { if (!string.IsNullOrEmpty(orderNo)) { Hashtable ht = this.service.getCarManagerDetail(orderNo); ViewData.Add("editType", "edit"); ViewData.Add("orderNo", ht["orderNo"]); ViewData.Add("carNo", ht["carNo"]); ViewData.Add("carDesc", ht["carDesc"]); ViewData.Add("supplierCode", ht["supplierCode"]); ViewData.Add("supplierName", ht["supplierName"]); ViewData.Add("planArriveTime", ht["planArriveTime"]); ViewData.Add("carDriver", ht["carDriver"]); ViewData.Add("passageway", ht["passageway"]); ViewData.Add("enabled", ht["enabled"]); } else { ViewData.Add("editType", "new"); } return View("EditOrder"); } public ActionResult addOutDoor(String orderNo) { if (!string.IsNullOrEmpty(orderNo)) { Hashtable ht = this.service.getCarArriveInfo(orderNo); ViewData.Add("editType", "edit"); ViewData.Add("orderNo", ht["orderNo"]); ViewData.Add("Operator", ht["Operator"]); ViewData.Add("outDep", ht["outDep"] == null ? "物流管理科" : ht["outDep"]); ViewData.Add("remarks", ht["remarks"]); ViewData.Add("CarNo2", ht["CarNo2"]); ViewData.Add("ascription", ht["ascription"]); ViewData.Add("material", ht["material"]); ViewData.Add("reason", ht["reason"]); ViewData.Add("outDateTime", ht["outDateTime"]); ViewData.Add("desc1", ht["desc1"]); ViewData.Add("desc2", ht["desc2"]); ViewData.Add("desc3", ht["desc3"]); ViewData.Add("desc4", ht["desc4"]); ViewData.Add("desc5", ht["desc5"]); ViewData.Add("desc6", ht["desc6"]); ViewData.Add("desc7", ht["desc7"]); ViewData.Add("desc8", ht["desc8"]); ViewData.Add("desc9", ht["desc9"]); ViewData.Add("outOperator", ht["outOperator"]); } else { ViewData.Add("editType", "new"); } return View("addOutDoor"); } public ActionResult onPrintOutPlant(String ids) { int delCount = 0; try { delCount = this.service.PrintOutPlant(ids, CurrentEmp.EmpId); } catch (Exception e) { delCount = -1; } Hashtable result = new Hashtable(); result.Add("status", delCount); return Json(result); } public ActionResult oninPlant(String ids) { int delCount = 0; try { delCount = this.service.ChangeInPlantStatus(ids, CurrentEmp.EmpId); } catch (Exception e) { delCount = -1; } Hashtable result = new Hashtable(); result.Add("status", delCount); return Json(result); } public ActionResult onOutPlant(String ids) { int delCount = 0; try { delCount = this.service.ChangeOutPlantStatus(ids, CurrentEmp.EmpId); } catch (Exception e) { delCount = -1; } Hashtable result = new Hashtable(); result.Add("status", delCount); return Json(result); } public ActionResult onWorking(String ids) { int delCount = 0; try { delCount = this.service.ChangeWorkingStatus(ids, CurrentEmp.EmpId); } catch (Exception e) { delCount = -1; } Hashtable result = new Hashtable(); result.Add("status", delCount); return Json(result); } /// /// 启用 /// /// /// public ActionResult onEnable(String ids) { int delCount = 0; try { delCount = this.service.EnableCarArrive(ids, CurrentEmp.EmpId); } catch (Exception e) { delCount = -1; } Hashtable result = new Hashtable(); result.Add("status", delCount); return Json(result); } /// /// 禁用 /// /// /// public ActionResult onDisable(String ids) { int delCount = 0; try { delCount = this.service.DisableCarArrive(ids, CurrentEmp.EmpId); } catch (Exception e) { delCount = -1; } Hashtable result = new Hashtable(); result.Add("status", delCount); return Json(result); } /// /// 保存菜单数据 /// /// public ActionResult saveCarManager() { String editType = Request.Form["editType"].ToString(); String orderNo = Request.Form["orderNo"].ToString(); String carNo = Request.Form["carNo"].ToString(); String carDesc = Request.Form["carDesc"].ToString(); String carDriver = Request.Form["carDriver"].ToString(); String passageway = Request.Form["passageway"].ToString(); String supplierName = Request.Form["supplierName"].ToString(); String enabled = "Y"; //Request.Form["enabled"].ToString(); ////传递要更新的数据库字段 WmsCarArrive CarArrive = new WmsCarArrive(); CarArrive.OrderNo = orderNo; CarArrive.CarNo = carNo; CarArrive.CarDesc = carDesc; CarArrive.CarDriver = carDriver; CarArrive.Passageway = passageway; CarArrive.SupplierName = supplierName; CarArrive.Enabled = enabled; String message = ""; if (editType != null && editType.Trim().Equals("edit")) { try { CarArrive.UpdateUserId = CurrentEmp.EmpId; this.service.updateCarArrive(CarArrive); message = "修改成功"; } catch (Exception e) { message = "修改失败!"; } } else { try { CarArrive.CreateUserId = CurrentEmp.EmpId; CarArrive.UpdateUserId = CurrentEmp.EmpId; message = service.saveCarArrive(CarArrive); } catch (Exception e) { message = "添加失败!"; } } Hashtable result = new Hashtable(); result.Add("message", message); return Json(result); } public ActionResult saveCarArriveInfo() { String editType = Request.Form["editType"].ToString(); String orderNo = Request.Form["orderNo"].ToString(); String Operator = Request.Form["operator"].ToString(); String outDep = Request.Form["outDep"].ToString(); String remarks = Request.Form["remarks"].ToString(); String carNo = Request.Form["CarNo"].ToString(); String ascription = Request.Form["ascription"].ToString(); String material = Request.Form["myradio"].ToString(); String reason = Request.Form["reason"].ToString(); String outDateTime = Request.Form["outDateTime"].ToString(); String desc1 = Request.Form["desc1"].ToString(); String desc2 = Request.Form["desc2"].ToString(); String desc3 = Request.Form["desc3"].ToString(); String desc4 = Request.Form["desc4"].ToString(); String desc5 = Request.Form["desc5"].ToString(); String desc6 = Request.Form["desc6"].ToString(); String desc7 = Request.Form["desc7"].ToString(); String desc8 = Request.Form["desc8"].ToString(); String desc9 = Request.Form["desc9"].ToString(); String outOperator = Request.Form["outOperator"].ToString(); ////传递要更新的数据库字段 WmsCarArrive CarArrive = new WmsCarArrive(); CarArrive.OrderNo = orderNo; CarArrive.Operator = Operator; CarArrive.outDep = outDep; CarArrive.remarks = remarks; CarArrive.CarNo = carNo; CarArrive.ascription = ascription; CarArrive.material = material; CarArrive.reason = reason; CarArrive.outDateTime = outDateTime; CarArrive.desc1 = desc1; CarArrive.desc2 = desc2; CarArrive.desc3 = desc3; CarArrive.desc4 = desc4; CarArrive.desc5 = desc5; CarArrive.desc6 = desc6; CarArrive.desc7 = desc7; CarArrive.desc8 = desc8; CarArrive.desc9 = desc9; CarArrive.outOperator = outOperator; String message = ""; if (editType != null && editType.Trim().Equals("edit")) { try { //CarArrive.UpdateUserId = CurrentEmp.EmpId; this.service.updateCarArriveInfo(CarArrive); message = "操作成功"; } catch (Exception e) { message = "操作失败!"; } } else { try { this.service.updateCarArriveInfo(CarArrive); message = "操作成功"; } catch (Exception e) { message = "操作失败!"; } } Hashtable result = new Hashtable(); result.Add("message", message); return Json(result); } public ActionResult GetOrderInfo(string orderNo) { Hashtable ht = this.service.getCarManagerDetail(orderNo); ViewData.Add("orderNo", ht["orderNo"]); ViewData.Add("carNo", ht["carNo"]); ViewData.Add("carDesc", ht["carDesc"]); ViewData.Add("supplierCode", ht["supplierCode"]); ViewData.Add("supplierName", ht["supplierName"]); ViewData.Add("planArriveTime", ht["planArriveTime"]); ViewData.Add("carDriver", ht["carDriver"]); ViewData.Add("passageway", ht["passageway"]); return Json(ht); } #region 下拉框 public ActionResult GetPart_no(string q) { List list = filePart(q); return writeResult(list); } private ActionResult writeResult(List list) { Hashtable result = new Hashtable(); result.Add("list", list); return Json(result); } /// /// 过滤零件号 /// /// /// public List filePart(string key) { Hashtable autoComplateList = GetItemPart(key); List result = new List(); foreach (System.Collections.DictionaryEntry item in autoComplateList) { if (item.Value.ToString().ToUpper().StartsWith(key.ToUpper())) { result.Add(item.Value.ToString()); } } return result; } /// /// 查询零件号 /// /// /// public Hashtable GetItemPart(string key) { List autoComplateList = new List(); Hashtable result = new Hashtable(); try { List ht = service.GetSupplier(key); for (int i = 0; i < ht.Count; i++) { result.Add(ht[i].VendorCode.ToString(), ht[i].VendorName.ToString()); } } catch (Exception e) { result = new Hashtable(); } return result; } #endregion } }