当前访客身份:游客 [ 登录 | 加入开源中国 ]

代码分享

当前位置:
代码分享 » C#  » Web编程
原来是王先生啊

MVC循环产生数据

原来是王先生啊 发布于 2016年08月22日 11时, 0评/676阅
分享到: 
收藏 +0
0
C#中MVC下数据简单传递
标签: <无>

代码片段(1) [全屏查看所有代码]

1. [代码][C#]代码     跳至 [1] [全屏预览]

@using Webdiyer.WebControls.Mvc;
@model PagedList<MyLibrary.WEB_KEHU>
@{
    int count = Model.Count();
    int i = 1;
}

@{
    Layout = null;
}
<!DOCTYPE html>
<html>


<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>客户管理</title>

    <link rel="shortcut icon" href="favicon.ico">
    <link href="~/Contents/css/bootstrap.min14ed.css" rel="stylesheet" />
    <link href="~/Contents/css/font-awesome.min93e3.css" rel="stylesheet" />
    <link href="~/Contents/css/plugins/sweetalert/sweetalert.css" rel="stylesheet" />
    <link href="~/Contents/css/animate.min.css" rel="stylesheet" />
    <link href="~/Contents/css/style.min862f.css" rel="stylesheet" />
    <link href="~/Contents/css/Site.css" rel="stylesheet" />


</head>

<body class="gray-bg">


    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox ">
                    <div class="ibox-title">
                        <h5>客户增减员</h5>
                    </div>
                    <div class="ibox-content">
                        <div class="bars pull-left" style="padding-bottom:10px;">
                            <div class="btn-group hidden-xs" id="exampleToolbar" role="group">
                                <button type="button" class="btn btn-outline btn-default" title="添加一条新记录" onclick="check()">
                                    <i class="glyphicon glyphicon-plus" aria-hidden="true"></i>
                                </button>
                                <button type="button" class="btn btn-outline btn-default" title="编辑">
                                    <i class="glyphicon glyphicon-pencil" aria-hidden="true"></i>
                                </button>
                                <button type="button" class="btn btn-outline btn-default" title="删除" onclick="del();">
                                    <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>
                                </button>
                            </div>
                        </div>
                        <div class="columns columns-right btn-group pull-right" style="padding-bottom:10px;">
                            <button class="btn btn-default btn-outline" type="button" name="toggle" title="查询">
                                <i class="glyphicon glyphicon-search"></i>
                            </button>
                            <button class="btn btn-default btn-outline" type="button" name="refresh" title="刷新">
                                <i class="glyphicon glyphicon-repeat"></i>
                            </button>
                        </div>
                        <div class="pull-right search" style="padding-bottom:10px;padding-right:6px;">
                            <input class="form-control input-outline" placeholder="搜索" type="text">
                        </div>
                        <div id="articles">
                            <table class="table table-bordered" id="lab">
                                <thead>
                                    <tr>
                                        <th>序号</th>
                                        <th>职工名</th>
                                        <th>身份证号码</th>
                                        <th>大公司名称</th>
                                        <th>小公司名称</th>
                                        <th>户口身份</th>
                                        <th>社保基数</th>
                                        <th>公积金基数</th>
                                        <th>公积金单位比例</th>
                                        <th>公积金个人比例</th>
                                        <th>公积金单位缴纳额</th>
                                        <th>公积金个人缴纳额</th>
                                        <th>社保开始时间</th>
                                        <th>公积金开始时间</th>
                                        <th>合同开始时间</th>
                                        <th>合同结束时间</th>
                                        <th>委托地</th>
                                        <th>标识</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @{
                                        foreach (var item in Model)
                                        {
                                            <tr id="@Html.DisplayFor(modelItem => item.K_ID)" onclick="show(this.id);">
                                                @{
                                                    
                                                        if (i <= count)
                                                        {
                                                            <td>@i</td>
                                                            i++;
                                                        }
                                                        <td>@Html.DisplayFor(modelItem => item.K_NAME)</td>
                                                        <td>@Html.DisplayFor(modelItem => item.K_SFZID)</td>
                                                        <td>@Html.DisplayFor(modelItem => item.K_DGS)</td>
                                                        <td>@Html.DisplayFor(modelItem => item.K_XGS)</td>
                                                        <td>@Html.DisplayFor(modelItem => item.K_YGSF)</td>
                                                        <td>@Html.DisplayFor(modelItem => item.K_SBJS)</td>
                                                        <td>@Html.DisplayFor(modelItem => item.K_GJJJS)</td>
                                                        <td>@Html.DisplayFor(modelItem => item.K_GJJDWBL)</td>
                                                        <td>@Html.DisplayFor(modelItem => item.K_GJJGRBL)</td>
                                                        <td>@Html.DisplayFor(modelItem => item.K_GJJDWJNE)</td>
                                                        <td>@Html.DisplayFor(modelItem => item.K_GJJGRJNE)</td>
                                                        <td>@Html.DisplayFor(modelItem => item.K_SBKSSJ)</td>
                                                        <td>@Html.DisplayFor(modelItem => item.K_GJJKSSJ)</td>
                                                        <td>@Html.DisplayFor(modelItem => item.K_HTKSSJ)</td>
                                                        <td>@Html.DisplayFor(modelItem => item.K_HTJSSJ)</td>
                                                        <td>@Html.DisplayFor(modelItem => item.K_WTD)</td>
                                                        <td>@Html.DisplayFor(modelItem => item.K_BS)</td>
                                                    }
                                            </tr>
                                                    }
                                    }

                                </tbody>
                            </table>
                        </div>    
                            <div class="text-center">
                                @Ajax.Pager(Model, new PagerOptions
                           {
                               PageIndexParameterName = "id",
                               ContainerTagName = "ul",
                               CssClass = "pagination",
                               CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>",
                               DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>",
                               PagerItemTemplate = "<li>{0}</li>"
                           }).AjaxOptions(a => a.SetUpdateTargetId("articles"))
                            </div>
                    </div>
                </div>
            </div>




            <script src="~/Contents/js/jquery.min.js"></script>
            <script src="~/Contents/js/bootstrap.min.js"></script>
            <script src="~/Contents/js/content.min.js"></script>
            <script src="~/Contents/js/ajax_gl.js" type="text/javascript"></script>
            <script src="~/Contents/js/plugins/sweetalert/sweetalert.min.js"></script>

</body>


<!-- Mirrored from www.zi-han.net/theme/hplus/table_bootstrap.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:20:06 GMT -->
</html>


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MyLibrary;
using Webdiyer.WebControls.Mvc;

namespace web.Controllers
{
    public class HomeController : Controller
    {
        private Entities et = new Entities();
        // GET: Home

        public ActionResult Index()
        { 
            return View();
        }
        public void delzg()
        {
            decimal id = decimal .Parse(Request.Params["id"]);

            var shanchu = et.WEB_KEHU.FirstOrDefault(k=>k.K_ID==id);
            et.WEB_KEHU.Remove(shanchu);
            et.SaveChanges();
            Response.Write("1");
        }
        public ActionResult AjaxPaging(int id = 1)
        {
            var model= et.WEB_KEHU.OrderByDescending(a=>a.K_ID).ToPagedList(id, 5);

            //Session["page"] = id;
            //int count = model.Count();
            string sj = DateTime.Now.ToString("yyyyMMddhhmmss");
            return View(model);
        }
        public ActionResult search()
        {
            return View();
        }
    }
}


开源中国-程序员在线工具:Git代码托管 API文档大全(120+) JS在线编辑演示 二维码 更多»

开源从代码分享开始 分享代码
原来是王先生啊的其它代码 全部(1)...