宝哥软件园

ASP .净MVC5网站开发显示文章列表(九)

编辑:宝哥软件园 来源:互联网 时间:2021-09-08

老习惯,先上个效果图:

1、在IBLL在InterfaceCommonModelService接口中添加获取公共模型列表的方法首先排序方法

///摘要///排序////summary///param name=' entity s '数据实体集/param ///param name='roderCode '排序代码[默认:身份证降序]/param///returns/returns iqueryablecommon model Order(iqueryablecommon model entity s,int roder code);查询数据方法///摘要///查询分页数据列表////summary///param name='总记录'总记录数/param ///param name='model '模型【全部全部】/param ///param name='pageIndex '页码/param ///param name='pageSize '每页记录数/param ///param name='title '标题【不使用设置空字符串】/param ///param name='categoryID '栏目【身份证】不使用设0】/param ///param name='inputer '用户名【不使用设置空字符串】/param ///param name='fromDate '起始日期【可为null】/param///param name=' ToDate '截止日期【可为【空】/param///param名称='订单代码'排序码/param /返回分页数据列表/返回IQueryableCommonModel查找页面列表(out int totalRecord、int pageIndex、int pageSize ),字符串模型、字符串标题、int categoryID、字符串输入器、NullableDateTime fromDate、NullableDateTime toDate、int order code);2、BLL

在CommonModelService写方法实现代码,内容都很简单主要是思路,直接上代码公共IQueryableCommonModel查找页面列表(out int totalRecord、int pageIndex、int pageSize ),字符串模型、字符串标题、int categoryID、字符串输入器、NullableDateTime fromDate、NullableDateTime toDate、int orderCode) { //获取实体列表IQueryableCommonModel _ common models=当前位置.实体;if (model==null || model!=' All ')_通用模型=_通用模型.其中(厘米=厘米. model==model);if(!字符串IsNullOrEmpty(title))_通用模型=_通用模型.其中(厘米=厘米。标题。包含(标题));if(categoryID 0)_公共模型=_公共模型.其中(厘米=厘米CategoryID==CategoryID);if(!字符串IsNullOrEmpty(inputer))_通用模型=_通用模型.其中(厘米=厘米. inputer==inputer);if (fromDate!=null)_通用模型=_通用模型.其中(厘米=厘米发布日期=开始日期);如果(今天!=null)_通用模型=_通用模型.其中(厘米=厘米.发布日期=ToDate);_常用型号=订单(_常用型号,订单代码);totalRecord=_commonModels .count();返回页面列表(_commonModels,pageIndex,pageSize).AsQueryable();}公共IQueryableCommonModel Order(IQueryableCommonModel实体,内部订单代码){ switch(订单代码){//默认排序default: entitys=entitys .orderbydecoding(cm=cm .发布日期);打破;}返回实体}3、网络由于CommonModel跟我们前台显示的数据并不一致,为了照顾数据网格中的数据显示再在尼尼微。网络模型中再构造一个视图模型CommonModelViewModel

使用系统;命名空间尼尼微.网络。模型{///摘要////通用模型视图模型///备注///创建:2014 .03 .10////备注////摘要公共类CommonModelViewModel { public int modelID { get;设置;} ///摘要///栏目ID////summary public int CategoryID { get;设置;} ///摘要///栏目名称////摘要公共字符串CategoryName { get设置;} ///摘要///模型名称////汇总公共字符串模型{ get设置;} ///摘要///标题////摘要公共字符串标题{ get设置;} ///摘要///录入者////摘要公共字符串输入器{ get设置;} ///摘要///点击////summary public int Hits { get;设置;} ///摘要///发布日期////摘要公共日期时间释放日期{获取设置;} ///摘要///状态////summary public int Status { get;设置;} ///摘要///状态文字////摘要公共字符串StatusString { get { return Ninesky .模型。公共模型。状态列表[状态];} } ///摘要///首页图片////摘要公共字符串DefaultPicUrl { get设置;} }}在文章控制器中添加一个返回json类型的JsonList方法

///摘要///文章列表【Json】注意权限问题,普通人员是否可以访问?】////summary ///param name='title '标题/param ///param name='input '录入/param ///param name='category '栏目/param ///param名称='从日期'日期起/param ///param name='toDate '日期止/param ///param name='pageIndex '页码/param ///param name='pageSize '每页记录/param////返回/返回公共操作结果JsonList(字符串标题、字符串输入、Nullableint类别、NullableDateTime fromDate、NullableDateTime toDate、int pageIndex=1、int pageSize=20) { if(类别==null)类别=0;int _ totalvar _ rows=commonModelService .FindPageList(out _total,pageIndex,pageSize,' Article ',title,(int)类别,输入,开始日期,结束日期,0)。选择(厘米=新的尼尼微网络。模特。commonmodelviewmodel(){ CategoryID=cm .CategoryID,CategoryName=cm .类别。名称,DefaultPicUrl=cm .默认图片,点击量=厘米.点击,输入=厘米。输入器,型号=厘米。模型,ModelID=cm .模型号,发布日期=厘米.发布日期,状态=厘米。状态,标题=厘米标题});返回Json(new { total=_total,rows=_rows .to list()});}下面是做界面了,在添加目录方法,这里不提供任何数据,数据在JsonList中获得

///摘要///全部文章////summary////returns/returns public action result List(){ return View();}右键添加视图

div id=' toolbar ' div a href=' # ' class=' measuri-link button ' data-options=' icon cl s 3360 ' icon-edit ',plain:true '修改/a a href=' # ' class=' measuri-link button ' data-options=' iconcl s 3360 ' icon-remove ',plain:true ' '删除/a a href=' # ' class=' measuri-link button ' data-options=' iconcl s 3360 ' icon-reload ',plain : true ' onclick=' $(' # article _ list ').datagrid(' reload ');'刷新/a /div div class='form-inline '标签栏目/labelinput id='combo_category '数据-选项=' url: ' @ Url .操作(' JsonTree ',' Category ',新{ model=' Article ' })' class=' measuri-combo tree '/标签标题/label input id=' textbox _ title ' class=' input-measuri ' style=' width :280 px '/label录入人/label input id=' textbox _ inputer ' class=' input-measuri '/label添加日期/label input id=' datebox _ from date ' type=' datetime ' class=' measuri-datebox ' style=' width :120 px /-input id=' datebox _ todate ' type=' datebox ' class=' measuri-datebox ' style=' width :120 px; /a href=' # ' id=' BTN _搜索'数据-选项=' iconcl s 3360 '图标-搜索' ' class=' easyui-link button '查询/a/div/div表id=' article _ list '/tablescript src=' http : ~/Scripts/common。js '/script脚本类型=' text/JavaScript ' $(' # article _ list ').datagrid({ loadMsg: '加载中……',分页:true,url: '@Url .操作(“JsonList”,“Article”),列: [[ { field: 'ModelID ',title: 'ID ',checkbox: true },{ field: 'CategoryName ',title: '栏目},{ field: 'Title ',title: '标题},{ field: 'Inputer ',title: '录入,align: 'right' },{ field: 'Hits ',title: '点击,align: 'right' },{ field: 'ReleaseDate ',title: '发布日期,对齐: '右',格式器:函数(值、行、索引){返回jsonDateFormat(值);} },{ field: 'StatusString ',title: '状态,width: 100,align: 'right' } ],toolbar: '#toolbar ',idField: 'ModelID ',});//查找$('#btn_search ').单击(函数(){ $('#article_list ')).datagrid('load ',{ title: $('#textbox_title ')).val(),input : $(“# textbox _ inputer”).val(),类别: $(' # combo _ category ').combotree('getValue '),FromDate : $(' # datebox _ Fromdate ').datebox('getValue '),today te : $(' # datebox _ today ').datebox(' GetVaLue ')});});}/脚本上面都是测量数据网格的内容。总体思路是基地址定位连接中实现查询公共模型列表,web中添加一个JsonList方法调用基地址定位连接中的方法并返回列表的Json类型。然后再添加一个目录调用JsonList用来显示。下篇文章做删除和修改操作,希望大家会持续关注。

更多资讯
游戏推荐
更多+