以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  分页显示后台数据问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=173302)

--  作者:狐表(小白)
--  发布时间:2021/11/23 15:44:00
--  分页显示后台数据问题
代码如下,通过文本框输入的值作为过滤条件加载数据库数据,每次单击下一页按钮时,总是自动跳转到输入文本提交查询界面,怎么修改?
Dim e As RequestEventArgs = Args(0)
Dim wb As New weui

If e.Path.StartsWith("Reports\\")
    Select Case e.Path
Case "Reports\\rwtb.htm"  \'任务填报
Dim yg as string
If e.PostValues.Count = 0 Then    
    wb.AddForm("","form1","rwtb.htm")
            With wb.AddInputGroup("form1","ipg1"," 生产任务填报")
    With .AddInput("xm","员工姓名","text")
\'.value = yg
End With
            End With
            With wb.AddButtonGroup("form1","btngrp1",false) \'水平排列
                .Add("btn1", "查询", "submit")
            End With
        Else
    e.Resp
        yg = e.PostValues("xm")
            Dim page As Integer = 0 \'默认page为0,显示第一页
            Dim pageRows As Integer = 20 \'每页10行
            If e.GetValues.ContainsKey("page") Then  \'如果地址中有page参数
                Integer.TryParse(e.GetValues("page"), page) \'提取page参数
            End If
            Dim StartRow As Integer = page * pageRows \'此页第一行
            Dim EndRow As Integer = (page + 1) * pageRows - 1 \'此页最后一行
            Dim cmd As New SQLCommand
            cmd.C \'记得设置数据源名称
            cmd.CommandText = "Select Count(*) Fr om {V_APP_生产完成填报明细} where 派工员工 = \'" & yg & "\'"
            Dim Count1 As Integer = cmd.ExecuteScalar() \'获取总的行数
            cmd.CommandText = "Select * Fr om (Select Row_Number() Over(Order by 订单编号) As RowNum,* Fr om {V_APP_生产完成填报明细} where 派工员工 = \'" & yg & "\') as a"
            cmd.CommandText = cmd.CommandText & "  Where RowNum >= " & StartRow & " And RowNum <= " & EndRow
            Dim dts As DataTable = cmd.ExecuteReader \'获取该页数据
            Dim sb As New StringBuilder
            Dim nms() As String = {"工序","订单编号","派工单号","产品型号","派工数量","派工金额"}
            sb.AppendLine("<Table border=\'1\'>") 
            sb.AppendLine("<caption>生产任务完成填报<caption></br>")
            sb.Append("<tr>")
            For Each nm As String In nms
                sb.Append("<td>" & nm & "</td>")
            Next
            sb.AppendLine("</tr>")
            For Each r As DataRow In dts.DataRows
                sb.Append("<tr>")
                For Each nm As String In nms
                     sb.Append("<td>" & r(nm) & "</td>")
                Next
    sb.Append("<td><a href=\'edit.htm?id=" & r("RowNum") & "&page=" & page & "\'>查看</a></td>")
                \'sb.Append("<td><a href=\'delete.htm?id=" & r("_Identify") & "&page=" & page & "\'>删除</a></td>")
                sb.AppendLine("</tr>")
            Next
            sb.AppendLine("</Table></br></br>")
            If page > 0 Then
                sb.Append("<a href=\'rwtb.htm?page=" & page - 1 & "\'>上一页</a> ")
            End If
            If EndRow < Count1 -1 Then
                sb.Append("<a href=\'rwtb.htm?page=" & page + 1 & "\'>下一页 </a>" )
            End If
            e.WriteString(sb.ToString)
        End If
[此贴子已经被作者于2021/11/23 15:45:40编辑过]

--  作者:有点蓝
--  发布时间:2021/11/23 16:07:00
--  
参考:http://www.foxtable.com/mobilehelp/topics/0116.htm