码迷,mamicode.com
首页 > 其他好文 > 详细

Controller

时间:2017-11-23 08:32:37      阅读:199      评论:0      收藏:0      [点我收藏+]

标签: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>");
            }

        }

Controller

标签:new   show   登录   删除   action   get   post   cat   http   

原文地址:http://www.cnblogs.com/chen0828/p/7881242.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!