//删除省份 public ActionResult delprovince() { var id = Convert.ToInt64(Request["IDs"]); var tdata = T_provinceService.LoadEntities(x => x.ID == id).FirstOrDefault(); if (tdata != null) { if (T_provinceService.DeleteEntity(tdata)) { return(Json(new { ret = "ok" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { msg = "没有成功删除信息!" }, JsonRequestBehavior.AllowGet)); } } return(Json(new { msg = "数据库中没有找到要删除的项目!" }, JsonRequestBehavior.AllowGet)); }
//添加省份 public ActionResult Addprovince(T_province tpe) { if (tpe.ID <= 0) { // var ts = T_provinceService.LoadEntities(x => x.str == tpe.str).FirstOrDefault(); if (T_provinceService.LoadEntities(x => x.str == tpe.str).FirstOrDefault() == null) { T_provinceService.AddEntity(tpe); return(Json(new { ret = "ok" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { msg = "不可添加重复的省份!~", JsonRequestBehavior.AllowGet })); } } else { return(Json(new { msg = "添加出错,请联系管理员!~", JsonRequestBehavior.AllowGet })); } }
public ActionResult Index() { ViewBag.province = T_provinceService.LoadEntities(x => x.ID > 0).DefaultIfEmpty().ToList(); ViewBag.City = T_CityService.LoadEntities(x => x.DelFlag == 0).DefaultIfEmpty().ToList(); return(View()); }