后台:sql: <resultMaps>
<resultMap id="E_AnnoucementResult" class="E_Annoucement">
<result property="mRID" column="RID" IsPK="false" IsMandatory="true" DefaultVal="" IsList="true" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
<result property="mFID" column="FID" IsPK="false" IsMandatory="true" DefaultVal="" IsList="true" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
<result property="mFNumber" column="FNumber" IsPK="false" IsMandatory="true" DefaultVal="" IsList="true" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
<result property="mFTitle" column="FTitle" IsPK="false" IsMandatory="true" DefaultVal="" IsList="true" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
<result property="mFDescription" column="FDescription" IsPK="false" IsMandatory="true" DefaultVal="" IsList="true" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
<result property="mFType" column="FType" IsPK="false" IsMandatory="true" DefaultVal="" IsList="true" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
<result property="mFReleasebyName" column="FReleasebyName" IsPK="false" IsMandatory="true" DefaultVal="" IsList="true" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
<result property="mFReleaseby" column="FReleaseby" IsPK="false" IsMandatory="true" DefaultVal="" IsList="true" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
<result property="mFReleaseUnit" column="FReleaseUnit" IsPK="false" IsMandatory="true" DefaultVal="" IsList="true" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
<result property="mFReleaseUnitName" column="FReleaseUnitName" IsPK="false" IsMandatory="true" DefaultVal="" IsList="true" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
<result property="mFReleaseTime" column="FReleaseTime" IsPK="false" IsMandatory="true" DefaultVal="" IsList="true" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
<result property="mOrgUnitID" column="OrgUnitID" IsPK="false" IsMandatory="true" DefaultVal="" IsList="true" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
<result property="mLastUpdateby" column="LastUpdateby" IsPK="false" IsMandatory="true" DefaultVal="" IsList="true" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
<result property="mLastUpdatetime" column="LastUpdatetime" IsPK="false" IsMandatory="true" DefaultVal="" IsList="false" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
<result property="mCreateby" column="Createby" IsPK="false" IsMandatory="true" DefaultVal="" IsList="false" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
<result property="mCreatetime" column="Createtime" IsPK="false" IsMandatory="true" DefaultVal="" IsList="false" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
<result property="mFIsSystem" column="FIsSystem" IsPK="false" IsMandatory="true" DefaultVal="" IsList="false" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
<result property="mFStatus" column="FStatus" IsPK="false" IsMandatory="true" DefaultVal="" IsList="false" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
</resultMap>
<resultMap id="E_AnnoucementMasterSlaveResult" class="E_AnnoucementMasterSlave">
<result property="Masterid" column="Masterid" IsPK="false" IsMandatory="true" DefaultVal="" IsList="true" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
<result property="SlaveList" column="SlaveList" IsPK="false" IsMandatory="true" DefaultVal="" IsList="true" IsInserted="false" IsUpdated="false" IsQueryCondition="false" IsFK="false" RelationTable="" RelationTablePK="" IsRedundancyField="false" RegExp="" des=""/>
</resultMap>
</resultMaps>
<!--根据编号 名称 查询公告信息列表 --> <select id="QueryAnnoucement" parameterClass="Hashtable" resultMap="E_AnnoucementResult"> <![CDATA[ SELECT row_number() over(order by an.LastUpdatetime desc ) RID ,an.FID ,an.FNumber ,an.FTitle ,an.FDescription ,an.FType ,p.FName_L1 as FReleasebyName ,an.FReleaseby ,an.FReleaseUnit as FReleaseUnit ,(select FNAME_L1 from T_ORG_ORGUNIT where fid=FReleaseUnit) as FReleaseUnitName ,an.FReleaseTime ,an.FReplyContent ,an.FAuditby ,an.FAuditTime ,an.OrgUnitID ,an.LastUpdateby ,an.LastUpdatetime ,an.Createby ,an.CreateTime ,an.FIsSystem ,an.FStatus FROM t_PO_NM_AnnouncementNotice an , t_srm_user u ,t_org_personnel p WHERE u.fpersonid=p.fid and u.fid=an.freleaseby ]]> <dynamic > <!--<isNotEmpty prepend="AND" property="mLoginOrgID"> <![CDATA[ exists (select 'X' from ( select fid from t_org_orgunit o start with o.fid=#mLoginOrgID# connect by prior o.fid =o.fparentid ) a where a.fid=an.orgunitid) ]]> </isNotEmpty>--> <isNotEmpty prepend="AND" property="mFType"> <![CDATA[ an.FType=#mFType# ]]> </isNotEmpty> <isNotEmpty prepend="AND" property="mFReleaseTimeS"> <![CDATA[ to_char(an.FReleaseTime,'yyyy-MM-dd')>=#mFReleaseTimeS# ]]> </isNotEmpty> <isNotEmpty prepend="AND" property="mFReleaseTimeE"> <![CDATA[ to_char(an.FReleaseTime,'yyyy-MM-dd') <=#mFReleaseTimeE# ]]> </isNotEmpty> <isNotEmpty prepend="AND" property="mFTitle"> <![CDATA[ an.FTitle like '%$mFTitle$%' ]]> </isNotEmpty> <isNotEmpty prepend="AND" property="mFStatus"> <![CDATA[ an.FStatus like '%$mFStatus$%' ]]> </isNotEmpty> </dynamic> <![CDATA[order by an.LastUpdatetime desc ]]> </select>
前台页面:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="NM_Test" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <div class="pageHeader"> <form id="pagerForm" οnsubmit="return navTabSearch(this);" action="NM/Test.aspx" runat="server" method="post"> <div class="searchBar"> <input type="hidden" name="pageNum" value="1"/> <input type="hidden" id="page" name="numPerPage" value="<%=mNumPerPage%>" /> <table class="pageFormContent"> <tr> <td>发布时间从:</td> <td> <input type="text" id="FReleaseTimeS" name="FReleaseTimeS" field="FReleaseTimeS" class="date" runat="server"/> <a class="inputDateButton"href="javascript:;">选择</a> </td> <td>至:</td> <td> <input type="text" id="FReleaseTimeE" name="FReleaseTimeE" field="FReleaseTimeE" class="date" runat="server"/> <a class="inputDateButton"href="javascript:;">选择</a> </td> <td>主题:</td> <td> <input type="text" id="FTitle" name="FTitle" field="FTitle" runat="server"/> </td> </tr> </table> <div class="subBar"> <ul> <li id='liMsg'></li> <li> <div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnTestQuery">查询</button></div></div> </li> </ul> </div> </div> </form> </div> <div class="pageContent"> <div class="panelBar"> <ul class="toolBar"> <li><a class="add" href="NM/TestEdit.aspx" target="dialog" rel="公告维护" mask="true" max="true" title="公告维护"><span>添加</span></a></li> <li><a class="edit" href="NM/TestEdit.aspx?FID={fid}" target="dialog" rel="公告维护" mask="true" id="Edit" max="true"><span>修改</span></a></li> <li class="line">line</li> <li><a class="delete" href="#" id="btnTestDelete"><span>删除</span></a></li> <%--<li style="display:block"><a class="icon" href="#" target="dwzExport" targetType="navTab" id="export" οnclick="Save()"><span>导出EXCEL</span></a></li>--%> </ul> </div> <table class="table" width="100%" targetType="navTab" Layouth="150" id="tab"> <thead> <tr> <th width="40"><input type="checkbox" group="ids" class="checkboxCtrl"/></th> <th width="40">序号</th> <th>主题</th> <th width="200">发布单位</th> <th width="120">发布人</th> <th width="100">发布时间</th> </tr> </thead> <tbody id="table"> <asp:Repeater ID="rpGrid" runat="server"> <ItemTemplate> <%#DataBinder.Eval(Container.DataItem, "mFID", "<tr target=\"fid\" rel='{0}'>")%> <%#DataBinder.Eval(Container.DataItem, "mFID","<td align='center'><input name='ids' type='checkbox' value='{0}' ></td>")%> <td><%# DataBinder.Eval(Container.DataItem, "mRID")%> </td> <td><a href='NM/TestEdit.aspx?Action=edit&FID=<%#DataBinder.Eval(Container.DataItem, "mFID")%>' target="dialog" rel="公告编辑界面" mask="true" max="true" title="公告编辑界面"> <%# DataBinder.Eval(Container.DataItem, "mFTitle")%></a></td> <td><%# DataBinder.Eval(Container.DataItem, "mFReleaseUnitName")%> </td> <td><%# DataBinder.Eval(Container.DataItem, "mFReleaseByName")%> </td> <td><%# DataBinder.Eval(Container.DataItem, "mFReleaseTime", "{0:yyyy-MM-dd}")%> </td> </tr> </ItemTemplate> </asp:Repeater> </tbody> </table> <div class="panelBar"> <div class="pages"> <span>显示</span> <select id="numPerPage" class="combox" name="numPerPage" οnchange="navTabPageBreak({numPerPage:this.value})"> <option value="20">20</option> <option value="50">50</option> <option value="100">100</option> <option value="200">200</option> </select> <span>条,共<%=mTotalCount%>条</span> </div> <div class="pagination" targetType="navTab" totalCount="<%= mTotalCount%>" numPerPage="<%=mNumPerPage%>" pageNumShown="<%=mPageNumShown%>" currentPage="<%=mPageNum %>"></div> </div> </div> </body> </html>
后天代码:using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using SCM.POS.NM.Domain; using SCM.POS.NM.Service; using SCM.POS.BD.Service; using System.Collections; public partial class NM_Test : ERDP.Web.UI.ListPage, IHttpHandler { ERDP.Common.LoginSession _login = new ERDP.Common.LoginSession(); protected void Page_Load(object sender, EventArgs e) { try { _login = GetLoginSession(); if(IsPostBack) { BindDate(); } } catch (Exception ex ) { Response.Write("<script>alertMsg.error("+ex.Message .Replace("'","").Replace("/","")+")</script>"); } } /// <summary> /// 数据绑定,同时需要设置数据总条数,当前页,每天条数 /// 当前页与每页条数由页面中的pagerForm表单回传得到 /// </summary> private void BindDate() { Annoucement annoucement = Annoucement.GetInstance(); IList<E_Annoucement> e_annoucements = null;//返回对象集合 Hashtable QueryPara = new Hashtable(); //开始时间 if (Server.UrlDecode(Request["FReleaseTimeS"]) != "" && Server.UrlDecode(Request["FReleaseTimeS"])!=null) { QueryPara.Add("mFReleaseTimeS", Convert.ToDateTime( Server.UrlDecode(Request["FReleaseTimeS"])).ToString("yyyy-MM-dd"));//加入条件查询参数 } //结束时间 if (Server.UrlDecode(Request["FReleaseTimeE"]) != "" && Server.UrlDecode(Request["FReleaseTimeE"]) != null) { QueryPara.Add("mFReleaseTimeE", Convert.ToDateTime(Server.UrlDecode(Request["mFReleaseTimeE"])).ToString("yyyy-MM-dd"));//加入条件查询参数 } if (Server.UrlDecode(Request["FReleaseTimeS"])!="" && Server.UrlDecode(Request["FReleaseTimeE"])!="") { if (Convert.ToDateTime( Server.UrlDecode(Request["FReleaseTimeS"])) >Convert.ToDateTime( Server.UrlDecode(Request["FReleaseTimeE"]))) { Response.Write("<script type='text/javascript'>alertMsg.info('发布时间(从)大于发布时间(止)');</script>"); return;//调成函数,直接跳出正在执行的函数不执行return后面的代码比如一个方法,一个函数,一次循环等等 } } if (Server.UrlDecode(Request["FTitle"]) != "" && Server.UrlDecode(Request["FTitle"]) != null) { QueryPara.Add("mFTitle", Server.UrlDecode(Request["FTitle"]).Trim()); } QueryPara.Add("mFType", "001"); QueryPara.Add("mLoginOrgID", _login.mOUID); QueryPara.Add("mUserID", _login.mUserID); QueryPara.Add("mPageNum", mPageNum);//页数 QueryPara.Add("mNumPerPage", mNumPerPage); e_annoucements = annoucement.QueryAnnoucement(QueryPara);//查询返回 mTotalCount = e_annoucements.Count;//总条数 if (mTotalCount == 0) { this.rpGrid.DataSource = null; this.rpGrid.DataBind(); Response.Write("<script type='text/javascript'>alertMsg.info('此条件下暂无记录!');</script>"); //绑定 数据源 } else { var list= e_annoucements.Skip((mPageNum-1)*mPageNum).Take(mPageNum);//返回剩余的,从剩余的开始 this.rpGrid.DataSource = list ; this.rpGrid.DataBind(); } } }