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>
  • 相关阅读:
    1.2.2 标准命令概述
    1.3 第一个Go程序
    2. 基础类型
    转载:Pixhawk源码笔记一:APM代码基本结构
    IIS6的工作进程回收
    在电脑前独坐,又已经凌晨3点了
    IT人:为什么快乐不起来
    平淡的一天,平淡的心情
    发现一个很好玩的东西
    Jmeter脚本增强检查点
  • 原文地址:https://www.cnblogs.com/GuoLianSheng/p/13265737.html
Copyright © 2011-2022 走看看