Exemplo n.º 1
0
        public ActionResult NewGoods()
        {
            string strErrText;

            //生成货物类别下拉列表项
            DDSystem dd = new DDSystem();
            List<GoodsType> listGoodsType = dd.LoadGoodsTypes(LoginAccountId, LoginStaffName, out strErrText);
            if (listGoodsType == null)
            {
                throw new Exception(strErrText);
            }
            List<SelectListItem> selectListGoodsType = new List<SelectListItem>();
            selectListGoodsType.Add(new SelectListItem { Text = string.Empty, Value = string.Empty });
            selectListGoodsType.AddRange(from t in listGoodsType
                                         orderby t.FullName
                                         select new SelectListItem
                                         {
                                             Text = t.FullName,
                                             Value = t.Id.ToString()
                                         });
            ViewData["GoodsTypes"] = new SelectList(selectListGoodsType, "Value", "Text");

            //创建空的Model
            GoodsViewModel model = new GoodsViewModel();

            return View(model);
        }
Exemplo n.º 2
0
        public ActionResult NewGoods(GoodsViewModel model)
        {
            if (ModelState.IsValid)
            {
                //创建数据
                Goods data = new Goods();
                data.Name = model.Name;
                data.TypeId = model.TypeId;
                data.GoodsNo = model.GoodsNo;
                data.SpecModel = model.SpecModel;
                data.GWeight = model.GWeight;
                data.Grade = model.Grade;
                data.Brand = model.Brand;
                data.PieceWeight = model.PieceWeight;
                data.Packing = model.Packing;
                data.Remark = model.Remark;

                //保存数据
                string strErrText;
                DDSystem dd = new DDSystem();
                if (dd.InsertGoods(data, LoginAccountId, LoginStaffName, out strErrText))
                {
                    return Json(string.Empty);
                }
                else
                {
                    return Json(strErrText);
                }
            }
            return View(model);
        }
Exemplo n.º 3
0
        public ActionResult ModifyGoods(string id)
        {
            string strErrText;

            //生成货物类别下拉列表项
            DDSystem dd = new DDSystem();
            List<GoodsType> listGoodsType = dd.LoadGoodsTypes(LoginAccountId, LoginStaffName, out strErrText);
            if (listGoodsType == null)
            {
                throw new Exception(strErrText);
            }
            List<SelectListItem> selectListGoodsType = new List<SelectListItem>();
            selectListGoodsType.Add(new SelectListItem { Text = string.Empty, Value = string.Empty });
            selectListGoodsType.AddRange(from t in listGoodsType
                                         orderby t.FullName
                                         select new SelectListItem
                                         {
                                             Text = t.FullName,
                                             Value = t.Id.ToString()
                                         });
            ViewData["GoodsTypes"] = new SelectList(selectListGoodsType, "Value", "Text");

            //生成Model数据
            Goods data = dd.LoadGoods(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText);
            if (data == null)
            {
                throw new Exception(strErrText);
            }

            GoodsViewModel model = new GoodsViewModel();
            model.Id = data.Id;
            model.Name = data.Name;
            model.TypeId = data.TypeId;
            model.GoodsNo = data.GoodsNo;
            model.SpecModel = data.SpecModel;
            model.GWeight = data.GWeight;
            model.Grade = data.Grade;
            model.Brand = data.Brand;
            model.PieceWeight = data.PieceWeight;
            model.Packing = data.Packing;
            model.Remark = data.Remark;

            return View(model);
        }