Dim cmd As New SQLCommand
Dim dt As Date
cmd.C
cmd.CommandText = "Select GetDate()"
dt = cmd.ExecuteScalar()
e.Form.Controls("开始日期").value = dt.Date.AddDays(-365)
Dim jb As New SQLGroupTableBuilder("查询表1","租赁发货单表身")
jb.C
jb.AddTable("租赁发货单表身","发货单号","租赁发货单表头","发货单号")
Dim Cols() As String = {"发货单号","发货单序号"}
jb.AddTable("租赁发货单表身",Cols,"租赁返还单表身",Cols,JoinModeEnum.Left)
jb.AddTable("租赁返还单表身","返还单号","租赁返还单表头","返还单号")
jb.AddTable("租赁发货单表头","客户编码","客户信息设置","客户编码")
jb.AddTable("租赁发货单表身","物料编码","物料编码设置","物料编码")
jb.Groups.AddDef("{租赁发货单表头}.客户编码")
jb.Groups.AddDef("客户简称")
jb.Groups.AddDef("{租赁发货单表身}.物料编码")
jb.Groups.AddDef("物料名称") '根据产品名称分组
jb.Groups.AddDef("规格型号") '根据产品名称分组
jb.Totals.AddDef("{租赁发货单表身}.发货数量") '对数量进行统计
jb.Totals.AddDef("{租赁发货单表身}.返还数量") '对数量进行统计
jb.Totals.AddDef("{租赁返还单表身}.价税合计","租金") '对数量进行统计
jb.Filter = "{租赁发货单表头}.发货日期 >= '" & dt.Date.AddDays(-365) & "'"
jb.Build()