Foxtable(狐表)用户栏目专家坐堂 → [分享]万能数据字典自定义模块


  共有4934人关注过本帖平板打印复制链接

主题:[分享]万能数据字典自定义模块

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


加好友 发短信
等级:小狐 帖子:360 积分:2794 威望:0 精华:0 注册:2010/4/30 18:38:00
[分享]万能数据字典自定义模块  发帖心情 Post By:2013/11/12 9:24:00 [只看该作者]

万能数据字典自定义模块, 

针对项目内所有表可以自定义相关字段下拉列表内容、是否允许编辑、是否为多值字段。

 

 下载信息  [文件大小:   下载次数: ]
点击浏览该文件:万能数据字典.foxdb

 

 

 

试用版和商业版用户先建设表,然后设置以下代码即可使用。如果觉得好用,请回复多点贴子,让更多的人使用这个扩展列表功能!

  

一、建表:列项设置

停用() ----> 逻辑型

表名() ----> 字符型(20)

列名() ----> 字符型(20)

下拉选项() ----> 字符型(536870910)

多值字段() ----> 逻辑型

允许编辑() ----> 逻辑型

 

二、代码

全局表事件代码:

1、PrepareEdit

==========================

Dim dr As DataRow
If e.Isfocuscell Then
    If e.col.IsString Then
        dr=DataTables("列项设置").find("表名='" & CurrentTable.name & "' and 列名='" & e.col.name & "' and 下拉选项 Is not null and 停用=false")
        If dr IsNot Nothing Then
            If dr("多值字段")=True Then
                DataTables(CurrentTable.name).DataCols(e.col.name).ExtendType = ExtendTypeEnum.Values
            ElseIf dr("多值字段")=False Then
                DataTables(CurrentTable.name).DataCols(e.col.name).ExtendType = ExtendTypeEnum.none
            End If
            e.col.AllowDirectType=dr("允许编辑")
            e.col.combolist=dr("下拉选项")
        Else
            e.col.combolist=""
        End If
    End If
End If
Select Case e.Table.name
    Case "列项设置"
        Select Case e.col.name
            Case "表名"
                Dim s As String
                For Each tb As Table In Tables
                    If s="" Then
                        s=tb.name
                    Else
                        s=s & "|" & tb.name
                    End If
                Next
                e.col.AllowDirectType=False
                e.col.combolist=s
            Case "列名"
                Dim s As String
                If e.Row.Isnull("表名")=False Then
                    For Each c As col In Tables(e.Row("表名")).cols
                        If DataTables(e.Row("表名")).datacols(c.name).IsString Then
                            If s="" Then
                                s=c.name
                            Else
                                s=s & "|" & c.name
                            End If
                        End If
                    Next
                    e.col.AllowDirectType=False
                    e.col.combolist=s
                End If
            Case "下拉选项"
                If e.Row.Isnull("表名") OrElse e.Row.Isnull("列名") Then
                    e.cancel=True
                End If
        End Select
End Select

 

 

2、DataColChanged

==========================

Dim dr As DataRow=e.DataRow
Select Case e.DataTable.name
    Case "列项设置"
        If e.DataCol.name="表名" Then
            If dr.Isnull("表名") OrElse e.NewValue<>e.OldValue Then
                dr("列名")=Nothing
            End If
        End If
End Select

 

 

3、Initialize (项目事件)

==========================

For Each dt As DataTable In DataTables
    dt.GlobalHandler.DataColChanged = True
    dt.GlobalHandler.PrepareEdit = True
Next


 

[此贴子已经被作者于2013-11-14 13:12:42编辑过]

 回到顶部
总数 13 1 2 下一页