October 2009
You are currently browsing the articles from KomKid.Net written in the month of October 2009.
การเรียกใช้ Number sequence สำหรับ running no. ต่าง ๆ ทำได้โดยใช้คำสั่ง
NumberSeq::newGetNum(ProdParameters::numRefProdJournalId()).num();
ตรง Parameter ก็เปลี่ยนไปขึ้นอยู่ว่าเป็น Number sequence ของ Module ไหน
และจะใช้งานได้ Number sequence ต้องไม่ตั้งค่าให้เป็น Continuous
1 2 3 4 5 6
| 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 ที่ต้องการได้


Written by Komkid on October 30th, 2009 with 2 comments.
Read more articles on Axapta and Programming.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| 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.locked(true);
_r = range.comObject();
_char = _r.characters(1);
_char.insert('MyStyle');
} |
Written by Komkid on October 30th, 2009 with no comments.
Read more articles on Axapta and Programming.
วิธี Enable/Disable หรือ Dialog Control ในขณะ runtime ทำได้โดย ดังนี้

1.classDeclaration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| 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)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| 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');
bAllCtrl.label('All');
ItemIdCtrl = ret.formBuildDesign().addControl(FormControlType::String,'ItemId');
ItemIdCtrl.extendedDataType(extendedTypeNum('ItemId'));
return ret;
} |
3.เซ็ตให้ control สามารถ override method ตอน runtime ได้
1 2 3 4 5 6 7 8 9 10
| public void dialogPostRun(DialogRunbase dialog)
{
;
super(dialog);
dialog.dialogForm().formRun().controlMethodOverload(true);
dialog.dialogForm().formRun().controlMethodOverloadObject(this);
SalesIdCtrl = dialog.dialogForm().formRun().design().controlName('SalesId');
ItemIdCtrl = dialog.dialogForm().formRun().design().controlName('ItemId');
bAllCtrl = dialog.dialogForm().formRun().design().controlName('bAll');
} |
4.ใช้ method dialogSelectCtrl เพื่อดำเนินการ update control ซึ่งในที่นี้ก็คือการ enable/disable ItemId
1 2 3 4 5 6 7 8 9 10 11 12
| public void dialogSelectCtrl()
{
;
if (bAllCtrl.value()== 0)
{
ItemIdCtrl.allowEdit(true);
}
else
{
ItemIdCtrl.allowEdit(false);
}
} |
Written by Komkid on October 19th, 2009 with no comments.
Read more articles on Axapta and Programming.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| 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{
formCheckboxControl.value(false);
}
}
}
} |
Written by Komkid on October 19th, 2009 with no comments.
Read more articles on Axapta and Programming.
วิธีส่งข้อมูลที่มีการ enter (vbNewLine) ไปให้ Formulas ของ Crystal Report ทำได้โดย ใส่เครื่องหมาย chr(34) (qoute) คร่อม chr(10) (Line Feed) ไปอีกที ดังนี้
1
| CrysRpt.Formulas(0) = "FormulaName=" & Chr(34) & Replace$(txtName.Text, vbNewLine, Chr(34) & " & Chr(10) & " & Chr(34)) & Chr(34) |
ถ้าข้อมูล คือ
บรรทัดที่ 1
บรรทัดที่ 2
พอใช้คำสั่งแล้ว ข้อมูลที่จะส่งไปก็จะเป็น
FormulaName=”บรรทัดที่ 1″ & Chr(10) & “บรรทัดที่ 2″
Written by Komkid on October 19th, 2009 with no comments.
Read more articles on Programming.
« Older articles
No newer articles