zoukankan      html  css  js  c++  java
  • MVC LINQ 分页


    @{
        Layout = null;
    }

    <link href="~/Content/bootstrap.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-3.4.1.min.js"></script>
    <input id="Button1" type="button" value="添加" onclick="location.href='http://localhost:56509/Red/Add'" />
    <input id="ChuaXun" type="text" placeholder="请输入名称"/>
            <input id="Cha" type="button" value="查询" />
    <table id="tb" class="table table-bordered">
        <tr>
            <td>ID</td>
            <td>活动名称</td>
            <td>奖品名称</td>
            <td>普通红包</td>
            <td>总金额</td>
            <td>剩余金额</td>
            <td>总数量</td>
            <td>剩余数量</td>
            <td>红包状态</td>
            <td>红包类型</td>
            <td>备注</td>
            <td>添加时间</td>
            <td>操作</td>
        </tr>
    </table>
    <input type='button' value='首页' onclick='First()' />
    <input type='button' value='上一页' onclick='Pre()' />
    <input type='button' value='下一页' onclick='Next()' />
    <input type='button' value='尾页' onclick='Last()' />
    <script>
        var pageIndex = 1;
        var pageSize = 5;
        //总条数
        var total = 0;
        //总页数
        var totalCount = 0;
        $(function () {
            ShowFenye(pageIndex);
       $("#Cha").click(function () {
                $.ajax({
                    url: "http://localhost:50084/api/searchs?name=" + $("#ChuaXun").val(),
                        data: null,
                        dataType: "json",
                        type: "get",
                        success: function (result) {
                            ShowList(result);
                        }
                    }); 
            });
        });
        function ShowFenye(pageIndex) {
            $.ajax({
                url: "http://localhost:50084/api/showGet?pageSize=4&pageIndex=" + pageIndex,
                data: null,
                dataType: "json",
                type: "get",
                success: function (result) {
                    total = result.total;
                    totalCount = total/ pageSize;
                    ShowList(result.list);
                }
            });
        }
        function ShowList(result) {
            var str = "";
            $.each(result, function (i, n) {
                str += "<tr><td>" + n.ID + "</td>";
                str += "<td>" + n.ActivityName + "</td>";
                str += "<td>" + n.Name + "</td>";
                str += "<td>" + n.Common + "</td>";
                str += "<td>" + n.Num + "</td>";
                str += "<td>" + n.Balance + "</td>";
                str += "<td>" + n.Number + "</td>";
                str += "<td>" + n.BalanceNum + "</td>";
                str += "<td>" + n.State + "</td>";
                str += "<td>" + n.Type + "</td>";
                str += "<td>" + n.Remark + "</td>";
                str += "<td>" + n.CreateTime + "</td> ";
                str += "<td><a href='javascript:Delete(" + n.ID + ")'>删除</a><a href='javascript:Update(" + n.ID + ")'>修改</a></td></tr>";
            });
            $("#tb tr:gt(0)").empty();
            $("#tb").append(str);
        }
        function First() {
            if (pageIndex <= 1) {
                alert("已是首页");
            }
            pageIndex = 1;
            ShowFenye(pageIndex);
        }
        function Pre() {
            if (pageIndex <= 1) {
                alert("已是首页");
            } else {
                pageIndex = pageIndex - 1;
                ShowFenye(pageIndex);
            }
        }
        function Next() {
            if (pageIndex >= totalCount) {
                alert("已是尾页");
            } else {
                pageIndex = pageIndex + 1;
                ShowFenye(pageIndex);
            }
        }
        function Last() {
            if (pageIndex >= totalCount) {
                alert("已是尾页");
            } else {
                pageIndex = totalCount;
                ShowFenye(pageIndex);
            }
        }
        function Delete(ID) {
            $.ajax({
                url: "http://localhost:50084/api/Delete ",
                data: { ID: ID },
                dataType: "text",
                type: "post",
                success: function (result) {
                    ShowFenye();
                }
            });
        }
        function Update(ID) {
            location.href = 'http://localhost:56509/Red/Update?ID=' + ID;
        }
    </script>
  • 相关阅读:
    centos7.6 安装与配置 MongoDB yum方式
    MongoDB 介绍
    centos 关闭selinux
    前端 HTML标签属性
    前端 HTML 标签嵌套规则
    前端 HTML 标签分类
    前端 HTML body标签相关内容 常用标签 表单标签 form里面的 input标签介绍
    前端 HTML body标签相关内容 常用标签 表单标签 form 表单控件分类
    前端 HTML form表单标签 select标签 option 下拉框
    POJ 1426
  • 原文地址:https://www.cnblogs.com/GuoLianSheng/p/13265737.html
Copyright © 2011-2022 走看看