|
18.12.2007, 04:00 | #1 |
Участник
|
C# and AX Development: Using the .NET Business Connector for Dynamics AX / Axapta
Источник: http://olondono.blogspot.com/2007/12...ector-for.html
============== Axapta ax; AxaptaRecord custtable; AxaptaObject query; AxaptaObject queryrun; AxaptaObject querybuilddatasource; AxaptaObject querybuildrange; //--------------------------------- // Making logon ax = new Axapta(); ax.Logon("", "", "", ""); //--------------------------------- //--------------------------------- // Create query objects and query data query = ax.CreateAxaptaObject("Query"); querybuilddatasource = query.Call("AddDataSource", 77) as AxaptaObject; // CustTable's tableId = 77 querybuildrange = querybuilddatasource.Call("AddRange", 1) as AxaptaObject; // AccountNum's fieldId = 1 querybuildrange.Call("value", "4000"); // We're looking for customer with AccountNum=4000 //--------------------------------- //--------------------------------- // Run query queryrun = ax.CreateAxaptaObject("QueryRun", query) as AxaptaObject; queryrun.Call("prompt"); queryrun.Call("next"); //--------------------------------- //--------------------------------- // Get result custtable = queryrun.Call("getNo", 1) as AxaptaRecord; MessageBox.Show((string)custtable.get_Field("Name")); //--------------------------------- //--------------------------------- // Making logoff ax.Logoff(); //--------------------------------- NOTE: Add reference to the Microsoft.Dynamics.BusinessConnectorNet library. Or, using the EASY WAY: Axapta ax; AxaptaRecord custtable; AxaptaObject connTest; //--------------------------------- // Making logon ax = new Axapta(); ax.Logon("", "", "", ""); //--------------------------------- //--------------------------------- // Make a call to our class and get the Customer connTest = ax.CreateAxaptaObject("ConnTest"); custtable = connTest.Call("getCust", "4000") as AxaptaRecord; MessageBox.Show((string)custtable.get_Field("Name")); //--------------------------------- //--------------------------------- // Making logoff ax.Logoff(); //--------------------------------- And the Axapta Class 'ConnTest' looks like: 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; } Источник: http://olondono.blogspot.com/2007/12...ector-for.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|