Axapta ax; AxaptaRecord custtable; AxaptaObject query; AxaptaObject queryrun; AxaptaObject querybuilddatasource; AxaptaObject querybuildrange; ax = new Axapta(); ax.Logon( "" , "" , "" , "" ); query = ax.CreateAxaptaObject( "Query" ); querybuilddatasource = query.Call( "AddDataSource" , 77) as AxaptaObject; querybuildrange = querybuilddatasource.Call( "AddRange" , 1) as AxaptaObject; querybuildrange.Call( "value" , "4000" ); queryrun = ax.CreateAxaptaObject( "QueryRun" , query) as AxaptaObject; queryrun.Call( "prompt" ); queryrun.Call( "next" ); custtable = queryrun.Call( "getNo" , 1) as AxaptaRecord; MessageBox.Show(( string )custtable.get_Field( "Name" )); ax.Logoff(); |
需要添加引用 Microsoft.Dynamics.BusinessConnectorNet 简单的:
Axapta ax; AxaptaRecord custtable; AxaptaObject connTest; ax = new Axapta(); ax.Logon( "" , "" , "" , "" ); connTest = ax.CreateAxaptaObject( "ConnTest" ); custtable = connTest.Call( "getCust" , "4000" ) as AxaptaRecord; MessageBox.Show(( string )custtable.get_Field( "Name" )); ax.Logoff(); |
ax中代码:
class ConnTest { } public CustTable getCust(str _custAccount) { Query q; QueryRun qr; QueryBuildDataSource qbds; QueryBuildRange qrange; TableId _tableId; CustTable _custtable; ; _tableId = tablename2id( "CustTable" ); q = new Query(); qbds = q.addDataSource(_tableId); qrange = qbds.addRange(fieldname2id(_tableId, "AccountNum" )); qrange.value(_custAccount); qr = new QueryRun(q); qr.interactive( false ); qr.prompt(); if (qr.next()) _custtable = qr.getNo(1); return _custtable; } |