当前位置 : 主页 > 手机开发 > harmonyos >

XDownPage2.0使用简单例子一

来源:互联网 收集:自由互联 发布时间:2023-10-08
有朋友问关于XdownPage2.0的使用的问题。我现在举一个简单的例子,从我的程序中摘出来的。(太忙,有时间再举稍稍复杂的例子) 四个文件: conn.asp 数据库联接代码 config.asp 一段关于


有朋友问关于XdownPage2.0的使用的问题。我现在举一个简单的例子,从我的程序中摘出来的。(太忙,有时间再举稍稍复杂的例子)

四个文件: 

conn.asp   数据库联接代码
config.asp    一段关于排序相关的代码
pages.asp   分页代码
index.asp    主程序

排序时用到的两个图片:


 

为了精简代码,我将很多与本功能无关的代码都去掉了,样式代码也去掉了,所以界面很难看。

'------------------------------------
'''  conn.asp
'------------------------------------

dbuser="scott"
dbpwd="tiger"
dbsource="oracleDB"
Set conn = Server.CreateObject("ADODB.Connection")
conn.CommandTimeout =60
connstr="Provider=MSDAORA.1;User ID="&dbuser&"; Password="&dbpwd&"; Data Source="&dbsource
conn.Open connstrsub CloseConn()
 conn.close
 set conn=nothing
end sub

'------------------------------------
'''  config.asp
'------------------------------------

sImageDir="/" & getRoot() & "/images/"  '图片路径
   upOrderFlag="<img border=0 src='" &sImageDir &  "sort_asc.gif'>"      '升序排列显示图标
   downOrderFlag="<img border=0 src='" &sImageDir &  "sort_desc.gif'>"   '降序排列显示图标
 '获得当前连接的排序方向
  function getOrderDir(fn,ofn,oDir)
   dim tDir
   tDir="desc"
   if(lcase(fn)=lcase(ofn)) then
    if(lcase(oDir)="asc") then 
     tDir="desc"
    else
     tDir="asc"
    end if
   end if
   getOrderDir=tDir
  end function  '书写排序指示图标
  function writeOrderDir(fn,ofn,oDir)
   dim tDir
   if(lcase(fn)=lcase(ofn)) then
    if(lcase(oDir)="asc") then 
     tDir=UpOrderFlag
    else
     tDir=downOrderFlag
    end if
   end if
   writeOrderDir=tDir
  end function
  
    '添加排序列头
  sub WriteOrderHeader(pHeaderTitle,pOrderField,tOrderField,tOrderDir)
      Response.Write "<span οnclick=""gotoOrder('" & pOrderField & "','" & getOrderDir(pOrderField,tOrderField,tOrderDir) & "')"" class='noticetitle' style='width:90%;cursor:default'>" & pHeaderTitle & " " & writeOrderDir(pOrderField,tOrderField,tOrderDir) & "</span>"
  end sub 
  
   '获得当前虚拟目录的名字
 function getRoot()
    url=Request.ServerVariables("URL")
    url=right(url,len(url)-1)
    getRoot= mid(url,1,instr(url,"/")-1)
 end function
 
  ' (3)  asp->htm 过滤特殊字符,(单,双引号以及其他html敏感字符)以防止 asp 字符串 嵌入到 htm 中显示数据时丢失数据
  function FilterParam3(str1)
    fp1=str1
    if isnull(fp1) or isempty(fp1) then  fp1="" 
    fp1=server.HTMLEncode(fp1)
    FilterParam3=fp1
  end function

'------------------------------------
'''  pages.asp
'------------------------------------

'分页代码 靠过来就可以了,别忘了将一些忘了注释的说明文字注释掉

'------------------------------------
'''  index.asp
'------------------------------------

<%Response.Buffer=-1%>
<!--#include file="conn.asp"-->
<!--#include file="config.asp"-->
<!--#include file="pages.asp"--><%
'费率管理
'writer:northsnow
'create date  :050802
%>
<script language="javascript">
//执行动态排序
function gotoOrder(uOrderField,uOrderDir)
{
  frmHidden.currentpage.value="1";
  frmHidden.flag.value="query";
  frmHidden.orderField.value=uOrderField;
  frmHidden.orderDir.value=uOrderDir;
  frmHidden.submit();
}//执行查询前将查询条件写到隐藏表单
function query()
{
  var oFormHidden=document.frmHidden;
  if(!oFormHidden) return false;
  oFormHidden.currentpage.value="";
  oFormHidden.flag.value="query";
  oFormHidden.sm.value=frmList.sm.value;
  oFormHidden.cj.value=frmList.cj.value;
  oFormHidden.cj_code.value=frmList.cj_code.value;
  oFormHidden.submit();
}//重置查询条件
function myreset()
{
  frmList.sm.value="";
  frmList.cj.value="";
  frmList.cj_code.value="";
}
</script>
<%      'on error resume next 
        '获取参数
  dim cx,cj,cj_code
  dim currentpage,flag,pagesize,rsTotalCount,orderDir,orderField
  currentpage=trim(request.form("currentpage"))
  div_p=trim(request("div_p"))
  flag=trim(request("flag"))
  pagesize=trim(request("pagesize"))
  rsTotalCount=trim(request("rsTotalCount"))
  orderDir=trim(Request("orderdir"))
  orderField=trim(Request("orderfield"))
        cx=Request("cx")
        cj=trim(request("cj"))
        cj_code=trim(request("cj_code"))
        sm=trim(request("sm"))
%> 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body topmargin="4"><div align=center><span id="qSpan">
<form name="frmList" action="#" method="post">
 <span  class="titlestyle">变动费率管理</span> <br>
<fieldset style="width:100%;padding:'2px 2px'" align="center" class="border">
<legend  class="border" align=right style="border:0px">
 <a href="#"  _fcksavedurl=""#" " οnclick="javascript:query()"  tabindex="1">查询</a>|
 <a href="#" onClick="javascript:myresetcx()" >重置</a>
 </legend>
  <table width="100%" align="center" >
  <tr >
    <td valign="middle" align="center" >
      <table width="100%" border="0" cellspacing="0" cellpadding="0" >
          <tr>
   <td align="center" width="50%">费率说明:
       <input name="sm" type="text" class="line" value="<%=sm%>"></td>
   <td align="center" width="50%">车间:
       <input name="cj" type="text" class="line" readonly  size="22"><input name="cj_code" type="hidden" class="line"  size="22"><a href="#" οnclick="javascript:selectcj()"><img src="../images/viewnew.gif" alt="查找车间" border="0"></a></td>
          </tr>
      </table>
    </td>
  </tr></form>
</table>
</fieldset></span><table width=100% align=center border="0" cellpadding="0" cellspacing="0">
<form name="manForm"><tr><td align=center valign=top><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <%
     
            '读取数据
      set rs=server.CreateObject("adodb.recordset")
      rs.CursorLocation=3
    
     
    
     '//形成最后的sql
      sql="select * from V_FL_201 where 1=1 "
     
      if cj_code<>"" then
         sql=sql&" and dept_code='"&cj_code&"'"
      end if
      if sm<>"" then
         sql=sql&" and sm like '%"&sm&"%'"
      end if 
     
        '分析排序
      orderStr=""
      if orderField<>"" then  
      orderStr=" order by " & orderField
      if orderDir<>"" then orderStr=orderStr & " " & orderDir
      end if 
      if orderStr="" then orderStr=" order by dept_name" 
      if orderStr<>"" then sql=sql & orderStr
     
      if pagesize="" then pagesize=15
      Set mypage=new xdownpage   '创建对象
      mypage.getconn=conn        '得到数据库连接
      mypage.pagesize=pagesize   '设置每一页的记录条数据为5条
      mypage.totalRecordCount=rsTotalCount  '传递总记录数,分页的时候不用每次都去查一次      mypage.getsql=sql
      mypage.GetSubmitForm="frmHidden"
      Response.write(mypage.GetSubmitForm1())      set rs=mypage.getrs()    '返回Recordset
     %> 
    <tr height="28">
        <td align=center valign=top>
             <table cellspacing="1" class="tableBorder1" cellpadding=0  bordercolordark=#FFFFFF width="100%" bordercolorlight=#014E4B>
      <tr height="25">
                          <td valign="center" align="left" width="6%" class="noticetitle" background="../images/topbg.gif">
                              <%WriteOrderHeader "车间","dept_name",OrderField,OrderDir%></td>
                          <td valign="center" align="left" width="6%" class="noticetitle" background="../images/topbg.gif">
                              <%WriteOrderHeader "说明","sm",OrderField,OrderDir%></td>
                          <td valign="center" align="left" width="6%" class="noticetitle" background="../images/topbg.gif">
                              <%WriteOrderHeader "费率","fl",OrderField,OrderDir%></td>
                        </tr>
                      <%i=1
                        do while not rs.EOF %>  
                        <tr <% if i mod 2=0 then %> class="tr2" <%else %> class="tr1" <%end if %>>
       <td height="23" align="center" class="inputstyle" valign="top" readonly   title="<%=FilterParam3(rs("dept_name"))%>">
            <input name="cj_name<%=i%>"   size="18"  value="<%=FilterParam3(rs("dept_name"))%>"  readonly   class="no"></td>
       <td height="23" align="center">
            <input name="sm<%=i%>" style='width:100%'  maxlength="30"  value="<%=FilterParam3(rs("sm"))%>"  class="no"></td>
       <td height="23" align="center">
            <input name="fl<%=i%>"  style='width:100%'  value="<%=FilterParam3(rs("fl"))%>" class="no"></td>
      </tr>
                        
                        <% i=i+1 
                           rs.MoveNext 
                        loop%>
                    </table>
       </td>
     </tr> 
     <tr><td><% mypage.showpage()%> 
       <%mypage.ShowPageSizeChange()%></td></tr> 
   </table>
 <td></tr></form>
</table>
<!--隐藏表单,用于页面导航和查询。-->
<form name="frmHidden" method="post" action="#">
 <input type="hidden" id="div_p" name="div_p" value="<%=div_p%>">
 <input type="hidden" name="flag"  value="" ID="Hidden1">
 <input type="hidden" name="pagesize" value="<%=pagesize%>" ID="1">
 <input type="hidden" name="currentpage" value="<%=currentpage%>" ID="Hidden2">
 <input type="hidden" name="rsTotalCount" value="<%=rsTotalCount%>" ID="2">
 <input type="hidden" name="orderField" value="<%=orderField%>" ID="Hidden7">
    <input type="hidden" name="orderDir" value="<%=orderDir%>" ID="Hidden8">
 <input type="hidden" name="sm"  value="<%=sm%>">
    <input type="hidden" name="cj"  value="<%=cj%>">
    <input type="hidden" name="cj_code"  value="<%=cj_code%>">
</form>
</body>
</html>

这点代码的输出界面如下:

上一篇:asp下闰年计算方法
下一篇:没有了
网友评论