Esempio n. 1
0
        public ActionResult ModifyGoodsType(string id)
        {
            string strErrText;

            //生成Model数据
            DDSystem  dd   = new DDSystem();
            GoodsType data = dd.LoadGoodsType(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText);

            if (data == null)
            {
                throw new Exception(strErrText);
            }

            GoodsTypeViewModel model = new GoodsTypeViewModel();

            model.Id       = data.Id;
            model.Name     = data.Name;
            model.ParentId = data.ParentId;
            model.Remark   = data.Remark;

            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 = "0"
            });
            selectlistGoodsType.AddRange(from t in listGoodsType
                                         where !t.FullPath.StartsWith(data.FullPath)
                                         orderby t.FullName
                                         select new SelectListItem
            {
                Text  = t.FullName,
                Value = t.Id.ToString()
            });
            ViewData["GoodsTypes"] = new SelectList(selectlistGoodsType, "Value", "Text", model.ParentId);

            return(View(model));
        }