Beispiel #1
0
        public ActionResult InventoryArea(InventoryAreaViewModel model)
        {
            if (ModelState.IsValid)
            {
                //名称编号不可重复
                var db = new DbEntities <InventoryArea>().SimpleClient;

                if (db.IsAny(ia => ia.InventoryAreaNo == model.InventoryAreaNo || ia.InventoryAreaName == model.InventoryAreaName))
                {
                    ModelState.AddModelError("InventoryAreaNo", "库区名称或编号已存在");
                }
                else
                {
                    //检验登录人身份,并获取对应ID
                    if (new IdentityAuth().GetCurUserID(HttpContext, out int curUserID))
                    {
                        InventoryArea entity = model.InitAddInventoryArea(curUserID);

                        if (db.Insert(entity))
                        {
                            TempData["Msg"] = $"库区 {entity.InventoryAreaName} 添加成功";
                            return(RedirectToAction("InventoryArea", "Warehouse"));
                        }
                        TempData["Msg"] = "添加失败";
                    }
                    else
                    {
                        TempData["Msg"] = "登录身份过期,请重新登录";
                    }
                }
            }
            SetSelectListItems.Warehouse(this);
            return(View(model));
        }
Beispiel #2
0
 public ActionResult InventoryArea()
 {
     SetSelectListItems.Warehouse(this);
     return(View());
 }