public ActionResult InventoryAllocation(InventoryAllocationViewModel model) { if (ModelState.IsValid) { if (new IdentityAuth().GetCurUserID(HttpContext, out int curUserID)) { InventoryAllocation entity = model.InitAddInventoryAllocation(curUserID); if (new DbEntities <InventoryAllocation>().SimpleClient.Insert(entity)) { TempData["Msg"] = "库位分配成功"; return(RedirectToAction("InventoryAllocation", "Warehouse")); } TempData["Msg"] = "失败"; } else { TempData["Msg"] = "登录身份过期,请重新登录"; } } SetSelectListItems.MaterialType(this, model.MaterialTypeID); SetSelectListItems.InventoryLocation(this, model.InventoryLocationID); return(View(model)); }
public ActionResult InventoryAllocation() { //视图模型 InventoryAllocationViewModel model = new InventoryAllocationViewModel(); //获取库存分配信息 List<InventoryAllocation> IAlist = new DbEntities<InventoryAllocation>().SimpleClient.GetList().OrderByDescending(ia => ia.ChangeTime).ThenByDescending(ia => ia.CreateTime).ToList(); //遍历所有的库位分配信息 foreach (InventoryAllocation item in IAlist) { //库位信息-物资种类 View_InventoryLocation View_InventoryLocationInfo = new DbEntities<View_InventoryLocation>().SimpleClient.GetSingle(vil => vil.InventoryLocationID == item.InventoryLocationID); View_MaterialType MaterialTypeInfo = new DbEntities<View_MaterialType>().SimpleClient.GetSingle(vmt => vmt.MaterialTypeID == item.MaterialTypeID); //添加库位分配的具体信息 V_InventoryAllocation v_Inventory = new V_InventoryAllocation { InventoryAllocation = item, InventoryLocation = View_InventoryLocationInfo, MaterialType = MaterialTypeInfo }; model.InventoryAllocations.Add(v_Inventory); } return View(model); }