创建了一个CA类后,如何打开和浏览表
以下是我创建的一个基于本地数据库的CA类,请问如何使用,浏览表,显示没有打开的表
ca.rar
(4.21 KB)
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