在路上

 找回密码
 立即注册
在路上 站点首页 学习 查看内容

MVC循环产生数据

2016-12-20 13:14| 发布者: zhangjf| 查看: 492| 评论: 0

摘要: C#中MVC下数据简单传递 @using Webdiyer.WebControls.Mvc;@model PagedListMyLibrary.WEB_KEHU@{ int count = Model.Count(); int i = 1;}@{ Layout = null;}!DOCTYPE htmlhtmlhead ...
C#中MVC下数据简单传递
  1. @using Webdiyer.WebControls.Mvc;
  2. @model PagedList<MyLibrary.WEB_KEHU>
  3. @{
  4. int count = Model.Count();
  5. int i = 1;
  6. }
  7. @{
  8. Layout = null;
  9. }
  10. <!DOCTYPE html>
  11. <html>
  12. <head>
  13. <meta charset="utf-8">
  14. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  15. <title>客户管理</title>
  16. <link rel="shortcut icon" href="favicon.ico">
  17. <link href="~/Contents/css/bootstrap.min14ed.css" rel="stylesheet" />
  18. <link href="~/Contents/css/font-awesome.min93e3.css" rel="stylesheet" />
  19. <link href="~/Contents/css/plugins/sweetalert/sweetalert.css" rel="stylesheet" />
  20. <link href="~/Contents/css/animate.min.css" rel="stylesheet" />
  21. <link href="~/Contents/css/style.min862f.css" rel="stylesheet" />
  22. <link href="~/Contents/css/Site.css" rel="stylesheet" />
  23. </head>
  24. <body class="gray-bg">
  25. <div class="wrapper wrapper-content animated fadeInRight">
  26. <div class="row">
  27. <div class="col-sm-12">
  28. <div class="ibox ">
  29. <div class="ibox-title">
  30. <h5>客户增减员</h5>
  31. </div>
  32. <div class="ibox-content">
  33. <div class="bars pull-left" style="padding-bottom:10px;">
  34. <div class="btn-group hidden-xs" id="exampleToolbar" role="group">
  35. <button type="button" class="btn btn-outline btn-default" title="添加一条新记录" onclick="check()">
  36. <i class="glyphicon glyphicon-plus" aria-hidden="true"></i>
  37. </button>
  38. <button type="button" class="btn btn-outline btn-default" title="编辑">
  39. <i class="glyphicon glyphicon-pencil" aria-hidden="true"></i>
  40. </button>
  41. <button type="button" class="btn btn-outline btn-default" title="删除" onclick="del();">
  42. <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>
  43. </button>
  44. </div>
  45. </div>
  46. <div class="columns columns-right btn-group pull-right" style="padding-bottom:10px;">
  47. <button class="btn btn-default btn-outline" type="button" name="toggle" title="查询">
  48. <i class="glyphicon glyphicon-search"></i>
  49. </button>
  50. <button class="btn btn-default btn-outline" type="button" name="refresh" title="刷新">
  51. <i class="glyphicon glyphicon-repeat"></i>
  52. </button>
  53. </div>
  54. <div class="pull-right search" style="padding-bottom:10px;padding-right:6px;">
  55. <input class="form-control input-outline" placeholder="搜索" type="text">
  56. </div>
  57. <div id="articles">
  58. <table class="table table-bordered" id="lab">
  59. <thead>
  60. <tr>
  61. <th>序号</th>
  62. <th>职工名</th>
  63. <th>身份证号码</th>
  64. <th>大公司名称</th>
  65. <th>小公司名称</th>
  66. <th>户口身份</th>
  67. <th>社保基数</th>
  68. <th>公积金基数</th>
  69. <th>公积金单位比例</th>
  70. <th>公积金个人比例</th>
  71. <th>公积金单位缴纳额</th>
  72. <th>公积金个人缴纳额</th>
  73. <th>社保开始时间</th>
  74. <th>公积金开始时间</th>
  75. <th>合同开始时间</th>
  76. <th>合同结束时间</th>
  77. <th>委托地</th>
  78. <th>标识</th>
  79. </tr>
  80. </thead>
  81. <tbody>
  82. @{
  83. foreach (var item in Model)
  84. {
  85. <tr id="@Html.DisplayFor(modelItem => item.K_ID)" onclick="show(this.id);">
  86. @{
  87. if (i <= count)
  88. {
  89. <td>@i</td>
  90. i++;
  91. }
  92. <td>@Html.DisplayFor(modelItem => item.K_NAME)</td>
  93. <td>@Html.DisplayFor(modelItem => item.K_SFZID)</td>
  94. <td>@Html.DisplayFor(modelItem => item.K_DGS)</td>
  95. <td>@Html.DisplayFor(modelItem => item.K_XGS)</td>
  96. <td>@Html.DisplayFor(modelItem => item.K_YGSF)</td>
  97. <td>@Html.DisplayFor(modelItem => item.K_SBJS)</td>
  98. <td>@Html.DisplayFor(modelItem => item.K_GJJJS)</td>
  99. <td>@Html.DisplayFor(modelItem => item.K_GJJDWBL)</td>
  100. <td>@Html.DisplayFor(modelItem => item.K_GJJGRBL)</td>
  101. <td>@Html.DisplayFor(modelItem => item.K_GJJDWJNE)</td>
  102. <td>@Html.DisplayFor(modelItem => item.K_GJJGRJNE)</td>
  103. <td>@Html.DisplayFor(modelItem => item.K_SBKSSJ)</td>
  104. <td>@Html.DisplayFor(modelItem => item.K_GJJKSSJ)</td>
  105. <td>@Html.DisplayFor(modelItem => item.K_HTKSSJ)</td>
  106. <td>@Html.DisplayFor(modelItem => item.K_HTJSSJ)</td>
  107. <td>@Html.DisplayFor(modelItem => item.K_WTD)</td>
  108. <td>@Html.DisplayFor(modelItem => item.K_BS)</td>
  109. }
  110. </tr>
  111. }
  112. }
  113. </tbody>
  114. </table>
  115. </div>
  116. <div class="text-center">
  117. @Ajax.Pager(Model, new PagerOptions
  118. {
  119. PageIndexParameterName = "id",
  120. ContainerTagName = "ul",
  121. CssClass = "pagination",
  122. CurrentPagerItemTemplate = "<li class="active"><a href="#">{0}</a></li>",
  123. DisabledPagerItemTemplate = "<li class="disabled"><a>{0}</a></li>",
  124. PagerItemTemplate = "<li>{0}</li>"
  125. }).AjaxOptions(a => a.SetUpdateTargetId("articles"))
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. <script src="~/Contents/js/jquery.min.js"></script>
  131. <script src="~/Contents/js/bootstrap.min.js"></script>
  132. <script src="~/Contents/js/content.min.js"></script>
  133. <script src="~/Contents/js/ajax_gl.js" type="text/javascript"></script>
  134. <script src="~/Contents/js/plugins/sweetalert/sweetalert.min.js"></script>
  135. </body>
  136. <!-- 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 -->
  137. </html>
  138. using System;
  139. using System.Collections.Generic;
  140. using System.Linq;
  141. using System.Web;
  142. using System.Web.Mvc;
  143. using MyLibrary;
  144. using Webdiyer.WebControls.Mvc;
  145. namespace web.Controllers
  146. {
  147. public class HomeController : Controller
  148. {
  149. private Entities et = new Entities();
  150. // GET: Home
  151. public ActionResult Index()
  152. {
  153. return View();
  154. }
  155. public void delzg()
  156. {
  157. decimal id = decimal .Parse(Request.Params["id"]);
  158. var shanchu = et.WEB_KEHU.FirstOrDefault(k=>k.K_ID==id);
  159. et.WEB_KEHU.Remove(shanchu);
  160. et.SaveChanges();
  161. Response.Write("1");
  162. }
  163. public ActionResult AjaxPaging(int id = 1)
  164. {
  165. var model= et.WEB_KEHU.OrderByDescending(a=>a.K_ID).ToPagedList(id, 5);
  166. //Session["page"] = id;
  167. //int count = model.Count();
  168. string sj = DateTime.Now.ToString("yyyyMMddhhmmss");
  169. return View(model);
  170. }
  171. public ActionResult search()
  172. {
  173. return View();
  174. }
  175. }
  176. }
复制代码

最新评论

小黑屋|在路上 ( 蜀ICP备15035742号-1 

;

GMT+8, 2025-7-8 06:52

Copyright 2015-2025 djqfx

返回顶部