示例#1
0
        public ActionResult ModifyProvince(string id)
        {
            string strErrText;

            //生成Model数据
            DDSystem province = new DDSystem();
            Province data     = province.LoadProvince(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText);

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

            ProvinceViewModel model = new ProvinceViewModel();

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

            //生成国家下拉列表项
            DDSystem       dd          = new DDSystem();
            List <Country> listCountry = dd.LoadCountrys(LoginAccountId, LoginStaffName, out strErrText);

            if (listCountry == null)
            {
                throw new Exception(strErrText);
            }
            List <SelectListItem> selectListCountry = new List <SelectListItem>();

            selectListCountry.Add(new SelectListItem {
                Text = string.Empty, Value = string.Empty
            });
            selectListCountry.AddRange(from c in listCountry
                                       select new SelectListItem
            {
                Text  = c.Name,
                Value = c.Name
            });
            ViewData["Countries"] = new SelectList(selectListCountry, "Value", "Text", model.CountryName);

            return(View(model));
        }