Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共9 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]代码错误,但不知错在何处,望高手赐教!

1楼
yanzhen2010 发表于:2011/8/27 17:27:00

If e.DataCol.Name = "住院号" Then
    If e.DataRow("住院号") IsNot Nothing Then
        Dim dr As DataRow = DataTables("长期医嘱").Find("[住院号] = '" & e.DataRow("住院号") & "'  ")
        If dr IsNot Nothing Then
            Dim cf As DataRow = DataTables("收费项目").Find("项目名称 = '餐费标准'")
            Dim jc As DataRow = DataTables("长期医嘱").Find("项目名称 = '诊疗费'And 执行 =1 And [住院号] = '" & e.DataRow("住院号") & "'")
            e.DataRow("本月开嘱日期") = DataTables("长期医嘱").Compute("min(开嘱日期)","[住院号] = '" & e.DataRow("住院号") & "'")
            e.DataRow("本月停嘱日期") = DataTables("长期医嘱").Compute("max(停嘱日期)","[住院号] = '" & e.DataRow("住院号") & "'")
            e.DataRow("假出日期") =jc("停嘱日期")
        Else
            e.DataRow("本月开嘱日期") = Nothing
            e.DataRow("本月停嘱日期") = Nothing
            e.DataRow("假出日期") =Nothing
        End If
    End If
End If

 

问题出在红色字体的代码上,加了条件[住院号] = '" & e.DataRow("住院号") & "'后出现问题。

 

 不管 执行 =1还是 执行 =true,代码分开写后,运行结果正确,代码如下:

If e.DataCol.Name = "住院号" Then
    If e.DataRow("住院号") IsNot Nothing Then
        Dim dr As DataRow = DataTables("长期医嘱").Find("[住院号] = '" & e.DataRow("住院号") & "'  ")
        Dim jc As DataRow = DataTables("长期医嘱").Find("项目名称 = '诊疗费'And 执行 =True And [住院号] = '" & e.DataRow("住院号") & "'")
           If dr IsNot Nothing Then
            Dim cf As DataRow = DataTables("收费项目").Find("项目名称 = '餐费标准'")
            e.DataRow("本月开嘱日期") = DataTables("长期医嘱").Compute("min(开嘱日期)","[住院号] = '" & e.DataRow("住院号") & "'")
            e.DataRow("本月停嘱日期") = DataTables("长期医嘱").Compute("max(停嘱日期)","[住院号] = '" & e.DataRow("住院号") & "'")
                   Else
            e.DataRow("本月开嘱日期") = Nothing
            e.DataRow("本月停嘱日期") = Nothing
                   End If
        If jc IsNot Nothing Then
            e.DataRow("假出日期") =jc("停嘱日期")
        Else
            e.DataRow("假出日期") =Nothing
        End If
    End If
End If

[此贴子已经被作者于2011-8-27 18:17:13编辑过]
2楼
hhbb 发表于:2011/8/27 17:59:00
Dim jc As DataRow = DataTables("长期医嘱").Find("项目名称 = '诊疗费' And 执行 =True And [住院号] = '" & e.DataRow("住院号") & "'")
3楼
yanzhen2010 发表于:2011/8/27 18:22:00

问题已升级,请高手指点:

如何找到第一行和最后一行

 

Dim jc As DataRow = DataTables("长期医嘱").Find("项目名称 = '诊疗费' And 执行 =True And [住院号] = '" & e.DataRow("住院号") & "'")

 

找出"长期医嘱"该住院号的第一个符合条件的数据,条件:项目名称= '诊疗费' 执行 =True

4楼
hhbb 发表于:2011/8/27 18:52:00
拜托看帮助
5楼
mr725 发表于:2011/8/27 20:48:00

Dim n As Integer = DataTables("长期医嘱").Compute("count(住院号)","你的条件···")

 

'最后一行

Dim jc As DataRow = DataTables("长期医嘱").Find("项目名称 = '诊疗费' And 执行 =True And [住院号] = '" & e.DataRow("住院号") & "'","",n-1)

6楼
yanzhen2010 发表于:2011/8/28 0:22:00
帮助看了n遍了,不符合我的要求。
7楼
czy 发表于:2011/8/28 0:48:00
什么破论坛啊,有回帖却看不到内容.
8楼
狐狸爸爸 发表于:2011/8/28 9:26:00

如何找出第一行和最后一行,这里有说明:
 
http://www.foxtable.com/help/topics/0396.htm

 

如果如果不根据Find的时候,应该设置排序参数,例如按日期排序,可以找出最早和最迟的一行,按价格排序,可以找出最贵和最便宜的商品。

在没有排序参数的情况下,所谓的第一行和最后一行,是没有意义的。
 

9楼
yanzhen2010 发表于:2011/8/28 10:48:00
以下是引用狐狸爸爸在2011-8-28 9:26:00的发言:

如何找出第一行和最后一行,这里有说明:
 
http://www.foxtable.com/help/topics/0396.htm

 

如果如果不根据Find的时候,应该设置排序参数,例如按日期排序,可以找出最早和最迟的一行,按价格排序,可以找出最贵和最便宜的商品。

在没有排序参数的情况下,所谓的第一行和最后一行,是没有意义的。
 

谢谢老总,帮助中的例子好像不太适合。如果符合条件的数据只有一行呢?我本来就要查找日期的,现在又要用日期排序,显得多余。

在易表中使用参数“1”第一行,“-1”最后一行。狐表只能用排序的办法解决吗?

共9 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .03125 s, 2 queries.