Пример #1
0
        public ActionResult Tray()
        {
            SetSelectListItems.Container(this);
            SetSelectListItems.TrayType(this);

            return(View());
        }
Пример #2
0
        public ActionResult Material()
        {
            //设置下拉框
            SetSelectListItems.MaterialType(this);
            SetSelectListItems.UnitList(this);
            SetSelectListItems.Container(this);

            return(View());
        }
Пример #3
0
        public ActionResult Material(MaterialViewModel model)
        {
            if (model.UnitInput == null && model.Unit == "-1")
            {
                ModelState.AddModelError("UnitInput", "请输入或选择一项单位");
            }
            if (ModelState.IsValid)
            {
                //物资型号模型不能相同
                var db = new DbEntities <Material>().SimpleClient;

                if (db.IsAny(m => m.SizeCode == model.SizeCode || m.MaterialModel == model.MaterialModel))
                {
                    ModelState.AddModelError("SizeCode", "编号或者型号不能相同");
                }
                else
                {
                    //获得对应实体
                    if (new IdentityAuth().GetCurUserID(HttpContext, out int creater))
                    {
                        Material entity = model.InitAddMaterial(creater);

                        //插入数据
                        if (new DbEntities <Material>().SimpleClient.Insert(entity))
                        {
                            TempData["Msg"] = "添加成功";
                            return(RedirectToAction("MaterialList", "Materials"));
                        }
                    }
                }
            }

            //设置下拉框
            SetSelectListItems.MaterialType(this, model.MaterialTypeID);
            SetSelectListItems.UnitList(this);
            SetSelectListItems.Container(this, model.MaterialContainer);
            TempData["Msg"] = "添加失败,请检查信息";
            return(View());
        }
Пример #4
0
        public ActionResult Tray(TrayViewModel model)
        {
            if (ModelState.IsValid)
            {
                //编号条码不重复
                var db = new DbEntities <Tray>().SimpleClient;

                if (db.IsAny(tr => tr.TrayNo == model.TrayNo || tr.TrayCode == model.TrayCode))
                {
                    ModelState.AddModelError("TrayCode", "托盘编号或条码");
                }
                else
                {
                    //检验登录人身份,并获取对应ID
                    if (new IdentityAuth().GetCurUserID(HttpContext, out int curUserID))
                    {
                        Tray entity = model.InitAddTray(curUserID);

                        if (db.Insert(entity))
                        {
                            TempData["Msg"] = $"托盘 [{entity.TrayNo}] 添加成功";
                            return(RedirectToAction("Tray", "Warehouse"));
                        }
                        TempData["Msg"] = "添加失败";
                    }
                    else
                    {
                        TempData["Msg"] = "登录身份过期,请重新登录";
                    }
                }
            }

            SetSelectListItems.Container(this, model.Container);
            SetSelectListItems.TrayType(this, model.TrayType);

            return(View(model));
        }