当前位置: 首页 > article >正文

图书管理系统源码,图书管理系统开发,图书借阅系统源码四TuShuManager应用程序MVC控制器Controllers

Asp.net web应用程序MVC之Controllers控制器

Controller在ASP.NET MVC中负责控制所有客户端与服务器端的交互,并且负责协调Model与View之间的数据传递,是ASP.NET MVC的核心。

  撰写Controller的基本要求:

    1、Controller必须为公开类别;

    2、Controller名称必须以Controller结尾;

    3、必须继承ASP.NET MVC内建的Controller类别,或继承有实作IController界面的自定义类别,或自行实作IController;

    4、所有动作方法必须为公开方法,任何非公开方法如声明为private或protected的方法都不会被视为一个动作方法。

  Controller中的每一个Action可以定义0~多个参数,当Controller中的某个Action方法被调用运行完之后,其回传值通常是ActionResult或者衍生类。当然,也可以直接使用.NET内建的基本数据型别当作回传型别,如果Action声明成void,则代表Action不会回传任何数据到客户端。

这里简单介绍一下其中的ReaderController.cs控制器方法

ReaderController.cs控制器

该方法是读者控制器包括了读者分类和读者的增删改查页面返回的数据都在这个控制器中,操作业务都是调用业务层Bll里面的方法实现

    public class ReaderController : Controller
    {
        // GET: Reader
        public ActionResult Index()
        {
            HttpCookie cookie = Request.Cookies["id"];
            HttpCookie cookie1 = Request.Cookies["username"];
            if (null == cookie || null == cookie1)
            { return RedirectToAction("index", "Login"); }

            return View();
        }
        public ActionResult ReaderCatgory()
        {
            HttpCookie cookie = Request.Cookies["id"];
            HttpCookie cookie1 = Request.Cookies["username"];
            if (null == cookie || null == cookie1)
            { return RedirectToAction("index", "Login"); }

            return View();
        }
        [HttpPost]
        public string ReaderCatgoryData()
        {
            int page = Convert.ToInt32(Request["page"].ToString());
            int limit = Convert.ToInt32(Request["limit"].ToString());
            var start = limit * page - limit + 1;//根据分页的页面去选择数据的开始因素
            var end = limit * page;//获得分页的最后因素

            return Bll.ReaderCatgory.ListPageTiaoJianJson(page,limit) ;
        }

        public ActionResult ReaderCatgoryAdd()
        {
            HttpCookie cookie = Request.Cookies["id"];
            HttpCookie cookie1 = Request.Cookies["username"];
            if (null == cookie || null == cookie1)
            { return RedirectToAction("index", "Login"); }

            return View();
        }
        [HttpPost]
        public JsonResult ReaderCatgorySave()
        {
        string rname = Request["rname"].ToString();
        string rnum  = Request["rnum"].ToString();
        string rday  = Request["rday"].ToString();
        string rxnum = Request["rxnum"].ToString();
            string idate = Request["idate"].ToString();
            int i = Bll.ReaderCatgory.ReaderCatgoryAdd(rname, rnum , rday , rxnum , idate);

            return Json(i, JsonRequestBehavior.AllowGet);
        }
        [HttpPost]
        public string ReaderCatgoryDelete()
     

http://www.kler.cn/a/153057.html

相关文章:

  • sql中group by和having的使用
  • Git——工作区管理
  • OpenCV快速入门:彩蛋——小游戏制作
  • 大数据:Hadoop刷题
  • 创建SpringBoot Helloword 程序详细步骤
  • 【C++ Primer Plus学习记录】嵌套循环和二维数组
  • 营销系统规则引擎
  • uni-app+ts----微信小程序锚点定位 、自动吸顶、滚动自动选择对应的锚点(点击tab跳转对应的元素位置)
  • 基于Spring、SpringMVC、MyBatis的外卖点餐网站
  • 【数据结构】初识排序 直接插入排序
  • Google Analytics(谷歌分析)是什么以及如何使用
  • 电商营销场景的RocketMQ实战01-RocketMQ原理
  • C语言贪吃蛇(有详细注释)
  • 四个方法,设置excel文件只读模式
  • C++相关闲碎记录(3)
  • 模糊C均值(Fuzzy C-means,FCM)聚类的可运行的python程序代码,复制即可用!!切记需要安装库 scikit-fuzzy
  • MFC、VC++操作excel后,excel程序进程无法正常退出的非暴力处理方法
  • 【Java SE】泛型
  • 高德Map
  • 基于web的舞蹈选课管理系统设计与实现