内部函数list
Dim e As RequestEventArgs = args(0)
Dim wb As New WeUI
Dim flt As String
If e.GetValues.ContainsKey("unfilter") Then '如果是取消筛选
wb.ClearCookie() '清除Cookie
ElseIf e.PostValues.Count > 0
flt = Functions.Execute("GetFilter",e, wb) '根据输入内容合成条件,注意WeUI也需要传递过去
Else
flt = Functions.Execute("GetCookieFilter",e) '根据Cookie合成条件
End If
'获取要显示的页码
Dim page As Integer = 0 '默认page为0,显示第一页
Dim pageRows As Integer = 10 '每页10行
If e.GetValues.ContainsKey("page") Then '如果地址中有page参数
Integer.TryParse(e.GetValues("page"), page) '提取page参数
End If
Dim StartRow As Integer = page * pageRows + 1 '此页第一行
Dim EndRow As Integer = (page + 1) * pageRows '此页最后一行
'提取此页数据
Dim cmd As New SQLCommand
cmd.ConnectionName = "orders" '记得设置数据源名称
cmd.CommandText = "Select Count(*) From {订单}"
If flt > "" Then
cmd.CommandText = cmd.CommandText & " where " & flt
End If
Dim Count As Integer = cmd.ExecuteScalar() '获取总的行数
Dim Pages As Integer = Math.Ceiling(Count/PageRows) '计算出总页数
cmd.CommandText = "Select Top " & pagerows & " *,(数量*单价) As 金额 from (Select [_identify] as 订单编号,日期,客户,(Select sum(数量) from {订单} where 订单编号={订单}.订单编号) As 数量,单价,产品 From {订单}) A where "
If flt > "" Then
cmd.CommandText &= iif(page=0, "1=1 and " & flt , "[订单编号] not In (Select top " & pagerows * page & " [_identify] from {订单} order by [_identify]) and " & flt & " order by [订单编号]")
Else
cmd.CommandText &= iif(page=0, "1=1" , "[订单编号] not In (Select top " & pagerows * page & " [_identify] from {订单} order by [_identify]) order by [订单编号]")
End If
Dim dt As DataTable = cmd.ExecuteReader
'合成网页
With wb.AddTable("","Table1")
.ActiveSheet = "menu" '指定菜单
.CreateFromDataTable(cmd.ExecuteReader)
End With
With wb.AddButtonGroup("","btg2", False)
If page > 0 Then
.Add("btnFirst", "第一页","","List.htm?page=0")
.Add("btnPrev", "上一页","","List.htm?page=" & page - 1)
Else
.Add("btnFirst", "第一页","button").Kind = 1
.Add("btnPrev", "上一页","button").Kind = 1
End If
If Endrow < count Then
.Add("btnNext", "下一页","","List.htm?page=" & page + 1)
.Add("btnLast", "最末页","","List.htm?page=" & pages - 1)
Else
.Add("btnNext", "下一页","button").Kind = 1
.Add("btnLast", "最末页","button").Kind = 1
End If
End With
With wb.AddActionSheet("","menu") '设计菜单
If flt = "" Then
.Add("mnuFilter", "数据筛选","filter.htm")
Else
.Add("mnuUnFilter", "取消筛选","list.htm?unfilter=true")
End If
.Add("mnuStatistics", "数据统计","tongji.htm")
.Add("mnuCancel","取消","",True)
End With
e.WriteString(wb.Build)