Exemple #1
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);
        }