zoukankan      html  css  js  c++  java
  • DTcms会员中心添加新页面-会员投稿,获得所有文章并分页

    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.UILabelarticle.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.UIPage下新建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);
            }
        }
    }

    模版文件:templatesmain下新建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配置

    最终效果

  • 相关阅读:
    javascript:void(0)是什么意思 天高地厚
    C#开发 WinForm中窗体显示和窗体传值相关知识
    c#在WinForm中重写ProgressBar控件(带%的显示)
    flash在C#中的应用
    c# winform 关于DataGridView的一些操作
    winform中输入数据的验证
    RadioButton和CheckBox
    Manifest文件的配置
    简单程序用于熟悉Activity生命周期
    Activity的生命周期
  • 原文地址:https://www.cnblogs.com/qigege/p/4967444.html
Copyright © 2011-2022 走看看