代码如下....
Dim q As new QueryBuilder
q.TableName = "清单"
q.SelectString = "select 住院ID,类别,sum(round(单价 * 用量,2)) as 金额 from [H_YIZ] where (开始日期 <= '" & d & "'and 停止日期 > '" & d & "' and 停止日期 is not null) or (开始日期 <= '" & d & "' and 停止日期 is null) and 住院ID in (" & sql & ") GROUP BY 住院ID,类别"
q.C
q.Build
If tables("清单").rows.count > 0 Then
中间省略..........
Else
MsgBox("该日无数据!",64,"提示")
End If
此主题相关图片如下:001.jpg
[此贴子已经被作者于2009-2-27 11:06:08编辑过]
未更新前还好好的...
看全部代码...
Dim dt As DataTable
Dim cmd As New SQLCommand
cmd.C
Dim sql as string = e.Form.Controls("CheckListBox1").value
Dim d as string = e.Form.Controls("DateTimePicker1").value
If sql = "" Then
MsgBox("请至少选择一名患者!",64,"提示")
Else If d = nothing Then
MsgBox("请选择清单日期!",64,"提示")
Else
Dim q As new QueryBuilder
q.TableName = "一日清单"
q.SelectString = "select 住院ID,类别,sum(round(单价 * 用量,2)) as 金额 from [H_YIZ] where (开始日期 <= '" & d & "'and 停止日期 > '" & d & "' and 停止日期 is not null) or (开始日期 <= '" & d & "' and 停止日期 is null) and 住院ID in (" & sql & ") GROUP BY 住院ID,类别"
q.C
q.Build
If tables("一日清单").rows.count > 0 Then
Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim tbl As Table = Tables("一日清单")
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String) = tbl.DataTable.GetUniqueValues("","住院ID")
doc.Pagesetting.LandScape = false
For Each Region As String In Regions
Dim rs As New prt.RenderTable
Dim dr As DataRow = datatables("住院信息").find("[住院ID] = '" & region & "'")
rs.Cells(0,0).Text = tables("单位信息")(0)("单位名称") & "住院费用每日清单"
rs.Cells(0,1).Text = " "
rs.Cells(1,1).Text = "床位: " & dr("床位") & " 姓名: " & dr("姓名") & " 住院号 : " & dr("住院号")
rs.Cells(1,0).Text = "费用日期: " & d
rs.Cells(0,0).SpanCols = 2
rs.Style.FontSize = 10
rs.Cells(0,0).Style.FontBold = True
rs.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
doc.Body.Children.Add(rs)
rt = New prt.RenderTable
rt.Style.TextAlignVert = prt.AlignVertEnum.Center
rt.Style.GridLines.Top = New prt.LineDef(0.4,Color.Black)
rt.Style.Spacing.Bottom = 5
rt.CellStyle.Spacing.All = 1
rt.Style.Font = tbl.Font
Rows = tbl.Datatable.Select("[住院ID] = '" & Region & "'")
rt.Cells(0,0).Text = "项目"
rt.Cells(0,1).Text = "金额"
rt.Cells(0,2).Text = "项目"
rt.Cells(0,3).Text = "金额"
rt.Cells(0,4).Text = "项目"
rt.Cells(0,5).Text = "金额"
For r As Integer = 0 To Rows.Count - 1
Dim x As Integer = (r Mod 6)+1
Dim y As Integer = (r \ 6) * 2
rt.Cells(x,y).Text = Rows(r)("类别")
rt.Cells(x,y+1).Text = Rows(r)("金额") & "元"
Next
Dim i as double = 0
For ii as integer = 0 To Rows.Count - 1
i = i + Rows(ii)("金额")
Next
rt.Cells(6,4).Text = "合计 :"
rt.Cells(6,5).Text = i & "元"
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
rt.Style.Gridlines.Horz = New prt.Linedef(0.3,Color.LightGray)
doc.Body.Children.Add(rt)
Next
doc.preview()
Else
MsgBox("该日无数据!",64,"提示")
End If
End If
[此贴子已经被作者于2009-2-27 10:07:17编辑过]
老爹...找到问题所在...
select 住院ID,类别,sum(round(单价 * 用量,2)) as 金额 from [H_YIZ] where (开始日期
<= '" & d & "'and 停止日期 > '" & d & "' and 停止日期 is not null) or (开始日期
<= '" & d & "' and 停止日期 is null) and 住院ID in (" & sql & ") GROUP BY 住院ID,类别
把"="号去掉就不会出错!!!.....WHY?难道日期比较不能用<=?
[此贴子已经被作者于2009-2-27 10:32:13编辑过]
也许问题不在这里。你留意一下生成的查询表,是不是确实筛选出了你要的内容。
可以肯定问题在这里啊...去掉=号虽然筛选的数据不合要求..但功能完全正常..
连MsgBox弹出都正常.(这个相当于OutPut.show了.)
就算筛选不出数据也应该弹出MsgBox呀..
难道是中间的代码出错? 我再检查下..
[此贴子已经被作者于2009-2-27 10:51:10编辑过]
真是见鬼了....2种方式的筛选数据完全正常...单纯一个按钮啊....同样的操作,同样的临时表....就是不知道问题在哪...
两种筛选方式出来的数据除了行数不同,其他是一样的啊...
此主题相关图片如下:001.jpg
此主题相关图片如下:002.jpg
[此贴子已经被作者于2009-2-27 11:00:46编辑过]