以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  求助,谢谢  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=127731)

--  作者:ezilu
--  发布时间:2018/11/20 21:52:00
--  求助,谢谢
Dim dtb As New DataTableBuilder("全刀统计")
dtb.AddDef("全刀医师", Gettype(String), 16)
Dim prds As List(of String) = DataTables("患者信息").GetValues("手术类型")
For Each prd As String In prds
dtb.AddDef(prd & "_全刀台次", Gettype(Integer))
dtb.AddDef(prd & "_全刀费", Gettype(Double))

Next
dtb.Build()
For Each cus As String In DataTables("患者信息").GetValues("全刀医师")
Dim dr As DataRow = DataTables("全刀统计").AddNew()
dr("全刀医师") = cus
For Each prd As String In prds
dr(prd & "_全刀台次") = DataTables("患者信息").Compute("Count(患者姓名)","全刀医师 = \'" & cus & "\' And [手术类型] = \'" & prd & "\'")
dr(prd & "_全刀费") = DataTables("患者信息").Compute("Sum(全刀手术费)","全刀医师 = \'" & cus & "\' And [手术类型] = \'" & prd & "\'")
Next
Next
Tables("工作量计_Table1").DataSource = DataTables("全刀统计")

这个代码看上去没错  可以统计出数据,但是,只能点击一次,点击第二次执行后,会闪退,应该是存在一个临时表的原因吧,怎么解决!!!

--  作者:有点蓝
--  发布时间:2018/11/20 22:09:00
--  
Dim dtb As New DataTableBuilder("全刀统计")
dtb.AddDef("全刀医师", Gettype(String), 16)
Dim prds As List(of String) = DataTables("患者信息").GetValues("手术类型")
For Each prd As String In prds
    dtb.AddDef(prd & "_全刀台次", Gettype(Integer))
    dtb.AddDef(prd & "_全刀费", Gettype(Double))
Next
Dim dt As DataTable = dtb.Build(True)
For Each cus As String In DataTables("患者信息").GetValues("全刀医师")
    Dim dr As DataRow = dt.AddNew()
    dr("全刀医师") = cus
    For Each prd As String In prds
        dr(prd & "_全刀台次") = DataTables("患者信息").Compute("Count(患者姓名)","全刀医师 = \'" & cus & "\' And [手术类型] = \'" & prd & "\'")
        dr(prd & "_全刀费") = DataTables("患者信息").Compute("Sum(全刀手术费)","全刀医师 = \'" & cus & "\' And [手术类型] = \'" & prd & "\'")
    Next
Next
Tables("工作量计_Table1").DataSource = dt

--  作者:ezilu
--  发布时间:2018/11/20 23:48:00
--  
谢谢大大