1 //生成导入模板 2 void creatTemplate() 3 { 4 SysExcelApplication m_application; 5 SysExcelWorkbooks m_workbooks; 6 SysExcelWorkbook m_workbook; 7 SysExcelWorksheets m_worksheets; 8 SysExcelWorksheet m_worksheet; 9 SysExcelCells m_cells; 10 int ... Read More
posted @ 2012-08-30 16:14
Sprite.z
Views(358)
Comments(0)
Diggs(0)
比如,已知一个扩展类型是ProjCategoryId,下面的代码将为你找出所有使用过这个扩展类型的表。 1 static void findTableWithProjCategoryId(Args _args) 2 { 3 xInfo xInfo = new xInfo(); 4 5 treeNode t = xInfo.rootNode().AOTfindChild("DataDictionary").AOTfindChild("Tables"); 6 treeNode childNode; 7 treeNode fields; 8 treenod.. Read More
posted @ 2012-08-30 16:10
Sprite.z
Views(268)
Comments(0)
Diggs(0)
curuserId()当前用户IDcurext()当前公司IDappl.company().ext()当前公司IDfieldid2pname(tablenum(VendTable),fieldnum(VendTable,DlvTerm)))获取字段名setFocus()获得焦点infolog.activateWindow(form.hWnd())获取窗口焦点currency::curPrice2CurPrice(Price,CurrencyCode,"USD",CurrencyDate)价格汇率转换Currency::curAmount2CurAmount();金额汇率转换 Read More
posted @ 2012-08-30 16:10
Sprite.z
Views(533)
Comments(0)
Diggs(0)
在某个class(比如可以加在winAPI中)中增加如下的方法,然后调用此方法即可。 1 client static str getPrivateProfileString(str section, str key, str value, str file) 2 { 3 #WinAPI 4 #define.sizeOfStringValue(1024) 5 Binary stringValue; 6 7 DLL DLL = new DLL(#KERNELDLL); 8 DLLFunction method = ... Read More
posted @ 2012-08-30 16:09
Sprite.z
Views(215)
Comments(0)
Diggs(0)
比如要在下拉框中显示ItemID,但是只显示ItemGroup='Group1' 且 ItemType='Bom'的物项,那么传统的使用扩展类型的方法就不使用了,因为扩展类型不能动态传递参数(Itemgroup和ITEMTYPE)。第一步,在InventTable里建立一个方法,lookupItemByItemTypeGroup。 1 client static void lookupItemByItemTypeGroup(FormStringControl lookupCtrl,ItemGroupId ItemGroupId,ItemType _ItemTYp Read More
posted @ 2012-08-30 16:03
Sprite.z
Views(517)
Comments(0)
Diggs(0)
有几个Ax开头的class值得我们研究一下,下面就是调用AxSalesTable和AxSalesLine来创建销售单的例子。 1 static void main(Args args) 2 { 3 AxSalesTable axSalesTable; 4 AxSalesLine axSalesLine; 5 ; 6 // 建立销售单头 7 axSalesTable = new AxSalesTable(); 8 axSalesTable.purchOrderFormNum('CUSTPONUM'); 9 axSalesTable.cust... Read More
posted @ 2012-08-30 15:59
Sprite.z
Views(265)
Comments(0)
Diggs(0)
1 static void Jinn_printter(Args _args) 2 { 3 Args m_args = new Args(); 4 SysReportRun m_reportRun; 5 printJobSettings m_printJobSettings = new printJobSettings(); 6 7 boolean isCorrect = true; 8 ; 9 try10 {11 if (winAPI::fileExists(... Read More
posted @ 2012-08-30 15:56
Sprite.z
Views(204)
Comments(0)
Diggs(0)
1 if (infolog.language() == "zh-hans")2 infolog.language("en-us");3 else4 infolog.language("zh-hans");5 infolog.navPane().loadStartupButtons();6 Infolog.navPane().refreshFavorites(infolog.navPane().selectedFavoriteGroup(), xInfo::currentWorkspaceNum()); Read More
posted @ 2012-08-30 15:54
Sprite.z
Views(189)
Comments(0)
Diggs(0)
窗体分隔符是通过组(group)容器来实现的,将它添加到窗口后,将属性HideIfEmpty和AlignChild设置为No;FrameType设置为Raise 3D;设置好其它外观样式后,重写它的鼠标事件就可以实现了。 1 int mouseUp(int x, int y, int button, boolean ctrl, boolean shift) 2 { 3 int ret; 4 ret = super(x, y, button, ctrl, shift); 5 return _formSplitterVertical.mouseUp(x, y, button... Read More
posted @ 2012-08-30 15:54
Sprite.z
Views(275)
Comments(0)
Diggs(0)
1 void resetUserData() 2 { 3 DialogButton button; 4 SysLastValue sysLastValue; 5 Dialog Dialog = new Dialog("@SYS70748"); 6 DialogField dlg = Dialog.addField(typeid(UserId)); 7 userId userId; 8 ; 9 dlg.value(curuserId());10 Dialog.doInit();... Read More
posted @ 2012-08-30 15:53
Sprite.z
Views(402)
Comments(0)
Diggs(0)
1 void clicked() 2 { 3 Dialog Dialog = new Dialog("Destroy Content Pane Window"); 4 DialogField dlgHide = Dialog.addField(typeid(Noyes),"Hide Content Pane Window"); 5 DialogField dlgShow = Dialog.addField(typeid(Noyes),"Show Content Pane Window"); 6 Dia... Read More
posted @ 2012-08-30 15:52
Sprite.z
Views(281)
Comments(0)
Diggs(0)
1 static void Job_ScheduleBatch2(Args _args) 2 { 3 BatchHeader batHeader; 4 BatchInfo batInfo; 5 RunBaseBatch rbbTask; 6 str sParmCaption = "My RunbaseBatch Report Run"; 7 ; 8 rbbTask = new AV_RunbaseBatchDemo(); 9 batInfo = rbbTask .batchInfo();10 batInfo .parmCapti... Read More
posted @ 2012-08-30 15:51
Sprite.z
Views(172)
Comments(0)
Diggs(0)
1 public int monthDiff(date _start, date _end) 2 { 3 int diff; 4 int startYear, startMonth; 5 int endYear, endMonth; 6 ; 7 startYear = year(_start); 8 startMonth = mthofyr(_start); 9 endYear = year(_end);10 endMonth = mthofyr(_end);11 //year12 //endYear... Read More
posted @ 2012-08-30 15:50
Sprite.z
Views(255)
Comments(0)
Diggs(0)
Job:1 static void testDialogJob(Args _args)2 {3 testDialogClass testDialogClass ;4 ;5 testDialogClass = new testDialogClass() ;6 info(testDialogClass.mystr()) ;7 }Class: 1 class testDialogClass 2 { 3 str mystr ; 4 } 5 void new() 6 { 7 Args args = new Args(); 8 FormRun fo... Read More
posted @ 2012-08-30 13:55
Sprite.z
Views(260)
Comments(0)
Diggs(0)
Here is a sample class which is called via Dialog framework to create & post free text invoice using X++ code. 1 public void xtest() 2 { 3 Dialog dialog; 4 DialogField dlgCustAcc; 5 DialogGroup dialogPeriodLengthGroup, dialogPeriodLengthGroup1; 6 DialogField dlgLedgerAcc... Read More
posted @ 2012-08-30 13:47
Sprite.z
Views(1292)
Comments(0)
Diggs(0)
今天我向大家介绍一种方法,用X++写一个方法就可以完成上述功能。1、在窗体下写下如下两个方法: 1 1、 2 3 public void gotoMainTable(Object ctrl, boolean isParmObject=false, container refFrom=connull()) 4 { 5 TableName tableName; 6 FormName formName; 7 int tableID; 8 int fieldID; 9 int ... Read More
posted @ 2012-08-30 13:38
Sprite.z
Views(253)
Comments(0)
Diggs(0)
1 UserGroupList UserGroupList;2 ;3 while select UserGroupList where UserGroupList.userId == curuserid()4 {5 info(UserGroupList.groupId);6 } Read More
posted @ 2012-08-30 13:35
Sprite.z
Views(301)
Comments(0)
Diggs(0)
1 Void click() 2 { 3 InventDim inventDim; 4 InventSum inventSum; 5 InventQty inventQty; 6 itemID YourItemID; 7 ; 8 YourItemID = 'YourItemID'; 9 while select sum(postedQty), sum(received), sum(deducted), sum(registered), sum(picked), sum(reservPhysical)10 from ... Read More
posted @ 2012-08-30 11:46
Sprite.z
Views(207)
Comments(0)
Diggs(0)
1 void saveimage()2 {3 image MyImage = new image();4 str 260 imgPath = EAMParameters::filePath();//从companyinfo表得到路径,页可以自定义你自己的路径5 ;6 MyImage.saveImage(imgPath + filename, ImageSaveType::BMP_UNCOMP);//filename是新的文件名7 } Read More
posted @ 2012-08-30 11:43
Sprite.z
Views(144)
Comments(0)
Diggs(0)
1 static void jobMain(Args _args) 2 { 3 treeNode treeNode; 4 xInfo xInfo = new xInfo(); 5 ; 6 treeNode = xInfo.rootNode(); 7 treeNode = treeNode::findNode("jobs").AOTfindChild("Job1"); 8 treeNode.AOTrun(); 9 treeNode = treeNode::findNode("jobs").AOTfindChild("Job2& Read More
posted @ 2012-08-30 11:42
Sprite.z
Views(270)
Comments(0)
Diggs(0)
1、找到 class EditorScripts。2、比如在右键增加AddDeveloperName菜单,当点击此菜单时,在当前行增加开发人员的名字。 1 void AddDeveloperName(Editor e) 2 { 3 int startLine = e.selectionStartLine(); 4 int startCol = e.selectionStartCol(); 5 ; 6 e.unmark(); 7 e.gotoLine(startLine); 8 e.gotoCol(startCol); 9 e.insertL... Read More
posted @ 2012-08-30 11:41
Sprite.z
Views(332)
Comments(0)
Diggs(0)
对于数组类型的字段,比如Dimension,假如你试图访问一个单独的数据,我们就不能直接使用Dimension[Index]的方式,否则我们将会的到类似"Query extended range failure: Right parenthesis expected near pos 0."的错误。下面的代码展示了怎样使用正确的方法访问数组类型Department。public void init(){ QueryBuildRange qbrDimension; ; super(); //Department's index is 1 ... Read More
posted @ 2012-08-30 11:40
Sprite.z
Views(278)
Comments(0)
Diggs(0)
假如你用过runbase类的话,你一定会对那里的pack/unpack机制印象深刻, 这种机制允许用户保存上一次输入的值,假如你也想让你的From拥有这种强大的功能的话,请参考加入以下6个方法。 1 public dataAreaId lastValueDataAreaId() 2 { 3 return curExt(); 4 } 5 6 private UserId lastValueUserId() 7 { 8 return curuserid(); 9 }10 11 private UtilElementType lastValueType()12 {13 ... Read More
posted @ 2012-08-30 11:38
Sprite.z
Views(277)
Comments(0)
Diggs(0)
1 Void click() 2 { 3 ResourceNode resourceNode; 4 FilePath imagename; 5 ; 6 resourceNode = SysResource::getResourceNode(resourcestr(ResourceName)); 7 if (resourceNode) 8 { 9 resourceNode. AOTload();10 imagename = SysResource::saveToTempFile(resourc... Read More
posted @ 2012-08-30 11:36
Sprite.z
Views(149)
Comments(0)
Diggs(0)
1 static void AccessAccess(Args _args) 2 { 3 LoginProperty LP = new LoginProperty(); 4 OdbcConnection myConnection; 5 Statement myStatement; 6 ResultSet myResult; 7 LP.setDSN("MSAccess2000"); 8 try { 9 myConnection = new OdbcConnection(LP);10 } 11 catch ... Read More
posted @ 2012-08-30 11:35
Sprite.z
Views(131)
Comments(0)
Diggs(0)
1 connection con=new connection(); 2 statement stm=con.createStatement(); 3 ResultSET R; 4 str 1024 strSql; 5 ; 6 7 strSql = 'select top 10 * from inventTable '; 8 R = stm.executeQuery(strSQL); 9 while(r.next())10 {11 print r.getString(1);12 }//调用存储过程://strsql='Execute SP \''+A+& Read More
posted @ 2012-08-30 11:33
Sprite.z
Views(176)
Comments(0)
Diggs(0)
1 Example 2 { 3 LoginProperty LP = new LoginProperty(); 4 OdbcConnection myConnection; 5 Statement myStatement; 6 ResultSet myResult; 7 ; 8 super(); 9 LP.setDSN("MSAccess2000");10 try 11 {12 //Do something 13 }14 catch 15 { 16 ... Read More
posted @ 2012-08-30 11:32
Sprite.z
Views(169)
Comments(0)
Diggs(0)
1 static void CreateFieldMethod(Args _args) 2 { 3 TreeNode tn1, tnAddr, methodsNode; 4 MemberFunction memberFunction; 5 str source; 6 ; 7 8 tn1 = infolog.findNode("\\Forms\\Address\\Data Sources\\Address\\Fields\\AddrRecId"); 9 tnAddr = infolo... Read More
posted @ 2012-08-30 11:30
Sprite.z
Views(157)
Comments(0)
Diggs(0)
1 int ret, j, i; 2 DictTable dictTable; 3 DictField DictField; 4 str curFieldName; 5 ; 6 dictTable = new DictTable(tableNum(yourTableName)); 7 i = dictTable.fieldCnt()-11;//这里系统会包括表的其他11个父类字段,所以减去11 8 for (j = 1; j <= i; j++) 9 {10 DictField=new DictField(dictTable.id(),dictTable.fi... Read More
posted @ 2012-08-30 11:28
Sprite.z
Views(145)
Comments(0)
Diggs(0)
1 void sendMail() { 2 SysMailer mailer = new SysMailer(); 3 ; 4 mailer.body("This is the body of the mail"); 5 mailer.subject("The message subject"); 6 mailer.fromAddress("Axapta_header@navision.com"); 7 mailer.fromName("Sell Axapta contract"); 8 mailer.tos(). Read More
posted @ 2012-08-30 11:26
Sprite.z
Views(148)
Comments(0)
Diggs(0)
1 Args ArgList = new Args(reportStr(My_Report));2 ReportRun My_Report = new ReportRun (ArgList);3 ;4 5 My_Report.design().caption('My Report');6 My_Report.query().interactive(false);7 My_Report.query().dataSourceNo(1).range(1).value('AA');//对报表里的数据源传递参数。若无,则可以不要。8 My_Report.run(); Read More
posted @ 2012-08-30 11:26
Sprite.z
Views(150)
Comments(0)
Diggs(0)
1 static void writeFile() 2 { 3 AsciiIo diskFile; 4 Filename diskFileName; 5 Str line; 6 Container c; 7 ; 8 c = [1, "MyText", 2, "HisText"]; 9 10 diskFileName = "c:\\test.txt";11 12 diskFile = new AsciiIo(diskFileName,'W');13 diskFile.outRecordDelimiter('\r\ Read More
posted @ 2012-08-30 11:24
Sprite.z
Views(150)
Comments(0)
Diggs(0)
1、在 Basic/setup/Number sequence/numberSequence 增加一个Sequence 编号:比如 'MySequence', from 1 to 9999999 format='######'。2、在form的数据源的Create方法添加以下代码。1 public void create(boolean _append = false)2 {3 NumberSeq _numberSeq;//declare a NumberSeq variable4 ;5 super(_append);6 _numberSeq = numberS Read More
posted @ 2012-08-30 11:22
Sprite.z
Views(179)
Comments(0)
Diggs(0)
本例中使用到很多Axapta高级技巧,比如函数的嵌套等,值得大家揣摩。例子中使用到的三个函数解释:fileExists(_name) 若存在文件,则返回 true。folderExists(_name) 若存在文件夹或文件,则返回true。pathExists(_name) 若存在文件夹,则返回true。 1 static void FindFile(Args _args) 2 { 3 #File 4 FileName fullFileName(FileName _path, FileName _fileName) 5 { 6 FileName p... Read More
posted @ 2012-08-30 11:20
Sprite.z
Views(174)
Comments(0)
Diggs(0)
1 str URL; 2 #DEFINE.MapURL('http://maps.google.com/maps?q=') 3 ; 4 if (!Address.QVS_Latitude || !Address.QVS_Longitude) 5 { 6 SmmUtility::GoogleMap(Address); 7 } 8 else 9 {10 URL = Address.QVS_Latitude;11 URL += "," + Address.QVS_Longitude;12 13 URL = #MapURL + URL;14 infolog.urlL Read More
posted @ 2012-08-30 11:19
Sprite.z
Views(327)
Comments(0)
Diggs(0)
1 ReportName.setTarget(printMedium::Printer);//直接打印到打印机2 this.suppressReportIsEmptyMessage(true);//空报表提示3 this.printJobSettings().suppressScalingMessage(true);//预览缩放提示 Read More
posted @ 2012-08-30 11:13
Sprite.z
Views(159)
Comments(0)
Diggs(0)
AX的进度条比较简单,参考以下代码。 1 #avifiles 2 SysOperationProgress simpleProgress = SysOperationProgress::newGeneral(#aviUpdate, 'Posting', 100); 3 ; 4 simpleprogress.setCaption('Please wait...'); 5 simpleProgress.incCount(5); 6 simpleprogress.setText(strfmt("Percent: %1"+'%', 5 Read More
posted @ 2012-08-30 11:09
Sprite.z
Views(258)
Comments(0)
Diggs(0)
1、先在form的声明的地方声明变量。1 public class FormRun extends ObjectRun2 {3 QueryBuildRange criteriaPosted;4 }2、数据源(datasource)对应的表的ini方法。1 public void init()2 {3 super();4 criteriaPosted=this.query().dataSourceName('YouTable').addRange(fieldNum(YouTable,FieldName));5 }3、数据源的ExecuteQuery方法下。1 public voi Read More
posted @ 2012-08-30 11:07
Sprite.z
Views(206)
Comments(0)
Diggs(0)
1 static void closeAxapta(Args _args)2 {3 infolog.shutDown(true);4 } Read More
posted @ 2012-08-30 11:01
Sprite.z
Views(147)
Comments(0)
Diggs(0)
1 public void init()2 {3 object obj;4 ;5 super();6 obj = element.design().sectionName("SalesLine_1").controlName("SalesLine_LineAmount");7 obj.SumAll(NoYes::Yes);8 } Read More
posted @ 2012-08-30 11:00
Sprite.z
Views(184)
Comments(0)
Diggs(0)
1 void modified()2 {3 object fieldNameRef;4 super();5 fieldNameRef = tableName_ds.object(fieldNum(tableName, fieldName));6 fieldNameRef.methodName();7 } Read More
posted @ 2012-08-30 10:59
Sprite.z
Views(148)
Comments(0)
Diggs(0)
1 static void loopFieldsInTable(Args _args) 2 { 3 dictTable dt; 4 int numberOfFields; 5 int fieldId; 6 int i; 7 ; 8 dt = new dictTable(tableNum(CustTable)); 9 //name of table10 info(dt.name()); 11 numberOfFields = dt.fieldCnt(); 12 info(int2str(numberOf... Read More
posted @ 2012-08-30 10:58
Sprite.z
Views(171)
Comments(0)
Diggs(0)
方法一,使用扩展类型 tableName。方法二,使用函数 PickTable(),参考下面的job(可以直接运行)。 1 static void GetSelectedTable(Args _args) 2 { 3 tableid a; 4 ; 5 6 a = pickTable(); 7 print 'Table ID is:'+int2str(a); 8 print 'Table Name is:'+tableID2Name(a); 9 pause;10 } Read More
posted @ 2012-08-30 10:57
Sprite.z
Views(164)
Comments(0)
Diggs(0)
1 static void ExportImageToExcel(Args _args) 2 { 3 container ImaPos; 4 COM comWorksheet; 5 COM comShapes; 6 COM comCells; 7 COM comFont; 8 COM comPageSetup; 9 SysExcelWorksheet sheet;10 SysExcelApplication excel;11 SysExcelWorkbooks boo... Read More
posted @ 2012-08-30 10:56
Sprite.z
Views(346)
Comments(0)
Diggs(0)
1 static void FindPrimaryIdx(Args _args) 2 { 3 DictTable dt; 4 DictIndex di; 5 Common cm; 6 IndexID idx; 7 int i, iCnt; 8 FieldID fid; 9 FieldID fids[,10];10 int fidsCnt = 0;11 str ... Read More
posted @ 2012-08-30 10:55
Sprite.z
Views(246)
Comments(0)
Diggs(0)
1 void startupPost() 2 { 3 int counter; 4 int num = 0; 5 int maxSessions = Info::licensedUsersTotal(); 6 xSession session; 7 UserInfo userInfo; 8 UserId currentUserId; 9 ;10 11 currentUserId = curuserid();12 13 for(counter = 1; ... Read More
posted @ 2012-08-30 10:52
Sprite.z
Views(209)
Comments(0)
Diggs(0)
1 static str Num2ChnStr(real realNum) 2 { 3 real y; 4 int b, a; 5 str je, x, hz1, hz2, e, h, f, m; 6 boolean IsNegative=false; 7 ; 8 if (realNum == 0) 9 return '零圆';10 if (realNum < 0)11 {12 realNum =... Read More
posted @ 2012-08-30 10:49
Sprite.z
Views(429)
Comments(0)
Diggs(0)
As we talk before, AX has no support with sigleton instance modle, but we can use the global cache insteaded.1、Create the global cache.1 SysGlobalCache globalCache;2 ;3 4 globalCache = ClassFactory.globalCache(); //全局缓存,客户端和服务端都可以用,但依赖调用方5 globalCache = Appl.globalCache(); //全局缓存,客户端和服务端都可以用,... Read More
posted @ 2012-08-30 10:38
Sprite.z
Views(235)
Comments(0)
Diggs(0)
1 static void dialog(Args _args) 2 { 3 Dialog dialog = new Dialog("Test dialog!"); //标题 4 DialogField dialogField1 = dialog.addField(typeid(ItemId),"Item Name"); //设置字段 5 DialogField dialogField2 = dialog.addField(typeid(noYes),"Update?"); 6 Dial... Read More
posted @ 2012-08-30 10:02
Sprite.z
Views(207)
Comments(0)
Diggs(0)
在AX中,我们很容易发现很多子窗口都通过一个“MenuItem”并绑定数据源,就可以完成数据的自动绑定了。其实细节是由“MenuItem”封装好了,我们也可以通过代码实现。 1 static void activateWindow(Args _args) 2 { 3 FormRun fr; 4 Args args = new Args(); 5 CustTable CustTable = CustTable::find("WIB-CHN"); //记录行,如果是母窗口数据源,则实现绑定 6 ; 7 args.name(formstr(Cu... Read More
posted @ 2012-08-30 09:59
Sprite.z
Views(210)
Comments(0)
Diggs(0)

浙公网安备 33010602011771号