Sebelumnya, pastikan sudah dapat hak akses untuk bisa hapus folder dan file tersebut
static void Test_Move_One_File(Args _args)
{
System.Exception ex;
Set permSet = new Set(Types::Class);
str errorMsg;
FileName _srcFile,_destFile;
;
_srcFile = "D:\\Move_Src\\File.txt";
_destFile = "D:\\Move_Dst\\File.txt";
try
{
permSet.add(new FileIOPermission(_srcFile, 'rw'));
permSet.add(new InteropPermission(InteropKind::ClrInterop));
permSet.add(new FileIOPermission(_destFile, 'rw'));
CodeAccessPermission::assertMultiple(permSet);
//Kalo file sumber tidak ada, maka batalkan proses
if(!System.IO.File::Exists(_srcFile))
{
Info("Source file not exist !! Proces terminated.");
Break;
}
else
{
Info("Source file exist !! File will be moved.");
if(System.IO.File::Exists(_destFile))
{
System.IO.File::Delete(_destFile);
}
}
System.IO.File::Move(strfmt(@"%1",_srcFile), strfmt(@"%1",_destFile));
CodeAccessPermission::revertAssert();
}
catch (Exception::CLRError)
{
ex = ClrInterop::getLastException();
if (ex != null)
{
ex = ex.get_InnerException();
if (ex != null)
{
error(ex.ToString());
}
}
}
}
Friday, June 8, 2012
List nama-nama file dalam folder
static void Test_ListDirFiles(Args _args)
{
FilePath filePath = "d:\\Documents\\Project";
FileNameFilter fileFilter = ["*.*", "All files"];
FileName fileName;
int fileHandle;
;
// Get first file in directory
[fileHandle, fileName] = WinAPI::findFirstFile(strFmt("%1\\%2", filePath, conPeek(fileFilter, 1)));
// While files found
while(fileName)
{
// ------------------------------------------
// Filepath and filename are known here...
// ------------------------------------------
info(strFmt("%1%2", filePath, fileName));
// Get next file
fileName = winAPI::findNextFile(fileHandle);
}
}
{
FilePath filePath = "d:\\Documents\\Project";
FileNameFilter fileFilter = ["*.*", "All files"];
FileName fileName;
int fileHandle;
;
// Get first file in directory
[fileHandle, fileName] = WinAPI::findFirstFile(strFmt("%1\\%2", filePath, conPeek(fileFilter, 1)));
// While files found
while(fileName)
{
// ------------------------------------------
// Filepath and filename are known here...
// ------------------------------------------
info(strFmt("%1%2", filePath, fileName));
// Get next file
fileName = winAPI::findNextFile(fileHandle);
}
}
Sunday, March 18, 2012
Menambah record baru pada kedua company
Berikut ini digunakan untuk melakukan insert data ke 2 company dengan menggunakan class.
Syntax nya changeCompany("HSP").
static void Create_to_2Company(Args _args)
{
AxPurchTable table;
AxPurchLine line;
;
table = new AxPurchTable();
table.parmOrderAccount('');
table.parmInventLocationId('WAREHOUSE');
table.save();
line = new AxPurchLine();
line.axPurchTable(table);
line.parmItemId('A001'); // Item number Q987
line.parmPurchQty(12); // 12 pcs.
line.save();
changeCompany("HSP")
{
table = new AxPurchTable();
table.parmOrderAccount('');
table.parmInventLocationId('WAREHOUSE');
table.save();
line = new AxPurchLine();
line.axPurchTable(table);
line.parmItemId('A001'); // Item number Q987
line.parmPurchQty(12); // 12 pcs.
line.save();
}
}
Syntax nya changeCompany("HSP").
static void Create_to_2Company(Args _args)
{
AxPurchTable table;
AxPurchLine line;
;
table = new AxPurchTable();
table.parmOrderAccount('');
table.parmInventLocationId('WAREHOUSE');
table.save();
line = new AxPurchLine();
line.axPurchTable(table);
line.parmItemId('A001'); // Item number Q987
line.parmPurchQty(12); // 12 pcs.
line.save();
changeCompany("HSP")
{
table = new AxPurchTable();
table.parmOrderAccount('');
table.parmInventLocationId('WAREHOUSE');
table.save();
line = new AxPurchLine();
line.axPurchTable(table);
line.parmItemId('A001'); // Item number Q987
line.parmPurchQty(12); // 12 pcs.
line.save();
}
}
Monday, March 5, 2012
Lookup modifikasi
Berikut ini digunakan untuk membuat lookup sendiri. Kasusnya, nambah form dan EditString, namun tidak ada relasi ke datasource (EdiString lepasan gitu.....)
public void lookup()
{
//super();
//Inisialisasi sysTableLookupClass
sysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(InventItemgroup), this);
Query query = New Query();
QueryBuildDataSource qbdsTbl1, qbdsTbl2;
QueryBuildRange qbr;
;
//Tambah tabel
qbdsTbl1 = query.addDataSource(tableNum(InventItemgroup));
//Tambah rentang Query untuk membatasi daftar record
qbr = qbdsTbl1.addRange(fieldNum(InventItemgroup,ItemGroupId));
qbr.value();
qbr = qbdsTbl1.addRange(fieldNum(InventItemgroup,Name));
qbr.value();
qbdsTbl1.relations(true);
sysTableLookup.addLookupfield(fieldNum(InventItemgroup, ItemGroupId));
sysTableLookup.addLookupfield(fieldNum(InventItemgroup, Name));
sysTableLookup.parmQuery(query);
//Tampilkan drop down
sysTableLookup.performFormLookup();
}
public void lookup()
{
//super();
//Inisialisasi sysTableLookupClass
sysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(InventItemgroup), this);
Query query = New Query();
QueryBuildDataSource qbdsTbl1, qbdsTbl2;
QueryBuildRange qbr;
;
//Tambah tabel
qbdsTbl1 = query.addDataSource(tableNum(InventItemgroup));
//Tambah rentang Query untuk membatasi daftar record
qbr = qbdsTbl1.addRange(fieldNum(InventItemgroup,ItemGroupId));
qbr.value();
qbr = qbdsTbl1.addRange(fieldNum(InventItemgroup,Name));
qbr.value();
qbdsTbl1.relations(true);
sysTableLookup.addLookupfield(fieldNum(InventItemgroup, ItemGroupId));
sysTableLookup.addLookupfield(fieldNum(InventItemgroup, Name));
sysTableLookup.parmQuery(query);
//Tampilkan drop down
sysTableLookup.performFormLookup();
}
Wednesday, February 22, 2012
Membuat dialog sederhana dengan lookup dan input value
Berikut ini dialog dasar dengan lookup dan inputan value.
static void OpenDialogItemGroup(Args _args)
{
Dialog dialog = new Dialog("Item grup selection");
DialogField fieldGroup;
DialogField fieldDisc;
ItemgroupId ItemgroupId;
Amount Amount;
;
fieldGroup = dialog.addField(typeid(ItemgroupId));
fieldDisc = dialog.addField(typeid(Amount),"Disc. Pct.");
if (dialog.run())
{
info("You selected: " + fieldGroup.value() + " " +int2str(fieldDisc.value()));
}
}
{
Dialog dialog = new Dialog("Item grup selection");
DialogField fieldGroup;
DialogField fieldDisc;
ItemgroupId ItemgroupId;
Amount Amount;
;
fieldGroup = dialog.addField(typeid(ItemgroupId));
fieldDisc = dialog.addField(typeid(Amount),"Disc. Pct.");
if (dialog.run())
{
info("You selected: " + fieldGroup.value() + " " +int2str(fieldDisc.value()));
}
}
Tuesday, August 2, 2011
Contoh manipulasi tanggal di AX 2009
static void Testing_Tgl(Args _args)
{
str tglitem,tglstr,blnstr,thnstr,tglwalbln;
date tgl,akhirbln;
date d = today(),x;
int i;
;
tglitem = '2011/06/10';
tglstr=date2str(str2date(tglitem,321), 123, 2, 0, 0, 0,0);
blnstr=date2str(str2date(tglitem,321), 123, 0, 0, 2, 0,0);
thnstr=date2str(str2date(tglitem,321), 123, 0, 0, 0, 0,4);
info('Tgl :' +tglstr);
info('Bln :' +blnstr);
info('thn :' +thnstr);
info('Waktu :'+time2str(timeNow(),TimeSeparator::Dot, TimeFormat::Hour24));
akhirbln = EndMth(str2date(tglitem,321));
info('Tgl Awal Bulan '+blnstr+': '+date2str(str2date(thnstr+blnstr+'01',321), 123,2,0,0,0,0));
info('Tgl Akhir Bulan '+blnstr+': '+date2str(akhirbln, 123, 2, 1, 0, 1,0));
// info(date2str(str2date(thnstr+blnstr+tglstr,321), 123, 2, 1, 2, 1,4));
info(date2str(str2date('201110'+tglstr,321), 123, 2, -1, 2, -1,4));
}
{
str tglitem,tglstr,blnstr,thnstr,tglwalbln;
date tgl,akhirbln;
date d = today(),x;
int i;
;
tglitem = '2011/06/10';
tglstr=date2str(str2date(tglitem,321), 123, 2, 0, 0, 0,0);
blnstr=date2str(str2date(tglitem,321), 123, 0, 0, 2, 0,0);
thnstr=date2str(str2date(tglitem,321), 123, 0, 0, 0, 0,4);
info('Tgl :' +tglstr);
info('Bln :' +blnstr);
info('thn :' +thnstr);
info('Waktu :'+time2str(timeNow(),TimeSeparator::Dot, TimeFormat::Hour24));
akhirbln = EndMth(str2date(tglitem,321));
info('Tgl Awal Bulan '+blnstr+': '+date2str(str2date(thnstr+blnstr+'01',321), 123,2,0,0,0,0));
info('Tgl Akhir Bulan '+blnstr+': '+date2str(akhirbln, 123, 2, 1, 0, 1,0));
// info(date2str(str2date(thnstr+blnstr+tglstr,321), 123, 2, 1, 2, 1,4));
info(date2str(str2date('201110'+tglstr,321), 123, 2, -1, 2, -1,4));
}
Friday, June 10, 2011
Mengetahui koneksi user di SQL Server
SELECT d.name, p.login_time,p.status,p.hostname,p.loginame
from master.dbo.sysprocesses p
join master.dbo.sysdatabases d on p.dbID = d.dbID
Subscribe to:
Posts (Atom)