以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  代码执行不太正确,请高手指点  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=11620)

--  作者:yanzhen2010
--  发布时间:2011/8/5 9:32:00
--  代码执行不太正确,请高手指点

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

 

可能是分为两步的原因,但如何合并到一起呢?

[此贴子已经被作者于2011-8-5 9:33:23编辑过]

--  作者:狐狸爸爸
--  发布时间:2011/8/5 9:44: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

--  作者:yanzhen2010
--  发布时间:2011/8/5 11:15:00
--  
以下是引用狐狸爸爸在2011-8-5 9:44: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
老总的代码不能正确返回“姓名”,我乱改了一下,换可以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.DataRow("住院号") & "\'")
    If dr IsNot Nothing Then
        e.DataRow("患者姓名") = dr("患者姓名")
    Else
        MsgBox("项目不存在,请重新输入!",64,"提示")
        e.DataRow("患者姓名") = Nothing
    End If
End If
不知符合语法不?
还是有问题,当拼音码为空时,不能自动清除姓名。
 

[此贴子已经被作者于2011-8-5 11:23:55编辑过]

--  作者:yanzhen2010
--  发布时间:2011/8/5 11:28:00
--  
以下是引用狐狸爸爸在2011-8-5 9:44: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("患者姓名")
我的录入步骤:1、从列表项目分离出住院号,2、根据住院号找出匹配的姓名。如果没有匹配的姓名,则如下:
  MsgBox("项目不存在,请重新输入!",64,"提示")
        e.DataRow("患者姓名") = Nothing