标签:new show 登录 删除 action get post cat http
//登录
public ActionResult Login()
{
return View();
}
[HttpPost]
public JsonResult Login(string name,string pwd)
{
Session["name"] = name;
var result = ub.Login(name,pwd);
if (result > 0)
{
return Json(new { code = 1, mes = "登录成功" });
}
else
{
return Json(new { code=0,mes="登录失败"});
}
}
//显示
public ActionResult show(int pageindex=1)
{
var result = ub.Show();
return View(result.ToPagedList(pageindex,2));
}
//添加
public ActionResult Add()
{
//获取用户表
var data = ub.getuse();
SelectList slist = new SelectList(data, "U_ID", "U_Name");
ViewBag.user = slist;
//获取业主表
var data1 = ub.getyezhu();
SelectList slist1 = new SelectList(data1, "Y_ID", "Y_XiaoQu");
ViewBag.yezhu = slist1;
//获取项目表
var data2 = ub.getshoufei();
SelectList slist2 = new SelectList(data2, "S_ID", "S_Name");
ViewBag.shoufei = slist2;
return View();
}
[HttpPost]
public ActionResult Add(ShouXiInfo s)
{
ShouXiInfo shou = new ShouXiInfo();
shou.U_ID = s.U_ID;
shou.Y_ID = s.Y_ID;
shou.S_ID = s.S_ID;
var result = ub.add(shou);
if (result > 0)
{
return Content("<script>alert(‘添加成功‘);location.href=‘/Jia/show‘</script>");
}
else
{
return Content("<script>alert(‘添加失败‘)</script>");
}
}
//删除
public ActionResult Del(int id)
{
var result = ub.Sdel(id);
if (result > 0)
{
return Content("<script>alert(‘删除成功‘);location.href=‘/Jia/show‘</script>");
}
else
{
return Content("<script>alert(‘失败‘)</script>");
}
}
标签:new show 登录 删除 action get post cat http
原文地址:http://www.cnblogs.com/chen0828/p/7881242.html