Günü Sözü
"Hiçbir şey bilmeyen cahildir, ama bilip de susan ahlaksızdır. " Bertolt Brecht.
"İyilik yapabildiğim zaman mutlu olurum; ama en büyük mutluluk yapılan bir haksızlığı düzeltmektir." Tolstoy
"İyilik yapabildiğim zaman mutlu olurum; ama en büyük mutluluk yapılan bir haksızlığı düzeltmektir." Tolstoy
4 Aralık 2014 Perşembe
Ax2012 Import Fixed Assets Table, csv,excel den sabit kıymetlere import
public void _createAssetTable(
AssetId _assetId
, AssetGroupId _assetGroupId
, AssetName _assetName
, AssetLocationId _assetLocationId
, Num _num
, AssetType _assetType
, AssetNameAlias _assetNameAlias
, AssetNotes _assetNotes
, AssetMajorTypeId _assetMajorTypeId)
{
AxAssetTable axAssetTable;
;
axAssetTable = new AxAssetTable();
axAssetTable.validateInput(true);
axAssetTable.parmAssetId(_assetId);
axAssetTable.parmAssetGroup(_assetGroupId ?_assetGroupId : assetGroupId);
axAssetTable.parmName(_assetName);
axAssetTable.parmLocation(_assetLocationId);
axAssetTable.parmSerialNum(_num);
axAssetTable.parmAssetType(_assetType);
axAssetTable.parmNameAlias(_assetNameAlias);
axAssetTable.parmNotes(_assetNotes);
axAssetTable.parmMajorType(_assetMajorTypeId);
axAssetTable.save();
}
// creates the Assets book
protected void CreateAssetBook(container _conLine)
{
#Define.AssetId(1)
#Define.BookId(2)
#Define.PostingProfile(9)
#Define.LifeTime(11)
#Define.LifeTimeRest(12)
#Define.DepreciationStartDate(16)
#Define.LastDepreciationDate(18)
#Define.AcquisitionDate(27)
AssetBook assetBook;
AxAssetBook axAssetBook = AxAssetBook::construct();
SysDictClass sysDictClassAxAssetBook = new SysDictClass(classIdGet(AxAssetBook));
;
assetBook = AssetBook::find(this.getLineValue(_conLine, #AssetId), this.getLineValue(_conLine, #BookId), true);
if(assetBook)
{
axAssetBook = AxAssetBook::newAssetBook(assetBook);
// AssetId
axAssetBook.parmAssetId(this.getLineValue(_conLine,#AssetId))
// BookId
axAssetBook.parmBookId(this.getLineValue(_conLine,#BookId));
// PostingProfile
axAssetBook.parmPostingProfile( this.getLineValue(_conLine, #PostingProfile) );
// LifeTime
axAssetBook.parmLifeTimes(str2num(this.getLineValue(_conLine,#LifeTime)));
// LifeTimeRest
axAssetBook.parmLifeTimeRest(str2num(this.getLineValue(_conLine,#LifeTimeRest)));
// DepreciationStartDate
axAssetBook.parmDepreciationStartDate(str2date((this.getLineValue(_conLine,#DepreciationStartDate),123));
// LastDepreciationDate
axAssetBook.parmLastDepreciationDate(str2dat(this.getLineValue(_conLine,#LastDepreciationDate),123));
// AcquisitionDate
axAssetBook.parmAcquisitionDate(str2date(this.getLineValue(_conLine,#AcquisitionDate),123));
axAssetBook.save();
}
else
{
throw error(strFmt(AssetBook::txtNotExist(), this.getLineValue(_conLine, #AssetId),
this.getLineValue(_conLine, #BookId)));
}
}
// gets the value from the container
protected anytype getLineValue(container _conLine,
int _columnNum,
Types _valueType = Types::String,
EnumId _enumId = 0)
{
str strValue;
anytype anyTypeValue;
DictEnum dictEnum;
strValue = conPeek(_conLine,
_columnNum);
switch(_valueType)
{
case Types::String :
anyTypeValue = strValue;
break;
case Types::Integer :
if(strValue)
{
anyTypeValue = str2int(strValue);
}
else
{
anyTypeValue = 0;
}
break;
case Types::Real :
if(strValue)
{
anyTypeValue = str2num(strValue);
}
else
{
anyTypeValue = 0.00;
}
break;
case Types::Enum :
if(!_enumId)
{
throw error(strFmt("@SYS22828", funcName()));
}
dictEnum = new DictEnum(_enumId);
if(!dictEnum)
{
throw error(strFmt("@SYS22828", funcName()));
}
if(strValue)
{
anyTypeValue = dictEnum.name2Value(strValue);
}
else
{
anyTypeValue = 0;
}
break;
case Types::Date :
if(strValue)
{
anyTypeValue = str2date(strValue,123);
}
else
{
anyTypeValue = dateNull();
}
break;
case Types::UtcDateTime :
if(strValue)
{
anyTypeValue = DateTimeUtil::parse(strValue);
}
else
{
anyTypeValue = utcDateTimeNull();
}
break;
default :
throw error(strFmt("@SYS26908", _valueType));
}
return anyTypeValue;
}
1 Aralık 2014 Pazartesi
Asset Table, Asset Book, Asset Trans insert,update,import
static void _assetbookCreate(Args _args)
{
AssetBook _assetBook;
AssetTrans _assetTrans;
try
{
ttsbegin;
_assetBook.clear();
_assetBook = AssetBook::find('assetid','assetbokid',true);
if(!_assetBook)
{
info('asset id yok');
// continue;
}
else
{
_assetBook.AssetId = 'asset id';
_assetBook.AcquisitionDate =26\06\2014;
_assetBook.VendAccount ='';
_assetBook.AssetGroup ='254-1';
_assetBook.VendInvoiceId ='';
_assetBook.AcquisitionPrice =0.00;
// _assetBook.DefaultDimension = ''; //22565574414;
_assetBook.DepreciationStartDate =26\06\2014;
_assetBook.LifeTime =5;
_assetBook.UsedFromDate = 26\06\2015;
_assetBook.LifeTime =60;
_assetBook.LifeTimeRest =60;
_assetBook.PostingProfile = 'NORMAL';
_assetBook.BookId='NORMAL';
_assetBook.Status = AssetStatus::NoAcquisition;
//_assetBook.Depreciation = NoYes::Yes;
_assetBook.insert();
}
ttscommit;
info("işlem başarıyla tamamlandı. hadi hayırlı olsun.");
}
catch
{
info(strFmt(" : %1 ",_assetBook.AssetId));
info("işlem sırsaında bir hata oluştu :(");
}
try
{
ttsbegin;
_assetTrans.clear();
_assetTrans.AssetId = 'asset id';
_assetTrans.TransDate = 26\06\2014;
_assetTrans.Voucher ='FIS no';
_assetTrans.AssetGroup ='grup no';
_assetTrans.TransType = 1;
_assetTrans.Txt ='Alım';
_assetTrans.CurrencyCode='TRY';
_assetTrans.BookId='NORMAL';
_assetTrans.AmountMST=4100;
_assetTrans.AmountCur=4100;
_assetTrans.DefaultDimension = 22565574414;
_assetTrans.insert();
ttscommit;
info("işlem başarıyla tamamlandı. hadi hayırlı olsun.");
}
catch
{
info(strFmt(" : %1 ",_assetTrans.AssetId));
info("işlem sırsaında bir hata oluştu :(");
}
}
1 Mart 2014 Cumartesi
AX 2012 kod ile excel e veri gönderme (sent to excel with code in ax 2012)
Buton click eventi ile gönderdim;
void clicked()
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
SysExcelCell cell;
SysExcelFont font;
int row;
Name _firmaadiadresi;
str fileName;
if(!element.args().caller())
throw error('Cant Run Directly');
if(element.args().record().TableId == tablenum(qqq))
{
_firmaadiadresi= CustTable::find(qqq.InvoiceAccount).name()+" "+ CustAddress();
}
fileName = "C:\\Test.xlsx";
application = SysExcelApplication::construct();
workbooks = application.workbooks();
workbooks.open(fileName); // networkden // workbooks.open("\\\\192.168.1...\\test.xlsx";
workbook =workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
// cell = cells.item(26,1);
// cell.value(_firmaadiadresi);
cells.item(17,1).value(_firmaadiadresi);
font = cell.font();
font.bold(true);
application.visible(true);
}
* qqq ile yzılan yere tablomuzu yazalım
static void koddanExcel(Args _args)
{
SysExcelApplication xlsApplication;
SysExcelWorkBooks xlsWorkBookCollection;
SysExcelWorkBook xlsWorkBook;
SysExcelWorkSheets xlsWorkSheetCollection;
SysExcelWorkSheet xlsWorkSheet;
SysExcelRange xlsRange;
CustTable custTable;
int row = 1;
str fileName;
;
//Filename
fileName = "C:\\Test.xlsx";
//Initialize Excel instance
xlsApplication = SysExcelApplication::construct();
//Open Excel document
//xlsApplication.visible(true);
//Create Excel WorkBook and WorkSheet
xlsWorkBookCollection = xlsApplication.workbooks();
xlsWorkBook = xlsWorkBookCollection.add();
xlsWorkSheetCollection = xlsWorkBook.worksheets();
xlsWorkSheet = xlsWorkSheetCollection.itemFromNum(1);
//Excel columns captions
xlsWorkSheet.cells().item(row,1).value("Account Num");
xlsWorkSheet.cells().item(row,2).value("Name");
row++;
//Fill Excel with CustTable AccountNum and Name fields (only 10 records)
// custtable accountNum ve name alanlarından sadece 10 kayıt
while select custTable
{
if(row == 10)
break;
xlsWorkSheet.cells().item(row,1).value(custTable.AccountNum);
xlsWorkSheet.cells().item(row,2).value(custTable.Name);
row++;
}
//dosya adını kontrol varsa sil
if(WinApi::fileExists(fileName))
WinApi::deleteFile(fileName);
//excel dökümanını kaydedelim
xlsWorkbook.saveAs(fileName);
//açalım
xlsApplication.visible(true);
//kapatmak istersek
//xlsApplication.quit();
//xlsApplication.finalize();
}
void clicked()
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
SysExcelCell cell;
SysExcelFont font;
int row;
Name _firmaadiadresi;
str fileName;
if(!element.args().caller())
throw error('Cant Run Directly');
if(element.args().record().TableId == tablenum(qqq))
{
_firmaadiadresi= CustTable::find(qqq.InvoiceAccount).name()+" "+ CustAddress();
}
fileName = "C:\\Test.xlsx";
application = SysExcelApplication::construct();
workbooks = application.workbooks();
workbooks.open(fileName); // networkden // workbooks.open("\\\\192.168.1...\\test.xlsx";
workbook =workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
// cell = cells.item(26,1);
// cell.value(_firmaadiadresi);
cells.item(17,1).value(_firmaadiadresi);
font = cell.font();
font.bold(true);
application.visible(true);
}
* qqq ile yzılan yere tablomuzu yazalım
static void koddanExcel(Args _args)
{
SysExcelApplication xlsApplication;
SysExcelWorkBooks xlsWorkBookCollection;
SysExcelWorkBook xlsWorkBook;
SysExcelWorkSheets xlsWorkSheetCollection;
SysExcelWorkSheet xlsWorkSheet;
SysExcelRange xlsRange;
CustTable custTable;
int row = 1;
str fileName;
;
//Filename
fileName = "C:\\Test.xlsx";
//Initialize Excel instance
xlsApplication = SysExcelApplication::construct();
//Open Excel document
//xlsApplication.visible(true);
//Create Excel WorkBook and WorkSheet
xlsWorkBookCollection = xlsApplication.workbooks();
xlsWorkBook = xlsWorkBookCollection.add();
xlsWorkSheetCollection = xlsWorkBook.worksheets();
xlsWorkSheet = xlsWorkSheetCollection.itemFromNum(1);
//Excel columns captions
xlsWorkSheet.cells().item(row,1).value("Account Num");
xlsWorkSheet.cells().item(row,2).value("Name");
row++;
//Fill Excel with CustTable AccountNum and Name fields (only 10 records)
// custtable accountNum ve name alanlarından sadece 10 kayıt
while select custTable
{
if(row == 10)
break;
xlsWorkSheet.cells().item(row,1).value(custTable.AccountNum);
xlsWorkSheet.cells().item(row,2).value(custTable.Name);
row++;
}
//dosya adını kontrol varsa sil
if(WinApi::fileExists(fileName))
WinApi::deleteFile(fileName);
//excel dökümanını kaydedelim
xlsWorkbook.saveAs(fileName);
//açalım
xlsApplication.visible(true);
//kapatmak istersek
//xlsApplication.quit();
//xlsApplication.finalize();
}
Kaydol:
Yorumlar (Atom)