| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1149 人关注过本帖
标题:创建了一个CA类后,如何打开和浏览表
只看楼主 加入收藏
fanjinyu9108
Rank: 2
等 级:论坛游民
帖 子:704
专家分:20
注 册:2014-1-16
结帖率:88.62%
收藏
已结贴  问题点数:14 回复次数:2 
创建了一个CA类后,如何打开和浏览表
以下是我创建的一个基于本地数据库的CA类,请问如何使用,浏览表,显示没有打开的表
ca.rar (4.21 KB)
搜索更多相关主题的帖子: 本地 创建 打开 浏览 显示 
2021-05-09 15:07
schtg
Rank: 12Rank: 12Rank: 12
来 自:Usa
等 级:贵宾
威 望:67
帖 子:1744
专家分:3333
注 册:2012-2-29
收藏
得分:14 
贴一帖我收集的示例,仅供参考。
程序代码:
PUBLIC oform1
  oform1=Newobject("Form1")
  oform1.Show
  RETURN

DEFINE CLASS Form1 AS form
    DEClass = "de"
    Top = 0
    Left = 0
    Height = 315
    Width = 561
    DoCreate = .T.
    Caption = "Form1"
    Name = "Form1"

    ADD OBJECT grdDmk AS grid WITH ;
        ColumnCount = 5,;
        Height = 200,;
        Left = 18,;
        RecordSource = "",;
        RecordSourceType = 0,;
        Top = 12,;
        Width = 414,;
        Name = "grdDmk",;
        Column1.ControlSource = "",;
        Column1.Name = "Column1",;
        Column2.ControlSource = "",;
        Column2.Name = "Column2",;
        Column3.ControlSource = "",;
        Column3.Name = "Column3",;
        Column4.ControlSource = "",;
        Column4.Name = "Column4",;
        Column5.ControlSource = "",;
        Column5.Name = "Column5"

    ADD OBJECT CA保存1 AS CA保存 WITH ;
        Top = 228,;
        Left = 120,;
        table = "dmk",;
        Name = "CA保存1"

    PROCEDURE Load
        CLOSE DATABASES ALL
        CLOSE ALL
        
        IF FILE(SYS(5)+CURDIR()+"dmk.dbf")
           ELSE
          CREATE dbf  dmk(id n(5,0),mc c(12),py c(12),dm c(13),id2 n(7,2),xh c(5))
          INSERT INTO dmk(id,mc,py,dm,id2,xh) values(1,"张三","ZS","123456789",123.11,"A01")
          INSERT INTO dmk(id,mc,py,dm,id2,xh) values(2,"李四","LS","912345678",789.12,"A02")
          INSERT INTO dmk(id,mc,py,dm,id2,xh) values(3,"王五","WW","812345679",456.23,"A03")
          INSERT INTO dmk(id,mc,py,dm,id2,xh) values(4,"孙六","SL","712345689",104.37,"A04")
          INSERT INTO dmk(id,mc,py,dm,id2,xh) values(5,"何二","HE","612345789",589.56,"A05")
          INSERT INTO dmk(id,mc,py,dm,id2,xh) values(6,"赵七","ZQ","512347890",321.13,"A06")
          INSERT INTO dmk(id,mc,py,dm,id2,xh) values(7,"钱一","QY","412356789",678.15,"A07")
          INSERT INTO dmk(id,mc,py,dm,id2,xh) values(8,"林八","LB","312456789",512.31,"A08")
          INSERT INTO dmk(id,mc,py,dm,id2,xh) values(9,"周九","ZJ","213456789",123.32,"A09")    
       ENDIF
       CLOSE ALL
       USE dmk ALIAS dmk IN 0
    ENDPROC


ENDDEFINE

DEFINE CLASS CA保存 AS commandbutton
    Height = 25
    Width = 60
    Caption = "CA保存"
    table = ""
    table2 = ""
    table3 = ""
    Name = "CA保存"

    PROCEDURE next
        
    ENDPROC
        
    PROCEDURE Init
        SET MULTILOCKS on
        If !Isblank(This.Table)
           =CURSORSETPROP('buffering',5,this.table )
        ENDIF
        
        IF !Isblank(This.table2)
           =CURSORSETPROP('buffering',5,this.table2)
        ENDIF
        
        IF !Isblank(This.table3)
           =CURSORSETPROP('buffering',5,this.table3)
        ENDIF
        
        WITH thisform.GRDdmk
              FOR I=1 TO .COLUMNCOUNT
                  .COLUMNS(I).HEADER1.CAPTION=FIELD(I)
                  .COLUMNS(I).HEADER1.ALIGNMENT=2
                  .COLUMNS(I).header1.Fontsize= 9 
                  .COLUMNS(I).header1.Fontname='微软雅黑'
              ENDFOR

 
               thisform.GRDdmk.column1.header1.caption = "序号"
               thisform.GRDdmk.column2.header1.caption = "名称"
               thisform.GRDdmk.column3.header1.caption = "拼音"
               thisform.GRDdmk.column4.header1.caption = "代码"
               thisform.GRDdmk.column5.header1.caption = "数量"

 
         ENDWITH
        
    ENDPROC
        
    PROCEDURE Click
        Begin Transaction
        If !Isblank(This.Table)
            t1=Tableupdate(.T.,.T.,This.Table)
        Else
            t1=.T.
        Endif
        If !Isblank(This.table2)
            t2=Tableupdate(.T.,.T.,This.Table2)
        Else
            t2=.T.
        Endif
        If !Isblank(This.table3)
            t3=Tableupdate(.T.,.T.,This.Table3)
        Else
            t3=.T.
        Endif
        If t1 And t2 And t3
            Wait Window '保存成功!' Nowait
            End Transaction
        Else
            Wait Window '数据已经变化,不能保存!'  Nowait
            Rollback
            If !Isblank(This.Table)
                = Tablerevert(.T.,This.Table)
            Endif
            If !Isblank(This.table2)
                = Tablerevert(.T.,This.Table2)
            Endif
            If !Isblank(This.table3)
                = Tablerevert(.T.,This.Table3)
            Endif
        Endif
        If !Isblank(This.Table)
            mtab1=This.Table
        Endif
        If !Isblank(This.Table2)
            mtab2=This.Table2
            Thisform.DE.&mtab2..CursorRefresh()
        Endif
        If !Isblank(This.Table3)
            mtab3=This.Table3
            Thisform.DE.&mtab3..CursorRefresh()
        Endif
        This.Next()
    ENDPROC
ENDDEFINE

DEFINE CLASS de AS dataenvironment
    Tag = "dsn=Visual FoxPro Database;uid=admin"
    DataSourceType = "ODBC"
    Name = "de"

    ADD OBJECT dmk AS cursoradapter WITH ;
        Height = 22,;
        Width = 23,;
        UseDeDataSource = .T.,;
        SelectCmd = "select id, mc, py, dm, id2 from dmk",;
        CursorSchema = "id I, mc C(20), py C(20), dm C(20), id2 I",;
        Alias = "dmk",;
        BufferModeOverride = 5,;
        Flags = 0,;
        FetchSize = -1,;
        KeyFieldList = "id",;
        Tables = "dmk",;
        UpdatableFieldList = "id, mc, py, dm, id2",;
        UpdateNameList = "id dmk.id, mc dmk.mc, py dmk.py, dm dmk.dm, id2 dmk.id2",;
        UseCursorSchema = .T.,;
        Name = "dmk"

    PROCEDURE BeforeOpenTables
        This.DataSource = sqlstringconnect([dsn=Visual FoxPro Database;uid=admin])
    ENDPROC
        
    PROCEDURE dmk.AutoOpen
        Return DoDefault()
        With This As CursorAdapter
            Text To .SelectCmd Textmerge NoShow PreText 15
                select id, mc, py, dm, id2 from dmk
            EndText
            Text To .CursorSchema Textmerge NoShow PreText 15
                id I,
                mc C(20),
                py C(20),
                dm C(20),
                id2 I
            EndText
            Text To .UpdatableFieldList Textmerge NoShow PreText 15
                id,
                mc,
                py,
                dm,
                id2
            EndText
            Text To .UpdateNameList Textmerge NoShow PreText 15
                id dmk.id,
                mc dmk.mc,
                py dmk.py,
                dm dmk.dm,
                id2 dmk.id2
            EndText
            .Alias = "dmk"
            .KeyFieldList = "id"
            .Tables = "dmk"
            .InsertCmdRefreshCmd = ""
            .InsertCmdRefreshKeyFieldList = ""
            .FetchMemo = .T.
            .FetchSize = -1
            .AllowUpdate = .T.
            .ConflictCheckType = 0
            .ConflictCheckCmd = ""
            .DataSourceType = ""
            .MapVarchar = .F.
            .TimestampFieldList = ""
            .UseCursorSchema = .T.
        EndWith
    ENDPROC
ENDDEFINE
2021-05-09 17:13
fanjinyu9108
Rank: 2
等 级:论坛游民
帖 子:704
专家分:20
注 册:2014-1-16
收藏
得分:0 
非常感谢,我来慢慢学习
2021-05-09 19:05
快速回复:创建了一个CA类后,如何打开和浏览表
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.060590 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved