Rss & SiteMap

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

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

标题:[求助]代码不能正确返回姓名,请指教

1楼
yanzhen2010 发表于:2011/8/5 14:13:00

If e.DataCol.Name = "住院号" Then
    Dim vals() As String = e.NewValue.split(":")
    If vals.length > 2 Then
        e.DataRow("住院号") =vals(2)
    Else
        e.DataRow("住院号") =vals(0)
    End If
    Dim dr As DataRow = DataTables("入院登记").Find("[住院号] = '" & e.NewValue & "'")
    If dr IsNot Nothing Then
        e.DataRow("患者姓名") = dr("患者姓名")
    Else
        MsgBox("项目不存在,请重新输入!",64,"提示")
        e.DataRow("患者姓名") = Nothing
    End If
End If

 

执行后把姓名自动清空了

我的录入步骤:1、从列表项目分离出住院号,2、根据住院号找出匹配的姓名。如果没有匹配的姓名,则如下:
  MsgBox("项目不存在,请重新输入!",64,"提示")
        e.DataRow("患者姓名") = Nothing
[此贴子已经被作者于2011-8-5 14:14:06编辑过]
2楼
狐狸爸爸 发表于:2011/8/5 14:27:00

Dim dr As DataRow = DataTables("入院登记").Find("[住院号] = '" & e.NewValue & "'")

 

改为:

 

Dim dr As DataRow = DataTables("入院登记").Find("[住院号] = '" & e.DataRow("住院号") & "'")

3楼
yanzhen2010 发表于:2011/8/5 15:10:00
以下是引用狐狸爸爸在2011-8-5 14:27:00的发言:

Dim dr As DataRow = DataTables("入院登记"). 

改为:

 

Dim dr As DataRow = DataTables("入院登记").

我也试过,将Find("[住院号] = '" & e.NewValue & "'")改为Find("[住院号] = '" & e.DataRow("住院号") & "'")后可以返回姓名,但将住院号清空后又提示错误,姓名不能自动清空。

我的意思:

如果住院号匹配,找出匹配的姓名,

如果住院号不匹配,进行提示,

如果住院号为空,姓名为空。

[此贴子已经被作者于2011-8-5 15:12:55编辑过]
4楼
狐狸爸爸 发表于:2011/8/5 15:18:00

If e.DataCol.Name = "住院号" Then
    Dim vals() As String = e.NewValue.split(":")
    If vals.length > 2 Then
        e.DataRow("住院号") =vals(2)
    Else
        e.DataRow("住院号") =vals(0)
    End If
    If e.DataRow.Isnull("住院号") Then
        e.DataRow("患者姓名") = Nothing
    Else
        Dim dr As DataRow = DataTables("入院登记").Find("[住院号] = '" & e.DataRow("住院号") & "'")
        If dr IsNot Nothing Then
            e.DataRow("患者姓名") = dr("患者姓名")
        Else
            MsgBox("项目不存在,请重新输入!",64,"提示")
            e.DataRow("患者姓名") = Nothing
        End If
    End If
End If

 

5楼
mr725 发表于:2011/8/5 15:25:00

最前面加上一个判断:

If e.NewValue = Nothing Then

Else

    Dim vals() As String = e.NewValue.split(":")
    If vals.length > 2 Then
        e.DataRow("住院号") =vals(2)
    Else
        e.DataRow("住院号") =vals(0)
    End If

..................

6楼
yanzhen2010 发表于:2011/8/5 16:06:00
以下是引用狐狸爸爸在2011-8-5 15:18:00的发言:

If e.DataCol.Name = "住院号" Then
    Dim vals() As String = e.NewValue.split(":")
    If vals.length > 2 Then
        e.DataRow("住院号") =vals(2)
    Else
        e.DataRow("住院号") =vals(0)
    End If
    If e.DataRow.Isnull("住院号") Then
        e.DataRow("患者姓名") = Nothing
    Else
        Dim dr As DataRow = DataTables("入院登记").Find("[住院号] = '" & e.DataRow("住院号") & "'")
        If dr IsNot Nothing Then
            e.DataRow("患者姓名") = dr("患者姓名")
        Else
            MsgBox("项目不存在,请重新输入!",64,"提示")
            e.DataRow("患者姓名") = Nothing
        End If
    End If
End If

 

不管 If e.DataRow.Isnull("住院号") Then
        e.DataRow("患者姓名") = Nothing
加在什么地方,都提示错误

是不是语言逻辑错误

清空住院号时好像和这一段有冲突 

Dim vals() As String = e.NewValue.split(":")
    If vals.length > 2 Then
        e.DataRow("住院号") =vals(2)
    Else
        e.DataRow("住院号") =vals(0)
    End If
感觉问题出在此处

[此贴子已经被作者于2011-8-5 16:15:36编辑过]
7楼
mr725 发表于:2011/8/5 16:10:00

这样呢:

 

If e.DataCol.Name = "住院号" Then

 

If e.NewValue = Nothing Then

Else

    Dim vals() As String = e.NewValue.split(":")
    If vals.length > 2 Then
        e.DataRow("住院号") =vals(2)
    Else
        e.DataRow("住院号") =vals(0)
    End If
    Dim dr As DataRow = DataTables("入院登记").Find("[住院号] = '" & e.NewValue & "'")
    If dr IsNot Nothing Then
        e.DataRow("患者姓名") = dr("患者姓名")
    Else
        MsgBox("项目不存在,请重新输入!",64,"提示")
        e.DataRow("患者姓名") = Nothing
    End If
End If


End If

 

 

或者把:

If e.NewValue = Nothing Then

Else

换成:

   If e.DataRow.Isnull("住院号") Then

    Else

[此贴子已经被作者于2011-8-5 16:12:43编辑过]
8楼
yanzhen2010 发表于:2011/8/5 17:40:00
以下是引用mr725在2011-8-5 16:10:00的发言:

这样呢:

 

If e.DataCol.Name = "住院号" Then

 

If e.NewValue = Nothing Then

Else

    Dim vals() As String = e.NewValue.split(":")
    If vals.length > 2 Then
        e.DataRow("住院号") =vals(2)
    Else
        e.DataRow("住院号") =vals(0)
    End If
    Dim dr As DataRow = DataTables("入院登记").Find("[住院号] = '" & e.NewValue & "'")
    If dr IsNot Nothing Then
        e.DataRow("患者姓名") = dr("患者姓名")
    Else
        MsgBox("项目不存在,请重新输入!",64,"提示")
        e.DataRow("患者姓名") = Nothing
    End If
End If


End If

 

 

或者把:

If e.NewValue = Nothing Then

Else

换成:

   If e.DataRow.Isnull("住院号") Then

    Else

[此贴子已经被作者于2011-8-5 16:12:43编辑过]

谢谢朋友,问题没有解决,清空住院号,错误依旧

9楼
mr725 发表于:2011/8/5 17:53:00
你发个例子上来吧,这样来回都没有效果,说明你的东东别人没有理解或····  总之原因很多啦···
10楼
blackzhu 发表于:2011/8/5 17:55:00
If e.NewValue is Nothing Then
共16 条记录, 每页显示 10 条, 页签: [1] [2]

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

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