Ejemplo n.º 1
0
        public ActionResult NewProvince()
        {
            string strErrText;

            //生成国家下拉列表项
            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
            ProvinceViewModel model = new ProvinceViewModel();

            return View(model);
        }
Ejemplo n.º 2
0
        public ActionResult NewProvince(ProvinceViewModel model)
        {
            if (ModelState.IsValid)
            {
                //创建数据
                Province data = new Province();
                data.Name = model.Name;
                data.CountryName = model.CountryName;
                data.Remark = model.Remark ?? string.Empty;

                //保存数据
                string strErrText;
                DDSystem province = new DDSystem();
                if (province.InsertProvince(data, LoginAccountId, LoginStaffName, out strErrText))
                {
                    return Json(string.Empty);
                }
                else
                {
                    return Json(strErrText);
                }
            }
            return View(model);
        }
Ejemplo n.º 3
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);
        }