Dim txt As String = e.Sender.Value
If txt = "" Then
e.Form.Controls("Panel2").Visible = True
Else
e.Form.StopRedraw()
e.Form.Controls("Panel2").Visible = False
Dim dtb As New DataTableBuilder("统计")
dtb.AddDef("供货方名称", GetType(String), 100)
dtb.AddDef("采购合同金额", GetType(Double))
dtb.AddDef("已支付金额", GetType(Double))
dtb.AddDef("未支付金额", GetType(Double))
dtb.AddDef("已开piao金额", GetType(Double))
dtb.AddDef("未开piao金额", GetType(Double))
dtb.AddDef("是否异常", GetType(Boolean))
dtb.AddDef("异常原因", GetType(String), 50)
dtb.Build()
Dim dt1 As DataTable = DataTables("采购合同管理")
Dim dt2 As DataTable = DataTables("委托支付管理")
Dim dt3 As DataTable = DataTables("进项piao录入")
For Each nm As String In dt1.SQLGetValues("供货方名称", "[项目名称] = '" & txt & "'")
Dim dr As DataRow = DataTables("统计").AddNew()
dr("供货方名称") = nm
dr("采购合同金额") = dt1.sqlCompute("Sum(采购合同金额)", "[供货方名称] = '" & dr("供货方名称") & "'")
dr("已支付金额") = dt2.sqlCompute("Sum(付款金额)", "[供货方名称] = '" & dr("供货方名称") & "'")
dr("未支付金额") = dr("采购合同金额") - dr("已支付金额")
dr("已开piao金额") = dt3.sqlCompute("Sum(税价合计金额)", "[供货方名称] = '" & dr("供货方名称") & "'")
dr("未开piao金额") = dr("已支付金额") - dr("已开piao金额")
If dr("未开piao金额") < 0 Then
dr("是否异常") = True
dr("异常原因") = "开piao金额大余委托支付金额"
ElseIf dr("未开piao金额") > 0 Then
dr("是否异常") = True
dr("异常原因") = "付款后未收到足额的进项piao"
End If
Next
' MainTable = Tables("统计")
With Tables("采购合同数据分析_Table1")
.DataSource = dtb.BuildDataSource()
.DataTable.DataCols.Add("序号", GetType(Integer)) '新增序号列
.DataTable.DataCols.Add("备注", GetType(String)) '新增序号列
.Cols("序号").Move(0)
For Each r As Row In Tables("采购合同数据分析_Table1").Rows
r("序号") = r.index + 1
Next
.DefaultRowHeight = 25 '所有行高
.Cols("序号").TextAlign = TextAlignEnum.Center '居中
.Cols("序号").Width = 60
.Cols("供货方名称").Width = 300
.Cols("采购合同金额").Width = 120
.Cols("已支付金额").Width = 120
.Cols("未支付金额").Width = 120
.Cols("已开piao金额").Width = 120
.Cols("未开piao金额").Width = 120
.Cols("是否异常").Width = 70
.Cols("异常原因").Width = 300
.ExtendLastCol = True '自动列宽
End With
e.Form.ResumeRedraw()
End If