Posts

Showing posts with the label MorphX

Axapta : Posting journal by code

static void InventJournalCheckPost(Args _args) { InventJournalTable inventJournalTable; InventJournalCheckPost journalCheckPost; ; ttsbegin; inventJournalTable = InventJournalTable::find("xxx",true); //Remove Journal "xxx" has not been locked by system inventJournalTable.SystemBlocked = true; inventJournalTable.update(); journalCheckPost = InventJournalCheckPost::newJournalCheckPost (JournalCheckPostType::Post,inventJournalTable); journalCheckPost.run(); inventJournalTable.SystemBlocked = false; inventJournalTable.update(); ttscommit; }

Axapta : Get next number sequence

Image
การเรียกใช้ Number sequence สำหรับ running no. ต่าง ๆ ทำได้โดยใช้คำสั่ง NumberSeq::newGetNum( ProdParameters :: numRefProdJournalId ()).num(); ตรง Parameter ก็เปลี่ยนไปขึ้นอยู่ว่าเป็น Number sequence ของ Module ไหน และจะใช้งานได้ Number sequence ต้องไม่ตั้งค่าให้เป็น Continuous JournalId myJournalId; ; myJournalId = NumberSeq::newGetNum(ProdParameters::numRefProdJournalId()).num(); myJournalId = NumberSeq::newGetNum(PurchParameters::numRefPurchaseOrderId()).num(); myJournalId = NumberSeq::newGetNum(InventParameters::numRefInventJournalId()).num(); myJournalId = NumberSeq::newGetNum(SalesParameters::numRefConfirmId()).num(); การตั้งค่า Number sequence ของแต่ละ module เข้าไปที่ Setup -> Parameters แล้วไปที่ tab Number sequences ตรง Reference แต่ละตัวสามารถ คลิกขวา Go to the main table เพื่อตั้งค่ารูปแบบ Running number ที่ต้องการได้

Axapta : Formatting style in Excel

static void ExcelFormating(Args _args) { #Excel SysExcelApplication excel; SysExcelWorkbooks books; SysExcelWorkbook book; SysExcelWorksheet sheet; SysExcelRange range; SysExcelStyles styles; SysExcelStyle style; SysExcelInterior interior; SysExcelFont font; COM _char, _r; ; excel = SysExcelApplication::construct(); excel.visible(true); books = excel.workbooks(); book = books.add(); sheet = excel.activeSheet(); range = sheet.range('A1'); styles = book.styles(); style = styles.add('MyStyle'); interior = style.interior(); interior.color(WinApi::RGB2int(246, 233, 206)); font = style.font(); font.bold(true); font.color(winapi::RGB2int(153, 204, 255)); range.style('MyStyle'); range...

Axapta : Enable/Disable Dialog Control at runtime

Image
วิธี Enable/Disable หรือ Dialog Control ในขณะ runtime ทำได้โดย ดังนี้ 1.classDeclaration class SCI_Costing extends RunBase { FormStringControl SalesIdCtrl, ItemIdCtrl; FormCheckBoxControl bAllCtrl; SalesId salesId; ItemId itemId; NoYes bAll; #define.CurrentVersion(1) #localmacro.CurrentList salesId, itemId, bAll #endmacro } 2.สร้าง dialog แบบอนุญาตให้ update control ได้ โดยใช้ dialog.allowUpdateOnSelectCtrl(true) protected Object dialog(Dialog dialog, boolean forceOnClient) { DialogRunBase ret; ; ret = super(dialog, forceOnClient); ret.caption('Costing report by order'); ret.allowUpdateOnSelectCtrl(true); //อนุญาตให้ update control ได้ SalesIdCtrl = ret.formBuildDesign().addControl(FormControlType::String,'SalesId'); SalesIdCtrl.extendedDataType(extendedTypeNum('SalesId')); bAllCtrl = ret.formBuildDesign().addControl(FormControlType::CheckBox,'bAll');...

Axapta : Get or Set Checkbox value

public void clicked() { Qty tmpQty1; Qty tmpQty2; FormCheckboxControl formCheckboxControl; ; super(); // ต้องรัน super ก่อน ไม่งั้นค่าไม่เปลี่ยน // รับค่าจาก design formCheckboxControl = element.design().control(control::ProdParmHistoricalCost_EndJob); // box::info(strfmt("%1",formCheckboxControl.value())); if(formCheckboxControl.value() == 1){ //ถ้า checked จะเป็น 1 tmpQty1 = ProdTable::find(ProdParmHistoricalCost.ProdId).QtySched; tmpQty2 = ProdTableJour::reportedFinishedGood(ProdParmHistoricalCost.prodId); if(tmpQty1 != tmpQty2){ if(box::yesNo("Sure?", DialogButton::Yes, "Confirm") == DialogButton::Yes) { if(box::yesNo("Sure?",DialogButton::Yes,"Confirm")== DialogButton::Yes){ formCheckboxControl.value(true); //สั่งให้ checked }else{ formCheckboxControl.value(false); //สั่งให้ ไม่ checked } }else{ formCh...

Axapta : Dialog with lookup control

Image
วิธีสร้าง dialog แบบที่มี control ซึ่ง lookup ได้ เช่น เลือก SalesId แล้วให้อีก control นึง คือ ItemId lookup มาเฉพาะของ SalesId นั้น ทำได้ดังนี้ 1.declare control ไว้ ตาม extended data type ที่จะใช้ class LookupDialog extends RunBase { FormStringControl SalesIdCtrl, ItemIdCtrl; } 2.สร้าง dialog protected Object dialog(Dialog dialog, boolean forceOnClient) { DialogRunBase ret; ; ret = super(dialog, forceOnClient); ret.caption('Costing report by order'); SalesIdCtrl = ret.formBuildDesign().addControl(FormControlType::String,'SalesId'); SalesIdCtrl.extendedDataType(extendedTypeNum('SalesId')); ItemIdCtrl = ret.formBuildDesign().addControl(FormControlType::String,'ItemId'); ItemIdCtrl.extendedDataType(extendedTypeNum('ItemId')); return ret; } 3.Set ให้ control สามารถ override method ตอน runtime ได้ public void dialogPostRun(DialogRunbase dialog) { ; super(dialog); dialog.dialogForm().formRun().co...

Axapta Properties

1. Data Dictionary 2. Form 3. Report 4. Query 5. Menus 6. Menu Items

Axapta : Form Properties

Form Property Type   Description Form data source       AllowCheck   = If set Configuration keys and Security keys will be validated at runtime. AllowCreate   = Enables inserting new record for the data source. AllowDelete   = Enables deletion of table records for the data source. AllowEdit   = Enables editing of table records for the data source. ...