Foxtable(狐表)用户栏目专家坐堂 → [求助]求一个简单的自动填表实例


  共有13814人关注过本帖树形打印复制链接

主题:[求助]求一个简单的自动填表实例

帅哥哟,离线,有人找我吗?
mr725
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 一级勋章
等级:MVP荣誉狐 帖子:5154 积分:31434 威望:0 精华:8 注册:2008/9/8 12:27:00
  发帖心情 Post By:2010/5/23 10:07:00 [显示全部帖子]

试试这个(放在datacolchanged事件中):

dim bm as string = currenttable.current("部门编码")
Dim ls() as String
ls = bm.split("-")
If bm <> "" Then
    Select Case ls.Length
        Case 1
            currenttable.current("部门全称") = currenttable.current("部门名称")
        Case 2
            Dim dr As DataRow
            dr = DataTables("部门表").Find("部门编码 = '" & ls(0) & "'")
            currenttable.current("部门全称") = dr("部门名称") & "-" & currenttable.current("部门名称")
        Case 3
            Dim dr As DataRow
            dr = DataTables("部门表").Find("部门编码 = '" & ls(0) & "-" & ls(1) & "'")

            currenttable.current("部门全称") = dr("部门全称") & "-" & currenttable.current("部门名称")
    End Select
End If

[此贴子已经被作者于2010-5-23 10:07:24编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
mr725
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 一级勋章
等级:MVP荣誉狐 帖子:5154 积分:31434 威望:0 精华:8 注册:2008/9/8 12:27:00
  发帖心情 Post By:2010/5/23 11:20:00 [显示全部帖子]

以下是引用我会用狐表在2010-5-23 10:33:00的发言:
谢谢,但第二项要求“填列部门编码时,编码必需依级次增加,不能填无上级的编码”还不能满足,虽然有提示(提示好像是代码错误提示),但还是能填不符合要求的编码。如:在没有编码3的时候还是能填编码3-1或者3-2-1 。mr725兄再帮助完善一下

以为你会用狐表呢···    在4楼基础上再加些判断:

If e.DataCol.Name = "部门编码" and e.DataRow.IsNull("部门编码") Then
    e.DataRow("部门名称") = nothing
    e.DataRow("部门全称") = nothing
ElseIf e.DataCol.Name = "部门名称" and e.DataRow.IsNull("部门名称") Then
    e.DataRow("部门全称") = nothing
Else
    dim bm as string = e.DataRow("部门编码")
    Dim ls() as String
    ls = bm.split("-")
    If bm <> "" Then
        Select Case ls.Length
            Case 1
                e.DataRow("部门全称") = e.DataRow("部门名称")
            Case 2
                Dim dr As DataRow
                dr = DataTables("部门表").Find("部门编码 = '" & ls(0) & "'")
                if dr IsNot Nothing Then
                    e.DataRow("部门全称") = dr("部门名称") & "-" & e.DataRow("部门名称")
                else
                    messagebox.show("没有上一级编码")
                    e.DataRow("部门编码") = nothing
                end if
            Case 3
                Dim dr As DataRow
                dr = DataTables("部门表").Find("部门编码 = '" & ls(0) & "-" & ls(1) & "'")
                if dr IsNot Nothing Then
                    e.DataRow("部门全称") = dr("部门全称") & "-" & e.DataRow("部门名称")
                else
                    messagebox.show("没有上一级编码")
                    e.DataRow("部门编码") = nothing                
                end if
        End Select
    End If
End If


 回到顶部