DTcms会员中心添加新页面-会员投稿,获得所有文章并分页

本文介绍了一个基于自定义分页的文章管理系统实现方案,包括DAL层、BLL层及UI层的具体实现细节,并展示了完整的HTML页面结构及后台逻辑交互。

DAL.article.cs

  /// <summary>
        /// 自定义:获得查询分页数据
        /// </summary>
        public DataSet GetList(int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * FROM " + databaseprefix + "article");
            
            if (strWhere.Trim() != "")
            {
                
                    strSql.Append(" where " + strWhere);
              
            }
            recordCount = Convert.ToInt32(DbHelperSQL.GetSingle(PagingHelper.CreateCountingSql(strSql.ToString())));
            return DbHelperSQL.Query(PagingHelper.CreatePagingSql(recordCount, pageSize, pageIndex, strSql.ToString(), filedOrder));
        }

BLL.article.cs

         /// <summary>
        /// 自定义:获得查询分页数据
        /// </summary>
        public DataSet GetList(int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            return dal.GetList(pageSize, pageIndex, strWhere, filedOrder,out recordCount);
        }

DTcms.Web.UI\Label\article.cs

 /// <summary>
        /// 自定义:文章分页列表(自定义页面大小)
        /// </summary>
        /// <param name="page_size">页面大小</param>
        /// <param name="page_index">当前页码</param>
        /// <param name="strwhere">查询条件</param>
        /// <param name="orderby">排序</param>
        /// <param name="totalcount">总记录数</param>
        /// <returns>DateTable</returns>
        protected DataTable get_article_list( int page_size, int page_index, string strwhere, out int totalcount)
        {
            DataTable dt = new DataTable();

            dt = new BLL.article().GetList(page_size, page_index, strwhere, " sort_id asc,add_time desc", out totalcount).Tables[0];
            
           
            return dt;
        }

DTcms.Web.UI\Page下新建user_article.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Web;
using DTcms.Common;

namespace DTcms.Web.UI.Page
{
    public partial class user_article : Web.UI.UserPage
    {
        protected int page;         //当前页码
        protected int totalcount;   //OUT数据总数
        /// <summary>
        /// 重写虚方法,此方法将在Init事件前执行
        /// </summary>
        protected override void InitPage()
        {
            page = DTRequest.GetQueryInt("page", 1);
        }
    }
}

模版文件:templates\main下新建user_article.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>文章管理 - {site.name}</title>
<meta name="keywords" content="{site.seo_keyword}" />
<meta name="description" content="{site.seo_description}" />
<link href="<%templateskin%>/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%templateskin%>/css/public.css" rel="stylesheet" type="text/css" />
 <link href="<%templateskin%>/css/index.css" rel="stylesheet" type="text/css" />

<link href="{config.webpath}css/pagination.css" rel="stylesheet" type="text/css" />
<link href="{config.webpath}scripts/artdialog/ui-dialog.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" charset="utf-8" src="{config.webpath}scripts/jquery/jquery-1.11.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="{config.webpath}scripts/artdialog/dialog-plus-min.js"></script>
<script type="text/javascript" charset="utf-8" src="<%templateskin%>/js/common.js"></script>
<script type="text/javascript">
    function ExecPostBack(checkValue) {
        if (arguments.length == 1) {
            ExecDelete('{config.webpath}tools/submit_ajax.ashx?action=user_address_delete', checkValue, '#turl');
        }else{
            var valueArr = '';
            $("input[name='checkId']:checked").each(function(i){
                valueArr += $(this).val();
                if(i < $("input[name='checkId']:checked").length - 1){
                    valueArr += ","
                }
            });
            ExecDelete('{config.webpath}tools/submit_ajax.ashx?action=user_address_delete', valueArr, '#turl');
        }
    }
</script>
</head>

<body>
<!--Header-->
<%template src="_header.html"%>
<!--/Header-->

<div class="section clearfix">
  <div class="line30"></div>

  <div class="info-wrap">
    <!--左侧导航-->
    <%template src="_ucenter_nav.html"%>
    <!--/左侧导航-->
    
    <!--右侧内容-->
    <div class="home-box">
      <!--收货地址列表-->
      <div class="u-tab-head">
        <p>
          <a class="selected" href="<%linkurl("user_article")%>">文章管理</a>
        </p>
        <span>
          
        </span>
      </div>
      <div class="u-tab-content">
        <div class="title-div">
          <strong>我的文章管理</strong>
        </div>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ftable">
          <tr>
            <th width="30">选择</td>
            <th align="left">标题</td>
            <th width="18%" align="left">状态</td>
            <th width="20%" align="left">时间</td>
            <th width="100">操作</td>
          </tr>
          <%set DataTable list=get_article_list(15, page, " user_name='"+userModel.user_name+"'", out totalcount)%><!--取得一个DataTable-->
          <%set string pagelist=get_page_link(15, page, totalcount, "user_article", "__id__")%> <!--取得分页页码列表-->
          <%foreach(DataRow dr in list.Rows)%>
            <tr>
              <td width="20" align="center">
                <input name="checkId" class="checkall" type="checkbox" value="{dr[id]}" >
              </td>
              <td>
                {dr[title]}
              </td>
              <td></td>
              <td></td>
              <td align="center">
                编辑 
         
              </td>
            </tr>
          <%/foreach%>
          <%if(list.Rows.Count==0)%>
            <tr><td colspan="5" align="center">暂无记录...</td></tr>
          <%/if%>
        </table>
        <div class="page-foot">
          <div class="flickr right">{pagelist}</div><!--放置页码列表-->
          <div class="page-btns">
            <a onclick="checkAll(this);" href="javascript:;">全选</a>
            <span class="pipe">|</span>
            <a onclick="ExecPostBack();" href="javascript:;">删除</a>
          </div>
        </div>
      </div>
      <input id="turl" type="hidden" value="<%linkurl("user_article")%>" /><!--存在跳转的URL值-->
      <!--/收货地址列表-->
    </div>
    <!--/右侧内容-->
  </div>
</div>

<!--Footer-->
<%template src="_footer.html"%>
<!--/Footer-->
</body>
</html>

页面中关键html代码

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="ftable">
          <tr>
            <th width="30">选择</td>
            <th align="left">标题</td>
            <th width="18%" align="left">状态</td>
            <th width="20%" align="left">时间</td>
            <th width="100">操作</td>
          </tr>
          <%set DataTable list=get_article_list(15, page, " user_name='"+userModel.user_name+"'", out totalcount)%><!--取得一个DataTable-->
          <%set string pagelist=get_page_link(15, page, totalcount, "user_article", "__id__")%> <!--取得分页页码列表-->
          <%foreach(DataRow dr in list.Rows)%>
            <tr>
              <td width="20" align="center">
                <input name="checkId" class="checkall" type="checkbox" value="{dr[id]}" >
              </td>
              <td>
                {dr[title]}
              </td>
              <td></td>
              <td></td>
              <td align="center">
                编辑 
         
              </td>
            </tr>
          <%/foreach%>
          <%if(list.Rows.Count==0)%>
            <tr><td colspan="5" align="center">暂无记录...</td></tr>
          <%/if%>
        </table>

在系统设置-URL配置

 

最终效果

转载于:https://www.cnblogs.com/qigege/p/4967444.html

此旗舰版 修改与 DTcms V5.0 正式版MSSQL源码 更新时间:2017年09月21日 在此版本基础上增加了所有旗 DTcms V5.0 旗舰版功能 经本人测试没测试出问题 如有发现问题可以留言 DTcms V5.0源码说明: 版本号:V5.0.0 数据库:MSSQL2005 修复日志: 2017-06-11 修复前台模板订单结算时地址无法选择BUG 2017-06-12 修复后台管理菜单无法上传图标的BUG 2017-07-09 修复第三方登录出错的BUG 2017-09-20 修复前台会员注册时获取手机验证码短信防止注册机重复发送短信BUG DTcms5.0改进的地方: 1. 后台管理界面加强美化,使用矢量图标代替位图,对于树型菜单增加可闭合和展开,调整了部分页面的布局; 2. 对于会员、订单等进行站点归类,更好区分每个站点数据; 3. 创建频道时,根据选择的功能创建不同的管理菜单; 4. 网页编辑器使用了UEditor百度编辑器,上传进行了改造,使用二进制上传文件; 5. 支付方式,第三方登录OAuth可每个站点设置不同的配置信息,不再限于全局使用; 6. 对系统架构进行全新改造,每增加一个频道自动创建对象数据库表存储; 7. 插件模板支持不同的站点可创建不同的对应模板; 8. DAL层代码改进,通过反射进行解析Model实体自动赋值,不必担心增加数据库字段而修改DAL层烦恼; 二、安装环境要求 开发工具:Microsoft Visual Studio 2010 操作系统:Windows Server 2008(推荐) 、Windows Server 2003(推荐)、Windows XP(基础测试环境) 数据库: Sql Server 2005(推荐)、Sql Server 2008(推荐) Web服务器:IIS 5.0及以上版本(推荐IIS7.0,应用池为集成模式) 环境要求:.NET Framework 4.x及以上
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值